filecat 6.62.0 → 6.62.2

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.
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[678,6010],{83277(e,s,t){t.d(s,{$j:()=>o,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list;options_local_file_path_prompt_list}class a{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}}class i extends n{tool_call_max=500;allow_exec_cmd_directly=!1;proxy_url;open_pick_model;max_recent_messages=12;compress_message_count=16;max_tool_content_chars=200}const c=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(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# 聊天循环最大次数\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',"cL",0,c])},93583(e,s,t){t.r(s),t.d(s,{default:()=>se});var n=t(96540),a=t(34843),i=t(86149),c=t(3606),o=t(92275),l=t(14284),r=t(7463),d=t(78247),u=t(40505),m=t(62042),h=t(45907),g=t(53459),p=t(72693),_=t(82893),x=t(61443),f=t(83277);function j(e){return null==e||e<0?"0":e.toLocaleString()}function v(e){const s=(0,f.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,f.$j)(e.content)).filter(Boolean).join("\n\n"):""}function b(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings}))}const y=/\.(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 w(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||y.test(e.name)?"text":"binary"}function S(e){return e.text()}function N(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function k(e){const s=[];for(const t of e){const e=w(t);let n="";if("text"===e)try{const e=await S(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 N(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var C=t(14944);var A=t(52035),$=t(85997),I=t(34299),M=t(74848);function D(e){const s=e.attachments&&e.attachments.length>0?(0,M.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,M.jsxs)("div",{className:"chat-message-attachment",children:[(0,M.jsx)($.In,{icon:"attach_file"}),(0,M.jsx)("span",{children:e.name}),(0,M.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,M.jsx)(n.Fragment,{children:(0,M.jsx)(H,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,M.jsx)(n.Fragment,{children:(0,M.jsx)(T,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,M.jsx)(n.Fragment,{children:(0,M.jsx)(K,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,M.jsx)(I.default,{context:e.text}):null;return(0,M.jsxs)(M.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,f.$j)(e.content);return a&&t.push((0,M.jsx)(n.Fragment,{children:(0,M.jsx)(I.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,M.jsx)(n.Fragment,{children:(0,M.jsx)(R,{callList:e.tool_call_ends})},`tool-${s}`)),(0,M.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,M.jsx)(I.default,{context:e.text}):null]})}(e);return 0===t.length?(0,M.jsxs)(M.Fragment,{children:[s,a]}):(0,M.jsxs)(M.Fragment,{children:[t,s,a]})}function R({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,M.jsxs)("div",{className:"chat-message-call-list",children:[(0,M.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,M.jsx)($.In,{icon:s?"expand_less":"expand_more"}),(0,M.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,M.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,M.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,M.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,M.jsxs)("div",{className:"call-list-item-header",children:[(0,M.jsx)($.In,{icon:e.success?"check_circle":"error"}),(0,M.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,M.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,M.jsxs)("details",{className:"call-list-details",children:[(0,M.jsx)("summary",{children:"参数"}),(0,M.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,M.jsxs)("details",{className:"call-list-details",children:[(0,M.jsx)("summary",{children:"错误"}),(0,M.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,M.jsxs)("details",{className:"call-list-details",children:[(0,M.jsx)("summary",{children:"结果"}),(0,M.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function H({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,M.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,M.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,M.jsx)("div",{className:"image-generation-image-wrapper",children:(0,M.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,M.jsx)("div",{className:"image-generation-image-wrapper",children:(0,M.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,M.jsx)("p",{className:"image-generation-prompt",children:(0,M.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,M.jsx)(I.default,{context:s})]}):(0,M.jsx)(I.default,{context:s||""})}function T({audio:e,text:s}){if(e){if(e.url)return(0,M.jsx)("div",{className:"audio-result",children:(0,M.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,M.jsx)("div",{className:"audio-result",children:(0,M.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,M.jsx)("div",{className:"audio-result",children:(0,M.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,M.jsx)("div",{className:"audio-result",children:(0,M.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,M.jsx)(I.default,{context:t})}function E({content:e,label:s}){const[t,a]=n.useState(!1);return(0,M.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,u.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,M.jsx)($.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function K({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,M.jsx)(I.default,{context:s})}if(!t)return(0,M.jsx)(I.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,M.jsxs)("div",{className:"embeddings-result",children:[(0,M.jsxs)("div",{className:"embeddings-summary",children:[(0,M.jsx)("strong",{children:"向量嵌入结果"}),(0,M.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,M.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,M.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,M.jsxs)("div",{className:"embeddings-toolbar",children:[(0,M.jsx)(E,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,M.jsx)(E,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,M.jsx)(E,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,M.jsx)("div",{className:"embeddings-preview",children:(0,M.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,M.jsxs)("details",{children:[(0,M.jsx)("summary",{children:"查看详细数据"}),(0,M.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function P(e,s){const t=function(){try{return(0,A.zp)().get(_.AG.ai_images_extra_params)||{}}catch{return{}}}(),n={prompt:e,n:t.n??1,size:t.size??"1024x1024",session_id:s};if(t.quality&&(n.quality=t.quality),t.style&&(n.style=t.style),t.extra_json)try{const e=JSON.parse(t.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const a=await l.jV.post("images/generations",n);if(0!==a.code)throw new Error(a.message||"图片生成失败");const i=a.data||{},c=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=c.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:i.session_id||s,images:c,text:o||`生成了 ${c.length} 张图片`}}async function V(e,s,t,n){try{switch(e){case"images":{const e=await P(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,c=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(c)))),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 l.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 B=t(57952),F=t(23430),q=t(87361);const L=({currentModelName:e,setCurrentModelName:s,envConfigRef:t,sysPromptList:n,batchMode:o,selectedMsgCount:r,onToggleSessionPanel:u,onCreateSession:h,onToggleBatchMode:p,onBatchDeleteMessages:f,bgProcessVisible:j,bgProcessCount:v,onToggleBgProcess:b,selectedSysPromptId:y,setSelectedSysPromptId:w})=>{const{t:S}=(0,i.B)(),N=(0,c.Zp)(),{check_user_auth:k}=(0,d.MH)(),[,C]=(0,a.fp)(_.AG.ai_session_collapsed);return(0,M.jsxs)(B.A,{children:[(0,M.jsx)($.rA,{icon:"menu",title:S("会话"),onClick:u}),(0,M.jsx)($.rA,{icon:"add",title:S("新会话"),onClick:()=>h()}),n.length>0&&(0,M.jsx)(x.l6,{value:y,options:[{title:S("选择系统提示词"),value:""},...n.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{w(e)},no_border:!0,width:"auto"}),(t.current?.ai_config_env?.options_agent_model_list?.length??0)>0&&(0,M.jsx)(x.l6,{value:e,options:t.current.ai_config_env.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{s(e),l.jV.post("set_active_model",{model_name:e}).then(()=>{(0,m.SK)("success"),l.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(t.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),o&&r>0&&(0,M.jsx)($.rA,{icon:"delete",title:S("删除选中消息"),onClick:f}),(0,M.jsx)($.rA,{icon:"terminal",title:S("后台进程"),onClick:b,selected:j,tip:v||null}),k(F.oV.ai_agent_setting)&&(0,M.jsx)($.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{N(q.o.ai_rebot_setting_page)}}),k(F.oV.ai_agent_setting)&&(0,M.jsx)($.rA,{icon:"settings",title:"ai setting",onClick:()=>{N(q.o.ai_agent_setting_page)}})]})};var O=t(27690);function z({sessions:e,activeSessionId:s,onSelectSession:t,onRenameSession:c,onDeleteSession:o,onToggleCmdAuto:l,onShowUsageStats:r,batchMode:d,selectedSessionIds:u,onToggleSessionSelect:m,onToggleBatchMode:h,onBatchDeleteSessions:g,onClearAllSessions:p}){const{t:x}=(0,i.B)(),[f,j]=(0,a.fp)(_.AG.ai_session_collapsed),[v,b]=(0,n.useState)(""),y=v.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(v.toLowerCase())||(e.summary||"").toLowerCase().includes(v.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(v.toLowerCase())):e;return(0,M.jsxs)("aside",{className:`chat-session-list ${f?"active":""} ${f?"collapsed":""}`,children:[(0,M.jsx)("div",{className:"chat-session-search",children:(0,M.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:x("搜索会话"),value:v,onChange:e=>b(e.target.value)})}),(0,M.jsx)("div",{className:"chat-session-items-wrap",children:y.map(e=>{return(0,M.jsx)("div",{children:(0,M.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${d?"batch-mode":""} ${e.running?"is-running":""}`,onClick:()=>{d&&m?m(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[d&&(0,M.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:u?.has(e.id)??!1,onChange:()=>m?.(e.id),onClick:e=>e.stopPropagation()}),(0,M.jsx)("span",{children:(n=e.title,n||"新会话")}),e.running&&(0,M.jsx)("span",{className:"chat-session-running",title:x("正在执行中")}),(0,M.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,M.jsx)("em",{className:"chat-session-source",children:e.source}),!d&&(0,M.jsx)(O.MenuSelect,{list:[{name:x("重命名"),click:()=>c(e.id,e.title)},{name:e.cmd_auto_allow?x("命令检测关闭"):x("命令检测开启"),click:()=>l?.(e.id,!e.cmd_auto_allow)},{name:x("字符消耗统计"),click:()=>r(e.id)},{name:x("删除"),click:()=>o(e.id)}],children:(0,M.jsx)($.In,{icon:"more_horiz"})})]})},e.id);var n})}),(0,M.jsxs)("div",{className:"chat-session-actions",children:[(0,M.jsx)($.rA,{icon:d?"check_circle":"checklist",title:x(d?"取消批量选择":"批量选择"),onClick:h}),d&&(u?.size??0)>0&&(0,M.jsx)($.rA,{icon:"delete",title:x("删除选中会话"),onClick:g}),!d&&(0,M.jsx)($.rA,{icon:"delete_sweep",title:x("删除全部会话"),onClick:p})]})]})}function J(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const G=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:c,onToggleMsgSelect:o,onDelete:l,onCopy:r,onToggleBatchMode:d,t:u})=>{const[m,h]=(0,n.useState)(new Set),g=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),p=e=>{h(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},_=()=>{h(e=>e.size>0&&g.every(s=>e.has(s))?new Set:new Set(g))};return(0,M.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[e.map(e=>{const n=m.has(e.id);return(0,M.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,M.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>o(e.id)}),e.is_loading?(0,M.jsxs)("div",{className:"ai-loading-bubble",children:[(0,M.jsxs)("div",{className:"ai-loading-dots",children:[(0,M.jsx)("span",{className:"ai-loading-dot"}),(0,M.jsx)("span",{className:"ai-loading-dot"}),(0,M.jsx)("span",{className:"ai-loading-dot"})]}),(0,M.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,M.jsxs)(M.Fragment,{children:[n?(0,M.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>p(e.id),children:[(0,M.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,M.jsx)("span",{className:"chat-message-summary-text",children:J(e)||u("(无内容)")})]}):(0,M.jsx)("div",{className:"chat-message-body",children:D(e)}),(0,M.jsxs)("div",{className:"message-collapse-bar",children:[(0,M.jsx)("button",{onClick:()=>p(e.id),children:u(n?"展开":"折叠")}),(0,M.jsx)("button",{onClick:_,children:u("全部折叠")})]}),(0,M.jsx)("div",{className:"message-actions",children:s?(0,M.jsx)("button",{onClick:()=>o(e.id),children:t.has(e.id)?u("取消选择"):u("选择")}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("button",{onClick:()=>l(e.id),children:u("删除")}),(0,M.jsx)("button",{onClick:()=>r(e.text),children:u("复制")}),(0,M.jsx)("button",{onClick:d,children:u("多选")})]})})]})]},e.id)}),(0,M.jsx)("div",{ref:c})]})};function W({onClose:e}){const{t:s}=(0,i.B)(),[t,c]=(0,a.fp)(_.AG.ai_images_extra_params),[o,l]=(0,n.useState)(t.size||"1024x1024"),[r,d]=(0,n.useState)(String(t.n??1)),[u,m]=(0,n.useState)(t.quality||""),[h,g]=(0,n.useState)(t.style||""),[p,f]=(0,n.useState)(t.extra_json||"");return(0,M.jsxs)("div",{className:"card floating",children:[(0,M.jsx)("div",{className:"card-title",children:(0,M.jsx)("h2",{children:s("图片生成参数设置")})}),(0,M.jsxs)("div",{className:"card-content",children:[(0,M.jsx)(x.Sm,{placeholderOut:s("图片尺寸 (size)"),value:o,handleInputChange:l,placeholder:"1024x1024"}),(0,M.jsx)(x.Sm,{placeholderOut:s("生成数量 (n)"),value:r,handleInputChange:d,type:"number"}),(0,M.jsx)(x.Sm,{placeholderOut:s("画质 (quality)"),value:u,handleInputChange:m,placeholder:"standard / hd"}),(0,M.jsx)(x.Sm,{placeholderOut:s("风格 (style)"),value:h,handleInputChange:g,placeholder:"vivid / natural"}),(0,M.jsx)(x.Sm,{placeholderOut:s("额外参数 JSON"),value:p,handleInputChange:f,placeholder:'{"key":"value"}'})]}),(0,M.jsxs)("div",{className:"card-action",children:[(0,M.jsx)("button",{className:"button button--flat button--grey",onClick:e,children:s("取消")}),(0,M.jsx)("button",{className:"button button--flat",onClick:()=>{const s={size:o,n:parseInt(r)||1};u&&(s.quality=u),h&&(s.style=h),p&&(s.extra_json=p),c(s),e()},children:s("确定")})]})]})}function Q({requestType:e}){const{t:s}=(0,i.B)(),[t,a]=(0,n.useState)(!1);return"completions"===e?null:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)($.rA,{icon:"tune",title:s("模型参数设置"),onClick:()=>a(!0)}),t&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)("div",{className:"overlay",onClick:()=>a(!1)}),"images"===e&&(0,M.jsx)(W,{onClose:()=>a(!1)})]})]})}const U=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:c,onChange:o},l){const r=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=r.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(l,()=>({getValue:()=>g(),setValue:e=>{const s=r.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=r.current;e&&(e.textContent="",u(!0))},focus:()=>r.current?.focus()})),(0,n.useEffect)(()=>{const e=r.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,M.jsx)("div",{ref:r,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:c,onInput:()=>o?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});function X({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,M.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,M.jsxs)("div",{className:"chat-attachment-chip",children:[(0,M.jsx)($.In,{icon:"attach_file"}),(0,M.jsx)("span",{title:e.name,children:e.name}),(0,M.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,M.jsx)($.In,{icon:"close"})})]},`${e.name}_${t}`))})}const Z=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:c,onRemoveAttachment:o,onOpenFilePicker:l,onAddFiles:r,onDrop:d,onDragOver:u,fileInputRef:m,requestType:h},g)=>{const{t:p}=(0,i.B)(),x=(0,n.useRef)(null),[f,j]=(0,n.useState)(!1),v=(0,n.useRef)(null),[b,y]=(0,a.fp)(_.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>x.current?.getValue()??"",setValue:e=>x.current?.setValue(e),clear:()=>x.current?.clear()}));const w=(0,n.useCallback)(e=>{const s=v.current;if(!s)return;const t=s.getBoundingClientRect().bottom-e.clientY;let n=Math.round(t/21.375);n=Math.max(2,Math.min(20,n)),y(n)},[y]),S=(0,n.useCallback)(()=>j(!0),[]),N=(0,n.useCallback)(()=>j(!1),[]);(0,n.useEffect)(()=>{if(!f)return;const e=w;return window.addEventListener("pointermove",e),window.addEventListener("pointerup",N),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",N)}},[f,w,N]);const k={minHeight:`${b}em`,maxHeight:`${b}em`};return(0,M.jsxs)("div",{ref:v,className:"chat-input-area",onDrop:d,onDragOver:u,children:[(0,M.jsx)("div",{className:"chat-input-resize-handle"+(f?" dragging":""),onPointerDown:S}),(0,M.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(r(e.target.files),e.currentTarget.value="")}}),(0,M.jsxs)("div",{className:"chat-input-shell",style:k,children:[(0,M.jsx)(X,{pendingAttachments:c,onRemove:o}),(0,M.jsx)(U,{ref:x,placeholder:p("输入消息"),onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),r(s))},className:"chat-input",style:k})]}),(0,M.jsx)($.rA,{title:p("添加文件"),icon:"attach_file",onClick:l}),(0,M.jsx)(Q,{requestType:h}),s?(0,M.jsx)($.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,M.jsx)($.Vi,{text:p("发送"),clickFun:e}),f&&(0,M.jsx)("div",{className:"chat-input-overlay",onPointerUp:N})]})}),Y={},ee=function(){const{t:e}=(0,i.B)(),[s,t]=(0,n.useState)([]),[c,l]=(0,n.useState)(!1),[r,d]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,p]=(0,n.useState)(!1),[x,f]=(0,a.fp)(_.AG.ai_bg_expanded),[,j]=(0,a.fp)(_.AG.ai_session_collapsed),v=()=>{f(!1)},b=(0,n.useCallback)(async()=>{l(!0);try{const e=new o.hf(o.HK.ai_bg_process_list_req);e.context={};const s=await C.ws.send(e);s?.context?.processes&&(t(s.context.processes),Y.onCountChange?.(s.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);Y.refresh=b;const y=(0,n.useCallback)(async e=>{p(!0),d(e);try{const s=new o.hf(o.HK.ai_bg_process_output_req);s.context={pid:e};const t=await C.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,m.zN)("获取进程输出失败")}finally{p(!1)}},[]),w=(0,n.useCallback)(async e=>{try{const s=new o.hf(o.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await C.ws.send(s);t?.context?.success?((0,m.SK)("进程已终止"),b(),r===e&&(d(null),h(null))):(0,m.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,m.zN)("终止进程失败")}},[b,r]);(0,n.useEffect)(()=>{b();const e=setInterval(b,5e3);return()=>clearInterval(e)},[b]);const S=s.filter(e=>e.running),N=s.filter(e=>!e.running);return(0,M.jsxs)(M.Fragment,{children:[x&&(0,M.jsx)("div",{className:"chat-session-overlay",onClick:v}),(0,M.jsxs)("aside",{className:"chat-bg-process-panel "+(x?"expanded":""),children:[(0,M.jsxs)("div",{className:"chat-bg-process-header",children:[(0,M.jsx)("span",{className:"chat-bg-process-title",children:e("后台进程")}),(0,M.jsx)($.rA,{icon:"close",title:e("关闭"),onClick:v})]}),(0,M.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,M.jsx)($.rA,{icon:"refresh",title:e("刷新"),onClick:b}),(0,M.jsxs)("span",{className:"chat-bg-process-count",children:[S.length," ",e("个运行中"),N.length>0&&` / ${N.length} ${e("个已退出")}`]})]}),(0,M.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===s.length&&(0,M.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}),!c&&0===s.length&&(0,M.jsx)("div",{className:"chat-bg-process-empty",children:e("暂无后台进程")}),S.map(s=>(0,M.jsxs)("div",{className:`chat-bg-process-item ${r===s.pid?"active":""} running`,children:[(0,M.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(s.pid),children:[(0,M.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",s.pid]}),(0,M.jsx)("span",{className:"chat-bg-process-cmd",title:s.cmd,children:s.cmd.length>40?s.cmd.slice(0,40)+"...":s.cmd}),(0,M.jsx)("span",{className:"chat-bg-process-time",children:new Date(s.start_time).toLocaleTimeString()}),(0,M.jsx)("span",{className:"chat-bg-process-status running-dot",title:e("运行中"),children:"●"})]}),(0,M.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,M.jsx)($.rA,{icon:"terminal",title:e("查看输出"),onClick:()=>y(s.pid)}),(0,M.jsx)($.rA,{icon:"stop",title:e("终止进程"),onClick:()=>w(s.pid)})]})]},s.pid)),N.map(e=>(0,M.jsx)("div",{className:`chat-bg-process-item ${r===e.pid?"active":""} finished`,children:(0,M.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,M.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,M.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,M.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,M.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==r&&(0,M.jsxs)("div",{className:"chat-bg-process-output",children:[(0,M.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,M.jsxs)("span",{children:["PID: ",r," ",e("输出")]}),(0,M.jsx)($.rA,{icon:"close",title:e("关闭"),onClick:()=>{d(null),h(null)}})]}),(0,M.jsx)("div",{className:"chat-bg-process-output-content",children:g?(0,M.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}):u?(0,M.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||e("(无输出)")}):null})]})]})]})};function se(){const{t:e}=(0,i.B)(),s=((0,c.Zp)(),(0,h.y)()),{check_user_auth:t}=(0,d.MH)();(0,p.w)();const[v,y]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[N,A]=(0,n.useState)(""),[$,I]=(0,n.useState)(null),[D,R]=(0,n.useState)(!1),H=(0,n.useRef)(null),[T,E]=(0,n.useState)([]),[K,P]=(0,a.fp)(_.AG.ai_session_collapsed),[B,F]=(0,a.fp)(_.AG.ai_bg_expanded),[q,O]=(0,a.fp)(_.AG.prompt_card),[J,W]=(0,n.useState)(!1),[Q,U]=(0,n.useState)(new Set),[X,se]=(0,n.useState)(new Set),[te,ne]=(0,n.useState)(""),ae=(0,n.useRef)(null),ie=(0,n.useRef)(null),ce=(0,n.useRef)(null),oe=(0,n.useRef)(!0),le=(0,n.useRef)(null),re=(0,n.useRef)(0),de=(0,n.useRef)(null),ue=(0,n.useRef)(N),me=(0,n.useRef)($);(0,n.useEffect)(()=>{ue.current=N},[N]),(0,n.useEffect)(()=>{me.current=$},[$]);const he=(0,n.useRef)(new f.qq),[ge,pe]=(0,n.useState)([]),[_e,xe]=(0,n.useState)(""),[fe,je]=(0,n.useState)(0),ve=()=>he?.current?.ai_config?.request_type||"completions",be=(0,n.useRef)((0,r.sg)(e=>{y(e),oe.current&&ye(!1)},50)).current,ye=(e=!1)=>{const s=ce.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},we=async()=>{const e=await l.jV.get("sessions");e.code===g.m.Success&&S(e.data??[])},Se=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:c,setActiveSessionId:l,refreshSessions:r,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,l)=>{const h=[...s(),n];t(h),i(e),g.current={abort:()=>{}};const p={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};h.push(p),t([...h]);const _=new Map;let x=!0,f=p;const j=s=>{const t=s.context||{},n=t.text||"",i=t.tool_call_ends,o=t.chunk_index??0;if("[DONE]"!==n)if(x)x=!1,f.text=n,i&&(f.content_list=[{tool_call_ends:i,content:f.text,role:"assistant"}]),f.is_loading=!1,f.chunk_index=o,_.set(o,f),c()===e&&a([...h]);else{const s=_.get(o);if(s)s.text+=n,i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),c()===e&&a([...h]);else{const s={id:Date.now()+Math.random(),sender:"bot",text:n,chunk_index:o};i&&(s.content_list=[{tool_call_ends:i,content:s.text,role:"assistant"}]),h.push(s),_.set(o,s),c()===e&&a([...h])}}},v=s=>{y(),g.current=null,i(s=>s===e?null:s),f.is_loading=!1,r(),d(!0),l()},b=s=>{y(),g.current=null,i(s=>s===e?null:s);const n=s.context||{};f.text="AI请求出错: "+(n.message||"未知错误"),f.is_loading=!1,c()===e&&t([...h]),l()},y=()=>{C.ws.off_message(`message_${o.HK.ai_chat_msg}`,j),C.ws.off_message(`message_${o.HK.ai_chat_end}`,v),C.ws.off_message(`message_${o.HK.ai_chat_error}`,b)};C.ws.addMsg(o.HK.ai_chat_msg,j),C.ws.addMsg(o.HK.ai_chat_end,v),C.ws.addMsg(o.HK.ai_chat_error,b),C.ws.sendData(o.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},_=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(c(),n,_)};return{startChatStream:p,processPendingQueue:_,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=c();e&&(C.ws.sendData(o.HK.ai_chat_abort,{session_id:e}),g.current&&(g.current=null,i(s=>s===e?null:s)))}}}({getMessages:()=>v,setMessages:y,setMessagesDebounced:be,setSending:I,getActiveSessionId:()=>ue.current,setActiveSessionId:A,refreshSessions:we,scrollToBottom:ye,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:()=>te}),Ne=async e=>{const s=await l.jV.get("sessions");if(s.code!==g.m.Success)return;const t=s.data??[];S(t);const n=null===e?t[0]?.id??"":e||N||t[0]?.id||"";n?await ke(n):(y([]),A(""))},ke=async(e,s=!1)=>{const t=await l.jV.post("session/get",{session_id:e});if(t.code!==g.m.Success||!t.data)return;const n=t.data;A(n.id),R(!!n.running),de.current&&de.current!==n.id&&C.ws.sendData(o.HK.ai_chat_subscribe,{session_id:de.current,subscribe:!1}),de.current=n.running?n.id:null,de.current&&C.ws.sendData(o.HK.ai_chat_subscribe,{session_id:de.current,subscribe:!0});const a=b(n.messages);n.running&&n.live_messages?.length?y([...a,...b(n.live_messages)]):y(a),ne(n.sys_prompt_id??""),s&&P(!1),Y.refresh?.(),requestAnimationFrame(()=>ye(!1))},Ce=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&E(e=>[...e,...s])},Ae=()=>{J&&(U(new Set),se(new Set)),W(e=>!e)};(0,n.useEffect)(()=>((async()=>{const e=await l.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){he.current=e.data;const s=e.data.ai_config?.model||"",t=(e.data.ai_config_env?.options_agent_model_list??[]).find(e=>e.label===s);xe(t?t.value:s)}await Ne();const s=await l.jV.get("system_prompts");s.code===g.m.Success&&pe(s.data??[])})(),requestAnimationFrame(()=>ye(!1)),Y.onCountChange=je,Y.refresh?.(),C.ws.addMsg(o.HK.ai_bg_process_count_notify,e=>{const s=e?.context?.count;"number"==typeof s&&je(s)}),()=>{C.ws.removeMsg(o.HK.ai_bg_process_count_notify)}),[]),(0,n.useEffect)(()=>{const e=ce.current;if(!e)return;const s=()=>{oe.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useEffect)(()=>{const e=()=>ue.current,s=()=>me.current,t=(t,n)=>{if(e()&&e()===t){if(le.current=null,R(!1),de.current===t&&(C.ws.sendData(o.HK.ai_chat_subscribe,{session_id:t,subscribe:!1}),de.current=null),s()===t)return;n?.length?y(e=>{const s=b(n),t=e[e.length-1];return"bot"===t?.sender?[...e.slice(0,-1),...s]:[...e,...s]}):ke(t).catch(()=>{}),we()}},n=t=>{const n=t?.context||{};if(!n.session_id)return;var a,i,c;a=n.session_id,i=n.text||"",c=n.tool_call_ends,e()&&e()===a&&s()!==a&&y(e=>{const s=e[e.length-1];if(s&&"bot"===s.sender){const t=[...e],n={...s};return n.text+=i,c&&(n.content_list=[{tool_call_ends:c,content:n.text,role:"assistant"}]),t[t.length-1]=n,le.current=n.id,oe.current&&requestAnimationFrame(()=>ye(!1)),t}const t={id:Date.now()+Math.random(),sender:"bot",text:i};return c&&(t.content_list=[{tool_call_ends:c,content:i,role:"assistant"}]),le.current=t.id,oe.current&&requestAnimationFrame(()=>ye(!1)),[...e,t]});const o=Date.now();o-re.current>1500&&(re.current=o,we())},a=e=>{const s=e?.context||{};s.session_id&&t(s.session_id,s.once_messages_list)},i=e=>{const s=e?.context||{};s.session_id&&t(s.session_id)};return C.ws.addMsg(o.HK.ai_chat_msg,n),C.ws.addMsg(o.HK.ai_chat_end,a),C.ws.addMsg(o.HK.ai_chat_error,i),()=>{C.ws.off_message(`message_${o.HK.ai_chat_msg}`,n),C.ws.off_message(`message_${o.HK.ai_chat_end}`,a),C.ws.off_message(`message_${o.HK.ai_chat_error}`,i),de.current&&(C.ws.sendData(o.HK.ai_chat_subscribe,{session_id:de.current,subscribe:!1}),de.current=null)}},[]),(0,n.useLayoutEffect)(()=>{oe.current&&ye(!1)},[v]);return(0,M.jsxs)(n.Fragment,{children:[(0,M.jsx)(L,{currentModelName:_e,setCurrentModelName:xe,envConfigRef:he,sysPromptList:ge,batchMode:J,selectedMsgCount:Q.size,onToggleSessionPanel:()=>{P(e=>!e)},onCreateSession:async e=>{const s=void 0!==e?e:te,t=await l.jV.post("session",{title:"新会话",sys_prompt_id:s||void 0});if(t.code!==g.m.Success)return;const n=t.data;A(n.id),y([]),ne(n.sys_prompt_id??""),P(!1),await Ne(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:()=>{0!==Q.size&&s({sub_title:e("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const e=[];v.forEach((s,t)=>{Q.has(s.id)&&e.push(t)}),y(v.filter(e=>!Q.has(e.id))),U(new Set),W(!1),N&&e.length>0&&l.jV.post("session/message/delete",{session_id:N,indices:e}).catch(console.error)}})},bgProcessVisible:B,bgProcessCount:fe,onToggleBgProcess:()=>F(e=>!e),selectedSysPromptId:te,setSelectedSysPromptId:e=>{ne(e),N&&l.jV.post("session/sys_prompt",{session_id:N,sys_prompt_id:e||void 0}).catch(console.error)}}),(0,M.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[K&&(0,M.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!1)}),(0,M.jsx)(z,{sessions:w,activeSessionId:N,onSelectSession:e=>ke(e,!1),onRenameSession:(e,t)=>{let n=t;s({confirm_fun:async()=>{await l.jV.post("sessions/update/meta",{id:e,title:n}),await Ne(N)},context_div:(0,M.jsx)("div",{className:"card-content",children:(0,M.jsx)(x.Sm,{value:n,handleInputChange:e=>{n=e}})})})},onDeleteSession:e=>{s({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await l.jV.post("session/delete",{session_id:e}),N===e?(A(""),await Ne(null)):await Ne(N)}})},onToggleCmdAuto:async(s,t)=>{await l.jV.post("session/cmd_auto_allow",{session_id:s,allow:t}),(0,m.SK)(e(t?"命令检测已开启":"命令检测已关闭")),await Ne(N)},onShowUsageStats:async s=>{O({open:!0,title:e("Token消耗统计"),context_div:(0,M.jsx)("div",{className:"usage-stats-loading",children:e("加载中...")}),cancel:()=>O({open:!1})});try{const t=await l.jV.post("session/usage_stats",{session_id:s});if(t.code===g.m.Success&&t.data){const s=t.data;O({open:!0,title:e("Token消耗统计"),context_div:(0,M.jsxs)("div",{className:"usage-stats-panel",children:[[{l:e("对话轮次"),v:(s.turns??0).toString()},{l:e("AI输入Token"),v:j(s.input_tokens)},{l:e("AI输出Token"),v:j(s.output_tokens)},{l:e("AI输入Token(最近一轮)"),v:j(s.recent_input_tokens)},{l:e("AI输出Token(最近一轮)"),v:j(s.recent_output_tokens)}].map((e,s)=>(0,M.jsxs)("div",{className:"usage-stats-row",children:[(0,M.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,M.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,M.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,M.jsx)("span",{className:"usage-stats-label",children:e("AI Token总计消耗")}),(0,M.jsx)("span",{className:"usage-stats-value",children:j((s.input_tokens||0)+(s.output_tokens||0))})]})]}),cancel:()=>O({open:!1})})}else O({open:!0,title:e("Token消耗统计"),context_div:(0,M.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>O({open:!1})})}catch{O({open:!0,title:e("Token消耗统计"),context_div:(0,M.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>O({open:!1})})}},batchMode:J,selectedSessionIds:X,onToggleSessionSelect:e=>{se(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Ae,onBatchDeleteSessions:()=>{0!==X.size&&s({sub_title:e("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of X)await l.jV.post("session/delete",{session_id:e});se(new Set),W(!1),X.has(N)?(A(""),await Ne(null)):await Ne(N)}})},onClearAllSessions:()=>{s({sub_title:e("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await l.jV.post("sessions/clear",{}),A(""),y([]),await Ne(null)}})}}),(0,M.jsx)(ee,{}),(0,M.jsxs)("section",{className:"chat-main",children:[0===v?.length&&(0,M.jsx)("div",{className:"chat-header",children:(0,M.jsx)("div",{children:e("询问服务器的一切")})}),(0,M.jsx)(G,{messages:v,batchMode:J,selectedMsgIds:Q,sending:$===N||D,chatContainerRef:ce,messagesEndRef:ie,onToggleMsgSelect:e=>{U(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:t=>{s({sub_title:e("确认删除这条消息吗?"),confirm_fun:async()=>{const e=v.findIndex(e=>e.id===t);if(e<0)return;const s=v.filter(e=>e.id!==t);y(s),N&&l.jV.post("session/message/delete",{session_id:N,indices:[e]}).catch(console.error)}})},onCopy:async e=>{(0,u.lW)(e),(0,m.SK)("复制成功")},onToggleBatchMode:Ae,t:e}),(0,M.jsx)(Z,{ref:H,onSend:async()=>{const e=(H.current?.getValue()??"").trim();if(!e&&0===T.length)return;if($===N){const s=await k(T);Se.enqueueMessage(e,s),H.current?.clear(),E([]);const t={id:Date.now(),sender:"user",text:e+(Se.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void y(e=>[...e,t])}let s=N;if(!s){const t=await l.jV.post("session",{title:(e||T[0]?.name||"新会话").slice(0,28),sys_prompt_id:te||void 0});if(t.code!==g.m.Success)return;s=t.data.id,A(s),await Ne(s)}const t=await k(T),n={id:Date.now(),sender:"user",text:e,attachments:t};H.current?.clear(),E([]);const a=ve();if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...v,n,t];y(i),I(s);return void(await V(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),y([...i]),I(null),we(),ye(!0),Se.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,y([...i]),I(null),Se.processPendingQueue()))}Se.startChatStream(s,n,()=>Se.processPendingQueue())},sending:$===N||D,onAbort:Se.abort,pendingAttachments:T,onRemoveAttachment:e=>{E(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ae.current?.click()},onAddFiles:Ce,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Ce(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ae,requestType:ve()})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>h});var n=t(96540),a=t(86149),i=t(14944),c=t(92275),o=t(34843),l=t(82893),r=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,a.B)(),[t,i]=(0,n.useState)(!1),c=!!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}),c&&(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)(r.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)(r.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(r.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function h(){const[e,s]=(0,o.fp)(l.AG.prompt_card),{t}=(0,a.B)(),r=(0,n.useRef)([]),h=(0,n.useRef)(!1),g=(0,n.useRef)(null),p=(0,n.useRef)(void 0),_=(0,n.useRef)(()=>{}),x=(0,n.useCallback)(e=>{s({open:!1}),h.current=!1,g.current&&(i.ws.sendData(c.HK.ai_confirm_cmd,{askId:g.current,approved:e}),g.current=null),_.current()},[s]),f=(0,n.useCallback)(()=>{if(h.current)return;if(0===r.current.length)return h.current=!1,void s({open:!1});h.current=!0;const e=r.current.shift();e?(g.current=e.askId,p.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>x(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>x(!1),onAllow:()=>x(!0),onAutoAllow:async()=>{if(p.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:p.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}x(!0)}})})):h.current=!1},[t,x,s]);_.current=f;const j=(0,n.useCallback)(e=>{r.current.push(e),f()},[f]);(0,n.useEffect)(()=>(i.ws.addMsg(c.HK.ai_confirm_cmd,e=>{const t=e.context||{};if(t.dismiss&&t.askId)return r.current=r.current.filter(e=>e.askId!==t.askId),void(h.current&&g.current===t.askId&&(g.current=null,h.current=!1,s({open:!1}),f()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})}),()=>{i.ws.removeMsg(c.HK.ai_confirm_cmd)}),[j]),(0,n.useEffect)(()=>()=>{r.current=[],h.current=!1,g.current=null},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>p});t(96540);var n=t(22091),a=t(53995),i=t(18569),c=t(77979),o=t(8263),l=t(69428),r=t.n(l),d=(t(3775),t(21499)),u=t(99214),m=t(19878),h=(t(72411),t(74848));const g=new n.A({html:!0,highlight:function(e,s){if(s&&m.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${m.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${g.utils.escapeHtml(e)}</code></pre>`}});function p(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:g.render(e.context)}})}g.use(a.A).use(i.A).use(c.A).use(o.A).use(r()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const c=s[t],o=c.content.trim(),l=c.info.trim();let r="";if(l&&m.A.getLanguage(l))try{r=m.A.highlight(o,{language:l}).value}catch(s){r=e.utils.escapeHtml(o)}else try{r=m.A.highlightAuto(o).value}catch(s){r=e.utils.escapeHtml(o)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(o)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${r}</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 c=e[t],o=c.attrIndex("href");if(o>=0){const e=c.attrs[o][1];c.attrs[o][1]=(0,d.bi)(window.location.href,e)}return s(e,t,n,a,i)}})},45907(e,s,t){t.d(s,{y:()=>i});var n=t(34843),a=t(82893);function i(){const[e,s]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:t,title:n,context_div:a})=>{s({open:!0,sub_title:e,handle:()=>{t(),s({open:!1,handle:null})},title:n,context_div:a})}}},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>"}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8714],{47374(e,t,i){i.d(t,{e:()=>d});var o=i(96540),n=i(3606),s=i(64694),a=i(34289),l=i(61443),r=i(75725),_=i(86149),c=i(85997),f=i(74848);function d(e){let t=(0,n.zy)();const[i,d]=(0,o.useState)([]),[p,m]=(0,o.useState)("/"),[h,u]=(0,o.useState)(void 0),{t:w,i18n:y}=(0,_.B)();o.useEffect(()=>{let t="",i=(0,a.vX)().split("/");i=i.filter(e=>e);const o=i.indexOf(e.baseRoute),n=[];if(-1!=o){t=(0,s.IO)(i.slice(0,o),e.baseRoute);const a=i.slice(o+1);for(let e=0;e<a.length;e++){const i=a[e];n.push({value:i,href:0===e?`${t}${i}/`:(0,s.IO)(n[e-1].href,i)})}m(t),d(n)}},[t]);const g=t=>{t.stopPropagation(),e.clickFun(t)};return(0,f.jsx)("div",{className:"breadcrumbs",onClick:e=>{u(void 0!==h?void 0:"")},children:(0,f.jsx)(o.Fragment,{children:void 0===h?(0,f.jsxs)(o.Fragment,{children:[(0,f.jsx)("span",{className:"chevron",children:(0,f.jsx)(n.N_,{to:p,onClick:g,children:(0,f.jsx)(c.In,{icon:"home"})})}),i.map((e,t)=>(0,f.jsxs)("span",{className:"chevron",children:[(0,f.jsx)(c.In,{icon:"keyboard_arrow_right"}),(0,f.jsx)(n.N_,{to:e.href,onClick:g,children:decodeURIComponent(e.value)})]},t))]}):(0,f.jsx)(r.QM,{click:()=>{u(void 0)},children:(0,f.jsx)(l.Sm,{width:"100%",placeholder:w("输入跳转的目录"),handlerEnter:t=>{e.input_path_enter&&e.input_path_enter(t),u(void 0)}})})})})}},78714(e,t,i){i.r(t),i.d(t,{default:()=>U});var o=i(96540),n=i(47374),s=i(34843),a=i(82893),l=i(14284),r=i(3606),_=i(57952),c=i(27690),f=i(34289),d=i(53459),p=i(99214),m=i(61443),h=i(47022),u=i(62042),w=i(86149),y=i(7523),g=i(78247),v=i(88815),x=i(6960),k=i(47071),j=i(14944),G=i(92275),A=i(23430);var C=i(34251),b=i(60096),z=i(85997),P=i(23496),F=i(12730),M=i(75725),$=i(70447),S=i(87361),D=i(40505),I=i(74848);let X={};function E(){const{t:e}=(0,w.B)();let t=(0,r.zy)();const i=(0,r.Zp)(),{check_user_auth:n}=(0,g.MH)(),[_,d]=(0,s.fp)(a.AG.nowFileList),[m,v]=(0,s.fp)(a.AG.uploadFiles),[x,k]=(0,s.fp)(a.AG.showPrompt),[b,P]=(0,s.fp)(a.AG.selectedFileList),[D,E]=(0,s.fp)(a.AG.copyedFileList),[K,Y]=(0,s.fp)(a.AG.cutedFileList),[L,R]=(0,s.fp)(a.AG.selectedFileList),[H,N]=(0,s.fp)(a.AG.clickFileList),[B,U]=(0,s.fp)(a.AG.fileShellShow),[W,O]=(0,s.fp)(a.AG.file_root_list),[Z,q]=(0,s.fp)(a.AG.file_root_index),[V,T]=(0,o.useState)(void 0),[J,Q]=(0,o.useState)(""),[ee,te]=(0,s.fp)(a.AG.workflow_show),[ie,oe]=(0,s.fp)(a.AG.workflow_realtime_show),[ne,se]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:ae}=(0,o.useContext)(y.F),[le,re]=(0,s.fp)(a.AG.user_base_info),{click_file:_e}=(0,g.kZ)(),[ce,fe]=(0,s.fp)(a.AG.prompt_card),de=(0,o.useMemo)(()=>_.files.reduce((e,t)=>e+(t.type!==h.Iw.folder?1:0),0),[_]),pe=(0,o.useMemo)(()=>_.files.reduce((e,t)=>e+(t.type===h.Iw.folder?1:0),0)+(_.folders?.length??0),[_]);function me(e){(0,u.SK)(e)}(0,o.useEffect)(()=>{X={}},[t]),(0,o.useEffect)(()=>()=>{U({show:!1,path:""})},[]);const he=(0,p.Vs)(),ue=t=>{fe({open:!0,title:e("信息"),context_div:(0,I.jsxs)("div",{style:{maxWidth:"25rem"},children:[(0,I.jsx)(M.Yh,{left:e("挂载位置磁盘"),right:t?.total_size}),(0,I.jsx)(M.Yh,{left:`${e("磁盘剩余")}`,right:t?.left_size}),(0,I.jsx)(M.Yh,{left:`${e("文件系统")}`,right:t?.fs_type}),(0,I.jsx)(M.Yh,{left:`${e("文件夹数")}`,right:pe}),(0,I.jsx)(M.Yh,{left:`${e("文件数")}`,right:de}),(0,I.jsx)(M.Yh,{left:`${e("当前位置")}`,right:(0,I.jsx)($.xP,{context:t?.now_absolute_path})})]}),cancel:()=>{j.ws.removeMsg(G.HK.file_info)}})};return(0,I.jsxs)(o.Fragment,{children:[b.length>0&&(0,I.jsx)(z.rA,{icon:"delete",title:e("删除"),onClick:()=>{k({show:!0,type:c.PromptEnum.FilesDelete,overlay:!0,data:{}})}}),b.length>0&&(0,I.jsx)(z.rA,{icon:"content_copy",title:e("复制"),onClick:function(){const e=(0,p.ib)(_,b);E(e.map(e=>(0,p.Ok)(e.name))),Y([]),me("已复制")}}),b.length>0&&(0,I.jsx)(z.rA,{icon:"content_cut",title:e("剪切"),onClick:function(){const e=(0,p.ib)(_,b);Y(e.map(e=>(0,p.Ok)(e.name))),E([]),me("已剪切")}}),(D.length>0||K.length>0)&&(0,I.jsx)(z.rA,{onClick:function(){k({show:!0,type:c.PromptEnum.Confirm,overlay:!0,data:{}})},icon:"content_paste",title:e("粘贴到此处"),tip:D.length+K.length}),b.length>0&&(0,I.jsx)(z.rA,{icon:"download",title:e("下载"),onClick:function(){const e=(0,p.ib)(_,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=encodeURIComponent((0,p.Ok)(i.name))}const t=l.$M.getDownloadUrl(e);window.open(t)}}),b.length>0&&(0,I.jsx)(z.rA,{icon:"compress",title:e("压缩"),onClick:function(){const e=(0,p.ib)(_,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=(0,p.Ok)(i.name)}e&&0!==e.length?k({show:!0,type:c.PromptEnum.Compress,overlay:!0,data:{files:e}}):(0,u.zN)("没有选中")}}),1===b.length&&(0,I.jsx)(z.rA,{icon:"edit_attributes",title:e("重命名"),onClick:function(){k({show:!0,type:c.PromptEnum.FileRename,overlay:!0,data:{}})}}),ne&&(0,I.jsx)(z.rA,{icon:"api",title:"workflow",onClick:()=>{te(!ee)}}),(0,I.jsx)(z.rA,{icon:"terminal",title:"shell",onClick:function(){B.show?U({show:!1,path:""}):U({show:!0,path:(0,f.GG)("file",(0,f.vX)())})}}),n(A.oV.share_file)&&(0,I.jsx)(z.rA,{icon:"share",title:e("文件分享"),onClick:()=>{i(`${S.o.share_list_setting_page}`)}}),(0,I.jsx)(z.rA,{icon:"grid_view",title:e("切换样式"),onClick:he}),(0,I.jsx)(z.rA,{icon:"create_new_folder",title:e("创建文件夹"),onClick:function(){k({show:!0,type:c.PromptEnum.DirNew,overlay:!0,data:{dir:(0,f.GG)("file",(0,f.vX)())}})}}),(0,I.jsx)(z.rA,{icon:"note_add",title:e("创建文本文件"),onClick:function(){k({show:!0,type:c.PromptEnum.FileNew,overlay:!0,data:{dir:(0,f.GG)("file",(0,f.vX)())}})}}),(0,I.jsx)(z.rA,{icon:"upload_file",title:e("上传"),onClick:()=>{k({show:!0,type:c.PromptEnum.UploadFile,overlay:!0,data:{call:e=>{let t=e.currentTarget?.files;if(!t)return;let i=!!t[0].webkitRelativePath;const o=[],n=new Set;for(let e=0;e<t.length;e++){const s=t[e],a=i?s.webkitRelativePath:`${s.webkitRelativePath}${s.name}`;s.fullPath=a,i&&n.add((0,F.S)(a)),o.push(s)}const s=[];if(i)for(const e of n)s.push({isDir:!0,fullPath:e,name:e});s.push(...o),v(s),k({show:!0,type:c.PromptEnum.FilesUpload,overlay:!1,data:{}})}}})}}),(0,I.jsx)(z.rA,{icon:"info",title:e("信息"),onClick:async()=>{let e;if(!X.now_absolute_path){j.ws.addMsg(G.HK.file_info,t=>{const i=t.context;e&&(X={...X,...i},j.ws.removeMsg(G.HK.file_info),ue(X))});const t=await j.ws.sendData(G.HK.file_info,{type:h.Iw.folder,path:(0,f.GG)("file",(0,f.vX)())});e=t.context,X=e,ue(X)}ue(X)}}),(0,I.jsx)(z.rA,{icon:"more_vert",title:e("切换目录"),onClick:t=>{const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory,o.items=W,o.item_pre_value=Z,o.textClick=async t=>{if(-1===t)return i(`${S.o.setting_private_env_setting}`),k({data:void 0,overlay:!1,type:"",show:!1}),void(0,u.N9)(e("请配置 文件夹路径"));(async e=>{q(e),await l.$M.post("base_switch",{root_index:e}),await ae(),i("/file/"),R([]),N([])})(t),k({data:void 0,overlay:!1,type:"",show:!1})},k({show:!0,type:c.PromptEnum.FileMenu,overlay:!1,data:o})}})]})}var K=i(2543),Y=i(21499),L=i(64694);const R=o.lazy(()=>Promise.all([i.e(7856),i.e(6349),i.e(3659)]).then(()=>i(63659))),H=o.lazy(()=>Promise.all([i.e(7856),i.e(1636)]).then(()=>i(81636)));let N,B="";function U(){const[e,t]=(0,s.fp)(a.AG.editorSetting),[i,u]=(0,s.fp)(a.AG.file_preview),{t:F}=(0,w.B)();let M=(0,r.zy)();const $=(0,r.Zp)(),[X,U]=(0,s.fp)(a.AG.nowFileList),[W,O]=(0,s.fp)(a.AG.showPrompt),[Z,q]=(0,s.fp)(a.AG.selectedFileList),[V,T]=(0,s.fp)(a.AG.clickFileList),[J,Q]=(0,s.fp)(a.AG.fileShellShow),[ee,te]=(0,o.useState)(""),[ie,oe]=(0,s.fp)(a.AG.workflow_show),[ne,se]=(0,s.fp)(a.AG.workflow_realtime_show),[ae,le]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:re}=(0,o.useContext)(y.F),[_e,ce]=(0,s.fp)(a.AG.user_base_info),{click_file:fe}=(0,g.kZ)(),[de,pe]=(0,s.fp)(a.AG.to_running_files),[me,he]=(0,s.fp)(a.AG.file_page),[ue]=(0,s.fp)(a.AG.blank_search_mode),[we,ye]=(0,s.fp)(a.AG.blank_search_mode_for_temp),ge=function(){const[e,t]=(0,s.fp)(a.AG.user_base_info),{t:i}=(0,w.B)(),{check_user_auth:n}=(0,g.MH)(),[_,d]=(0,s.fp)(a.AG.router_jump),m=(0,r.Zp)(),{initUserInfo:u}=(0,o.useContext)(y.F),[v,x]=(0,s.fp)(a.AG.nowFileList),[k,b]=(0,s.fp)(a.AG.showPrompt),[z,F]=(0,s.fp)(a.AG.fileShellShow),[M,$]=(0,s.fp)(a.AG.blank_search_mode);return t=>{t.preventDefault(),t.stopPropagation();const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory;const s=[{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.time_minx_max),children:i("时间逆序")}),v:A.t8.time_minx_max},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.time_max_min),children:i("时间顺序")}),v:A.t8.time_max_min}],a=[{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.size_min_max),children:i("大小顺序")}),v:A.t8.size_min_max},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.size_max_min),children:i("大小逆序")}),v:A.t8.size_max_min}],r=[{r:(0,I.jsx)("span",{style:(0,D.ok)(!e.user_data.file_list_pagination_mode||e.user_data.file_list_pagination_mode===A.yM.all),children:i("全部加载文件")}),v:A.yM.all},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.file_list_pagination_mode===A.yM.pagination),children:i("分页滚动加载文件")}),v:A.yM.pagination}],_=[{r:(0,I.jsx)("span",{style:(0,D.ok)(!e.user_data.file_time_show_type||e.user_data.file_time_show_type===A.KD.current),children:i("最近时间")}),v:A.KD.current},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.file_time_show_type===A.KD.time),children:i("准确时间")}),v:A.KD.time}],w=[{r:i("文件列表展示"),items:[{r:i("文件排序"),v:"",items:[{r:(0,I.jsx)("span",{style:(0,D.ok)(!e.user_data.dir_show_type),children:i("系统默认")}),v:A.t8.defualt},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.name),children:i("名字")}),v:A.t8.name},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.time_minx_max||e.user_data.dir_show_type===A.t8.time_max_min),children:i("修改时间")}),v:!1,items:s},{r:(0,I.jsx)("span",{style:(0,D.ok)(e.user_data.dir_show_type===A.t8.size_min_max||e.user_data.dir_show_type===A.t8.size_max_min),children:i("文件大小")}),v:!1,items:a}]},{r:i("文件加载方式"),v:"",items:r},{r:i("时间展示"),v:"",items:_},{r:i("缩放调整"),v:"zoom_adjust"},{r:(0,I.jsx)("span",{style:(0,D.ok)(M),children:i("以空白搜索模式打开目录")}),v:"blank_search_mode"}]},{r:i("以配置表方式打开目录"),v:"gcfg_dir_config"}];v?.folders?.find(e=>".git"===e.name)&&w.push({r:i("查看Git提交"),v:"git_page"}),n(A.oV.code_resource)&&w.push({r:i("添加http资源根目录"),v:"code_resource"}),n(A.oV.http_proxy)&&w.push({r:i("在此目录下载http资源"),v:"http_resource"}),e?.user_data?.quick_cmd&&(0,p.LL)([...e.user_data.quick_cmd],w),o.items=w,o.textClick=async e=>{if(console.log(e),!1===e)return;const t={};if("gcfg_dir_config"===e){const e=(0,f.GG)("file",(0,f.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`${S.o.gcfg_page}/${encodeURIComponent(e)}`)}if("git_page"===e){const e=(0,f.GG)("file",(0,f.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`${S.o.git_page}/${encodeURIComponent(e)}`)}if("code_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,f.GG)("file",(0,f.vX)())});return d({page_self_router_api_data:[`/api/${Date.now()}`,e.context.now_absolute_path]}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/setting/customer_router/")}if("http_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,f.GG)("file",(0,f.vX)())});return d({http_download_map_path:e.context.now_absolute_path}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/proxy/http/")}if("zoom_adjust"===e)return b({data:void 0,overlay:!1,type:"",show:!1}),void setTimeout(()=>{b({show:!0,type:c.PromptEnum.ZoomAdjust,overlay:!1,data:{}})},0);if("object"==typeof e&&"quick_cmd"===e.tag){let t=e.cmd;t&&(t.endsWith("\r")||(t+="\r",F({show:!0,path:(0,f.GG)("file",(0,f.vX)()),cmd:t})))}else{if("blank_search_mode"===e)return $(!M),void b({data:void 0,overlay:!1,type:"",show:!1});if(e===A.yM.all||e===A.yM.pagination)t.is_pagination_mode=!0;else if(e===A.KD.current||e===A.KD.time)t.is_file_show_type=!0;else{if(e!==A.t8.defualt&&e!==A.t8.name&&e!==A.t8.size_max_min&&e!==A.t8.size_min_max&&e!==A.t8.time_max_min&&e!==A.t8.time_minx_max)return;t.is_dir_list_type=!0}}await l.wm.post(P.s.user_save_private_attr,{type:e,...t}),await u(),b({data:void 0,overlay:!1,type:"",show:!1}),m((0,f.vX)())},b({show:!0,type:c.PromptEnum.FileMenu,overlay:!1,data:o})}}(),ve=async()=>{const e=new k.Nd;e.dir_path=`${(0,f.GG)("file",(0,f.vX)())}`,j.ws.addMsg(G.HK.workflow_realtime,e=>{const t=e.context;if(e.context){for(const e of t.sucess_file_list)(0,p.Ys)(e);for(const e of t.failed_file_list)(0,p.V$)(e);pe(new Set(t.running_file_list))}}),await j.ws.sendData(G.HK.workflow_realtime,e)},xe=async e=>{let t=!1;for(const i of e.files??[])i.origin_size=i.size,i.size=(0,v.v7)(i.size),_e.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,Y.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",t||!i.name.endsWith(".workflow.yml")&&!i.name.endsWith(".act")||(t=!0,Promise.resolve().then(()=>{ve()})),i.name===k.SB&&(t=!0);for(const i of e.folders??[])_e.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,Y.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",i.name===k.SB&&(t=!0);le(t)};(0,o.useEffect)(()=>async()=>{pe(new Set)},[]);const ke=()=>{(async()=>{const e=(0,f.GG)("file",(0,f.vX)());if(ue||we)return;let t;if(_e.user_data.file_list_pagination_mode===A.yM.pagination){if(B!==e){if(B=e,1!==me.page_num)return void he({page_size:me.page_size,page_num:1})}else if(me.page_num<0)return;if(t=await l.$M.post("file_get_page",{param_path:e,page_num:me.page_num,page_size:me.page_size}),t.code!==d.m.Success)return;const i=t.data;return xe(i),i.files?.length?(U(e=>{const t=(0,K.cloneDeep)(1===me.page_num?i.files:[...e?.files??[],...i.files]),o={...e,files:t};return(0,p.yC)(o,_e.user_data.dir_show_type),o}),void(N=t.data)):void he({page_size:me.page_size,page_num:-1})}if(t=await l.$M.get(e),t.code!==d.m.Success)return;const i=t.data;(0,p.yC)(i,_e.user_data.dir_show_type),xe(t.data),U(t.data),N=t.data})(),t({open:!1}),u({open:!1}),le(!1)};(0,o.useEffect)(()=>{ke()},[M,me]);const je=e=>{e.target===e.currentTarget&&(q([]),T([]))};return(0,I.jsxs)(o.Fragment,{children:[(0,I.jsxs)(_.A,{left_children:(0,I.jsx)(m.$Z,{handleEnterPress:async()=>{if(ue||we){if(q([]),T([]),!ee||!ee.trim())return void U({files:[],folders:[]});const e=(0,f.GG)("file",(0,f.vX)()),t=await l.$M.post("file_get_page",{param_path:e,page_num:1,page_size:1e4,search:ee.trim()});if(t.code!==d.m.Success)return;const i=t.data;return(0,p.yC)(i,_e.user_data.dir_show_type),xe(i),U(i),void(N=i)}if(!N)return;q([]),T([]);const e=[],t=[];for(const t of N.files??[])t.name.includes(ee)&&e.push(t);for(const e of N.folders??[])e.name.includes(ee)&&t.push(e);U({files:e,folders:t})},placeholder:F("搜索当前目录"),icon:"search",value:"",mobile_hidden:!0,handleInputChange:e=>{te(e)},max_width:"25em"}),children:[(0,I.jsx)("div",{className:"mobile-context-btn",children:(0,I.jsx)(z.rA,{icon:"more_horiz",title:F("右键"),onClick:()=>{const e=Z[Z.length-1];if(void 0!==e){const t=[...X.folders??[],...X.files??[]][e];if(t){const i=document.querySelectorAll(".item")[e],o=i?i.getBoundingClientRect():{left:window.innerWidth/2,bottom:100},n={preventDefault:()=>{},stopPropagation:()=>{},clientX:o.left+10,clientY:o.bottom??100},s=new C.ik;s.path=(0,L.IO)((0,f.vX)(),t.name),s.filename=t.name,s.x=n.clientX,s.y=n.clientY,s.type=t.type===h.Iw.folder?h.Iw.folder:(0,C.uL)(t.name),s.size=t.origin_size,O({show:!0,type:c.PromptEnum.FileMenu,overlay:!1,data:s})}}else{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:window.innerWidth/2,clientY:window.innerHeight/2};ge(e)}}})}),(0,I.jsx)(E,{})]}),(0,I.jsx)(n.e,{baseRoute:"file",clickFun:function(){if(q([]),T([]),_e.user_data.file_list_pagination_mode===A.yM.pagination){const e=document.getElementById("listing");e&&(e.scrollTop=0),he({page_size:me.page_size,page_num:1})}},input_path_enter:e=>{var t;q([]),T([]),U({files:[],folders:[]}),!function(e){return"string"==typeof e&&0!==e.length&&(/^[a-zA-Z]:[\\\/]/.test(e)||/^\\\\[^\\/]+[\\/]/.test(e)||/^\//.test(e))}(e)?$(function(e,t){let i=function(e){let t="\\";for(const i of e)if("/"===i||"\\"===i){t=i;break}return t}(e);if("."===t)return e;if(".."===t){if(e.length>1){let t=e[e.length-1]===i?1:0;for(let o=e.length-1-t;o>=0;o--)if(e[o]===i)return e.substring(0,o+1)}return e}return e.endsWith(i)&&t.startsWith(i)?e.slice(0,-1)+t:e.endsWith(i)||t.startsWith(i)?e+t:e+i+t}((0,f.vX)(),e)):(e=e.replace(0===(t=_e.user_data).folder_item_now||void 0===t.folder_item_now?t.cwd:t.folder_items[t.folder_item_now-1].path,""),$(e))}}),_e.user_data.file_list_pagination_mode===A.yM.pagination?(0,I.jsx)(b.$J,{handleContextMenu:ge,clickBlank:je,list:X.files}):(0,I.jsx)(b.t$,{handleContextMenu:ge,file_list:X.files,folder_list:X.folders,clickBlank:je}),ie&&(0,I.jsx)(R,{}),ne.open&&(0,I.jsx)(H,{})]})}}}]);