filecat 7.14.4 → 7.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filecat",
3
- "version": "7.14.4",
3
+ "version": "7.15.0",
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([[3299],{77481(e,t,s){s.d(t,{S:()=>o,X:()=>l});var n=s(96540),i=s(61443),a=s(74848);function l(e){const[t,s]=n.useState([]),l=(0,n.useRef)(-1),[o,r]=(0,n.useState)(-1),[c,d]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]);const h=()=>{l.current=-1,r(-1),d(-1)};return(0,a.jsxs)("table",{children:[(0,a.jsx)("thead",{children:(0,a.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let l=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(l=`${t} (${n.label})`)}return(0,a.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,a.jsx)(i.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:l}):t},s)})})}),(0,a.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,a.jsx)("tr",{className:n?(o===s?"row-dragging":"")+(c===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(l.current=s,r(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||l.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=l.current,s=c;h(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:h,children:t.map((s,n)=>{const i=n===t.length-1?"small":"";return(0,a.jsx)("td",{className:i,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function o(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))})}},53299(e,t,s){s.r(t),s.d(t,{default:()=>L});var n=s(96540),i=s(75725),a=s(23430),l=s(70447),o=s(85997),r=s(61443),c=s(14284),d=s(53459),h=s(77481),u=s(22022),p=s(82893),_=s(40505),x=s(62042),m=s(21499),j=s(21469),v=s(64694),f=s(74848);function g(e){const{t}=(0,u.Bd)(),[s,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{if(e.getItems){const t=await e.getItems();a(t)}})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e.title}),e.info_click&&(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{e.info_click()},title:"信息"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:t("添加"),onClick:()=>{const t=[];for(let s=0;s<e.headers.length-1;s++)t.push("");a([t,...s])}}),(0,f.jsx)(o.rA,{icon:"save",title:t("保存"),onClick:async()=>{e.save&&await e.save(s)}})]}),children:(0,f.jsx)(h.X,{headers:e.headers,rows:s.map((n,i)=>{const l=[];for(let t=0;t<e.headers.length;t++)l.push((0,f.jsx)(r.Sm,{value:n[t],handleInputChange:e=>{n[t]=e,a([...s])},no_border:!0}));return l.push((0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"delete",title:t("删除"),onClick:()=>(e=>{s.splice(e,1),a([...s])})(i)}),n[0]&&(0,f.jsx)(o.rA,{icon:"content_copy",title:t("复制地址"),onClick:()=>{const e=(0,m.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);(0,_.lW)(e),(0,x.SK)(e)}}),n[0]&&e.need_copy&&(0,f.jsx)(o.rA,{icon:"open_in_new",title:t("打开新页面"),onClick:()=>{const e=(0,m.bi)(`${window.location.origin}${j.m.base_url}`,n[0]);window.open(e)}})]})),l}),width:"10rem",onRowDrag:(e,t)=>{a((0,v.TI)(s,e,t))}})})})}var w=s(34843),y=s(78247),S=s(24659);function C(){const{t:e}=(0,u.Bd)(),[t,s]=(0,w.fp)(p.AG.prompt_card),a=(0,S.K)(),g=[e("路由"),e("auth"),e("备注")],[C,b]=(0,w.fp)(p.AG.editorSetting),[k,A]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("api/customer_router");e.code===d.m.Success&&A(e.data)})()},[]);return(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("api_rt")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{(()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})})()},title:"信息"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{A([{note:"",needAuth:!1,router:""},...k])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("api/customer_router/save",k)).code===d.m.Success&&(0,x.SK)("保存成功")}})]}),children:(0,f.jsx)(h.X,{headers:g,rows:k.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.router,handleInputChange:e=>{t.router=e,A([...k])},no_border:!0}),(0,f.jsx)(r.l6,{defaultValue:t.needAuth,onChange:e=>{t.needAuth=e,A([...k])},options:a,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e,A([...k])},no_border:!0}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{k.splice(e,1),A([...k])})(s)}),(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(async e=>{if(!e.router)return void(0,x.zN)("路由不能为空");const t=await c.XO.get(`jscode/${encodeURIComponent(e.router)}`);b({model:"ace/mode/javascript",open:!0,fileName:e.router,save:async t=>{const s={context:t,router:e.router};(await c.XO.post("jscode/save",s)).code===d.m.Success&&(y.xK.set_value_temp(""),b({open:!1,model:"",fileName:"",save:null}),(0,x.SK)("成功"))}}),y.xK.set_value_temp(t.data)})(t)}),t.router&&(0,f.jsx)(o.rA,{icon:"content_copy",title:e("复制地址"),onClick:()=>{(0,_.lW)((0,m.bi)(window.location.origin+j.m.base_url,t.router)),(0,x.SK)(e("已复制"))}})]})];return n}),width:"10rem",onRowDrag:(e,t)=>{A((0,v.TI)(k,e,t))}})})})}var b=s(23496),k=s(4412);function A(){const{t:e}=(0,u.Bd)(),[t,s]=(0,w.fp)(p.AG.prompt_card),[a,l]=(0,w.fp)(p.AG.router_jump),o=[e("路由"),e("路径"),e("过期时间(s)"),e("备注")],r=[e("路由"),e("文件路径"),"token","user id",e("备注")];return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(k.aZ,{position:"right"}),(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{maxWidth:"50rem",children:[(0,f.jsx)(g,{title:e("页面资源路由"),headers:o,getItems:async()=>{const e=await c.XO.get(b.s.setting_customer_router);if(e.code===d.m.Success){if(a?.page_self_router_api_data){for(const t of e.data)t[1]===a?.page_self_router_api_data[1]&&(0,x.N9)("已经存在的页面资源路由配置目录设置");const t={};Object.assign(t,a?.page_self_router_api_data),e.data=[t,...e.data],l({})}return e.data}return[]},save:async e=>{(await c.XO.post(b.s.setting_customer_router_save,e)).code===d.m.Success&&(0,x.SK)("success")},info_click:()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由,会自动识别地址,将页面转到对应结果。路径支持文件路径(如果是文件夹路径的最后最后一个名字将会成为资源实际地址,整个目录将会变成一个http目录),http地址。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})},need_copy:!0}),(0,f.jsx)(g,{title:e("wf_rt"),headers:r,getItems:async()=>{const e=await c.XO.get(b.s.setting_customer_workflow_router);return e.code===d.m.Success?e.data:[]},save:async e=>{(await c.XO.post(b.s.setting_customer_workflow_router_save,e)).code===d.m.Success&&(0,x.SK)("保存成功")},info_click:()=>{let e=(0,f.jsx)("div",{children:'默认需要以 "/api" 开头的路由,文件路径是有效的workflow路径。token也可以是文件绝对路径,请求的时候请设置同样的authorization请求头字段。'});s({open:!0,title:"信息",context_div:(0,f.jsx)("div",{children:e})})}})]}),(0,f.jsx)(i.VP,{maxWidth:"50rem",children:(0,f.jsx)(C,{})})]})]})}var I=s(74777),V=s(6960),N=s(7523);function X(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),[s,i]=(0,n.useState)(!1),[h,_]=(0,n.useState)("https://registry.npmjs.org"),[m,j]=(0,n.useState)(""),[v,g]=(0,n.useState)(180),[S,C]=(0,n.useState)(!1),[b,k]=(0,w.fp)(p.AG.prompt_card);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("auto_upgrade_setting");if(e.code===d.m.Success){const t=e.data;i(t.open||!1),_(t.version_check_url||"https://registry.npmjs.org"),j(t.exe_download_url||""),g(t.check_interval_seconds||180)}})()},[]);return t(a.oV.sys_setting_page)?(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("自动升级")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{k({open:!0,title:e("信息"),context_div:(0,f.jsx)("div",{children:e("自动升级在 windows 下目前可能不稳定")})})},title:e("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("保存"),clickFun:async()=>{if(!h)return void(0,x.zN)(e("ver_req"));if(s&&(!v||v<10))return void(0,x.zN)(e("chk_10s"));const t=new I.Mm;t.open=s,t.version_check_url=h,t.exe_download_url=m,t.check_interval_seconds=v;(await c.XO.post("auto_upgrade_setting/save",t)).code===d.m.Success&&(0,x.SK)(e("保存成功"))}}),children:[(0,f.jsx)("div",{children:e("ver_url")}),(0,f.jsx)(r.Sm,{placeholder:"https://registry.npmjs.org",value:h,handleInputChange:e=>{_(e)}}),(0,f.jsx)(r.l6,{value:s,onChange:e=>{i(e)},options:[{title:e("开启"),value:!0},{title:e("关闭"),value:!1}]}),s&&(0,f.jsxs)(f.Fragment,{children:[!1,(0,f.jsx)("div",{children:e("检测频率(秒)")}),(0,f.jsx)(r.Sm,{placeholder:e("def_180"),value:v,handleInputChange:e=>{g(Number(e)||180)}}),(0,f.jsx)("div",{style:{marginTop:"12px"},children:(0,f.jsx)(o.C3,{text:e(S?"升级检测中...":"立即升级"),clickFun:async()=>{C(!0);try{(await c.XO.post("auto_upgrade_setting/upgrade_now",{})).code===d.m.Success&&(0,x.SK)(e("已触发升级检测,请查看服务端日志"))}catch(t){(0,x.zN)(e("触发升级失败"))}finally{C(!1)}}})})]})]}):null}function z(){const{t:e}=(0,u.Bd)(),[,t]=(0,w.fp)(p.AG.prompt_card),[s,i]=(0,n.useState)(""),[a,_]=(0,n.useState)(5610),[m,j]=(0,n.useState)(5710);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("sys_option/status");if(e.code===d.m.Success){const t=e.data?.sys_env;i((t?.browser_proxy_allow||[]).join("\n")),_(t?.browser_proxy_port_start||5610),j(t?.browser_proxy_port_end||5710)}})()},[]);return(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("网页代理")}),(0,f.jsx)(o.rA,{icon:"info",title:e("信息"),onClick:()=>{t({open:!0,title:e("信息"),context_div:(0,f.jsx)("div",{children:(0,f.jsx)("div",{children:e("wbvpn_tip")})})})}})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{const t=s.split("\n").map(e=>e.trim()).filter(e=>!!e);(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{browser_proxy_allow:t,browser_proxy_port_start:Number(a)||5610,browser_proxy_port_end:Number(m)||5710}})).code===d.m.Success&&(0,x.SK)(e("修改成功"))}}),children:[(0,f.jsx)("div",{children:e("wbvpn_allow")}),(0,f.jsx)(r.Z2,{style:{minHeight:"5rem",resize:"vertical"},placeholder:e("wbvpn_allow_ph"),value:s,onChange:e=>{i(e.target.value)}}),(0,f.jsx)("div",{children:e("wbvpn_port_range")}),(0,f.jsx)(h.S,{isFlex:!0,columns:[(0,f.jsx)(r.Sm,{placeholder:"5610",value:a,handleInputChange:e=>_(e)}),(0,f.jsx)("span",{style:{padding:"0 6px"},children:"-"}),(0,f.jsx)(r.Sm,{placeholder:"5710",value:m,handleInputChange:e=>j(e)})]})]})}function F(){const[e,t]=(0,n.useState)(""),[s,a]=(0,n.useState)(""),[_,m]=(0,n.useState)(!1),[j,v]=(0,n.useState)(""),[g,S]=(0,n.useState)(!1),[C,A]=(0,n.useState)(""),[F,K]=(0,w.fp)(p.AG.prompt_card),[O,B]=(0,n.useState)(!1),[P,$]=(0,n.useState)(""),[E,M]=(0,n.useState)(""),[D,T]=(0,n.useState)(I.aM.close),[G,q]=(0,n.useState)(!1),[Z,R]=(0,n.useState)(void 0),{t:W,i18n:H}=(0,u.Bd)(),[U,Q]=(0,w.fp)(p.AG.user_base_info),{check_user_auth:J}=(0,y.MH)(),{initUserInfo:L}=(0,n.useContext)(N.F);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("sys_option/status");if(e.code===d.m.Success){S(e.data.recycle_open),A(e.data.recycle_dir);const s=e.data.sys_env;t(s?.web_site_title),a(s?.logo||""),m(s?.show_login_user_info),v(s?.http_proxy||"");const n=e.data.https_setting;n&&(B(n.open),$(n.cert_path||""),M(n.key_path||""))}const s=await c.XO.get("token");if(s.code===d.m.Success){const e=s.data;if(!e)return;e.length&&R(e.length),e.mode&&T(e.mode),void 0!==e.persist&&q(e.persist)}})()},[]);return(0,f.jsxs)("div",{children:[(0,f.jsx)(k.aZ,{children:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("span",{className:"credits",children:[W("系统运行于"),": ",(0,V.s)(U.runing_time_length)]}),(0,f.jsx)("span",{className:"credits",children:(0,f.jsxs)("a",{href:"https://github.com/xiaobaidadada/filecat",target:"_blank",children:["version:7.14.4",null!=U.latest_version&&"7.14.4"!==U.latest_version?` -> ${U.latest_version}`:""]})}),(0,f.jsx)("span",{className:"credits",children:(0,f.jsx)("a",{href:W("官网地址"),target:"_blank",children:`filecat ${W("功能文档")}`})}),(0,f.jsxs)("span",{className:"credits",children:[W("安装方式")," :",U.process_env_run_env]})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:W("通用设置")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{K({open:!0,title:W("信息"),context_div:(0,f.jsx)("div",{children:(0,f.jsx)("div",{children:W("pxy_tip")})})})},title:W("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:W("确定修改"),clickFun:async()=>{(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.sys_env,value:{web_site_title:e,show_login_user_info:_,http_proxy:j,logo:s}})).code===d.m.Success&&((0,x.SK)("修改成功"),L())}}),children:[W("网站标题"),(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{t(e)}}),W("网站 Logo"),(0,f.jsx)(r.Sm,{placeholder:W("lclorur"),value:s,handleInputChange:e=>{a(e)}}),(0,f.jsx)("div",{children:W("pxy_url")}),(0,f.jsx)(r.Sm,{placeholder:"http://127.0.0.1:7890",value:j,handleInputChange:e=>{v(e)}}),W("lgn_usr"),(0,f.jsx)("input",{type:"checkbox",checked:_,onChange:()=>{m(!_)}})]}),(0,f.jsxs)(l.Zp,{title:W("https_s"),rightBottomCom:(0,f.jsx)(o.C3,{text:W("确定修改"),clickFun:async()=>{if(O){if(!P)return void(0,x.zN)("证书路径不能为空");if(!E)return void(0,x.zN)("私钥路径不能为空")}const e=new I.CH;e.open=O,e.cert_path=P,e.key_path=E;(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.https,value:e,open:O})).code===d.m.Success&&(0,x.SK)("HTTPS 设置已保存,需重启服务器才能生效")}}),children:[(0,f.jsx)(r.l6,{value:O,onChange:e=>{B(e)},options:[{title:W("开启"),value:!0},{title:W("关闭"),value:!1}]}),O&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{children:W("ssl_crt")}),(0,f.jsx)(r.Sm,{placeholder:W("crt_pth"),value:P,handleInputChange:e=>{$(e)}}),(0,f.jsx)("div",{children:W("ssl_key")}),(0,f.jsx)(r.Sm,{placeholder:W("ky_pth"),value:E,handleInputChange:e=>{M(e)}})]})]}),(0,f.jsx)(X,{}),(0,f.jsx)(z,{})]}),(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:W("文件回收站")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{K({open:!0,title:W("信息"),context_div:(0,f.jsx)("div",{children:W("格式:[被删除的文件所在父目录] 回收站目录 [; ...]")})})},title:W("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:W("确定修改"),clickFun:async()=>{if(g&&!C)return void(0,x.zN)("目录不能为空");(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.cyc,value:C,open:g})).code===d.m.Success&&(0,x.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:W("目录"),value:C,handleInputChange:e=>{A(e)}}),(0,f.jsx)(r.l6,{value:g,onChange:e=>{S(e)},options:[{title:W("开启"),value:!0},{title:W("关闭"),value:!1}]})]}),(0,f.jsxs)(l.Zp,{title:W("tk_exp"),rightBottomCom:(0,f.jsx)(h.S,{isFlex:!0,columns:[(0,f.jsx)(o.C3,{text:W("清空token"),clickFun:async()=>{(await c.XO.get("token/clear")).code===d.m.Success&&(0,x.SK)("清理完成,重新登录")}}),(0,f.jsx)(o.C3,{text:W("保存"),clickFun:async()=>{const e=new I.Gd;e.mode=D,e.persist=G,I.aM.length!==e.mode||Z||(0,x.zN)("秒数不能为空"),e.length=parseInt(Z);(await c.XO.post("token/save",e)).code===d.m.Success&&(0,x.SK)("保存成功")}})]}),children:[(0,f.jsx)(h.S,{isFlex:!0,columns:[(0,f.jsx)(r.U6,{value:1,context:W("关闭"),selected:D===I.aM.close,onchange:()=>{T(I.aM.close)}}),(0,f.jsx)(r.U6,{value:1,context:W("指定时间"),selected:D===I.aM.length,onchange:()=>{T(I.aM.length)}}),(0,f.jsx)(r.U6,{value:1,context:W("永不过期"),selected:D===I.aM.forver,onchange:()=>{T(I.aM.forver)}})]}),D===I.aM.length&&(0,f.jsx)(r.Sm,{placeholder:W("秒"),value:Z,handleInputChange:e=>{R(e)}}),(0,f.jsxs)("label",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,whiteSpace:"nowrap"},children:[(0,f.jsx)("input",{type:"checkbox",checked:G,onChange:()=>q(!G)}),W("持久化")]})]})]})]})})]})}var K=s(92350);function O(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:a}=(0,n.useContext)(N.F),[_,m]=(0,n.useState)([]),[j,g]=(0,n.useState)([]),[C,b]=(0,w.fp)(p.AG.prompt_card),[,k]=(0,w.fp)(p.AG.editorSetting),[A,I]=(0,n.useState)([]),[V,X]=(0,n.useState)([]),[z,F]=(0,n.useState)([]),[O,B]=(0,n.useState)([]),[P,$]=(0,n.useState)(""),[E,M]=(0,n.useState)([]),D=(0,S.K)(),T=[e("软件"),e("是否安装"),e("路径")],G=[e("编号"),e("路径"),e("备注")],q=[e("编号"),e("路径"),e("是否开启"),e("备注")],Z=[e("编号"),e("文件路径"),e("是否开启"),e("系统启动执行"),e("corn表达式"),e("用户id"),e("备注")],R=[e("编号"),e("路径"),e("单用户并发数量"),e("系统并发数量"),e("big_res"),e("big_sz"),e("大文件并发数量"),e("big_ck"),e("备注")],W=[e("编号"),e("名称"),e("路径"),e("是否开启"),e("params"),e("备注")],{check_user_auth:H}=(0,y.MH)(),U=async()=>{const e=await c.XO.get("env/path/get");e.code===d.m.Success&&F(e.data)},Q=async()=>{const e=await c.XO.get("workflow_setting_get");e.code===d.m.Success&&B(e.data)};(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("outside/software/get");e.code===d.m.Success&&g(e.data);const t=await c.XO.get("pty_cmd");t.code===d.m.Success&&$(t.data),U(),Q();const s=await c.XO.get("protection_dir/sys");s.code===d.m.Success&&I(s.data??[]);const n=await c.XO.get("dir_upload_max_num");n.code===d.m.Success&&X(n.data??[]);const i=await c.XO.get("plugin/list");i.code===d.m.Success&&M(i.data??[])})()},[]);const J=(0,K.Q)(),L=async()=>{(await c.XO.post("plugin/list/save",E)).code===d.m.Success&&(0,x.SK)(e("保存成功"))};return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(i.J,{widthPer:100,maxWidth:"100rem",children:(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("up_conc")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("文件上传")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...V,{path:"",note:"",user_upload_num:2,sys_upload_num:6,ws_file_standard_size:52428800,ws_file_parallel_num:2,ws_file_block_mb_size:524288}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{for(const e of V)if(e.open_ws_file){if("number"!=typeof e.ws_file_block_mb_size)return void(0,x.zN)(`编号:${e.index??""} 文件块的大小设置有问题`);if("number"!=typeof e.ws_file_parallel_num)return void(0,x.zN)(`编号:${e.index??""} 并发数量设置有问题`);if("number"!=typeof e.ws_file_standard_size)return void(0,x.zN)(`编号:${e.index??""} 大文件size设置有问题`)}(0,v.di)(V,e=>e.index??0);(await c.XO.post("dir_upload_max_num/save",V)).code===d.m.Success&&((0,x.SK)("保存成功"),a())}})]}),children:(0,f.jsx)(h.X,{headers:R,rows:V.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.index,placeholder:s,handleInputChange:e=>{t.index=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.user_upload_num,handleInputChange:e=>{t.user_upload_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.sys_upload_num,handleInputChange:e=>{t.sys_upload_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.l6,{value:!0===t.open_ws_file,onChange:e=>{t.open_ws_file=e,X([...V])},options:D,no_border:!0}),(0,f.jsx)(r.Sm,{value:"number"==typeof t.ws_file_standard_size?t.ws_file_standard_size/1024/1024:void 0,handleInputChange:e=>{t.ws_file_standard_size=1024*parseInt(e)*1024},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.ws_file_parallel_num,handleInputChange:e=>{t.ws_file_parallel_num=parseInt(e)},no_border:!0}),(0,f.jsx)(r.Sm,{value:"number"==typeof t.ws_file_block_mb_size?t.ws_file_block_mb_size/1024/1024:void 0,handleInputChange:e=>{t.ws_file_block_mb_size=1024*parseInt(e)*1024},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{V.splice(e,1),X([...V])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{X((0,v.TI)(V,e,t))}})})}),(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"50rem",children:(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("PATH")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("环境路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"list",title:e("查看"),onClick:async()=>{const t=await c.XO.get("env/process/view");t.code===d.m.Success?b({open:!0,title:e("进程环境变量"),context_div:(0,f.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:"60vh",overflow:"auto",margin:0,fontSize:"0.85rem",lineHeight:"1.5"},children:t.data})}):(0,x.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:async()=>{const t=await c.XO.get("env/process/get");t.code===d.m.Success?(y.xK.set_value_temp(t.data??""),k({model:"ace/mode/ini",open:!0,fileName:"",save:async t=>{(await c.XO.post("env/process/save",{text:t})).code===d.m.Success?(0,x.SK)(e("保存成功")):(0,x.zN)(e("保存失败")),y.xK.set_value_temp("")}})):(0,x.zN)(e("获取失败"))}}),(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{F([...z,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("env/path/save",{paths:z})).code===d.m.Success&&((0,x.SK)("保存成功"),U(),s())}})]}),children:(0,f.jsx)(h.X,{headers:q,rows:z.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,F([...z])},options:D,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{z.splice(e,1),F([...z])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{F((0,v.TI)(z,e,t))}})}),(0,f.jsx)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("PTY CMD")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("pty")},title:e("信息")})]}),rightBottomCom:(0,f.jsx)(o.C3,{text:e("更新"),clickFun:async()=>{(await c.XO.post("pty_cmd/save",{str:P})).code===d.m.Success&&((0,x.SK)("保存成功"),a())}}),children:(0,f.jsx)(r.Sm,{placeholder:e("cmd need pty env"),value:P,handleInputChange:e=>{$(e)}})}),(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("Workflow Job")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("Workflow")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{B([...O,{open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("workflow_setting_save",O)).code===d.m.Success&&((0,x.SK)("ok"),Q())}})]}),children:(0,f.jsx)(h.X,{headers:Z,rows:O.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.file_path,handleInputChange:e=>{t.file_path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,B([...O])},options:D,no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.sys_power_on,onChange:e=>{t.sys_power_on=e,B([...O])},options:D,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cron_str,handleInputChange:e=>{t.cron_str=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.user_id,handleInputChange:e=>{t.user_id=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{O.splice(e,1),B([...O])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{B((0,v.TI)(O,e,t))}})}),(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("插件配置")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("插件配置")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{M([...E,{name:"",path:"",note:"",open:!1}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:L})]}),children:(0,f.jsx)(h.X,{headers:W,rows:E.map((t,s)=>{const n=[s,(0,f.jsx)(r.Sm,{value:t.name,handleInputChange:e=>{t.name=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:!!t.open,onChange:e=>{t.open=e,M([...E])},options:D,no_border:!0}),(0,f.jsx)(o.mu,{icon:"edit",save:async e=>{t.params=e,await L()},title:""}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{E.splice(e,1),M([...E])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{M((0,v.TI)(E,e,t))}})})]})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"50rem",children:(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("系统保护路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J("保护目录")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{I([...A,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("protection_dir/sys/save",A)).code===d.m.Success&&((0,x.SK)("保存成功"),a())}})]}),children:(0,f.jsx)(h.X,{headers:G,rows:A.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{A.splice(e,1),I([...A])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{I((0,v.TI)(A,e,t))}})}),(0,f.jsx)(l.uF,{title:e("外部软件"),titleCom:(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("outside/software/save",j)).code===d.m.Success&&((0,x.SK)("保存成功"),s())}}),children:(0,f.jsx)(h.X,{headers:T,rows:j.map((t,s)=>[(0,f.jsx)("div",{children:t.id}),(0,f.jsx)(l.fq,{ok:t.installed}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0,placeholder:e("use_env")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{J(t.id)},title:e("信息")})]),width:"10rem"})})]})})]})]})}function B(e){const{t,i18n:s}=(0,u.Bd)(),[i,l]=(0,w.fp)(p.AG.user_base_info),o=[{title:t("用户权限"),list:[{title:t("用户管理"),permission:a.oV.user_manage},{title:t("角色管理"),permission:a.oV.role_manage}]},{title:t("系统管理权限"),list:[{title:t("系统信息"),permission:a.oV.all_sys},{title:t("系统进程关闭"),permission:a.oV.sys_process_close},{title:t("dc_ctdl"),permission:a.oV.docker_container_update},{title:t("dc_idl"),permission:a.oV.docker_images_delete},{title:t("systemd管理"),permission:a.oV.systemd},{title:t("防火墙管理"),permission:a.oV.firewall}]},{title:t("网络功能权限"),list:[{title:t("系统网络"),permission:a.oV.vir_net},{title:t("内网穿透"),permission:a.oV.tcp_proxy},{title:"ddns",permission:a.oV.ddns}]},{title:t("Ai 设置权限"),list:[{title:t("Ai 配置"),permission:a.oV.ai_agent_setting},{title:t("ai_page"),permission:a.oV.ai_agent_page},{title:t("sw_mdl"),permission:a.oV.ai_model_switch}]},{title:t("文件权限"),list:[{title:t("log_del"),permission:a.oV.filecat_file_delete_cut_rename},{title:t("log_wr"),permission:a.oV.filecat_file_context_update_upload_created_copy_decompression},{title:t("内容更新"),permission:a.oV.filecat_file_context_update},{title:t("文件回收站修改"),permission:a.oV.recycle_file_save},{title:t("文件分享"),permission:a.oV.share_file}]},{title:t("系统设置权限"),list:[{title:t("系统页面"),permission:a.oV.sys_setting_page},{title:t("htts"),permission:a.oV.https_file},{title:t("tk_time"),permission:a.oV.token_update},{title:t("修改密码"),permission:a.oV.update_password},{title:t("磁盘挂载"),permission:a.oV.sys_disk_mount},{title:t("通用设置"),permission:a.oV.sys_env_setting_key},{title:t("md_set"),permission:a.oV.md_editor_setting},{title:t("目录挂载"),permission:a.oV.file_mount}]},{title:t("系统环境设置"),list:[{title:t("sys_env"),permission:a.oV.sys_env_page},{title:t("up_lim"),permission:a.oV.dir_upload_max_num},{title:t("path_md"),permission:a.oV.env_path_update},{title:"pty cmd "+t("更新"),permission:a.oV.pty_cmd_update},{title:"workflow job",permission:a.oV.workflow_job},{title:t("path_up"),permission:a.oV.sys_protection_dir},{title:t("外部软件路径"),permission:a.oV.outside_software_path}]},{title:t("个人环境设置"),list:[{title:t("个性化设置"),permission:a.oV.private_sys_env}]},{title:t("自定义路由"),list:[{title:t("自定义路由页面"),permission:a.oV.auth_router_page},{title:t("wf_api"),permission:a.oV.workflow_api},{title:t("自定义资源路由"),permission:a.oV.code_resource},{title:t("api_rt"),permission:a.oV.code_api}]},{title:t("标签编辑权限"),list:[{title:t("ssh代理"),permission:a.oV.ssh_proxy_tag_update},{title:t("http代理"),permission:a.oV.http_proxy_tag_update},{title:t("浏览器代理"),permission:a.oV.browser_proxy_tag_update},{title:t("rdp代理"),permission:a.oV.rdp_proxy_tag_update},{title:t("网络唤醒"),permission:a.oV.wol_proxy_tag_update},{title:t("rtsp播放器"),permission:a.oV.rtsp_proxy_tag_update}]},{title:t("代理功能"),list:[{title:t("ssh代理"),permission:a.oV.ssh_proxy},{title:t("http代理"),permission:a.oV.http_proxy},{title:t("pxy_off"),permission:a.oV.http_proxy_download_cancel},{title:t("浏览器代理"),permission:a.oV.browser_proxy},{title:t("浏览器代理编辑"),permission:a.oV.browser_proxy_edit},{title:t("rdp代理"),permission:a.oV.rdp_proxy}]},{title:t("其他功能"),list:[{title:t("wf_run"),permission:a.oV.workflow_exe},{title:t("wf_user"),permission:a.oV.workflow_exe_user,noDisable:!0},{title:t("网络唤醒"),permission:a.oV.wol_proxy},{title:t("端口扫描"),permission:a.oV.port_scan},{title:t("rtsp播放器"),permission:a.oV.rtsp_proxy},{title:t("ssh_sv"),permission:a.oV.crypto_ssh_file},{title:t("cmd_rst"),permission:a.oV.shell_cmd_filecat_restart},{title:t("cmd_upg"),permission:a.oV.shell_cmd_filecat_upgrade},{title:t("cmd_dwn"),permission:a.oV.shell_cmd_filecat_kill_self},{title:t("cmd_ai"),permission:a.oV.ai_chat_cmd}]}];return(0,f.jsx)(n.Fragment,{children:o.map((t,s)=>(0,f.jsxs)("div",{children:[(0,f.jsx)("h3",{children:t.title}),t.list.map((t,s)=>(0,f.jsxs)("div",{children:[(0,f.jsx)("input",{type:"checkbox",disabled:!t.noDisable&&e.is_disable(t.permission),checked:e.is_selected(t.permission,t.noDisable),onChange:()=>{e.select_auth(t.permission)}}),t.title]},s))]},s))})}const P=new Map;function $(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:_}=(0,n.useContext)(N.F),[j,g]=(0,w.fp)(p.AG.user_base_info),[y,S]=(0,n.useState)([]),[C,b]=(0,w.fp)(p.AG.prompt_card),[k,A]=(0,n.useState)(!1),[I,V]=(0,n.useState)(!1),[X,z]=(0,w.fp)(p.AG.confirm),[F,O]=(0,n.useState)(""),[$,E]=(0,n.useState)(""),[M,D]=(0,n.useState)(""),[T,G]=(0,n.useState)([]),[q,Z]=(0,n.useState)([]),[R,W]=(0,n.useState)([]),[H,U]=(0,n.useState)(""),[Q,J]=(0,n.useState)(""),[L,Y]=(0,n.useState)("en"),[ee,te]=(0,n.useState)(""),[se,ne]=(0,n.useState)([]),[ie,ae]=(0,n.useState)(""),[le,oe]=(0,n.useState)(!1),[re,ce]=(0,n.useState)(""),[de,he]=(0,n.useState)(""),[ue,pe]=(0,n.useState)({}),_e=(0,K.o)(),[xe,me]=(0,n.useState)([]),[je,ve]=(0,n.useState)(void 0),fe=[e("用户id"),e("用户名"),e("目录范围"),e("备注")],ge=async()=>{const e=await c.wm.get("all_users");if(e.code===d.m.Success){const t=e.data??[];if(je){const e=[];for(const s of t)`${s.id}${s.username}${s.cwd}${s.note}`.includes(je)&&e.push(s);S(e)}else S(t)}const t=await c.wm.get("all_roles");if(t.code===d.m.Success){me(t.data),P.clear();for(const e of t.data)P.set(e.role_id,e)}},we=e=>{O(e?.username??""),E(e?.password??""),D(e?.cwd??""),G(e?.access_dirs??[]),Z(e?.not_access_dirs??[]),W(e?.only_read_dirs??[]),U(e?.access_cmd??""),J(e?.not_access_cmd??""),Y(e?.language??""),te(e?.theme??""),ne(e?.auth_list??[]),ae(e?.note??""),oe(e?.is_root??!1),ce(e?.id??""),e?.bind_role_id?ye(e.bind_role_id,e.auth_list??[]):(he(""),pe({}))};(0,n.useEffect)(()=>{ge()},[]);const ye=(e,t=[])=>{if(!e)return he(""),void pe({});const s=P.get(e);if(s){if(s.cwd&&D(s.cwd),s.access_dirs&&s.access_dirs.length>0&&G(s.access_dirs),s.not_access_dirs&&s.not_access_dirs.length>0&&Z(s.not_access_dirs),s.only_read_dirs&&s.only_read_dirs.length>0&&W(s.only_read_dirs),s.access_cmd&&U(s.access_cmd),s.not_access_cmd&&J(s.not_access_cmd),s.language&&Y(s.language),s.theme&&te(s.theme),s.auth_list&&s.auth_list.length>0){const e=new Set(s.auth_list);for(const s of t)e.add(s);ne(Array.from(e))}he(e),pe(s)}},Se=()=>{if(!F)return void(0,x.zN)("username not empty");if((0,m.CB)(F))return void(0,x.zN)("username not empty char");if(!M)return void(0,x.zN)("cwd not empty");const e=new a.E0;return e.language=L,e.theme=ee,e.access_dirs=T,e.username=F,e.password=$,e.not_access_dirs=q,e.only_read_dirs=R,e.cwd=M,e.note=ie,e.access_cmd=H,e.not_access_cmd=Q,e.auth_list=se,e.bind_role_id=de,e};return(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.uF,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("用户")})}),titleCom:(0,f.jsxs)("div",{className:"div-row",style:{gap:"0.5rem"},children:[(0,f.jsx)(r.Sm,{placeholder:e("过滤"),value:je,handleInputChange:e=>{ve(e)},handlerEnter:()=>{ge()}}),(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{A(!0),V(!1),we(void 0)}})]}),children:(0,f.jsx)(h.X,{headers:fe,rows:y.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.id}),(0,f.jsx)(l.xP,{children:t.username}),(0,f.jsx)(l.xP,{children:t.cwd}),(0,f.jsx)(l.xP,{children:t.note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{A(!1),V(!0),we(e)})(t)}),!t.is_root&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async t=>{z({open:!0,title:e("确定删除吗"),handle:async()=>{const e=new a.E0;e.username=t,(await c.wm.post("delete_user",e)).code===d.m.Success&&((0,x.SK)("删除完成"),ge(),z({open:!1,handle:null}))}})})(t.username)})]})];return n}),width:"10rem"})})})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(k||I)&&(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e(""+(k?"添加":"编辑"))})," "]}),rightBottomCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:()=>{A(!1),V(!1),we(void 0)}}),k&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{if(!$)return void(0,x.zN)("password not empty");if((0,m.CB)($))return void(0,x.zN)("username not empty char");const e=Se(),t=await c.wm.post("create_user",e);ge(),t.code===d.m.Success&&((0,x.SK)("创建完成"),ge(),A(!1),V(!1),we(void 0))}}),I&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=Se();if(!e)return;e.id=re;(await c.wm.post("save_user",e)).code===d.m.Success&&((0,x.SK)("保存完成"),ge())}})]}),children:[(0,f.jsx)("label",{children:e("用户名")}),(0,f.jsx)(r.Sm,{value:F,handleInputChange:e=>O(e)}),(0,f.jsx)("label",{children:e("密码")}),(0,f.jsx)(r.Sm,{type:"password",value:$,handleInputChange:e=>E(e)}),(0,f.jsxs)("label",{children:[!ue?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{G([...T,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{disabled:""!==ue.cwd&&void 0!==ue.cwd,value:M,handleInputChange:e=>D(e)}),(T??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==ue?.access_dirs?.length&&void 0!==ue?.access_dirs?.length,value:t,handleInputChange:e=>{T[s]=e,G([...T])}})}),0===ue?.access_dirs?.length||void 0===ue?.access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{T.splice(s,1),G([...T])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!ue?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{Z([...q,""])},title:e("添加")}),e("禁止目录范围")]}),(q??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==ue?.not_access_dirs?.length&&void 0!==ue?.not_access_dirs?.length,value:t,handleInputChange:e=>{q[s]=e,Z([...q])}})}),0===ue?.not_access_dirs?.length||void 0===ue?.not_access_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{q.splice(s,1),Z([...q])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[!ue?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{W([...R,""])},title:e("添加")}),e("只读目录范围")]}),(R??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{disabled:0!==ue?.only_read_dirs?.length&&void 0!==ue?.only_read_dirs?.length,value:t,handleInputChange:e=>{R[s]=e,W([...R])}})}),0===ue?.only_read_dirs?.length||void 0===ue?.only_read_dirs?.length&&(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{R.splice(s,1),W([...R])},title:e("删除")})]},s)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==ue.access_cmd&&void 0!==ue.access_cmd,value:H,placeholder:"use blank split",handleInputChange:e=>U(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{disabled:""!==ue.not_access_cmd&&void 0!==ue.not_access_cmd,value:Q,placeholder:"use blank split",handleInputChange:e=>J(e)}),!le&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)("label",{children:e("角色")}),(0,f.jsx)(r.l6,{value:de,onChange:e=>{ye(e)},options:(()=>{const e=[];e.push({title:"NOT",value:""});for(let t of xe)e.push({title:t.role_name,value:t.role_id});return e})()})]}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{disabled:""!==ue.language&&void 0!==ue.language,value:L,onChange:e=>{Y(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"English",value:"en"},{title:"中文",value:"zh"}]}),(0,f.jsx)("label",{children:e("主题")}),(0,f.jsx)(r.l6,{disabled:""!==ue.theme&&void 0!==ue.theme,value:ee,onChange:e=>{te(e)},options:_e}),(0,f.jsx)(B,{is_disable:e=>{if(!0===le)return!0;if(de){const t=P.get(de);if(t)return(t.auth_list??[]).includes(e)}return!1},is_selected:(e,t)=>!t&&!0===le||void 0!==se?.find(t=>t===e),select_auth:e=>{se?se.includes(e)?((0,v.I)(se,t=>t===e),ne([...se])):ne([...se,e]):ne([e])}}),(0,f.jsx)("label",{children:e("备注")}),(0,f.jsx)(r.Sm,{value:ie,handleInputChange:e=>ae(e)})]})})})]})}function E(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s}=(0,n.useContext)(N.F),[_,m]=(0,n.useState)([]),[j,g]=(0,w.fp)(p.AG.prompt_card),[y,S]=(0,n.useState)(!1),[C,b]=(0,n.useState)(!1),[k,A]=(0,w.fp)(p.AG.confirm),[I,V]=(0,n.useState)(""),[X,z]=(0,n.useState)(""),[F,O]=(0,n.useState)([]),[P,$]=(0,n.useState)([]),[E,M]=(0,n.useState)([]),[D,T]=(0,n.useState)(""),[G,q]=(0,n.useState)(""),[Z,R]=(0,n.useState)(""),[W,H]=(0,n.useState)(""),[U,Q]=(0,n.useState)([]),[J,L]=(0,n.useState)(""),[Y,ee]=(0,n.useState)(""),te=(0,K.o)(),se=[e("角色id"),e("角色名"),e("备注")],ne=async()=>{const e=await c.wm.get("all_roles");e.code===d.m.Success&&m(e.data)},ie=e=>{V(e?.role_name??""),z(e?.cwd??""),O(e?.access_dirs??[]),$(e?.not_access_dirs??[]),M(e?.only_read_dirs??[]),T(e?.access_cmd??""),q(e?.not_access_cmd??""),R(e?.language??""),H(e?.theme??""),Q(e?.auth_list??[]),L(e?.role_id??""),ee(e?.role_note??"")};(0,n.useEffect)(()=>{ne()},[]);const ae=()=>{if(!I)return void(0,x.zN)("role_name not empty");const e=new a.E0;return e.language=Z,e.theme=W,e.access_dirs=F,e.role_name=I,e.not_access_dirs=P,e.only_read_dirs=E,e.cwd=X,e.access_cmd=D,e.not_access_cmd=G,e.auth_list=U,e.role_note=Y,e};return(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(0,f.jsx)(i.xh,{children:(0,f.jsx)(l.uF,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("角色")})}),titleCom:(0,f.jsx)("div",{children:(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{S(!0),b(!1),ie(void 0)}})}),children:(0,f.jsx)(h.X,{headers:se,rows:_.map((t,s)=>{const n=[(0,f.jsx)("p",{children:t.role_id}),(0,f.jsx)(l.xP,{children:t.role_name}),(0,f.jsx)(l.xP,{children:t.role_note}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{S(!1),b(!0),ie(e)})(t)}),!t.is_root&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async t=>{A({open:!0,title:e("确定删除吗"),handle:async()=>{const e=new a.E0;e.role_id=t,(await c.wm.post("delete_role",e)).code===d.m.Success&&((0,x.SK)("删除完成"),ne(),A({open:!1,handle:null}))}})})(t.role_id)})]})];return n}),width:"10rem"})})})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"40rem",children:(y||C)&&(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e(""+(y?"添加":"编辑"))})," "]}),rightBottomCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:()=>{S(!1),b(!1),ie(void 0)}}),y&&(0,f.jsx)(o.rA,{icon:"add_circle",title:e("添加"),onClick:async()=>{const e=ae();if(!e)return;const t=await c.wm.post("create_role",e);ne(),t.code===d.m.Success&&((0,x.SK)("创建完成"),ne(),S(!1),b(!1),ie(void 0))}}),C&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const e=ae();if(!e)return;e.role_id=J;(await c.wm.post("save_role",e)).code===d.m.Success&&((0,x.SK)("保存完成"),ne())}})]}),children:[(0,f.jsx)("label",{children:e("角色名")}),(0,f.jsx)(r.Sm,{value:I,handleInputChange:e=>V(e)}),(0,f.jsx)("label",{children:e("角色备注")}),(0,f.jsx)(r.Sm,{value:Y,handleInputChange:e=>ee(e)}),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{O([...F,""])},title:"添加"}),e("目录范围")]}),(0,f.jsx)(r.Sm,{value:X,handleInputChange:e=>z(e)}),(F??[]).map((e,t)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{F[t]=e,O([...F])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{F.splice(t,1),O([...F])},title:"删除"})]},t)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{$([...P,""])},title:"添加"}),e("禁止目录范围")]}),(P??[]).map((t,s)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:t,handleInputChange:e=>{P[s]=e,$([...P])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{P.splice(s,1),$([...P])},title:e("删除")})]},s)),(0,f.jsxs)("label",{children:[(0,f.jsx)(o.rA,{icon:"add",onClick:()=>{M([...E,""])},title:e("添加")}),e("只读目录范围")]}),(E??[]).map((e,t)=>(0,f.jsxs)("div",{style:{display:"flex"},children:[(0,f.jsx)("div",{style:{width:"90%"},children:(0,f.jsx)(r.Sm,{value:e,handleInputChange:e=>{E[t]=e,M([...E])}})}),(0,f.jsx)(o.rA,{icon:"delete",onClick:()=>{E.splice(t,1),M([...E])},title:"删除"})]},t)),(0,f.jsx)("label",{children:e("可执行的命令")}),(0,f.jsx)(r.Sm,{value:D,placeholder:"use blank split",handleInputChange:e=>T(e)}),(0,f.jsx)("label",{children:e("禁止执行的命令")}),(0,f.jsx)(r.Sm,{value:G,placeholder:"use blank split",handleInputChange:e=>q(e)}),(0,f.jsx)("label",{children:e("语言")}),(0,f.jsx)(r.l6,{value:Z,onChange:e=>{R(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"NOT",value:""},{title:"English",value:"en"},{title:"中文",value:"zh"}]}),(0,f.jsx)("label",{children:e("主题")}),(0,f.jsx)(r.l6,{value:W,onChange:e=>{H(e)},options:te}),(0,f.jsx)(B,{is_disable:()=>!1,is_selected:(e,t)=>void 0!==U?.find(t=>t===e),select_auth:e=>{U?(U.find(t=>t==e)?(0,v.I)(U,t=>t===e):U.push(e),Q([...U])):Q([e])}})]})})})]})}var M=s(93245);function D(){const{t:e,i18n:t}=(0,u.Bd)(),{initUserInfo:s,reloadUserInfo:_}=(0,n.useContext)(N.F),[m,j]=(0,n.useState)([]),[g,y]=(0,w.fp)(p.AG.prompt_card),[C,k]=(0,n.useState)([]),[A,V]=(0,n.useState)([]),[X,z]=(0,n.useState)([]),[F,O]=(0,w.fp)(p.AG.user_base_info),B=(0,S.K)(),P=(0,K.o)(),$=[e("编号"),e("路径"),e("是否默认"),e("备注")],E=[e("编号"),e("路径"),e("备注")],D=[e("编号"),e("命令"),e("父编号"),e("备注")],T=[e("文件后缀"),e("命令"),e("其他参数"),e("备注")],[G,q]=(0,n.useState)(""),[Z,R]=(0,n.useState)(""),[W,H]=(0,n.useState)(""),[U,Q]=(0,n.useState)(!1),[J,L]=(0,n.useState)(""),[Y,ee]=(0,n.useState)(""),[te,se]=(0,n.useState)(""),[ne,ie]=(0,n.useState)(!1),[ae,le]=(0,n.useState)(""),[oe,re]=(0,n.useState)([]);(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("filesSetting");e.code===d.m.Success&&(j(e.data.dirs),V(e.data.quick_cmd),z(e.data.file_quick_cmd));const t=await c.XO.get("protection_dir");t.code===d.m.Success&&k(t.data??[])})(),L(F?.user_data?.language),ee(F?.user_data?.theme),se(F?.user_data?.upload_file_ignore);const e=F?.user_data?.editor_auto_save;ie(!!e?.enable),le(null!=e?.interval?String(e.interval):""),re(e?.editors??[])},[]);const ce=(0,K.Q)();return(0,f.jsx)(n.Fragment,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsxs)(i.VP,{widthPer:33,children:[(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{title:e("修改密码"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{if(!G||!Z)return void(0,x.zN)("账号密码不能为空");if(Z!==W)return void(0,x.zN)("两次密码不一样");const e=new a.tl;e.username=G,e.password=Z,e.confirm_password=W,e.user_id=F.user_data.id;(await c.wm.post("updatePassword",e)).code===d.m.Success&&(0,x.SK)("修改成功")}}),children:[(0,f.jsx)(r.Sm,{placeholder:e("新账号"),value:G,handleInputChange:e=>{q(e)}}),(0,f.jsx)(r.cA,{placeholder:e("新密码"),handleInputChange:e=>{R(e)}}),(0,f.jsx)(r.cA,{placeholder:e("确认密码"),handleInputChange:e=>{H(e)}})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{title:e("个性化设置"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{(await c.XO.post(b.s.setting_sys_option_status_save,{type:I.Mu.private_sys_env,value:{language:J,theme:Y,upload_file_ignore:te}})).code===d.m.Success&&((0,x.SK)("修改成功"),s())}}),children:[e("语言"),(0,f.jsx)(r.l6,{value:J,onChange:e=>{L(e)},options:[{title:e("跟随系统"),value:"sys"},{title:"English",value:"en"},{title:"中文",value:"zh"},{title:"Deutsch",value:"de"},{title:"ドイツ語",value:"ja"},{title:"독일어",value:"ko"},{title:"Немецкий язык",value:"ru"},{title:"Allemand",value:"fr"},{title:"Alemán",value:"es"}]}),e("主题"),(0,f.jsx)(r.l6,{value:Y,onChange:e=>{ee(e)},options:P}),(0,f.jsx)(r.Sm,{value:te,handleInputChange:e=>{se(e)},placeholderOut:e("拖拽文件上传忽略列表"),placeholder:"node_modules *.js",no_border:!0})]})}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(l.Zp,{title:e("编辑器自动保存"),rightBottomCom:(0,f.jsx)(o.C3,{text:e("确定修改"),clickFun:async()=>{const t=parseInt(String(ae),10);if(isNaN(t)||t<1)return void(0,x.zN)(e("请输入不小于 1 的整数(秒)"));(await c.wm.post(b.s.user_save_private_attr,{is_editor_auto_save:!0,editor_auto_save:{enable:ne,interval:t,editors:oe}})).code===d.m.Success&&((0,x.SK)("修改成功"),s())}}),children:[(0,f.jsx)(r.BC,{label:e("开启"),children:(0,f.jsx)(r.l6,{value:ne,onChange:e=>{ie(e)},options:B,no_border:!0})}),(0,f.jsx)(r.BC,{label:e("自动保存间隔(秒)"),children:(0,f.jsx)(r.Sm,{type:"number",value:ae,handleInputChange:e=>{le(e)},placeholder:"30",no_border:!0})}),(0,f.jsx)("h3",{children:e("编辑器")}),M.d.map(t=>(0,f.jsxs)("div",{children:[(0,f.jsx)("input",{type:"checkbox",checked:oe.includes(t.id),onChange:e=>{const s=e.target.checked;re(s?[...oe,t.id]:oe.filter(e=>e!==t.id))}}),e(t.label)]},t.id))]})})]}),(0,f.jsxs)(i.VP,{children:[(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("文件夹路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{ce("文件夹路径")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{j([...m,{note:"",default:!1,path:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{for(let e=0;e<m.length;e++)m[e].index=e;(await c.XO.post("filesSetting/save",{dirs:m})).code===d.m.Success&&((0,x.SK)("保存成功"),_(),s())}})]}),children:(0,f.jsx)(h.X,{headers:$,rows:m.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.l6,{value:t.default,onChange:e=>{((e,t,s)=>{const n=[];for(let e=0;e<m.length;e++)m[e].default=e===s&&t,n.push(m[e]);j(n)})(0,e,s)},options:B,no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)("div",{children:0!==s&&(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{m.splice(e,1),j([...m])})(s)})})];return n}),width:"10rem",onRowDrag:(e,t)=>{0!==e&&0!==t&&j((0,v.TI)(m,e,t))}})}),(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("个人保护路径")})," ",(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{ce("保护目录")},title:e("信息")})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{k([...C,{path:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("protection_dir/save",C)).code===d.m.Success&&((0,x.SK)("保存成功"),_())}})]}),children:(0,f.jsx)(h.X,{headers:E,rows:C.map((t,s)=>{const n=[(0,f.jsx)("div",{children:s}),(0,f.jsx)(r.Sm,{value:t.path,handleInputChange:e=>{t.path=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{C.splice(e,1),k([...C])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{k((0,v.TI)(C,e,t))}})})]}),(0,f.jsxs)(i.xh,{children:[(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("目录快捷命令")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{ce("目录快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{V([...A,{cmd:"",note:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("filesSetting/save",{quick_cmd:A})).code===d.m.Success&&((0,x.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(h.X,{headers:D,rows:A.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.index,handleInputChange:e=>{t.index=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cmd,handleInputChange:e=>{t.cmd=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.father_index,handleInputChange:e=>{t.father_index=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{A.splice(e,1),V([...A])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{V((0,v.TI)(A,e,t))}})}),(0,f.jsx)(l.uF,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("文件快捷命令")}),(0,f.jsx)(o.rA,{icon:"info",onClick:()=>{ce("文件快捷命令")},title:"info"})]}),titleCom:(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{z([...X,{cmd:"",note:"",file_suffix:"",params:""}])}}),(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await c.XO.post("filesSetting/save",{file_quick_cmd:X})).code===d.m.Success&&((0,x.SK)("保存成功"),s())}})]}),children:(0,f.jsx)(h.X,{headers:T,rows:X.map((t,s)=>{const n=[(0,f.jsx)(r.Sm,{value:t.file_suffix,handleInputChange:e=>{t.file_suffix=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.cmd,handleInputChange:e=>{t.cmd=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.params,handleInputChange:e=>{t.params=e},no_border:!0}),(0,f.jsx)(r.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{X.splice(e,1),z([...X])})(s)})];return n}),width:"10rem",onRowDrag:(e,t)=>{z((0,v.TI)(X,e,t))}})})]})]})]})})}var T=s(45907),G=s(17903);const q=["password","private_key","secret_key"],Z="webdav",R="@authorize",W={smb:[{keys:["server","username","password"],on_next:"load_shares"},{keys:["share"]}],baidu:[{keys:["app_id","app_key","secret_key"],on_next:"save_app"},{keys:[R]}]};function H(){const{t:e}=(0,u.Bd)(),t=(0,T.y)(),[,s]=(0,w.fp)(p.AG.prompt_card),[i,a]=(0,n.useState)([]),[d,_]=(0,n.useState)([]),[m,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[y,S]=(0,n.useState)(Z),[C,b]=(0,n.useState)(""),[k,A]=(0,n.useState)({}),[I,V]=(0,n.useState)(1),[N,X]=(0,n.useState)([]),[z,F]=(0,n.useState)("oob"),[K,O]=(0,n.useState)(""),[B,P]=(0,n.useState)(!0),$=async()=>{try{const[e,t]=await Promise.all([c.I2.post("credential/list",{}),c.I2.post("credential/meta",{})]);a(Array.isArray(e?.data)?e.data:[]),_(Array.isArray(t?.data)?t.data:[])}catch(e){}};(0,n.useEffect)(()=>{$()},[]);const E=d.find(e=>e.type===y)?.fields??[],M=W[y],D=M?.length??1,H=()=>{j(!1),g(""),S(Z),b(""),A({}),V(1),X([]),O(""),P(!0)},U=t=>{if(!C.trim())return e("请填写备注");for(const s of E){if(!1===t.includes(s.key))continue;const n=String(k[s.key]??"").trim()||v&&q.includes(s.key);if(s.required&&!n)return e(s.label)}},Q=async()=>{try{const e=await c.I2.post("baidu/authorize_url",{id:v,mode:z});e?.data&&window.open(e.data,"_blank","noopener,noreferrer")}catch(e){}},J=async()=>{if(K.trim())try{const t=await c.I2.post("baidu/exchange",{id:v,code:K.trim(),mode:z});(0,x.SK)(`${e("授权成功")}:${t?.data?.baidu_name??""}`),O(""),await $()}catch(e){}else(0,x.zN)(e("请填写授权码"))},L=M?.[I-1]?.keys??E.map(e=>e.key),Y=L.includes(R),ee=I===D,te=D>1;return(0,f.jsxs)(l.Zp,{self_title:(0,f.jsxs)("span",{className:" div-row ",children:[(0,f.jsx)("h2",{children:e("凭证管理")}),(0,f.jsx)(o.rA,{icon:"info",title:e("信息"),onClick:()=>{s({open:!0,title:e("信息"),context_div:(0,f.jsxs)("div",{children:[(0,f.jsxs)("ul",{children:[(0,f.jsx)("li",{children:e("crd_tp")}),(0,f.jsx)("li",{children:e("pwdkept")}),(0,f.jsx)("li",{children:e("tstbfrs")})]}),(0,f.jsxs)("ul",{children:[(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"WebDAV"}),":",e("prtwbdv")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"SSH / SFTP"}),":",e("prtsftp")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"S3 兼容对象存储"}),":",e("prt_s3")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"SMB"}),":",e("prt_smb")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:"百度网盘"}),":",e("prt_bd")]}),(0,f.jsxs)("li",{children:[(0,f.jsx)("b",{children:e("本地目录")}),":",e("prt_local")]})]})]})})}})]}),rightBottomCom:(0,f.jsxs)("div",{children:[!m&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{H(),j(!0)}}),m&&(0,f.jsxs)(f.Fragment,{children:[te&&I>1&&(0,f.jsx)(o.rA,{icon:"arrow_back",title:e("上一步"),onClick:()=>V(I-1)}),te&&!ee&&(0,f.jsx)(o.rA,{icon:"arrow_forward",title:e("下一步"),onClick:async()=>{const t=U(M?.[I-1]?.keys??[]);if(t)return void(0,x.zN)(`${e("请填写")}${t}`);const s=M?.[I-1]?.on_next;try{if("load_shares"===s&&!await(async()=>{const t=await c.I2.post("share/list",{driver:y,id:v||void 0,config:{server:k.server,username:k.username,password:k.password}}),s=t?.data??[];return s.length?(X(s.map(e=>({label:e.name,value:e.name}))),!0):((0,x.zN)(e("没有找到共享")),!1)})())return;if("save_app"===s&&!await(async()=>{try{const e=await c.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:y,note:C,config:k,enabled:B});return!v&&e?.data?.id&&g(e.data.id),!0}catch(e){return!1}})())return;V(I+1)}catch(e){}}}),(!te||ee)&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{const t=U(E.map(e=>e.key));if(t)(0,x.zN)(`${e("请填写")}${t}`);else try{await c.I2.post(v?"credential/update":"credential/add",{id:v||void 0,type:y,note:C,config:k,enabled:B}),(0,x.SK)(e("保存成功")),H(),await $()}catch(e){}}}),(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:H})]})]}),children:[m&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.Sm,{placeholder:e("备注"),value:C,handleInputChange:b}),(0,f.jsx)(r.l6,{value:y,options:d.map(e=>({title:e.name,value:e.type})),onChange:e=>{S(e),A({}),X([]),V(1),O("")}}),Y?(()=>{const s=i.find(e=>e.id===v)?.accounts??[];return(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.BC,{label:e("授权方式"),label_width:"6rem",children:(0,f.jsxs)("div",{className:"div-row",children:[(0,f.jsx)(r.U6,{name:"baidu_auth_mode",value:"one_click",context:e("一键授权"),selected:"one_click"===z,onchange:()=>F("one_click")}),(0,f.jsx)(r.U6,{name:"baidu_auth_mode",value:"oob",context:e("outh_ob"),selected:"oob"===z,onchange:()=>F("oob")})]})}),"oob"===z&&(0,f.jsx)(r.BC,{label:e("授权码"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("粘贴授权码 code"),value:K,handleInputChange:O})}),(0,f.jsxs)("div",{className:"div-row",children:[(0,f.jsx)(o.rA,{icon:"open_in_new",title:e("去授权"),onClick:Q}),"oob"===z&&(0,f.jsx)(o.rA,{icon:"check",title:e("完成授权"),onClick:J})]}),s.length>0&&(0,f.jsx)(h.X,{headers:[e("账号名"),e("百度账号"),e("授权状态"),e("使用"),e("授权时间"),e("操作")],rows:s.map(s=>[(0,f.jsx)(l.xP,{context:s.note||s.account_name||s.id}),(0,f.jsx)(l.xP,{context:s.account_name||s.id}),(0,f.jsx)(l.xP,{context:s.authorized?e("已授权"):e("未授权")}),(0,f.jsx)(l.xP,{context:!1===s.enabled?e("停用"):e("启用")}),(0,f.jsx)("p",{children:s.obtained_at?(0,G.eK)(s.obtained_at):"-"}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"network_check",title:e("授权检测"),onClick:()=>(async(t,s)=>{try{const n=await c.I2.post("baidu/verify",{id:t,account_id:s}),i=n?.data??{};i.valid?(0,x.SK)(e("账号可用")):(0,x.zN)(`${e("账号不可用")}:${i.error??""}`),await $()}catch(e){}})(v,s.id)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>((s,n)=>{t({title:e("确认删除"),sub_title:n.note||n.account_name||n.id,confirm_fun:async()=>{try{await c.I2.post("baidu/deauthorize",{id:s,account_id:n.id}),(0,x.SK)(e("已删除")),await $()}catch(e){}}})})(v,s)})]})])})]},R)})():E.filter(e=>L.includes(e.key)).map(t=>{if("share"===t.key&&"smb"===y)return(0,f.jsx)(r.BC,{label:e(t.label),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:k[t.key]??"",options:N,onChange:e=>A({...k,[t.key]:e})})},t.key);const s="password"===t.type;return(0,f.jsx)(n.Fragment,{children:(0,f.jsx)(r.Sm,{type:s?"password":"text",placeholder:t.label,value:k[t.key]??"",handleInputChange:e=>A({...k,[t.key]:e})})},t.key)})]}),!m&&(0,f.jsx)(h.X,{headers:[e("备注"),e("类型"),e("操作")],rows:i.map(s=>{return[(0,f.jsx)(l.xP,{context:s.note}),(0,f.jsx)(l.xP,{context:(n=s.type,d.find(e=>e.type===n)?.name??n)}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{j(!0),g(e.id),S(e.type),b(e.note??""),A({...e.config??{}}),O(""),P(!1!==e.enabled),V(W[e.type]?.length??1),"smb"===e.type&&c.I2.post("share/list",{driver:"smb",id:e.id,config:e.config??{}}).then(e=>{X((e?.data??[]).map(e=>({label:e.name,value:e.name})))}).catch(()=>{})})(s)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async s=>{t({title:e("确认删除"),sub_title:s.note,confirm_fun:async()=>{try{await c.I2.post("credential/delete",{id:s.id}),(0,x.SK)(e("已删除")),await $()}catch(e){}}})})(s)})]})];var n})})]})}function U(){const{t:e}=(0,u.Bd)(),t=(0,T.y)(),[s,i]=(0,n.useState)([]),[a,d]=(0,n.useState)([]),[p,_]=(0,n.useState)([]),[m,j]=(0,n.useState)(!1),[v,g]=(0,n.useState)(""),[w,y]=(0,n.useState)("webdav"),[S,C]=(0,n.useState)(""),[b,k]=(0,n.useState)(""),[A,I]=(0,n.useState)(""),[V,N]=(0,n.useState)(""),[X,z]=(0,n.useState)(""),F=async()=>{try{const[e,t,s]=await Promise.all([c.I2.post("list",{}),c.I2.post("credential/list",{}),c.I2.post("driver/list",{})]);i(Array.isArray(e?.data)?e.data:[]),d(Array.isArray(t?.data)?t.data:[]),_(Array.isArray(s?.data)?s.data:[])}catch(e){}};(0,n.useEffect)(()=>{F()},[]);const K=(0,G.p_)(b,a),O=K.length>0,B=()=>{j(!1),g(""),y("webdav"),C(""),k(""),I(""),N(""),z("")};return(0,f.jsxs)(l.Zp,{self_title:(0,f.jsx)("span",{className:" div-row ",children:(0,f.jsx)("h2",{children:e("挂载列表")})}),rightBottomCom:(0,f.jsxs)("div",{children:[!m&&(0,f.jsx)(o.rA,{icon:"add",title:e("添加"),onClick:()=>{B(),j(!0)}}),m&&(0,f.jsx)(o.rA,{icon:"network_check",title:e("测试连接"),onClick:async()=>{if(b)try{const t=await c.I2.post("test",{id:v||void 0,driver:w,credential_id:b,account_id:A,root_dir:V}),s=t?.data;s?.ok?(0,x.SK)(`${e("连接成功")}(${s.count??0})`):(0,x.zN)(`${e("连接失败")}:${s?.error??""}`)}catch(e){}else(0,x.zN)(e("请选择凭据"))}}),m&&(0,f.jsx)(o.rA,{icon:"save",title:e("保存"),onClick:async()=>{if(b)if(!O||A)if(S.trim())try{await c.I2.post(v?"update":"add",{id:v||void 0,driver:w,mount_path:S,credential_id:b,account_id:O?A:void 0,root_dir:V,note:X,color:G.OT,readonly:!1,enabled:!0}),(0,x.SK)(e("保存成功")),B(),await F()}catch(e){}else(0,x.zN)(e("munt_rq"));else(0,x.zN)(e("请选择账号"));else(0,x.zN)(e("请选择凭据"))}}),m&&(0,f.jsx)(o.rA,{icon:"cancel",title:e("取消"),onClick:B})]}),children:[m&&(0,f.jsxs)(n.Fragment,{children:[(0,f.jsx)(r.BC,{label:e("挂载类型"),label_width:"6rem",children:(0,f.jsx)(r.l6,{value:w,options:p.map(e=>({title:e.name,value:e.type})),onChange:e=>{y(e),k(""),I("")}})}),(0,f.jsx)(r.BC,{label:e("凭据"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:b,options:(P=w,(0,G.XT)(P,a)),onChange:e=>{k(e),I("")}})}),O&&(0,f.jsx)(r.BC,{label:e("账号"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.l6,{value:A,options:K,onChange:I})}),(0,f.jsx)(r.BC,{label:e("本地目录"),label_width:"6rem",required:!0,children:(0,f.jsx)(r.Sm,{placeholder:e("被挂载的本地绝对路径"),value:S,handleInputChange:C})}),(0,f.jsx)(r.BC,{label:e("strtdrt"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("远端目录"),value:V,handleInputChange:N})}),(0,f.jsx)(r.BC,{label:e("备注"),label_width:"6rem",children:(0,f.jsx)(r.Sm,{placeholder:e("列表显示的名称"),value:X,handleInputChange:z})})]}),!m&&(0,f.jsx)(h.X,{headers:[e("备注"),e("挂载类型"),e("凭据"),e("账号"),e("操作")],rows:s.map(s=>{const n=a.find(e=>e.id===s.credential_id),i=(n?.accounts??[]).find(e=>e.id===s.account_id);return[(0,f.jsx)("p",{children:s.note}),(0,f.jsx)("p",{children:(l=s.driver,p.find(e=>e.type===l)?.name??l)}),(0,f.jsx)("p",{children:n?n.note:e("凭据已丢失")}),(0,f.jsx)("p",{children:s.account_id?i?i.note||i.account_name||i.nickname||i.id:e("账号已丢失"):"-"}),(0,f.jsxs)("div",{children:[(0,f.jsx)(o.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>{j(!0),g(e.id),y(e.driver),C(e.mount_path??""),k(e.credential_id??""),I(e.account_id??""),N(e.root_dir??""),z(e.note??"")})(s)}),(0,f.jsx)(o.rA,{icon:"delete",title:e("删除"),onClick:()=>(async s=>{t({title:e("确认删除"),sub_title:s.mount_path,confirm_fun:async()=>{try{await c.I2.post("delete",{id:s.id}),(0,x.SK)(e("已删除")),await F()}catch(e){}}})})(s)})]})];var l})})]});var P}function Q(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),s=t(a.oV.file_mount),[r,d]=(0,w.fp)(p.AG.mount_enabled);(0,n.useEffect)(()=>{s&&(async()=>{try{const e=await c.I2.post("enabled/get",{});d(!0===e?.data)}catch(e){d(!1)}})()},[s]);return s?(0,f.jsxs)(n.Fragment,{children:[(0,f.jsxs)(k.aZ,{position:"right",children:[(0,f.jsx)("span",{className:"header-label",children:e("总开关")}),(0,f.jsx)(o.rA,{icon:!0===r?"cloud_done":"cloud_off",title:e(!0===r?"muntont":"muntoff"),selected:!0===r,onClick:async()=>{const t=!r;try{const s=await c.I2.post("enabled/set",{enabled:t}),n=!0===s?.data;d(n),(0,x.SK)(e(n?"挂载已启用":"挂载已停用"))}catch(e){}}})]}),(0,f.jsx)(i.xh,{children:(0,f.jsxs)(i.fI,{children:[(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"60rem",children:(0,f.jsx)(H,{})}),(0,f.jsx)(i.VP,{widthPer:50,maxWidth:"60rem",children:(0,f.jsx)(U,{})})]})})]}):(0,f.jsx)(i.fI,{children:(0,f.jsx)(i.VP,{children:(0,f.jsx)(l.Zp,{self_title:(0,f.jsx)("h2",{children:e("网盘挂载")}),children:(0,f.jsx)("p",{children:e("nmuntpr")})})})})}var J=s(87361);function L(){const{t:e}=(0,u.Bd)(),{check_user_auth:t}=(0,y.MH)(),s=[{index:1,name:`${e("个人环境")}`,rto:"private_env_setting",component:(0,f.jsx)(D,{})}];return t(a.oV.sys_setting_page)&&s.unshift({index:1,name:e("系统"),rto:"password",component:(0,f.jsx)(F,{})}),t(a.oV.sys_env_page)&&s.push({index:1,name:`${e("系统环境")}`,rto:"env_setting/",component:(0,f.jsx)(O,{})}),t(a.oV.auth_router_page)&&s.push({index:1,name:e("自定义路由"),rto:"customer_router/",component:(0,f.jsx)(A,{})}),t(a.oV.user_manage)&&s.push({index:1,name:e("用户管理"),rto:"user_manager/",component:(0,f.jsx)($,{})}),t(a.oV.role_manage)&&s.push({index:1,name:e("角色管理"),rto:"role_manager/",component:(0,f.jsx)(E,{})}),t(a.oV.file_mount)&&s.push({index:1,name:e("网盘挂载"),rto:"mount_setting/",component:(0,f.jsx)(Q,{})}),(0,f.jsx)(i.W1,{optionList:s,father_route:J.o.setting})}},92350(e,t,s){s.d(t,{Q:()=>h,o:()=>p});var n=s(34843),i=s(82893),a=s(74777),l=s(96540),o=s(22022),r=s(23430),c=s(14284),d=s(74848);function h(){const[e,t]=(0,n.fp)(i.AG.prompt_card),{t:s,i18n:l}=(0,o.Bd)();return e=>{let n;e===a.jk.ffmpeg?n=(0,d.jsx)("div",{children:"视频转换,rtsp播放器等媒体功能都需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置"}):e===a.jk.smartmontools?n=(0,d.jsx)("div",{children:"磁盘检查需要这个软件。linux下你可以使用apt或者yum来安装,或者直接输入软件的位置。"}):"保护目录"===e?n=(0,d.jsxs)("div",{children:["在删除的时候保护目录会拒绝删除。",(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"可以使用 /* 来表达该目录下所有文件都禁止删除"}),(0,d.jsx)("li",{children:"可以使用 /** 来表达该目录下所有子目录文件都禁止删除"})]})]}):"文件夹路径"===e?n=(0,d.jsx)("div",{children:"用于在文件夹下切换根目录"}):"环境路径"===e?n=(0,d.jsx)("div",{children:"当在不同用户环境下运行的时候由于没有执行终端去加载PATH,这里可以添加额外的PATH路径,点击这里的保存还会更新系统上的path路径"}):"pty"===e?n=(0,d.jsx)("div",{children:"一些需要Pty环境的命令"}):"文件上传"===e?n=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"对于不同的目录(包括所有子目录),可能是机械或者固态硬盘,机械硬盘在处理多个小文件的时候会做随机i/o,由于一般只有一个盘头所以会影响整体效率,特别是写操作,这里提供了上传时候的最大数量限制,对于下载数量目前不做限制."}),(0,d.jsx)("li",{children:"大文件支持断点和分块并发传输,建议并发数量设置为2,分块大小设置为10MB,大文件判断为500MB,设置过大的话会上传的时候会占据较大内存"})]})}):"目录快捷命令"===e?n=(0,d.jsx)("div",{children:"右键文件夹空白处用于,打开终端快捷执行命令"}):"文件快捷命令"===e?n=(0,d.jsx)("div",{children:"用于右键特定后缀的文件,执行一些快捷命令,文件后缀可以是多个,用空格分割"}):"Workflow"===e?n=(0,d.jsx)("div",{children:(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:"在特定的时间启动系统中的workflow任务"}),(0,d.jsx)("li",{children:"cron表达式是定时器 格式为: 秒 分 时 日 月 星期"}),(0,d.jsxs)("li",{children:[(0,d.jsx)("li",{children:'1. "*"(通配符,所有值)'}),(0,d.jsx)("li",{children:'2. "," 是枚举: 0 0 1,15 * * *'}),(0,d.jsx)("li",{children:'3. "-" 是范围: 0 0 1-5 * * *'}),(0,d.jsx)("li",{children:'4. "/" 是步长,标识每隔n执行 */3 * * * * * 每隔三秒,必须配合 * 使用 ,/ 只能写一次 ,有了/就成了定时器,而不是指定时间执行'})]})]})}):"插件配置"===e?n=(0,d.jsx)("div",{children:s("路径可以是一个 js 文件也可以是一个node 项目目录")}):"机器人配置"===e&&(n=(0,d.jsxs)("div",{children:[(0,d.jsx)("dv",{children:"机器人功能用于开通各种第三方支持的机器人,让第三方机器人接入本地的 AI 模型。"}),(0,d.jsxs)("ul",{children:[(0,d.jsx)("li",{children:" 1. qq 机器人需要先在手机 app 中添加,然后在https://q.qq.com/qqbot/ 登录机器人配置页面,在开发管理中复制机器人的 appId,appSecret 到这里就完成了配置了。目前 qq 机器人不稳定,且创建后无法删除(2026.07.05)"}),(0,d.jsx)("li",{children:" 2. https://opensource.dingtalk.com/developerpedia/docs/explore/tutorials/stream/bot/nodejs/create-bot 这个是钉钉机器人开通教程,注意复制钉钉的 clientId 的是时候不要复制成appId 了。"}),(0,d.jsx)("li",{children:" 3. 企业微信机器人的开通甚至不需要 pc 操作,在通讯录中点击智能机器人,选择 api 模式,就创建完成了,手机上直接复制 id 和密钥。"}),(0,d.jsx)("li",{children:" 4. 飞书https://open.feishu.cn/document/develop-an-echo-bot/introduction?from=banner 登录这个开发者后台,按照这个地址教程创建机器人,使用的时候这个机器人是作为一个应用,可以在工作台内搜索你的这个机器人的名字。"})]})]})),t({open:!0,title:"信息",context_div:(0,d.jsx)("div",{children:n})})}}let u=r.Ky;function p(){const[e,t]=(0,l.useState)([]);return(0,l.useEffect)(()=>{(async()=>{try{const e=await c.XO.get("themes");if(0===e.code){const s=e.data||[];u=[...r.Ky,...s],t(u)}else console.warn("获取主题列表失败,使用默认列表"),t(u)}catch(e){t(u)}})()},[]),e}},6960(e,t,s){s.d(t,{s:()=>l});var n=s(72635);const i=1440,a=525600;function l(e){e=e>1e12?e:1e3*e;const t=Date.now(),s=Math.abs(t-e)/6e4;return s<1?n.Ay.t("小于一分钟"):s<60?`${s.toFixed(0)} ${n.Ay.t("分钟前")}`:s<i?`${(s/60).toFixed(0)} ${n.Ay.t("小时前")}`:s<43200?`${(s/i).toFixed(0)} ${n.Ay.t("天前")}`:s<a?`${(s/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(s/a).toFixed(0)} ${n.Ay.t("年前")}`}},93245(e,t,s){s.d(t,{a:()=>r});var n=s(96540),i=s(34843),a=s(82893),l=s(23430);const o=[{id:l.nE.ace,label:"文本编辑器(ace)"},{id:l.nE.md,label:"md编辑器"},{id:l.nE.mind,label:"思维导图编辑器"},{id:l.nE.draw,label:"draw编辑器"},{id:l.nE.timeline,label:"时间线编辑器"},{id:l.nE.image,label:"图片编辑器"},{id:l.nE.excel,label:"excel编辑器"}];function r(e,t,s,l=!1){const[o]=(0,i.fp)(a.AG.user_base_info),r=o?.user_data?.editor_auto_save,c=(0,n.useRef)(r);c.current=r;const d=(0,n.useRef)(t);d.current=t;const h=(0,n.useRef)(s);h.current=s,(0,n.useEffect)(()=>{if(l)return;const t=c.current;if(!t?.enable||t.interval<=0||!t.editors?.includes(e))return;const s=setInterval(()=>{d.current()&&h.current(!0)},1e3*t.interval);return()=>clearInterval(s)},[r,e,l])}s.d(t,["d",0,o])},24659(e,t,s){var n=s(22022);s.d(t,["K",0,()=>{const{t:e}=(0,n.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8365],{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])},16514(e,s,t){t.r(s),t.d(s,{default:()=>ce});var n=t(96540),a=t(34843),i=t(22022),o=t(61973),c=t(14284),r=t(7463),l=t(78247),d=t(53459),u=t(72693),m=t(82893),g=t(61443),h=t(83277);function _(e){return null==e||e<0?"0":e.toLocaleString()}var p=t(14944),f=t(92275),x=t(62042);function j(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,h.$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 v(e){const s=(0,h.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,h.$j)(e.content)).filter(Boolean).join("\n\n"):""}let b=0;function w(){return-++b}function y(e=[]){let s=0;return e.filter(e=>"user"===e.role||"assistant"===e.role).map(e=>({id:++s,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list??(e.tool_call_ends?.length?[{tool_call_ends:e.tool_call_ends,content:v(e),role:"assistant"}]:void 0),images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const S=/\.(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 N(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||S.test(e.name)?"text":"binary"}function k(e){return e.text()}function C(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function A(e){const s=[];for(const t of e){const e=N(t);let n="";if("text"===e)try{const e=await k(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 C(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}function I(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var M=t(21499),$=t(64694),R=t(45907),B=t(74848);var D=t(40505);function T(e){const{active_session_id_ref:s,local_owner_ref:t,subscribed_ref:a,set_messages:i,scroll_to_bottom:o,auto_scroll_ref:c,mark_session_running:r,refresh_sessions:l,reload_session:d,set_active_session_running:u}=e,m=(0,n.useRef)(new Map);return(0,n.useEffect)(()=>{const e=()=>s.current,n=(s,n)=>{if(r(s,!1),m.current.clear(),e()&&e()===s){if(u(!1),a.current===s&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:s,subscribe:!1}),a.current=null),t.current===s)return void(t.current=null);n?.length?i(e=>{let s=e.length;for(;s>0&&"bot"===e[s-1].sender;)s--;return[...e.slice(0,s),...y(n)].map((e,s)=>({...e,id:s+1}))}):d(s).catch(()=>{})}l()},g=s=>{const n=s?.context||{};n.session_id&&(((s,n,a,r,l=0)=>{e()&&e()===s&&t.current!==s&&i(e=>{const s=m.current,t=r?-(l+1):l;let i=e;if(!r){const e=-(l+1),t=s.get(e);void 0!==t&&(i=i.filter(e=>e.id!==t),s.delete(e))}const d=s.get(t),u=void 0===d?-1:i.findIndex(e=>e.id===d),g=-1===u?{id:w(),sender:"bot",text:""}:{...i[u]};if(-1===u&&s.set(t,g.id),r?(g.text=n,g.is_loading=!0):n&&(g.text=g.text+n,g.is_loading=!1),a&&(g.content_list=[{tool_call_ends:a,content:g.text,role:"assistant"}],g.is_loading=!1),c.current&&requestAnimationFrame(()=>o()),-1===u)return[...i,g];const h=i.slice();return h[u]=g,h})})(n.session_id,n.text||"",n.tool_call_ends,n.notice,n.chunk_index),r(n.session_id,!0))},h=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)},_=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)};return p.ws.addMsg(f.HK.ai_chat_msg,g),p.ws.addMsg(f.HK.ai_chat_end,h),p.ws.addMsg(f.HK.ai_chat_error,_),()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,g),p.ws.off_message(`message_${f.HK.ai_chat_end}`,h),p.ws.off_message(`message_${f.HK.ai_chat_error}`,_),a.current&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:a.current,subscribe:!1}),a.current=null)}},[]),{chunkBubbleRef:m,bind_live_bubbles:(e,s)=>{m.current.clear();for(let t=0;t<s;t++){const n=e[e.length-s+t];n&&m.current.set(t,n.id)}},clear_bubbles:()=>m.current.clear()}}var V=t(85997),H=t(34299);function E(e){const s=e.attachments&&e.attachments.length>0?(0,B.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,B.jsxs)("div",{className:"chat-message-attachment",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{children:e.name}),(0,B.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(K,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(z,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(F,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,B.jsx)(H.default,{context:e.text}):null;return(0,B.jsxs)(B.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,h.$j)(e.content);return a&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(H.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(P,{callList:e.tool_call_ends})},`tool-${s}`)),(0,B.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,B.jsx)(H.default,{context:e.text}):null]})}(e);return 0===t.length?(0,B.jsxs)(B.Fragment,{children:[s,a]}):(0,B.jsxs)(B.Fragment,{children:[t,s,a]})}function P({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,B.jsxs)("div",{className:"chat-message-call-list",children:[(0,B.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,B.jsx)(V.In,{icon:s?"expand_less":"expand_more"}),(0,B.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,B.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,B.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,B.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,B.jsxs)("div",{className:"call-list-item-header",children:[(0,B.jsx)(V.In,{icon:e.success?"check_circle":"error"}),(0,B.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,B.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"参数"}),(0,B.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"错误"}),(0,B.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"结果"}),(0,B.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function K({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,B.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,B.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,B.jsx)("p",{className:"image-generation-prompt",children:(0,B.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,B.jsx)(H.default,{context:s})]}):(0,B.jsx)(H.default,{context:s||""})}function z({audio:e,text:s}){if(e){if(e.url)return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,B.jsx)("div",{className:"audio-result",children:(0,B.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,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,B.jsx)(H.default,{context:t})}function L({content:e,label:s}){const[t,a]=n.useState(!1);return(0,B.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,D.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,B.jsx)(V.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function F({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,B.jsx)(H.default,{context:s})}if(!t)return(0,B.jsx)(H.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,B.jsxs)("div",{className:"embeddings-result",children:[(0,B.jsxs)("div",{className:"embeddings-summary",children:[(0,B.jsx)("strong",{children:"向量嵌入结果"}),(0,B.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,B.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,B.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,B.jsxs)("div",{className:"embeddings-toolbar",children:[(0,B.jsx)(L,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,B.jsx)(L,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,B.jsx)(L,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,B.jsx)("div",{className:"embeddings-preview",children:(0,B.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,B.jsxs)("details",{children:[(0,B.jsx)("summary",{children:"查看详细数据"}),(0,B.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function O(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 c.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 c.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 q=t(4412),U=t(23430),G=t(87361),J=t(80389),W=t(7523),Q=t(23496);const X=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:r,sysPromptList:u,batchMode:h,selectedMsgCount:_,sessionVisible:p,onToggleSessionPanel:f,onCreateSession:j,onToggleBatchMode:v,onBatchDeleteMessages:b,bgProcessVisible:w,bgProcessCount:y,onToggleBgProcess:S,selectedSysPromptId:N,setSelectedSysPromptId:k,inline:C})=>{const{t:A}=(0,i.Bd)(),I=(0,o.Zp)(),{check_user_auth:M}=(0,l.MH)(),[,$]=(0,a.fp)(m.AG.ai_session_collapsed),{open:R}=function(){const{t:e}=(0,i.Bd)(),[,s]=(0,a.fp)(m.AG.prompt_card),[t,o]=(0,a.fp)(m.AG.ai_chat_zoom),{initUserInfo:r}=(0,n.useContext)(W.F);return{open:()=>{const n=t,a=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,B.jsx)(J.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 c.wm.post(Q.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,x.SK)(e("缩放调整成功")),r(),a()}})}}}(),D=M(U.oV.ai_model_switch)||M(U.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 H=t.find(e=>e.active),E=H?`${H.index}::${e}`:"",P=(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(V.rA,{icon:"menu",title:A("会话"),onClick:f,selected:p}),(0,B.jsx)(V.rA,{icon:"add",title:A("新会话"),onClick:()=>j()}),u.length>0&&(0,B.jsx)(g.l6,{value:N,options:[{title:A("选择系统提示词"),value:""},...u.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{k(e)},no_border:!0,width:"auto"}),D&&T.length>0&&(0,B.jsx)(g.l6,{value:E,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),c.jV.post("set_active_model",{index:Number(n),model_name:i}).then(e=>{e?.code===d.m.Success?((0,x.SK)("success"),r()):(0,x.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),h&&(0,B.jsx)(V.rA,{icon:"done",title:A("完成"),onClick:v}),h&&_>0&&(0,B.jsx)(V.rA,{icon:"delete",title:A("删除选中消息"),onClick:b}),(0,B.jsx)(V.rA,{icon:"zoom_in",title:A("缩放调整"),onClick:R}),(0,B.jsx)(V.rA,{icon:"terminal",title:A("后台进程"),onClick:S,selected:w,tip:y||null}),M(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{I(G.o.ai_rebot_setting_page)}}),M(U.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"settings",title:"ai setting",onClick:()=>{I(G.o.ai_agent_setting_page)}})]});return C?(0,B.jsx)("div",{className:"chat-inline-header",children:P}):(0,B.jsx)(q.aZ,{position:"right",children:P})};var Z=t(89824);function Y({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:a,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:g,onToggleBatchMode:h,onBatchDeleteSessions:_,onClearAllSessions:p,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,B.jsxs)("aside",{className:"chat-session-list",children:[(0,B.jsx)("div",{className:"chat-session-search",children:(0,B.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:v("搜索会话"),value:b,onChange:e=>w(e.target.value)})}),(0,B.jsx)("div",{className:"chat-session-items-wrap",children:A.map((e,n)=>{return(0,B.jsx)("div",{children:(0,B.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&&g?g(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,B.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>g?.(e.id),onClick:e=>e.stopPropagation()}),(0,B.jsx)("span",{children:(i=e.title,i||"新会话")}),f&&e.owner_name&&(0,B.jsx)("em",{className:"chat-session-owner",title:e.owner_name,children:e.owner_name}),e.running&&(0,B.jsx)("span",{className:"chat-session-running",title:v("正在执行中")}),(0,B.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,B.jsx)("em",{className:"chat-session-source",children:e.source}),!u&&(0,B.jsx)(Z.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,B.jsx)(V.In,{icon:"more_horiz"})})]})},e.id);var i})}),(0,B.jsxs)("div",{className:"chat-session-actions",children:[(0,B.jsx)(V.rA,{icon:u?"check_circle":"checklist",title:v(u?"取消批量选择":"批量选择"),onClick:h}),j&&!u&&(0,B.jsx)(V.rA,{icon:f?"person":"groups",title:v(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,B.jsx)(V.rA,{icon:"delete",title:v("删除选中会话"),onClick:_}),!u&&p&&(0,B.jsx)(V.rA,{icon:"delete_sweep",title:v("删除全部会话"),onClick:p})]})]})}function ee(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const se=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:d,onToggleBatchMode:u,onBatchCopy:m,onBatchDelete:g,showBatchBar:h,t:_})=>{const[p,f]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),j=e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},v=()=>{f(e=>e.size>0&&x.every(s=>e.has(s))?new Set:new Set(x))};return(0,B.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[h&&(0,B.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,B.jsxs)("span",{className:"batch-bar-count",children:[_("已选")," ",t.size]}),(0,B.jsx)("button",{onClick:m,children:_("复制所选")}),(0,B.jsx)("button",{onClick:g,className:"danger",children:_("删除所选")}),(0,B.jsx)("button",{onClick:u,children:_("取消")})]}),e.map(e=>{const n=p.has(e.id);return(0,B.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,B.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,B.jsxs)("div",{className:"ai-loading-bubble",children:[(0,B.jsxs)("div",{className:"ai-loading-dots",children:[(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"})]}),(0,B.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,B.jsxs)(B.Fragment,{children:[n?(0,B.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>j(e.id),children:[(0,B.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,B.jsx)("span",{className:"chat-message-summary-text",children:ee(e)||_("(无内容)")})]}):(0,B.jsx)("div",{className:"chat-message-body",children:E(e)}),(0,B.jsxs)("div",{className:"message-actions",children:[(0,B.jsx)("button",{onClick:()=>r(e.id),children:_("删除")}),(0,B.jsx)("button",{onClick:()=>l(e),children:_("复制")}),(0,B.jsx)("button",{onClick:d,children:_("全部复制")}),(0,B.jsx)("button",{onClick:u,children:_("多选")})]}),(0,B.jsxs)("div",{className:"message-collapse-bar",children:[(0,B.jsx)("button",{onClick:()=>j(e.id),children:_(n?"展开":"折叠")}),(0,B.jsx)("button",{onClick:v,children:_("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,B.jsx)("span",{className:"message-elapsed",children:(0,M.kf)(e.elapsed_ms)})]})]})]},e.id)}),(0,B.jsx)("div",{ref:o})]})},te=(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,g]=(0,n.useState)(!1),h=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>h(),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,B.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?.(h()),onCompositionStart:()=>g(!0),onCompositionEnd:()=>g(!1),"data-placeholder":d?e:void 0})});var ne=t(84369);function ae({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,B.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,B.jsxs)("div",{className:"chat-attachment-chip",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{title:e.name,children:e.name}),(0,B.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,B.jsx)(V.In,{icon:"close"})})]},`${e.name}_${t}`))})}const ie=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:o,onRemoveAttachment:c,onOpenFilePicker:r,onAddFiles:l,onDrop:d,onDragOver:u,fileInputRef:g,readonly:h=!1},_)=>{const{t:p}=(0,i.Bd)(),f=(0,n.useRef)(null),x=(0,n.useRef)(null),[j,v]=(0,a.fp)(m.AG.ai_chat_input_height);(0,n.useImperativeHandle)(_,()=>({getValue:()=>f.current?.getValue()??"",setValue:e=>f.current?.setValue(e),clear:()=>f.current?.clear()}));const{dragging:b,on_pointer_down:w,on_pointer_up:y}=(0,ne.y)({direction:"vertical",get_start_size:()=>j,px_to_unit:e=>e/(()=>{const e=x.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>v(e)}),S={minHeight:`${j}em`,maxHeight:`${j}em`};return(0,B.jsxs)("div",{ref:x,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:d,onDragOver:h?void 0:u,children:[!h&&(0,B.jsx)("div",{className:"chat-input-resize-handle"+(b?" dragging":""),onPointerDown:w}),(0,B.jsx)("input",{ref:g,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,B.jsxs)("div",{className:"chat-input-shell",children:[(0,B.jsx)(ae,{pendingAttachments:o,onRemove:c}),(0,B.jsx)(te,{ref:f,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,B.jsx)(V.rA,{title:p("添加文件"),icon:"attach_file",onClick:r}),h?(0,B.jsx)("button",{className:"little-button button",disabled:!0,children:p("发送")}):s?(0,B.jsx)(V.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,B.jsx)(V.Vi,{text:p("发送"),clickFun:e}),b&&(0,B.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),oe=function(e){const{t:s}=(0,i.Bd)(),[t,o]=(0,n.useState)([]),[c,r]=(0,n.useState)(!1),[l,d]=(0,n.useState)(null),[u,g]=(0,n.useState)(null),[h,_]=(0,n.useState)(!1),[j,v]=(0,a.fp)(m.AG.ai_bg_expanded),[,b]=(0,a.fp)(m.AG.ai_session_collapsed),w=()=>{v(!1)},y=(0,n.useCallback)(async()=>{r(!0);try{const s=new f.hf(f.HK.ai_bg_process_list_req);s.context={};const t=await p.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{r(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=y);const S=(0,n.useCallback)(async e=>{_(!0),d(e);try{const s=new f.hf(f.HK.ai_bg_process_output_req);s.context={pid:e};const t=await p.ws.send(s);g(t.context)}catch(e){console.error("获取进程输出失败",e),(0,x.zN)("获取进程输出失败")}finally{_(!1)}},[]),N=(0,n.useCallback)(async e=>{try{const s=new f.hf(f.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await p.ws.send(s);t?.context?.success?((0,x.SK)("进程已终止"),y(),l===e&&(d(null),g(null))):(0,x.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,x.zN)("终止进程失败")}},[y,l]);(0,n.useEffect)(()=>{y();const e=setInterval(y,5e3);return()=>clearInterval(e)},[y]);const k=t.filter(e=>e.running),C=t.filter(e=>!e.running);return(0,B.jsxs)(B.Fragment,{children:[j&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:w}),(0,B.jsxs)("aside",{className:"chat-bg-process-panel "+(j?"expanded":""),children:[(0,B.jsxs)("div",{className:"chat-bg-process-header",children:[(0,B.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:w})]}),(0,B.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,B.jsx)(V.rA,{icon:"refresh",title:s("刷新"),onClick:y}),(0,B.jsxs)("span",{className:"chat-bg-process-count",children:[k.length," ",s("个运行中"),C.length>0&&` / ${C.length} ${s("个已退出")}`]})]}),(0,B.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),k.map(e=>(0,B.jsxs)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} running`,children:[(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>S(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,B.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,B.jsx)(V.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>S(e.pid)}),(0,B.jsx)(V.rA,{icon:"stop",title:s("终止进程"),onClick:()=>N(e.pid)})]})]},e.pid)),C.map(e=>(0,B.jsx)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} finished`,children:(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>S(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==l&&(0,B.jsxs)("div",{className:"chat-bg-process-output",children:[(0,B.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,B.jsxs)("span",{children:["PID: ",l," ",s("输出")]}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:()=>{d(null),g(null)}})]}),(0,B.jsx)("div",{className:"chat-bg-process-output-content",children:h?(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):u?(0,B.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||s("(无输出)")}):null})]})]})]})};function ce(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:h,sync_url:v=!0,on_session_change:b}=e,{t:S}=(0,i.Bd)(),[N,k]=(0,o.ok)(),C=v&&N.get("session")||"",{check_user_auth:V}=(0,l.MH)();(0,u.w)();const[H]=(0,a.fp)(m.AG.user_base_info),E=!!H?.user_data?.is_root,[P,K]=(0,a.fp)(m.AG.ai_session_collapsed),[z,L]=(0,a.fp)(m.AG.ai_bg_expanded),[F,q]=(0,a.fp)(m.AG.prompt_card),[U]=(0,a.fp)(m.AG.ai_chat_zoom),[G,J]=(0,n.useState)(null),[W,Q]=(0,n.useState)([]),[Z,ee]=(0,n.useState)(new Set),[te,ne]=(0,n.useState)([]),[ae,ce]=(0,n.useState)(""),[re,le]=(0,n.useState)([]),[de,ue]=(0,n.useState)(0),me=(0,n.useRef)(null),ge=(0,n.useRef)(null),he=(0,n.useRef)(null),_e=(0,n.useRef)({}),pe=(0,n.useRef)({}),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current=G},[G]);const xe=(0,n.useRef)(null),je=(0,n.useRef)([]),ve=(0,n.useRef)(""),be=(0,n.useRef)(!1),we=(0,n.useRef)(null),ye=(0,n.useRef)(()=>{}),Se=function(e){const{admin_call:s,owner_of_session:t,get_sessions:a,activeSessionId:o,admin_mode_ref:r}=e,{t:l}=(0,i.Bd)(),u=(0,R.y)(),[m,g]=(0,n.useState)([]),[h,_]=(0,n.useState)(!1),[p,f]=(0,n.useState)(new Set),v=(0,n.useRef)(null),b=(0,n.useRef)(!0),w=(0,n.useRef)(!1),S=(e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s},N=(e=!1)=>{const s=v.current;if(!s)return;s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"});let t=0;const n=()=>{const s=v.current;s&&(s.scrollTo({top:s.scrollHeight,behavior:e&&0===t?"smooth":"auto"}),++t<6&&requestAnimationFrame(n))};requestAnimationFrame(n)},k=()=>{w.current=!0};return(0,n.useLayoutEffect)(()=>{w.current&&(w.current=!1,b.current=!0),b.current&&N(!1)},[m]),(0,n.useEffect)(()=>{const e=v.current;if(!e)return;const s=()=>{b.current=S(e)};e.addEventListener("scroll",s);const t=()=>{b.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()}},[]),{messages:m,setMessages:g,batchMode:h,setBatchMode:_,selectedMsgIds:p,setSelectedMsgIds:f,chatContainerRef:v,autoScrollRef:b,isNearBottom:S,scrollToBottom:N,request_scroll_bottom:k,apply_session:e=>{if(!e)return g([]),void k();let s=e.messages??[];e.live_messages?.length&&(s=[...s,...e.live_messages]),g(y(s)),k()},handleDelete:e=>{u({sub_title:l("cf_one"),confirm_fun:async()=>{const n=m.findIndex(s=>s.id===e);if(n<0)return;if(g(m.filter(s=>s.id!==e)),!o)return;const a=t(o);a?s("message_delete",{session_id:o,user_id:a,indices:[n]}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:[n]}).catch(console.error)}})},handleCopy:async e=>{(0,D.lW)(j(e)),(0,x.SK)("复制成功")},handleCopyAll:async()=>{const e=a();if(!e.length)return void(0,x.SK)("暂无聊天记录");const t=[];for(const n of e){const e=n.user_id?await s("get",{session_id:n.id,user_id:n.user_id}):await c.jV.post("session/get",{session_id:n.id});if(e.code!==d.m.Success||!e.data)continue;const a=e.data,i=y([...a.messages??[],...a.live_messages??[]]).map(j).filter(Boolean).join("\n\n\n");i&&t.push(i)}t.length?((0,D.lW)(t.join("\n\n\n")),(0,x.SK)("复制成功")):(0,x.SK)("暂无聊天记录")},handleBatchCopy:()=>{const e=m.filter(e=>p.has(e.id)).map(j).filter(Boolean).join("\n\n\n");e?((0,D.lW)(e),(0,x.SK)("复制成功")):(0,x.SK)("暂无内容")},toggleBatchMode:()=>{h&&f(new Set),_(e=>!e)},toggleMsgSelect:e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},batchDeleteMessages:()=>{0!==p.size&&u({sub_title:l("cf_msgs"),confirm_fun:async()=>{const e=[];if(m.forEach((s,t)=>{p.has(s.id)&&e.push(t)}),g(m.filter(e=>!p.has(e.id))),f(new Set),_(!1),!o||0===e.length)return;const n=t(o);n?s("message_delete",{session_id:o,user_id:n,indices:e}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:e}).catch(console.error)}})}}}({admin_call:(e,s)=>c.jV.post("admin/session",{action:e,...s||{}}),owner_of_session:e=>be.current?je.current.find(s=>s.id===e)?.user_id:void 0,get_sessions:()=>je.current,activeSessionId:ve.current,admin_mode_ref:be});ye.current=Se.apply_session;const Ne=function(e){const{on_session_loaded:s,set_session_panel_open:t,on_session_change:a,init_cwd:o,write_url_session:r,url_session_id:l,init_session_id:u}=e,{t:m}=(0,i.Bd)(),h=(0,R.y)(),[_,p]=(0,n.useState)([]),[f,j]=(0,n.useState)(""),[v,b]=(0,n.useState)(""),[w,y]=(0,n.useState)(!1),[S,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(!1),A=(0,n.useRef)(!1),I=(0,n.useRef)([]);(0,n.useEffect)(()=>{A.current=w},[w]),(0,n.useEffect)(()=>{I.current=_},[_]);const D=(e,s={})=>c.jV.post("admin/session",{action:e,...s}),T=e=>{if(A.current)return I.current.find(s=>s.id===e)?.user_id},V=async(e,n=!1,i)=>{const o=i??I.current.find(s=>s.id===e)?.user_id,u=A.current&&o?await D("get",{session_id:e,user_id:o}):await c.jV.post("session/get",{session_id:e});if(u.code!==d.m.Success||!u.data)return!1;const m=u.data;return j(m.id),l!==m.id&&r(m.id),a?.(m.id),N(!!m.running),b(m.sys_prompt_id??""),n&&t(!0),s(m),!0},H=async e=>{const t=A.current?await D("list_all_sessions"):await c.jV.get("sessions");if(t.code!==d.m.Success)return!1;const n=t.data??[];p(n);const a=null===e?n[0]?.id??"":e||f||n[0]?.id||"";if(!a)return j(""),r(null),s(null),!1;const i=n.find(e=>e.id===a)?.user_id;return await V(a,!1,i)},E=async e=>{if(!e)return null;const s=await c.jV.get("sessions");if(s.code!==d.m.Success)return null;const t=s.data??[],n=(0,M.ed)(e),a=t.find(e=>(0,M.ed)(e.file_cwd_path)===n);if(a)return a.id;const i=await c.jV.post("session",{file_cwd_path:n});return i.code!==d.m.Success?null:i.data.id};return{sessions:_,setSessions:p,sessions_ref:I,activeSessionId:f,setActiveSessionId:j,selectedSysPromptId:v,setSelectedSysPromptId:b,admin_all_mode:w,admin_mode_ref:A,readonly:k,activeSessionRunning:S,setActiveSessionRunning:N,admin_call:D,call:(e,s,t)=>A.current?D(e,s):t(),owner_of_session:T,refreshSessions:async()=>{const e=A.current?await D("list_all_sessions"):await c.jV.get("sessions");e.code===d.m.Success&&p(e.data??[])},markSessionRunning:(e,s)=>{p(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})},loadSession:V,loadSessions:H,createSession:async e=>{const n=await c.jV.post("session",{sys_prompt_id:e||void 0,file_cwd_path:o||void 0});if(n.code!==d.m.Success)return;const a=n.data;j(a.id),b(a.sys_prompt_id??""),t(!0),s(null),await H(a.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},locate_session_by_cwd:E,init_active_session:async()=>{if(o){const e=await E(o);e&&await H(e)||await H()}else u?await H(u)||await H():l&&await H(l)||await H()},reorderSessions:(e,s)=>{if(A.current)return;const t=I.current.findIndex(s=>s.id===e),n=I.current.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const a=(0,$.TI)(I.current,t,n);p(a),c.jV.post("sessions/update/sort",{session_ids:a.map(e=>e.id)}).catch(()=>{})},deleteSession:e=>{h({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=T(e);s?await D("delete",{session_id:e,user_id:s}):await c.jV.post("session/delete",{session_id:e}),f===e?(j(""),await H(null)):await H(f)}})},renameSession:(e,s)=>{let t=s;h({confirm_fun:async()=>{const s=T(e);s?await D("rename",{session_id:e,user_id:s,title:t}):await c.jV.post("sessions/update/meta",{id:e,title:t}),await H(f)},context_div:(0,B.jsx)("div",{className:"card-content",children:(0,B.jsx)(g.Sm,{value:t,handleInputChange:e=>{t=e}})})})},toggleCmdAuto:async(e,s)=>{const t=T(e);t?await D("cmd_auto",{session_id:e,user_id:t,allow:s}):await c.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,x.SK)(m(s?"命令检测已开启":"命令检测已关闭")),await H(f)},batchDeleteSessions:(e,s)=>{0!==e.size&&h({sub_title:m("cf_ses"),confirm_fun:async()=>{if(A.current)await D("batch_delete",{session_ids:Array.from(e)});else for(const s of e)await c.jV.post("session/delete",{session_id:s});s(),e.has(f)?(j(""),await H(null)):await H(f)}})},clearAllSessions:()=>{h({sub_title:m("cf_all"),confirm_fun:async()=>{await c.jV.post("sessions/clear",{}),j(""),s(null),await H(null)}})},toggleAllUsersMode:async()=>{const e=!w;y(e),A.current=e,C(e),j(""),s(null);const t=e?await D("list_all_sessions"):await c.jV.get("sessions"),n=t.code===d.m.Success?t.data??[]:[];p(n),n[0]?.id&&await V(n[0].id,!1,n[0].user_id)},changeSystemPrompt:e=>{if(b(e),!f)return;const s=T(f);s?D("sys_prompt",{session_id:f,user_id:s,sys_prompt_id:e||void 0}).catch(console.error):c.jV.post("session/sys_prompt",{session_id:f,sys_prompt_id:e||void 0}).catch(console.error)}}}({on_session_loaded:e=>ye.current(e),set_session_panel_open:e=>K(!e),on_session_change:b,init_cwd:h,write_url_session:e=>{v&&k(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},url_session_id:C,init_session_id:t});(0,n.useEffect)(()=>{ve.current=Ne.activeSessionId,be.current=Ne.admin_all_mode,je.current=Ne.sessions},[Ne.activeSessionId,Ne.admin_all_mode,Ne.sessions]);T({active_session_id_ref:ve,local_owner_ref:xe,subscribed_ref:we,set_messages:Se.setMessages,scroll_to_bottom:()=>Se.scrollToBottom(!1),auto_scroll_ref:Se.autoScrollRef,mark_session_running:Ne.markSessionRunning,refresh_sessions:Ne.refreshSessions,reload_session:e=>Ne.loadSession(e),set_active_session_running:Ne.setActiveSessionRunning});const ke=(0,n.useRef)((0,r.sg)(e=>{Se.setMessages(e),Se.autoScrollRef.current&&Se.scrollToBottom(!1)},50)).current,Ce=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:o,setActiveSessionId:c,refreshSessions:r,scrollToBottom:l,buildRequestMessages:d,getSelectedSysPromptId:u,setLocalOwner:m}=e,g=(0,n.useRef)([]),h=(0,n.useRef)(null),_=(e,n,c)=>{const g=s(),_=g.length+1,x={...n,id:_},j=[...g,x];t(j),i(e),m(e),h.current={abort:()=>{}};const v={id:-1,sender:"bot",text:"AI thinking ...",is_loading:!0};j.push(v),t([...j]);const b=new Map,w=()=>{o()===e&&a([...j])},S=()=>{const e=j.indexOf(v);-1!==e&&j.splice(e,1)},N=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 v.id=-1,v.text=n,v.is_loading=!0,j.includes(v)||j.push(v),void w();if("[DONE]"===n)return;if(!n&&!a)return;S();let o=b.get(i);o||(o={id:_+1+i,sender:"bot",text:"",is_loading:!0},j.push(o),b.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),w()},k=s=>{const n=s.context||{};n.session_id===e&&(A(),h.current=null,m(null),i(s=>s===e?null:s),o()===e&&t(e=>{const s=e.filter(I);let t=s;if(n.once_messages_list?.length){let e=-1;for(let t=s.length-1;t>=0;t--)if("user"===s[t].sender){e=t;break}const a=e>=0?e+1:s.length;t=[...s.slice(0,a),...y(n.once_messages_list)]}return t.map((e,s)=>({...e,id:s+1}))}),r(),l(!0),c())},C=s=>{const n=s.context||{};if(n.session_id!==e)return;A(),h.current=null,i(s=>s===e?null:s);const a="AI request error: "+(n.message||"未知错误");S();const r=[...j].reverse().find(e=>"bot"===e.sender);r?(r.text=r.text?`${r.text}\n\n${a}`:a,r.is_loading=!1):j.push({id:_+1,sender:"bot",text:a}),o()===e&&t([...j].map((e,s)=>({...e,id:s+1}))),c()},A=()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,N),p.ws.off_message(`message_${f.HK.ai_chat_end}`,k),p.ws.off_message(`message_${f.HK.ai_chat_error}`,C)};p.ws.addMsg(f.HK.ai_chat_msg,N),p.ws.addMsg(f.HK.ai_chat_end,k),p.ws.addMsg(f.HK.ai_chat_error,C),p.ws.sendData(f.HK.ai_chat_req,{messages:d(n),session_id:e,sys_prompt_id:u()})},x=()=>{const e=g.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:w(),sender:"user",text:s.text,attachments:s.attachments};_(o(),n,x)};return{startChatStream:_,processPendingQueue:x,enqueueMessage:(e,s)=>{g.current.push({text:e,attachments:s})},getQueueLength:()=>g.current.length,abort:()=>{const e=o();e&&(p.ws.sendData(f.HK.ai_chat_abort,{session_id:e}),h.current&&(h.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>Se.messages,setMessages:Se.setMessages,setMessagesDebounced:ke,setSending:J,getActiveSessionId:()=>ve.current,setActiveSessionId:Ne.setActiveSessionId,refreshSessions:Ne.refreshSessions,scrollToBottom:Se.scrollToBottom,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:()=>Ne.selectedSysPromptId,setLocalOwner:e=>{xe.current=e}}),Ae=e=>{ce(e?.ai_config?.model??"")},Ie=async()=>{try{const e=await c.jV.get("public_models");e.code===d.m.Success&&le(e.data?.groups??[])}catch{le([])}},Me=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&Q(e=>[...e,...s])},$e=e=>Ne.owner_of_session(e),Re=()=>{Se.batchMode&&(Se.setSelectedMsgIds(new Set),ee(new Set)),Se.setBatchMode(e=>!e)};(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Ae(e.data)),await Ie(),await Ne.init_active_session();const s=await c.jV.get("system_prompts");s.code===d.m.Success&&ne(s.data??[])})(),requestAnimationFrame(()=>Se.scrollToBottom(!1)),_e.current.onCountChange=ue,_e.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ue(s)};return p.ws.addMsg(f.HK.ai_bg_process_count_notify,e),()=>{p.ws.off_message(`message_${f.HK.ai_bg_process_count_notify}`,e)}},[]);const Be=G===Ne.activeSessionId||Ne.activeSessionRunning;return(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(X,{inline:s,currentModelName:ae,setCurrentModelName:ce,modelGroups:re,onModelChanged:async()=>{await Ie();const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Ae(e.data))},sysPromptList:te,batchMode:Se.batchMode,selectedMsgCount:Se.selectedMsgIds.size,sessionVisible:!P,onToggleSessionPanel:()=>K(e=>!e),onCreateSession:Ne.createSession,onBatchDeleteMessages:Se.batchDeleteMessages,onToggleBatchMode:Re,bgProcessVisible:z,bgProcessCount:de,onToggleBgProcess:()=>L(e=>!e),selectedSysPromptId:Ne.selectedSysPromptId,setSelectedSysPromptId:Ne.changeSystemPrompt}),(0,B.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":U},children:[!P&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:()=>K(!0)}),!P&&(0,B.jsx)(Y,{sessions:Ne.sessions,activeSessionId:Ne.activeSessionId,onSelectSession:e=>Ne.loadSession(e,!1),onReorderSessions:Ne.reorderSessions,onRenameSession:Ne.renameSession,onDeleteSession:Ne.deleteSession,onToggleCmdAuto:Ne.toggleCmdAuto,onShowUsageStats:async e=>{q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-loading",children:S("加载中...")}),cancel:()=>q({open:!1})});try{const s=$e(e),t=s?await Ne.admin_call("usage_stats",{session_id:e,user_id:s}):await c.jV.post("session/usage_stats",{session_id:e});if(t.code===d.m.Success&&t.data){const e=t.data;q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsxs)("div",{className:"usage-stats-panel",children:[[{l:S("对话轮次"),v:(e.turns??0).toString()},{l:S("AI输入Token"),v:_(e.input_tokens)},{l:S("AI输出Token"),v:_(e.output_tokens)},{l:S("AI输入Token(最近一轮)"),v:_(e.recent_input_tokens)},{l:S("AI输出Token(最近一轮)"),v:_(e.recent_output_tokens)}].map((e,s)=>(0,B.jsxs)("div",{className:"usage-stats-row",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,B.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,B.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:S("AI Token总计消耗")}),(0,B.jsx)("span",{className:"usage-stats-value",children:_((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>q({open:!1})})}else q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:S("暂无统计数据")}),cancel:()=>q({open:!1})})}catch{q({open:!0,title:S("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:S("暂无统计数据")}),cancel:()=>q({open:!1})})}},onShowSessionSetting:e=>{let s=Ne.sessions.find(s=>s.id===e)?.file_cwd_path??"";q({open:!0,title:S("会话设置"),context_div:(0,B.jsxs)("div",{className:"session-setting",children:[(0,B.jsx)("div",{className:"session-setting__label",children:S("服务器工作目录")}),(0,B.jsx)(g.Sm,{value:s,placeholder:S("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=$e(e);(t?await Ne.admin_call("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await c.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===d.m.Success&&(0,x.SK)(S("保存成功"))}catch{}q({open:!1}),await Ne.loadSessions(Ne.activeSessionId)},cancel:()=>q({open:!1})})},batchMode:Se.batchMode,selectedSessionIds:Z,onToggleSessionSelect:e=>{ee(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Re,onBatchDeleteSessions:()=>Ne.batchDeleteSessions(Z,()=>{ee(new Set),Se.setBatchMode(!1)}),onClearAllSessions:Ne.admin_all_mode?void 0:Ne.clearAllSessions,allUsersMode:Ne.admin_all_mode,onToggleAllUsersMode:Ne.toggleAllUsersMode,showAllUsersEntry:E}),(0,B.jsx)(oe,{panelRef:_e}),(0,B.jsxs)("section",{className:"chat-main",children:[0===Se.messages?.length&&(0,B.jsx)("div",{className:"chat-header",children:(0,B.jsx)("div",{children:S("ai_ask")})}),(0,B.jsx)(se,{messages:Se.messages,batchMode:Se.batchMode,selectedMsgIds:Se.selectedMsgIds,sending:Be,chatContainerRef:Se.chatContainerRef,messagesEndRef:he,onToggleMsgSelect:Se.toggleMsgSelect,onDelete:Se.handleDelete,onCopy:Se.handleCopy,onCopyAll:Se.handleCopyAll,onToggleBatchMode:Re,onBatchCopy:Se.handleBatchCopy,onBatchDelete:Se.batchDeleteMessages,showBatchBar:Se.batchMode&&Se.selectedMsgIds.size>0&&0===Z.size,t:S}),(0,B.jsx)(ie,{ref:me,onSend:async()=>{if(Ne.admin_all_mode)return;const e=(me.current?.getValue()??"").trim();if(!e&&0===W.length)return;if(G===Ne.activeSessionId){const s=await A(W);Ce.enqueueMessage(e,s),me.current?.clear(),Q([]);const t={id:w(),sender:"user",text:e+(Ce.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void Se.setMessages(e=>[...e,t])}let s=Ne.activeSessionId;if(!s){const t=await c.jV.post("session",{title:(e||W[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:h||void 0});if(t.code!==d.m.Success)return;s=t.data.id,Ne.setActiveSessionId(s),b?.(s),await Ne.loadSessions(s)}const t=await A(W),n={id:w(),sender:"user",text:e,attachments:t};me.current?.clear(),Q([]);const a=pe.current?.ai_config?.request_type||"completions";if("completions"!==a){const t={id:Se.messages.length+2,sender:"bot",text:"处理中...",is_loading:!0},i={...n,id:Se.messages.length+1},o=[...Se.messages,i,t];Se.setMessages(o),J(s);return void(await O(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),Se.setMessages([...o]),J(null),Ne.refreshSessions(),Se.scrollToBottom(!0),Ce.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,Se.setMessages([...o]),J(null),Ce.processPendingQueue()))}Ce.startChatStream(s,n,()=>Ce.processPendingQueue())},readonly:Ne.admin_all_mode,sending:Be,onAbort:Ce.abort,pendingAttachments:W,onRemoveAttachment:e=>{Q(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ge.current?.click()},onAddFiles:Me,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Me(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ge})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>g});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 g(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,a.Bd)(),l=(0,n.useRef)([]),g=(0,n.useRef)(!1),h=(0,n.useRef)(null),_=(0,n.useRef)(void 0),p=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),g.current=!1,h.current&&(i.ws.sendData(o.HK.ai_confirm_cmd,{askId:h.current,approved:e}),h.current=null),p.current()},[s]),x=(0,n.useCallback)(()=>{if(g.current)return;if(0===l.current.length)return g.current=!1,void s({open:!1});g.current=!0;const e=l.current.shift();e?(h.current=e.askId,_.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(_.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:_.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):g.current=!1},[t,f,s]);p.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(g.current&&h.current===t.askId&&(h.current=null,g.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=[],g.current=!1,h.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),g=t(89117),h=t(86063),_=t(89334),p=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,h.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,g.Hm)(s),n=(0,h.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,g.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,_.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,_.Rh)(v,p.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,[g,h]=(0,n.useState)(!1),_=(0,n.useRef)(null),p=(0,n.useRef)(u);p.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=_.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)),p.current(r)},[]),v=n.useMemo(()=>void 0===d?j:a.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{_.current=null,h(!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;_.current={pos:t(e),size:s()},h(!0)},[]);return(0,n.useEffect)(()=>{if(!g)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[g,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:g,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>"}}]);