@deepseekcode/cli 1.0.12 → 1.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +10 -0
  2. package/dist/cli.js +1062 -939
  3. package/package.json +2 -1
  4. package/web/dist/assets/AgentFlowView-CfSu-PAH.js +1 -0
  5. package/web/dist/assets/AgentsView-0Gf3EdnC.js +1 -0
  6. package/web/dist/assets/{AskQuestionModal-ydX_B4wI.js → AskQuestionModal-UE0P8HVH.js} +1 -1
  7. package/web/dist/assets/{AuditView-BzMImL6n.js → AuditView-DzmxbLTN.js} +1 -1
  8. package/web/dist/assets/AutomationView-zrlVDQLZ.js +1 -0
  9. package/web/dist/assets/ChannelConfigView-3CHuvU_y.js +8 -0
  10. package/web/dist/assets/{FileTreeView-PejM6X2U.js → FileTreeView-Cc3rRokq.js} +3 -3
  11. package/web/dist/assets/{HookApprovalModal-BZrqAd9G.js → HookApprovalModal-DVpdbNbM.js} +1 -1
  12. package/web/dist/assets/HookConfigView-C3-HYLVR.js +3 -0
  13. package/web/dist/assets/{InboxView-72c5rEjQ.js → InboxView-DkJjMxlg.js} +1 -1
  14. package/web/dist/assets/ModelsView-DERNLd5f.js +1 -0
  15. package/web/dist/assets/SessionGrid-BD_2wvuD.js +21 -0
  16. package/web/dist/assets/{SettingsPanel-qg3WBeuf.js → SettingsPanel-BVIE5AdZ.js} +3 -3
  17. package/web/dist/assets/{SkillsView-C13I-2on.js → SkillsView-DU81ko6V.js} +1 -1
  18. package/web/dist/assets/TerminalView-DiRF3hQA.js +3 -0
  19. package/web/dist/assets/Toast-Bmm1ZZzF.js +1 -0
  20. package/web/dist/assets/ToolsView-Bo87RtdV.js +1 -0
  21. package/web/dist/assets/hookRisk-Ds8oxbfO.js +1 -0
  22. package/web/dist/assets/{icons-uody4X-4.js → icons-CjRO1znb.js} +54 -49
  23. package/web/dist/assets/index-CAwHhr7A.js +20 -0
  24. package/web/dist/assets/index-Czlzypr3.css +1 -0
  25. package/web/dist/assets/{markdown-BUScHEtT.js → markdown-hmVtvQNZ.js} +1 -1
  26. package/web/dist/assets/panels-C0Mxu2Md.js +1 -0
  27. package/web/dist/assets/{react-vendor-C5NlWs7r.js → react-vendor-Dp4P972X.js} +6 -6
  28. package/web/dist/assets/{state-DKyBAq9j.js → state-C_jK7HTi.js} +3 -3
  29. package/web/dist/index.html +6 -6
  30. package/web/dist/assets/AgentFlowView-BevVKfXk.js +0 -1
  31. package/web/dist/assets/AgentsView-C6uUk-Ot.js +0 -1
  32. package/web/dist/assets/AutomationView-CUDpr7WY.js +0 -1
  33. package/web/dist/assets/ChannelConfigView-DlRO4DS2.js +0 -8
  34. package/web/dist/assets/HookConfigView-5pYKJRQk.js +0 -3
  35. package/web/dist/assets/ModelsView-CVg05tUX.js +0 -1
  36. package/web/dist/assets/SessionGrid-CHFCkdr0.js +0 -20
  37. package/web/dist/assets/TerminalView-BVRuIrII.js +0 -3
  38. package/web/dist/assets/Toast-CcbSW0V2.js +0 -1
  39. package/web/dist/assets/ToolsView-_k5gi04A.js +0 -1
  40. package/web/dist/assets/hookRisk-DHeJr1SL.js +0 -1
  41. package/web/dist/assets/index-DuBeChMI.css +0 -1
  42. package/web/dist/assets/index-futMRNcm.js +0 -21
  43. package/web/dist/assets/panels-C_0RapVg.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as t}from"./markdown-hmVtvQNZ.js";import{r as a,R as oe,Z as st,P as ce,u as Ke,X as De,_ as at,s as de,$ as Ae,a0 as rt,a1 as lt,N as nt,J as ot,a2 as ct,a3 as dt,D as it,a4 as $e,A as ut,a5 as xt}from"./icons-CjRO1znb.js";import"./Toast-Bmm1ZZzF.js";import{a as x,t as C,M as Ee}from"./index-CAwHhr7A.js";import"./react-vendor-Dp4P972X.js";import"./state-C_jK7HTi.js";function pt(){const[g,y]=a.useState([]),[k,h]=a.useState("1.0"),[O,d]=a.useState(!0),[I,H]=a.useState(!0),[Y,K]=a.useState(null),j=a.useCallback(async()=>{H(!0),K(null);try{const f=await x.providers.presets();f.success&&f.data?(y(Array.isArray(f.data.providers)?f.data.providers:[]),h(f.data.version||"1.0"),d(f.data.customSupported!==!1)):K(f.error||"获取 Provider 列表失败")}catch(f){K(f instanceof Error?f.message:"未知错误")}finally{H(!1)}},[]);return a.useEffect(()=>{j()},[j]),{presets:g,loading:I,error:Y,version:k,customSupported:O,reload:j}}const V={provider:"",modelId:"",modelName:"",baseUrl:"",apiKeys:"",apiType:"openai-completions",temperature:1,maxTokens:32768,contextWindow:1e6},mt={providerKey:"",apiKey:"",modelIds:"",baseUrl:"",apiType:"openai-completions",setDefault:!1},ze={deepseek:10,moonshotai:20,"moonshotai-cn":21,"kimi-for-coding":22,zhipuai:30,zai:31,"alibaba-cn":40,alibaba:41,minimax:50,"minimax-cn":51,moark:60,siliconflow:70,"siliconflow-cn":71,"stepfun-ai":80,stepfun:81,modelscope:90,openai:100,anthropic:110,google:120,"google-vertex":121,meta:130,mistral:140,groq:150,xai:160,cohere:170,openrouter:180,huggingface:190};function kt(){var Se,Me;const{presets:g,loading:y,reload:k}=pt(),[h,O]=a.useState([]),[d,I]=a.useState(null),[H,Y]=a.useState(!0),[K,j]=a.useState(null),[f,ue]=a.useState(null),[Fe,D]=a.useState(!1),[P,W]=a.useState(null),[n,b]=a.useState(V),[xe,pe]=a.useState(!1),[me,T]=a.useState(null),[o,Le]=a.useState(null),[Re,A]=a.useState(!1),[be,G]=a.useState("select"),[N,$]=a.useState(null),[i,w]=a.useState(mt),[he,fe]=a.useState(!1),[ge,S]=a.useState(null),[ve,se]=a.useState(!1),[J,ye]=a.useState(!1),[B,X]=a.useState(""),[ke,je]=a.useState({}),[ae,Ne]=a.useState(!1),[re,_]=a.useState([]),[E,z]=a.useState(new Set),[we,U]=a.useState(null),[Z,le]=a.useState(""),M=a.useCallback(async()=>{try{const e=await x.config.provider.get();e.success&&e.data&&Le(e.data)}catch{}},[]),p=a.useCallback(async()=>{Y(!0),j(null);try{const[e,s]=await Promise.all([x.models.list(),x.system.status()]);if(await M(),e.success&&e.data&&Array.isArray(e.data.models)&&O(e.data.models),s.success&&s.data){const r=s.data.models||{total:0,online:0,offline:0};I({overallStatus:r.offline===0?"healthy":r.online>0?"degraded":"unhealthy",healthRate:r.total>0?r.online/r.total:0,healthyInstances:r.online,totalInstances:r.total,totalRequests:0})}}catch{j("加载模型失败")}finally{Y(!1)}},[M]);a.useEffect(()=>{p()},[p]),a.useEffect(()=>{const e=()=>{p(),M()};return window.addEventListener("models-updated",e),()=>window.removeEventListener("models-updated",e)},[p,M]);const F=a.useCallback(e=>`${e.provider}:${e.id}`,[]),Oe=a.useCallback(e=>ke[F(e)]||{inputTokens:0,outputTokens:0},[F,ke]),Ce=a.useCallback((e,s,r)=>{const l=F(e);je(u=>{var c,m;return{...u,[l]:{inputTokens:s==="inputTokens"?r:((c=u[l])==null?void 0:c.inputTokens)||0,outputTokens:s==="outputTokens"?r:((m=u[l])==null?void 0:m.outputTokens)||0}}})},[F]),We=a.useCallback(e=>{je(s=>({...s,[F(e)]:{inputTokens:0,outputTokens:0}}))},[F]),q=a.useMemo(()=>{const e=[...g];return e.find(s=>s.key==="custom")||e.push({key:"custom",name:"Custom",baseUrl:"",apiType:"openai-completions",defaultModel:"",isCustom:!0}),e},[g]),Q=a.useMemo(()=>[...q].sort((e,s)=>{if(e.isCustom)return-1;if(s.isCustom)return 1;const r=ze[e.key],l=ze[s.key];return r!==void 0&&l!==void 0?r-l:r!==void 0?-1:l!==void 0?1:e.name.localeCompare(s.name)}),[q]),Pe=a.useMemo(()=>{const e=B.trim().toLowerCase();return e?Q.filter(s=>s.name.toLowerCase().includes(e)||s.key.toLowerCase().includes(e)||(s.defaultModel||"").toLowerCase().includes(e)||(s.baseUrl||"").toLowerCase().includes(e)||(s.models||[]).some(r=>String(r).toLowerCase().includes(e))):Q},[Q,B]),Te=a.useCallback(e=>{var c,m;const s=(c=o==null?void 0:o.providers)==null?void 0:c[e.key],r=h.filter(R=>R.provider===e.key).map(R=>R.id),l=((m=e.models)==null?void 0:m.slice(0,3).join(", "))||e.defaultModel,u=r.length>0?r.join(", "):l;$(e.key),w({providerKey:e.key,apiKey:"",modelIds:u,baseUrl:(s==null?void 0:s.baseUrl)||e.baseUrl,apiType:(s==null?void 0:s.apiType)||e.apiType,setDefault:(o==null?void 0:o.defaultProvider)!==e.key}),G("form"),A(!0),S(null),se(!1),_([]),z(new Set),U(null),le("")},[h,o]),ne=a.useCallback(()=>{$("custom"),w({providerKey:"",apiKey:"",modelIds:"",baseUrl:"",apiType:"openai-completions",setDefault:!(o!=null&&o.configured)}),G("form"),A(!0),S(null),se(!1),_([]),z(new Set),U(null),le("")},[o]),Ge=a.useCallback(async()=>{var s;const e=i.baseUrl;if(!e){U("请先填写 Base URL");return}Ne(!0),U(null),_([]),z(new Set);try{const r=i.apiKey.replace(/[^\x00-\xFF]/g,"");r!==i.apiKey&&C.warning("API Key 包含非法字符,已自动过滤");const l=await x.models.fetch(e,r);if(l.success&&((s=l.data)!=null&&s.models)){_(l.data.models);const u=new Set(i.modelIds.split(",").map(c=>c.trim()).filter(Boolean));z(u),C.success(`获取到 ${l.data.models.length} 个模型`)}else U(l.error||"获取模型列表失败,请检查 Base URL 和 API Key")}catch(r){U(r instanceof Error?r.message:"请求失败")}finally{Ne(!1)}},[i.baseUrl,i.apiKey,i.modelIds]),Be=a.useCallback(e=>{z(s=>{const r=new Set(s);return r.has(e)?r.delete(e):r.add(e),r})},[]),_e=a.useCallback(()=>{const e=Array.from(E).join(", ");w(s=>({...s,modelIds:e}))},[E]),qe=async e=>{const s=h.find(c=>c.id===e);if(!s)return;const r=s.enabled!==!1,l=s.name||e,u=c=>r&&/default model/i.test(c);try{const c=await x.models.toggle(s.provider,e);if(c.success){await p();return}const m=c.error||"";u(m)?C.error(`“${l}” 是默认模型,无法直接禁用。请先在「Provider 配置」中更换默认模型,再进行禁用。`):C.error(m||"操作失败,请重试")}catch(c){const m=c instanceof Error?c.message:"";u(m)?C.error(`“${l}” 是默认模型,无法直接禁用。请先在「Provider 配置」中更换默认模型,再进行禁用。`):C.error(m||"操作失败,请重试")}},Ve=async e=>{ue(e);try{await x.models.test(e),await p()}finally{ue(null)}},He=async(e,s)=>{if(confirm(`确定要删除模型 "${s}" 吗?此操作不可撤销。`))try{(await x.models.delete(e,s)).success&&await p()}catch{}},Ye=e=>{W({provider:e.provider,modelId:e.id}),b({provider:e.provider,modelId:e.id,modelName:e.name,baseUrl:"",apiKeys:"",apiType:e.apiType||"openai-completions",temperature:e.temperature??1,maxTokens:e.maxTokens??32768,contextWindow:e.contextWindow??1e6}),T(null),D(!0)},Je=async()=>{var Ie;const e=q.find(v=>v.key===N)||null,s=N==="custom"?i.providerKey.trim():(e==null?void 0:e.key)||"";if(!s){S("请先输入 Provider 名称");return}if(!i.apiKey.trim()){S("请输入 API Key");return}const r=e||{baseUrl:"",apiType:"openai-completions",defaultModel:""},l=(Ie=o==null?void 0:o.providers)==null?void 0:Ie[s],c=i.apiKey.trim()||(l!=null&&l.hasApiKey?void 0:""),m=c!==void 0&&c!==""?c.replace(/[^\x00-\xFF]/g,""):c,R={provider:s,baseUrl:i.baseUrl||r.baseUrl,apiType:i.apiType||r.apiType,apiKey:m,models:(i.modelIds||r.defaultModel||"").split(",").map((v,tt)=>({id:v.trim(),name:v.trim(),enabled:!0,priority:10+tt})).filter(v=>v.id.length>0)};(!(o!=null&&o.configured)||i.setDefault)&&(R.setDefault=!0),fe(!0),S(null);try{const v=await x.config.provider.save(R);v.success?(A(!1),G("select"),$(null),await M(),await p()):S(v.error||"保存失败")}catch(v){S(v instanceof Error?v.message:"未知错误")}finally{fe(!1)}},Xe=async e=>{if(confirm(`确定要移除 "${e}" 的配置吗?这将删除其 API Key 和模型。`))try{await x.config.provider.delete(e),await M(),await p()}catch{}},Ze=async()=>{if(!n.provider.trim()||!n.modelId.trim()){T("提供商名称和模型 ID 不能为空");return}pe(!0),T(null);try{if(P){const e={name:n.modelName.trim()||n.modelId.trim(),temperature:n.temperature,maxTokens:n.maxTokens,contextWindow:n.contextWindow},s=await x.models.update(P.provider,P.modelId,{model:e});s.success?(D(!1),W(null),b(V),await p()):T(s.error||"保存失败")}else{const e={id:n.modelId.trim(),name:n.modelName.trim()||n.modelId.trim(),temperature:n.temperature,maxTokens:n.maxTokens,contextWindow:n.contextWindow,enabled:!0,apiType:n.apiType};if(n.baseUrl.trim()&&(e.baseUrl=n.baseUrl.trim()),n.apiKeys.trim()){const l=n.apiKeys.split(",").map(u=>u.trim()).filter(Boolean).map(u=>u.replace(/[^\x00-\xFF]/g,""));e.apiKeys=l,e.apiKey=l[0]}const s=await x.models.create({provider:n.provider.trim(),model:e});s.success?(D(!1),b(V),await p()):T(s.error||"保存失败")}}catch(e){T(e instanceof Error?e.message:"未知错误")}finally{pe(!1)}},Qe=e=>{switch(e){case"online":return"text-accent-green";case"offline":return"text-dark-muted";case"error":return"text-accent-red";default:return"text-dark-muted"}},et=e=>{switch(e){case"online":return t.jsx(xt,{size:14});case"offline":return t.jsx($e,{size:14});case"error":return t.jsx(ut,{size:14});default:return t.jsx($e,{size:14})}},L=a.useMemo(()=>q.find(e=>e.key===N)||null,[N,q]);return H?t.jsx("div",{className:"flex h-64 items-center justify-center text-dark-muted",children:"加载中..."}):K?t.jsx("div",{className:"flex h-64 items-center justify-center text-accent-red",children:K}):t.jsxs("div",{className:"p-6 space-y-6 flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h2",{className:"text-base font-semibold",children:"Provider 配置"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:async()=>{try{await x.providers.refresh(),C.success("Provider 列表已刷新"),ye(!0),await k(),setTimeout(()=>{k()},3e3)}catch{C.error("刷新失败,请稍后重试")}},className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs border border-dark-border rounded hover:bg-dark-hover",title:"从远端刷新 Provider 列表",children:[t.jsx(oe,{size:12}),"刷新列表"]}),t.jsxs("button",{onClick:()=>{J&&X(""),ye(e=>!e)},className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[J?t.jsx(st,{size:12}):t.jsx(ce,{size:12}),J?"收起":"新增 Provider"]})]})]}),J&&t.jsxs("div",{children:[t.jsxs("div",{className:"relative mb-3 max-w-md",children:[t.jsx(Ke,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted"}),t.jsx("input",{value:B,onChange:e=>X(e.target.value),className:"w-full pl-8 pr-8 py-1.5 text-xs bg-dark-bg border border-dark-border rounded focus:outline-none focus:border-accent-blue",placeholder:"搜索 Provider 名称 / 模型..."}),B&&t.jsx("button",{onClick:()=>X(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-white",title:"清除","aria-label":"清除搜索",children:t.jsx(De,{size:13})})]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3 max-h-[420px] overflow-y-auto custom-scrollbar pr-1",children:y?t.jsxs("div",{className:"col-span-full flex items-center justify-center py-4 text-dark-muted text-sm",children:[t.jsx(at,{size:14,className:"mr-2 animate-spin"}),"加载 Provider 列表..."]}):Pe.length===0?t.jsxs("div",{className:"col-span-full border border-accent-red/30 bg-accent-red/10 rounded-lg p-4 text-center",children:[t.jsx("div",{className:"text-sm text-accent-red font-medium mb-1",children:"未找到匹配的 Provider"}),t.jsxs("div",{className:"text-xs text-dark-muted mb-3",children:["没有与「",B,"」匹配的 Provider,请检查拼写或改用完整列表"]}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsxs("button",{onClick:()=>X(""),className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs border border-dark-border rounded hover:bg-dark-hover",children:[t.jsx(De,{size:12}),"清除搜索"]}),t.jsxs("button",{onClick:ne,className:"inline-flex items-center gap-1 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[t.jsx(ce,{size:12}),"添加自定义 Provider"]})]})]}):Pe.map(e=>{var u,c;const s=(u=o==null?void 0:o.providers)==null?void 0:u[e.key],r=s==null?void 0:s.hasApiKey,l=(o==null?void 0:o.defaultProvider)===e.key;return t.jsxs("div",{className:`text-left p-3 rounded-lg border transition-colors relative ${r?"border-accent-green/30 bg-dark-surface hover:border-accent-green/50":"border-dark-border bg-dark-surface hover:border-dark-hover"}`,children:[t.jsxs("div",{onClick:()=>e.key==="custom"?ne():Te(e),className:"cursor-pointer",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"text-sm font-medium",children:e.name}),r&&t.jsx(de,{size:14,className:"text-accent-green"})]}),t.jsxs("div",{className:"text-[10px] text-dark-muted space-y-0.5",children:[t.jsx("div",{children:e.baseUrl||"自定义地址"}),t.jsx("div",{children:e.defaultModel||"无默认模型"}),t.jsxs("div",{children:[s?`${s.modelCount} 已配置`:`${((c=e.models)==null?void 0:c.length)||0} 可用`,e.models&&e.models.length>0&&!s&&t.jsx("span",{className:"text-accent-blue",children:" ✓"})]})]}),l&&t.jsx("div",{className:"mt-1 text-[10px] text-accent-blue",children:"默认 Provider"})]}),r&&t.jsx("button",{onClick:m=>{m.stopPropagation(),Xe(e.key)},className:"absolute top-1.5 right-1.5 p-1 rounded text-dark-muted hover:bg-accent-red/10 hover:text-accent-red transition-colors",title:"删除 Provider","aria-label":`删除 ${e.name}`,children:t.jsx(Ae,{size:13})})]})})})]})]}),d&&t.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[t.jsx(ee,{title:"总体状态",value:d.totalInstances===0?"未配置":d.overallStatus==="healthy"?"健康":d.overallStatus==="degraded"?"降级":"异常",color:d.totalInstances===0?"blue":d.overallStatus==="healthy"?"green":d.overallStatus==="degraded"?"yellow":"red"}),t.jsx(ee,{title:"健康率",value:d.totalInstances===0?"N/A":`${(d.healthRate*100).toFixed(0)}%`,color:d.totalInstances===0?"blue":d.healthRate>.8?"green":d.healthRate>.5?"yellow":"red"}),t.jsx(ee,{title:"在线实例",value:d.totalInstances===0?"无":`${d.healthyInstances}/${d.totalInstances}`,color:d.healthyInstances>0?"green":"red"}),t.jsx(ee,{title:"总请求数",value:d.totalRequests>0?d.totalRequests.toLocaleString():"0",color:"blue"})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsx("h3",{className:"text-sm font-medium",children:"已配置模型"}),t.jsxs("button",{onClick:()=>{W(null),b(V),T(null),D(!0)},className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs bg-accent-blue text-white rounded hover:opacity-90",children:[t.jsx(ce,{size:12}),"添加模型"]})]}),t.jsxs("div",{className:"space-y-2 max-h-[480px] overflow-y-auto custom-scrollbar pr-1",children:[h.map(e=>{const s=Oe(e),r=s.inputTokens+s.outputTokens;return t.jsx("div",{className:`bg-dark-surface border rounded-lg p-3 ${e.status==="online"?"border-accent-green":"border-dark-border opacity-70"}`,children:t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[t.jsx("span",{className:Qe(e.status),children:et(e.status)}),t.jsx("span",{className:"font-medium text-sm",children:e.name}),t.jsx("span",{className:"text-[10px] text-dark-muted px-1.5 py-0.5 bg-dark-bg rounded",children:e.provider}),e.apiType&&t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${e.apiType==="anthropic-messages"?"bg-accent-purple/20 text-accent-purple":"bg-accent-blue/20 text-accent-blue"}`,children:e.apiType==="anthropic-messages"?"Anthropic":"OpenAI"}),e.isGlobalDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green font-medium",children:"全局默认"}),e.isPlanDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue font-medium",children:"Plan 默认"}),e.isActDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-yellow/20 text-accent-yellow font-medium",children:"Act 默认"}),e.isGoalDefault&&t.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-purple/20 text-accent-purple font-medium",children:"Goal 默认"})]}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 text-xs",children:[t.jsx(te,{label:"负载",value:`${e.load}/${e.maxLoad}`}),t.jsx(te,{label:"Token",value:`${e.tokens}/${e.maxTokens}`}),t.jsx(te,{label:"输入价格",value:`$${e.price.input}/1K`}),t.jsx(te,{label:"输出价格",value:`$${e.price.output}/1K`})]}),t.jsxs("div",{className:"mt-3 grid grid-cols-1 sm:grid-cols-4 gap-3 items-end",children:[t.jsx(Ue,{label:"输入 token",value:s.inputTokens,onChange:l=>Ce(e,"inputTokens",l)}),t.jsx(Ue,{label:"输出 token",value:s.outputTokens,onChange:l=>Ce(e,"outputTokens",l)}),t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-dark-muted mb-1",children:"总 token"}),t.jsx("div",{className:"px-3 py-2 rounded border border-dark-border bg-dark-bg text-sm font-mono",children:r.toLocaleString()})]}),t.jsxs("button",{onClick:()=>We(e),className:"inline-flex items-center justify-center gap-1.5 px-3 py-2 rounded border border-dark-border text-sm text-dark-muted hover:bg-dark-hover",children:[t.jsx(rt,{size:13}),"重置"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!e.isGlobalDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await x.models.setDefaults({global:`${e.provider}:${e.id}`}),await p()}catch(l){j(l instanceof Error?l.message:"设置全局默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-green/30 text-accent-green hover:bg-accent-green/10",title:"设为全局默认",children:"全局默认"}),!e.isPlanDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await x.models.setDefaults({plan:`${e.provider}:${e.id}`}),await p()}catch(l){j(l instanceof Error?l.message:"设置 Plan 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-blue/30 text-accent-blue hover:bg-accent-blue/10",title:"设为 Plan 默认",children:"Plan 默认"}),!e.isActDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await x.models.setDefaults({act:`${e.provider}:${e.id}`}),await p()}catch(l){j(l instanceof Error?l.message:"设置 Act 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-yellow/30 text-accent-yellow hover:bg-accent-yellow/10",title:"设为 Act 默认",children:"Act 默认"}),!e.isGoalDefault&&e.enabled!==!1&&t.jsx("button",{onClick:async()=>{try{await x.models.setDefaults({goal:`${e.provider}:${e.id}`}),await p()}catch(l){j(l instanceof Error?l.message:"设置 Goal 默认失败")}},className:"px-2 py-1 rounded text-[10px] border border-accent-purple/30 text-accent-purple hover:bg-accent-purple/10",title:"设为 Goal 默认",children:"Goal 默认"}),t.jsx("button",{onClick:()=>Ye(e),className:"p-1.5 rounded hover:bg-accent-blue/10 text-dark-muted hover:text-accent-blue",title:"编辑模型",children:t.jsx(lt,{size:13})}),t.jsx("button",{onClick:()=>He(e.provider,e.id),className:"p-1.5 rounded hover:bg-accent-red/10 text-dark-muted hover:text-accent-red",title:"删除模型",children:t.jsx(Ae,{size:13})}),t.jsx("button",{onClick:()=>Ve(e.id),disabled:f===e.id,className:"p-1.5 rounded hover:bg-dark-hover disabled:opacity-50",title:"刷新",children:t.jsx(oe,{size:13,className:f===e.id?"animate-spin":""})}),t.jsx("button",{onClick:()=>qe(e.id),className:`px-2 py-0.5 rounded text-xs transition-colors ${e.status==="online"?"bg-accent-red/20 text-accent-red hover:bg-accent-red/30":"bg-accent-green/20 text-accent-green hover:bg-accent-green/30"}`,children:e.status==="online"?"禁用":"启用"})]})]})},e.id)}),h.length===0&&t.jsxs("div",{className:"text-center text-dark-muted py-6",children:[t.jsx(nt,{size:36,className:"mx-auto mb-2 opacity-40"}),t.jsx("p",{className:"text-sm",children:"暂无模型,请先在上方配置 Provider"})]})]})]}),t.jsx(Ee,{isOpen:Re,onClose:()=>{A(!1),G("select"),$(null)},title:be==="select"?"选择 Provider":(L==null?void 0:L.name)||"Provider 配置",size:"xl",children:be==="select"?t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[Q.filter(e=>e.key!=="custom").map(e=>t.jsxs("button",{onClick:()=>Te(e),className:"text-left p-3 rounded-lg border border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(de,{size:14,className:"text-accent-blue"}),t.jsx("span",{className:"text-sm font-medium",children:e.name})]}),t.jsx("div",{className:"text-xs text-dark-muted",children:e.defaultModel})]},e.key)),t.jsxs("button",{onClick:ne,className:"text-left p-3 rounded-lg border border-dashed border-dark-border bg-dark-bg hover:border-accent-blue transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx(ot,{size:14,className:"text-accent-blue"}),t.jsx("span",{className:"text-sm font-medium",children:"自定义 Provider"})]}),t.jsx("div",{className:"text-xs text-dark-muted",children:"手动填写 Provider 名称、Base URL 和模型 ID"})]})]})}):t.jsxs("div",{className:"space-y-3",children:[N==="custom"&&t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"Provider 名称 *"}),t.jsx("input",{value:i.providerKey,onChange:e=>w(s=>({...s,providerKey:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"例如: my-provider"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API Key *"}),t.jsxs("div",{className:"relative",children:[t.jsx("input",{type:ve?"text":"password",value:i.apiKey,onChange:e=>w(s=>({...s,apiKey:e.target.value})),className:"w-full px-3 py-2 pr-10 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"输入 API Key"}),t.jsx("button",{onClick:()=>se(e=>!e),className:"absolute right-2 top-2 text-dark-muted hover:text-white",children:ve?t.jsx(ct,{size:14}):t.jsx(dt,{size:14})})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型 ID"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:i.modelIds,onChange:e=>w(s=>({...s,modelIds:e.target.value})),className:"flex-1 px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:(L==null?void 0:L.defaultModel)||"gpt-4o, deepseek-chat"}),t.jsxs("button",{onClick:Ge,disabled:ae||!i.baseUrl,className:"inline-flex items-center gap-1 px-3 py-2 rounded text-sm border border-accent-blue/30 text-accent-blue hover:bg-accent-blue/10 disabled:opacity-50 whitespace-nowrap",title:"从 API 获取模型列表",children:[ae?t.jsx(oe,{size:13,className:"animate-spin"}):t.jsx(it,{size:13}),ae?"获取中...":"获取模型列表"]})]}),we&&t.jsx("div",{className:"mt-1 text-xs text-accent-red",children:we}),re.length>0&&t.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg bg-dark-bg p-2",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("span",{className:"text-xs text-dark-muted",children:["已获取 ",t.jsx("strong",{className:"text-dark-text",children:re.length})," 个模型, 已选 ",t.jsx("strong",{className:"text-accent-blue",children:E.size})," 个"]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx("button",{onClick:_e,className:"px-2 py-0.5 text-[10px] bg-accent-blue text-white rounded hover:opacity-90",children:"应用选中"}),t.jsx("button",{onClick:()=>{_([]),z(new Set)},className:"px-2 py-0.5 text-[10px] border border-dark-border rounded hover:bg-dark-hover",children:"关闭"})]})]}),t.jsxs("div",{className:"relative mb-2",children:[t.jsx(Ke,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-dark-muted"}),t.jsx("input",{value:Z,onChange:e=>le(e.target.value),className:"w-full pl-7 pr-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:outline-none focus:border-accent-blue",placeholder:"搜索模型..."})]}),t.jsx("div",{className:"max-h-48 overflow-y-auto custom-scrollbar grid grid-cols-2 sm:grid-cols-3 gap-1",children:re.filter(e=>!Z||e.id.toLowerCase().includes(Z.toLowerCase())||e.name.toLowerCase().includes(Z.toLowerCase())).map(e=>t.jsxs("label",{className:`flex items-center gap-1.5 px-2 py-1 rounded cursor-pointer text-xs transition-colors ${E.has(e.id)?"bg-accent-blue/20 text-accent-blue border border-accent-blue/30":"hover:bg-dark-hover border border-transparent"}`,children:[t.jsx("input",{type:"checkbox",checked:E.has(e.id),onChange:()=>Be(e.id),className:"sr-only"}),E.has(e.id)?t.jsx(de,{size:10}):t.jsx("div",{className:"w-2.5 h-2.5 rounded border border-dark-border"}),t.jsx("span",{className:"truncate",children:e.id})]},e.id))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"Base URL"}),t.jsx("input",{value:i.baseUrl,onChange:e=>w(s=>({...s,baseUrl:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"https://api.example.com/v1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API 类型"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:["openai-completions","anthropic-messages"].map(e=>t.jsxs("label",{className:`flex items-center justify-center gap-1.5 px-3 py-2 rounded text-sm cursor-pointer border transition-colors ${i.apiType===e?"bg-accent-blue/20 border-accent-blue text-accent-blue":"bg-dark-bg border-dark-border text-dark-muted hover:border-dark-hover"}`,children:[t.jsx("input",{type:"radio",name:"providerApiType",value:e,checked:i.apiType===e,onChange:s=>w(r=>({...r,apiType:s.target.value})),className:"sr-only"}),e==="openai-completions"?"OpenAI Compatible":"Anthropic Messages"]},e))})]}),t.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:i.setDefault,onChange:e=>w(s=>({...s,setDefault:e.target.checked})),className:"accent-accent-blue"}),t.jsx("span",{className:"text-sm text-dark-muted",children:"设为默认 Provider"})]}),ge&&t.jsx("div",{className:"text-sm text-accent-red",children:ge}),t.jsxs("div",{className:"flex justify-between gap-2 pt-2",children:[t.jsx("div",{children:N&&N!=="custom"&&((Me=(Se=o==null?void 0:o.providers)==null?void 0:Se[N])==null?void 0:Me.hasApiKey)&&t.jsx("button",{onClick:async()=>{if(confirm(`确定要删除 "${N}" 的配置吗?`))try{await x.config.provider.delete(N),A(!1),$(null),await M(),await p()}catch{}},className:"px-4 py-2 rounded border border-accent-red/30 text-accent-red hover:bg-accent-red/10 transition-colors text-sm",children:"删除 Provider"})}),t.jsx("button",{onClick:()=>{G("select"),$(null),A(!1)},className:"px-4 py-2 rounded border border-dark-border hover:bg-dark-hover transition-colors text-sm",children:"取消"}),t.jsx("button",{onClick:Je,disabled:he,className:"px-4 py-2 bg-accent-blue text-white rounded hover:bg-accent-blue/80 transition-colors text-sm disabled:opacity-50",children:he?"保存中...":"保存"})]})]})}),t.jsx(Ee,{isOpen:Fe,onClose:()=>{D(!1),W(null)},title:P?"编辑模型":"添加模型",size:"lg",children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"提供商名称 *"}),t.jsx("input",{value:n.provider,onChange:e=>b(s=>({...s,provider:e.target.value})),disabled:!!P,className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50",placeholder:"例如: openai, deepseek"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型 ID *"}),t.jsx("input",{value:n.modelId,onChange:e=>b(s=>({...s,modelId:e.target.value})),disabled:!!P,className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50",placeholder:"例如: gpt-4o, deepseek-chat"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"模型名称"}),t.jsx("input",{value:n.modelName,onChange:e=>b(s=>({...s,modelName:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"留空则使用模型 ID"})]}),t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[t.jsx(ie,{label:"温度",value:n.temperature,step:"0.1",min:"0",max:"2",onChange:e=>b(s=>({...s,temperature:e}))}),t.jsx(ie,{label:"最大 Token",value:n.maxTokens,onChange:e=>b(s=>({...s,maxTokens:e}))}),t.jsx(ie,{label:"上下文窗",value:n.contextWindow,onChange:e=>b(s=>({...s,contextWindow:e}))})]}),!P&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API 地址"}),t.jsx("input",{value:n.baseUrl,onChange:e=>b(s=>({...s,baseUrl:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"https://api.example.com/v1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API Key(多个用逗号分隔)"}),t.jsx("input",{value:n.apiKeys,onChange:e=>b(s=>({...s,apiKeys:e.target.value})),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue",placeholder:"sk-xxx, sk-yyy"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:"API 类型"}),t.jsx("div",{className:"grid grid-cols-2 gap-2",children:["openai-completions","anthropic-messages"].map(e=>t.jsxs("label",{className:`flex items-center justify-center gap-1.5 px-3 py-2 rounded text-sm cursor-pointer border transition-colors ${n.apiType===e?"bg-accent-blue/20 border-accent-blue text-accent-blue":"bg-dark-bg border-dark-border text-dark-muted hover:border-dark-hover"}`,children:[t.jsx("input",{type:"radio",name:"addModelApiType",value:e,checked:n.apiType===e,onChange:s=>b(r=>({...r,apiType:s.target.value})),className:"sr-only"}),e==="openai-completions"?"OpenAI Compatible":"Anthropic Messages"]},e))})]})]}),me&&t.jsx("div",{className:"text-sm text-accent-red bg-accent-red/10 p-2 rounded",children:me}),t.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[t.jsx("button",{onClick:()=>{D(!1),W(null),b(V)},className:"px-4 py-2 rounded border border-dark-border hover:bg-dark-hover transition-colors text-sm",children:"取消"}),t.jsx("button",{onClick:Ze,disabled:xe,className:"px-4 py-2 bg-accent-blue text-white rounded hover:bg-accent-blue/80 transition-colors text-sm disabled:opacity-50",children:xe?"保存中...":"保存"})]})]})})]})}function ee({title:g,value:y,color:k}){const h={green:"bg-accent-green/10 text-accent-green",yellow:"bg-accent-yellow/10 text-accent-yellow",red:"bg-accent-red/10 text-accent-red",blue:"bg-accent-blue/10 text-accent-blue"};return t.jsxs("div",{className:`${h[k]} rounded-lg p-3`,children:[t.jsx("div",{className:"text-xs opacity-70",children:g}),t.jsx("div",{className:"text-xl font-semibold",children:y})]})}function te({label:g,value:y}){return t.jsxs("div",{children:[t.jsx("div",{className:"text-dark-muted",children:g}),t.jsx("div",{children:y})]})}function Ue({label:g,value:y,onChange:k}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-[11px] text-dark-muted mb-1",children:g}),t.jsx("input",{type:"number",min:"0",value:y,onChange:h=>k(parseInt(h.target.value,10)||0),className:"w-full px-3 py-2 rounded border border-dark-border bg-dark-bg text-sm focus:outline-none focus:border-accent-blue"})]})}function ie({label:g,value:y,onChange:k,min:h,max:O,step:d}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm text-dark-muted mb-1",children:g}),t.jsx("input",{type:"number",value:y,min:h,max:O,step:d,onChange:I=>k(d?parseFloat(I.target.value)||0:parseInt(I.target.value,10)||0),className:"w-full px-3 py-2 bg-dark-bg border border-dark-border rounded text-sm focus:outline-none focus:border-accent-blue"})]})}export{kt as ModelsView,kt as default};
@@ -0,0 +1,21 @@
1
+ import{j as e,M as wt,P as je}from"./markdown-hmVtvQNZ.js";import{r as p,s as Nt,ar as Ve,e as se,a as ee,b as Re,au as Qe,X as ue,av as Et,A as re,o as Se,L as pe,an as Ie,F as Ae,aw as Te,ax as vt,D as jt,p as St,B as At,a5 as Tt,ay as Me,az as Ct,R as me,w as _t,$ as Rt,aA as It,u as Ot,aB as Lt,ao as Dt,aC as Ft,ak as $t,aD as Mt,ai as Pt,n as zt,aE as Bt,V as et,Z as Ut,q as Ht,ag as Gt,aa as qt}from"./icons-CjRO1znb.js";import{i as H,e as F,w as U,j as Pe,u as ne,a as Q,t as K,k as z,l as Wt,W as Kt,m as Zt,n as Ce,b as Jt,o as ze,d as _e}from"./index-CAwHhr7A.js";import{c as Xt,e as Yt,R as Vt}from"./hookRisk-Ds8oxbfO.js";import"./react-vendor-Dp4P972X.js";import"./state-C_jK7HTi.js";function Be({value:s,max:t=100,size:n="md",variant:r="default",showLabel:a=!1,className:l}){const o=Math.min(Math.max(s/t*100,0),100),d={sm:"h-1",md:"h-2",lg:"h-3"},i={default:"bg-accent-blue",success:"bg-accent-green",warning:"bg-accent-yellow",error:"bg-accent-red"};return e.jsxs("div",{className:H("w-full",l),children:[e.jsx("div",{className:H("w-full bg-dark-border rounded-full overflow-hidden",d[n]),children:e.jsx("div",{className:H("h-full rounded-full transition-all duration-300",i[r]),style:{width:`${o}%`}})}),a&&e.jsxs("span",{className:"text-xs text-dark-muted mt-1",children:[Math.round(o),"%"]})]})}Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/});Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/});Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}});Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}});Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript"));Prism.languages.js=Prism.languages.javascript;(function(s){s.languages.typescript=s.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),s.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete s.languages.typescript.parameter,delete s.languages.typescript["literal-property"];var t=s.languages.extend("typescript",{});delete t["class-name"],s.languages.typescript["class-name"].inside=t,s.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),s.languages.ts=s.languages.typescript})(Prism);(function(s){var t=s.util.clone(s.languages.javascript),n=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,r=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function l(i,c){return i=i.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return a}),RegExp(i,c)}a=l(a).source,s.languages.jsx=s.languages.extend("markup",t),s.languages.jsx.tag.pattern=l(/<\/?(?:[\w.:-]+(?:<S>+(?:[\w.:$-]+(?:=(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s{'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*\/?)?>/.source),s.languages.jsx.tag.inside.tag.pattern=/^<\/?[^\s>\/]*/,s.languages.jsx.tag.inside["attr-value"].pattern=/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/,s.languages.jsx.tag.inside.tag.inside["class-name"]=/^[A-Z]\w*(?:\.[A-Z]\w*)*$/,s.languages.jsx.tag.inside.comment=t.comment,s.languages.insertBefore("inside","attr-name",{spread:{pattern:l(/<SPREAD>/.source),inside:s.languages.jsx}},s.languages.jsx.tag),s.languages.insertBefore("inside","special-attr",{script:{pattern:l(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:s.languages.jsx}}},s.languages.jsx.tag);var o=function(i){return i?typeof i=="string"?i:typeof i.content=="string"?i.content:i.content.map(o).join(""):""},d=function(i){for(var c=[],u=0;u<i.length;u++){var g=i[u],f=!1;if(typeof g!="string"&&(g.type==="tag"&&g.content[0]&&g.content[0].type==="tag"?g.content[0].content[0].content==="</"?c.length>0&&c[c.length-1].tagName===o(g.content[0].content[1])&&c.pop():g.content[g.content.length-1].content==="/>"||c.push({tagName:o(g.content[0].content[1]),openedBraces:0}):c.length>0&&g.type==="punctuation"&&g.content==="{"?c[c.length-1].openedBraces++:c.length>0&&c[c.length-1].openedBraces>0&&g.type==="punctuation"&&g.content==="}"?c[c.length-1].openedBraces--:f=!0),(f||typeof g=="string")&&c.length>0&&c[c.length-1].openedBraces===0){var m=o(g);u<i.length-1&&(typeof i[u+1]=="string"||i[u+1].type==="plain-text")&&(m+=o(i[u+1]),i.splice(u+1,1)),u>0&&(typeof i[u-1]=="string"||i[u-1].type==="plain-text")&&(m=o(i[u-1])+m,i.splice(u-1,1),u--),i[u]=new s.Token("plain-text",m,null,m)}g.content&&typeof g.content!="string"&&d(g.content)}};s.hooks.add("after-tokenize",function(i){i.language!=="jsx"&&i.language!=="tsx"||d(i.tokens)})})(Prism);(function(s){var t=s.util.clone(s.languages.typescript);s.languages.tsx=s.languages.extend("jsx",t),delete s.languages.tsx.parameter,delete s.languages.tsx["literal-property"];var n=s.languages.tsx.tag;n.pattern=RegExp(/(^|[^\w$]|(?=<\/))/.source+"(?:"+n.pattern.source+")",n.pattern.flags),n.lookbehind=!0})(Prism);(function(s){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;s.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},s.languages.css.atrule.inside.rest=s.languages.css;var n=s.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))})(Prism);Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}};Prism.languages.webmanifest=Prism.languages.json;(function(s){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};s.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=s.languages.bash;for(var a=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],l=r.variable[1].inside,o=0;o<a.length;o++)l[a[o]]=s.languages.bash[a[o]];s.languages.sh=s.languages.bash,s.languages.shell=s.languages.bash})(Prism);Prism.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/};Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python;Prism.languages.py=Prism.languages.python;(function(s){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(u){return u=u.replace(/<inner>/g,function(){return t}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+u+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return r}),l=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;s.languages.markdown=s.languages.extend("markup",{}),s.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:s.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+a+l+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+l+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:s.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+l+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+a+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:s.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/\b__(?:(?!_)<inner>|_(?:(?!_)<inner>)+_)+__\b|\*\*(?:(?!\*)<inner>|\*(?:(?!\*)<inner>)+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/\b_(?:(?!_)<inner>|__(?:(?!_)<inner>)+__)+_\b|\*(?:(?!\*)<inner>|\*\*(?:(?!\*)<inner>)+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~)<inner>)+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:n(/!?\[(?:(?!\])<inner>)+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\])<inner>)+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach(function(u){["url","bold","italic","strike","code-snippet"].forEach(function(g){u!==g&&(s.languages.markdown[u].inside.content.inside[g]=s.languages.markdown[g])})}),s.hooks.add("after-tokenize",function(u){if(u.language!=="markdown"&&u.language!=="md")return;function g(f){if(!(!f||typeof f=="string"))for(var m=0,k=f.length;m<k;m++){var w=f[m];if(w.type!=="code"){g(w.content);continue}var y=w.content[1],E=w.content[3];if(y&&E&&y.type==="code-language"&&E.type==="code-block"&&typeof y.content=="string"){var h=y.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");h=(/[a-z][\w-]*/i.exec(h)||[""])[0].toLowerCase();var S="language-"+h;E.alias?typeof E.alias=="string"?E.alias=[E.alias,S]:E.alias.push(S):E.alias=[S]}}}g(u.tokens)}),s.hooks.add("wrap",function(u){if(u.type==="code-block"){for(var g="",f=0,m=u.classes.length;f<m;f++){var k=u.classes[f],w=/language-(.+)/.exec(k);if(w){g=w[1];break}}var y=s.languages[g];if(y)u.content=s.highlight(c(u.content),y,g);else if(g&&g!=="none"&&s.plugins.autoloader){var E="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);u.attributes.id=E,s.plugins.autoloader.loadLanguages(g,function(){var h=document.getElementById(E);h&&(h.innerHTML=s.highlight(h.textContent,s.languages[g],g))})}}});var o=RegExp(s.languages.markup.tag.pattern.source,"gi"),d={amp:"&",lt:"<",gt:">",quot:'"'},i=String.fromCodePoint||String.fromCharCode;function c(u){var g=u.replace(o,"");return g=g.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(f,m){if(m=m.toLowerCase(),m[0]==="#"){var k;return m[1]==="x"?k=parseInt(m.slice(2),16):k=Number(m.slice(1)),i(k)}else{var w=d[m];return w||f}}),g}s.languages.md=s.languages.markdown})(Prism);(function(s){var t=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+t.source+")?|"+t.source+"(?:[ ]+"+n.source+")?)",a=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),l=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function o(d,i){i=(i||"").replace(/m/g,"")+"m";var c=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return d});return RegExp(c,i)}s.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g,function(){return r}).replace(/<<key>>/g,function(){return"(?:"+a+"|"+l+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:o(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:o(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:o(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:o(l),lookbehind:!0,greedy:!0},number:{pattern:o(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:t,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},s.languages.yml=s.languages.yaml})(Prism);Prism.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/};const Qt={js:"JavaScript",ts:"TypeScript",jsx:"JSX",tsx:"TSX",py:"Python",python:"Python",bash:"Bash",shell:"Shell",css:"CSS",json:"JSON",yaml:"YAML",yml:"YAML",sql:"SQL",md:"Markdown",markdown:"Markdown",xml:"XML",html:"HTML"};function en({language:s,code:t}){const[n,r]=p.useState(!1),a=p.useRef(null);p.useEffect(()=>{a.current&&je.highlightElement(a.current)},[t,s]);const l=async()=>{try{await navigator.clipboard.writeText(t),r(!0),setTimeout(()=>r(!1),2e3)}catch(d){console.error("Failed to copy:",d)}},o=Qt[s]||s.toUpperCase();return e.jsxs("div",{className:"relative group rounded-lg overflow-hidden border border-dark-border my-2",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 bg-dark-surface border-b border-dark-border",children:[e.jsx("span",{className:"text-xs text-dark-muted font-mono",children:o}),e.jsx("button",{onClick:l,className:"flex items-center gap-1 text-xs px-2 py-1 rounded hover:bg-dark-hover transition-colors",children:n?e.jsxs(e.Fragment,{children:[e.jsx(Nt,{size:12,className:"text-accent-green"}),e.jsx("span",{className:"text-accent-green",children:"已复制"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ve,{size:12}),e.jsx("span",{children:"复制"})]})})]}),e.jsx("pre",{className:"bg-dark-bg p-3 overflow-x-auto custom-scrollbar text-sm",children:e.jsx("code",{ref:a,className:`language-${s}`,children:t})})]})}const Ue=80;function tn({content:s,className:t=""}){const[n,r]=p.useState(s),a=p.useRef(0),l=p.useRef(null),o=p.useRef(s);o.current=s,p.useEffect(()=>{if(s===n)return;const i=Date.now(),c=i-a.current;c>=Ue?(r(s),a.current=i):l.current||(l.current=setTimeout(()=>{l.current=null,r(o.current),a.current=Date.now()},Ue-c))},[s]),p.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const d=(n||"").replace(/\\n/g,`
2
+ `).replace(/\n{3,}/g,`
3
+
4
+ `);return e.jsx("div",{className:`markdown-content ${t}`,style:{wordBreak:"break-word"},children:e.jsx(wt,{components:{code({className:i,children:c,...u}){const g=/language-(\w+)/.exec(i||""),f=String(c).replace(/\n$/,"");return g&&g[1]?e.jsx(en,{language:g[1],code:f}):e.jsx("code",{className:"bg-dark-hover px-1.5 py-0.5 rounded text-sm font-mono text-accent-blue",...u,children:c})},a({href:i,children:c}){return e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"text-accent-blue hover:underline",children:c})},table({children:i}){return e.jsx("div",{className:"overflow-x-auto custom-scrollbar my-2",children:e.jsx("table",{className:"w-full border-collapse border border-dark-border",children:i})})},th({children:i}){return e.jsx("th",{className:"border border-dark-border px-3 py-2 text-left bg-dark-hover font-medium",children:i})},td({children:i}){return e.jsx("td",{className:"border border-dark-border px-3 py-2",children:i})},p({children:i}){return e.jsx("p",{className:"mb-0.5 leading-snug last:mb-0",children:i})},blockquote({children:i}){return e.jsx("blockquote",{className:"border-l-4 border-accent-blue pl-3 my-1 text-dark-muted italic",children:i})},h1({children:i}){return e.jsx("h1",{className:"text-2xl font-bold mt-3 mb-1 text-dark-text border-b border-dark-border pb-1",children:i})},h2({children:i}){return e.jsx("h2",{className:"text-xl font-semibold mt-3 mb-1 text-dark-text border-b border-dark-border pb-1",children:i})},h3({children:i}){return e.jsx("h3",{className:"text-lg font-semibold mt-2 mb-1 text-dark-text",children:i})}},children:d})})}Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity;Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup;Prism.hooks.add("wrap",function(s){s.type==="entity"&&(s.attributes.title=s.content.replace(/&amp;/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,n){var r={};r["language-"+n]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[n]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var a={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};a["language-"+n]={pattern:/[\s\S]+/,inside:Prism.languages[n]};var l={};l[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:a},Prism.languages.insertBefore("markup","cdata",l)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(s,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+s+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.ssml=Prism.languages.xml;Prism.languages.atom=Prism.languages.xml;Prism.languages.rss=Prism.languages.xml;Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/});Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}});delete Prism.languages.go["class-name"];(function(s){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source,n=0;n<2;n++)t=t.replace(/<self>/g,function(){return t});t=t.replace(/<self>/g,function(){return/[^\s\S]/.source}),s.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/},s.languages.rust["closure-params"].inside.rest=s.languages.rust,s.languages.rust.attribute.inside.string=s.languages.rust.string})(Prism);(function(s){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};s.languages.java=s.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:t,function:[s.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),s.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),s.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism);Prism.languages.c=Prism.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/});Prism.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}});Prism.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},Prism.languages.c.string],char:Prism.languages.c.char,comment:Prism.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:Prism.languages.c}}}});Prism.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/});delete Prism.languages.c.boolean;(function(s){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=/\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g,function(){return t.source});s.languages.cpp=s.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g,function(){return t.source})),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),s.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g,function(){return n})+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),s.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:s.languages.cpp}}}}),s.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),s.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:s.languages.extend("cpp",{})}}),s.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},s.languages.cpp["base-clause"])})(Prism);(function(s){var t=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,n=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],r=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,a=/<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,l=/[{}\[\](),:;]/;s.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:t,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:r,operator:a,punctuation:l};var o={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:s.languages.php},d=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:o}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:o}}];s.languages.insertBefore("php","variable",{string:d,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:d,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,number:r,operator:a,punctuation:l}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),s.hooks.add("before-tokenize",function(i){if(/<\?/.test(i.code)){var c=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;s.languages["markup-templating"].buildPlaceholders(i,"php",c)}}),s.hooks.add("after-tokenize",function(i){s.languages["markup-templating"].tokenizePlaceholders(i,"php")})})(Prism);(function(s){s.languages.ruby=s.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===|<?=>|[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),s.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:s.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete s.languages.ruby.function;var n="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",r=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;s.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+n+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+r),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+r+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),s.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+n),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+n),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete s.languages.ruby.string,s.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),s.languages.rb=s.languages.ruby})(Prism);class nn{diff(t,n,r={}){let a;typeof r=="function"?(a=r,r={}):"callback"in r&&(a=r.callback);const l=this.castInput(t,r),o=this.castInput(n,r),d=this.removeEmpty(this.tokenize(l,r)),i=this.removeEmpty(this.tokenize(o,r));return this.diffWithOptionsObj(d,i,r,a)}diffWithOptionsObj(t,n,r,a){var l;const o=h=>{if(h=this.postProcess(h,r),a){setTimeout(function(){a(h)},0);return}else return h},d=n.length,i=t.length;let c=1,u=d+i;r.maxEditLength!=null&&(u=Math.min(u,r.maxEditLength));const g=(l=r.timeout)!==null&&l!==void 0?l:1/0,f=Date.now()+g,m=[{oldPos:-1,lastComponent:void 0}];let k=this.extractCommon(m[0],n,t,0,r);if(m[0].oldPos+1>=i&&k+1>=d)return o(this.buildValues(m[0].lastComponent,n,t));let w=-1/0,y=1/0;const E=()=>{for(let h=Math.max(w,-c);h<=Math.min(y,c);h+=2){let S;const I=m[h-1],A=m[h+1];I&&(m[h-1]=void 0);let R=!1;if(A){const $=A.oldPos-h;R=A&&0<=$&&$<d}const O=I&&I.oldPos+1<i;if(!R&&!O){m[h]=void 0;continue}if(!O||R&&I.oldPos<A.oldPos?S=this.addToPath(A,!0,!1,0,r):S=this.addToPath(I,!1,!0,1,r),k=this.extractCommon(S,n,t,h,r),S.oldPos+1>=i&&k+1>=d)return o(this.buildValues(S.lastComponent,n,t))||!0;m[h]=S,S.oldPos+1>=i&&(y=Math.min(y,h-1)),k+1>=d&&(w=Math.max(w,h+1))}c++};if(a)(function h(){setTimeout(function(){if(c>u||Date.now()>f)return a(void 0);E()||h()},0)})();else for(;c<=u&&Date.now()<=f;){const h=E();if(h)return h}}addToPath(t,n,r,a,l){const o=t.lastComponent;return o&&!l.oneChangePerToken&&o.added===n&&o.removed===r?{oldPos:t.oldPos+a,lastComponent:{count:o.count+1,added:n,removed:r,previousComponent:o.previousComponent}}:{oldPos:t.oldPos+a,lastComponent:{count:1,added:n,removed:r,previousComponent:o}}}extractCommon(t,n,r,a,l){const o=n.length,d=r.length;let i=t.oldPos,c=i-a,u=0;for(;c+1<o&&i+1<d&&this.equals(r[i+1],n[c+1],l);)c++,i++,u++,l.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return u&&!l.oneChangePerToken&&(t.lastComponent={count:u,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=i,c}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const a=[];let l;for(;t;)a.push(t),l=t.previousComponent,delete t.previousComponent,t=l;a.reverse();const o=a.length;let d=0,i=0,c=0;for(;d<o;d++){const u=a[d];if(u.removed)u.value=this.join(r.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let g=n.slice(i,i+u.count);g=g.map(function(f,m){const k=r[c+m];return k.length>f.length?k:f}),u.value=this.join(g)}else u.value=this.join(n.slice(i,i+u.count));i+=u.count,u.added||(c+=u.count)}}return a}}class sn extends nn{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const rn=new sn;function an(s,t,n){return rn.diff(s,t,n)}const on=.4;function He(s){const t=[];let n=0;for(;n<s.length;){const r=s[n];if(/[\p{L}\p{N}_]/u.test(r)){let a=n+1;for(;a<s.length&&/[\p{L}\p{N}_]/u.test(s[a]);)a++;t.push(s.slice(n,a)),n=a}else if(/\s/.test(r)){let a=n+1;for(;a<s.length&&/\s/.test(s[a]);)a++;t.push(s.slice(n,a)),n=a}else{const l=s.codePointAt(n)>65535?2:1;t.push(s.slice(n,n+l)),n+=l}}return t}function ln(s,t){const n=an(He(s),He(t)),r=s.length+t.length;let a=0;const l=[],o=[];let d=0,i=0;for(const c of n){const u=c.value.reduce((g,f)=>g+f.length,0);c.removed?(a+=u,l.push({start:d,end:d+u}),d+=u):c.added?(a+=u,o.push({start:i,end:i+u}),i+=u):(d+=u,i+=u)}return r>0&&a/r>on?[[],[]]:[l,o]}function tt(s){const t=[];let n=null;for(const r of s.split(`
5
+ `)){if(r.startsWith("---")||r.startsWith("+++")||r.startsWith("index ")||r.startsWith("diff --git")||r.startsWith("==="))continue;const a=r.match(/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/);if(a){n&&t.push(n),n={oldStart:parseInt(a[1],10),oldLines:parseInt(a[2]??"1",10),newStart:parseInt(a[3],10),newLines:parseInt(a[4]??"1",10),lines:[]};continue}if(!r.startsWith("\\")){if(n&&(r.startsWith("+")||r.startsWith("-")||r.startsWith(" ")||r==="")){n.lines.push(r);continue}n&&r&&(t.push(n),n=null)}}return n&&t.push(n),t}function nt(s){let t=s.oldStart,n=s.newStart;const r=[];for(const a of s.lines){const l=a[0]==="+"||a[0]==="-"?a[0]:" ",o=a.slice(1);let d=null,i=null;l==="-"?d=t++:(l==="+"||(d=t++),i=n++),r.push({marker:l,code:o,oldLine:d,newLine:i})}return r}const cn=p.memo(function({filePath:t,content:n,language:r}){if(!n&&!t)return null;const[a,l]=p.useState("unified"),[o,d]=p.useState(!1),i=dn(t,r),c=(n==null?void 0:n.includes("@@"))||(n==null?void 0:n.includes("+++"))||(n==null?void 0:n.includes("---")),u=c?un(n||""):null;return e.jsxs("div",{className:"mt-2 border border-dark-border rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-dark-surface border-b border-dark-border",children:[e.jsx("span",{className:"text-accent-purple text-xs",children:"📝"}),e.jsx("span",{className:"text-xs font-mono text-dark-fg truncate",children:t||"file"}),u&&e.jsxs("span",{className:"text-xs ml-2 flex gap-2",children:[e.jsxs("span",{className:"text-green-400",children:["+",u.additions]}),e.jsxs("span",{className:"text-red-400",children:["-",u.deletions]})]}),e.jsx("span",{className:"text-xs text-dark-muted ml-auto",children:i}),c&&e.jsxs("div",{className:"flex gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>l("unified"),className:`text-xs px-1.5 py-0.5 rounded ${a==="unified"?"bg-accent-blue/20 text-accent-blue":"text-dark-muted hover:text-dark-fg"}`,title:"Unified view",children:"Unified"}),e.jsx("button",{onClick:()=>l("side-by-side"),className:`text-xs px-1.5 py-0.5 rounded ${a==="side-by-side"?"bg-accent-blue/20 text-accent-blue":"text-dark-muted hover:text-dark-fg"}`,title:"Side-by-side view",children:"Side"})]}),e.jsx("button",{onClick:()=>d(!o),className:"text-xs text-dark-muted hover:text-dark-fg ml-1",children:o?"▶":"▼"})]}),!o&&e.jsxs("div",{className:"bg-dark-bg overflow-x-auto max-h-96 overflow-y-auto custom-scrollbar",children:[c?a==="unified"?gn(n||"",i):fn(n||"",i):e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:n||"(no content)"}),u&&e.jsxs("div",{className:"sticky bottom-0 bg-dark-surface border-t border-dark-border px-3 py-1 flex gap-4 text-xs text-dark-muted",children:[e.jsxs("span",{className:"text-green-400",children:["+",u.additions," additions"]}),e.jsxs("span",{className:"text-red-400",children:["-",u.deletions," deletions"]}),e.jsxs("span",{children:[u.hunks," hunks"]})]})]})]})});function dn(s,t){var a;if(t)return t;if(!s)return"plaintext";const n=(a=s.split(".").pop())==null?void 0:a.toLowerCase();return{ts:"typescript",tsx:"typescript",mts:"typescript",js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",py:"python",go:"go",rs:"rust",cpp:"cpp",cxx:"cpp",hpp:"cpp",cc:"cpp",c:"cpp",h:"cpp",css:"css",scss:"css",html:"markup",htm:"markup",svg:"markup",xml:"xml",json:"json",yml:"yaml",yaml:"yaml",md:"markdown",sql:"sql",sh:"bash",bash:"bash",zsh:"bash",php:"php",rb:"ruby"}[n||""]||"plaintext"}function un(s){const t=s.split(`
6
+ `);let n=0,r=0,a=0;for(const l of t)l.startsWith("@@")?a++:l.startsWith("+")&&!l.startsWith("+++")?n++:l.startsWith("-")&&!l.startsWith("---")&&r++;return{additions:n,deletions:r,hunks:a,filesChanged:1}}function pn(s){const t=[],n=(a,l)=>{if(!l)return;const o=t[t.length-1];o&&o.type===a?o.text+=l:t.push({type:a,text:l})},r=(a,l)=>{if(typeof a=="string"){n(l,a);return}const o=a.type||l;if(typeof a.content=="string"){n(o,a.content);return}for(const d of a.content)r(d,o)};for(const a of s)r(a,"");return t}function st(s,t){const n=je.languages[t];return n?pn(je.tokenize(s,n)):[{type:"",text:s}]}function mn(s,t){if(t.length===0)return s.map(a=>({...a,word:!1}));const n=[];let r=0;for(const a of s){const l=r,o=r+a.text.length;let d=0;for(const i of t){const c=Math.max(0,i.start-l),u=Math.min(a.text.length,i.end-l);u<=0||c>=a.text.length||(c>d&&n.push({type:a.type,text:a.text.slice(d,c),word:!1}),n.push({type:a.type,text:a.text.slice(c,u),word:!0}),d=u)}d<a.text.length&&n.push({type:a.type,text:a.text.slice(d),word:!1}),r=o}return n}function xn({code:s,marker:t,lang:n,ranges:r}){const a=t==="-"?[{type:"",text:s}]:st(s,n),l=mn(a,r),o=t==="+"?"bg-green-900/30":t==="-"?"bg-red-900/30":"",d=t==="+"?"bg-green-700/60":"bg-red-700/60";return e.jsx("span",{className:`flex-1 whitespace-pre-wrap px-2 ${o}`,children:l.length===0?" ":l.map((i,c)=>e.jsx("span",{className:[i.type?`token ${i.type}`:"",i.word&&t!==" "?d:""].join(" "),children:i.text},c))})}function gn(s,t){const n=tt(s);if(n.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:s});const r=[];let a=0;for(const l of n){const o=nt(l);r.push(e.jsxs("div",{className:"flex text-xs font-mono leading-snug bg-accent-blue/5 text-accent-blue font-bold px-2",style:{minHeight:"1.25rem"},children:[e.jsx("span",{className:"select-none shrink-0 text-right pr-1",children:"@"}),e.jsxs("span",{className:"flex-1 whitespace-pre-wrap",children:["@@ -",l.oldStart,",",l.oldLines," +",l.newStart,",",l.newLines," @@"]})]},a++));const d=new Map;for(let i=0;i<o.length;){if(o[i].marker!=="-"){i++;continue}const c=i;for(;i<o.length&&o[i].marker==="-";)i++;const u=i;for(;i<o.length&&o[i].marker==="+";)i++;const g=Math.min(u-c,i-u);for(let f=0;f<g;f++){const[m,k]=ln(o[c+f].code,o[u+f].code);d.set(c+f,m),d.set(u+f,k)}}for(let i=0;i<o.length;i++){const c=o[i],u=c.marker==="+",g=c.marker==="-",f=u?"bg-green-900/30":g?"bg-red-900/30":"",m=c.marker==="-"?c.oldLine:c.newLine;r.push(e.jsxs("div",{className:"flex text-xs font-mono leading-snug",style:{minHeight:"1.25rem"},children:[e.jsxs("span",{className:`select-none shrink-0 w-9 text-right pr-1 ${f} ${u?"text-green-400":g?"text-red-400":"text-dark-muted"}`,children:[c.marker===" "?"":c.marker,m??""]}),e.jsx(xn,{code:c.code,marker:c.marker,lang:t,ranges:d.get(i)??[]})]},a++))}}return e.jsx("div",{children:r})}function Ge({code:s,lang:t,kind:n}){if(s==="")return e.jsx("span",{className:"flex-1 px-2 border-r border-dark-border/30 font-mono text-xs leading-snug",style:{minHeight:"1.25rem"},children:" "});const r=n==="remove"?[{type:"",text:s}]:st(s,t),a=n==="add"?"bg-green-900/30":n==="remove"?"bg-red-900/30":"";return e.jsx("span",{className:`flex-1 px-2 border-r border-dark-border/30 font-mono text-xs leading-snug ${a}`,children:r.map((l,o)=>e.jsx("span",{className:l.type?`token ${l.type}`:"",children:l.text},o))})}function fn(s,t){const n=tt(s);if(n.length===0)return e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:s});const r=[];for(const a of n){const l=nt(a);r.push({left:`@@ -${a.oldStart},${a.oldLines} +${a.newStart},${a.newLines} @@`,right:"",type:"header"});let o=[],d=[];const i=()=>{(o.length>0||d.length>0)&&(hn(r,o,d),o=[],d=[])};for(const c of l)c.marker==="-"?o.push(c.code):c.marker==="+"?d.push(c.code):(i(),r.push({left:c.code,right:c.code,type:"context"}));i()}return e.jsxs("div",{children:[e.jsxs("div",{className:"flex border-b border-dark-border text-xs font-bold text-dark-muted",children:[e.jsx("div",{className:"flex-1 px-2 py-0.5 border-r border-dark-border",children:"Old"}),e.jsx("div",{className:"flex-1 px-2 py-0.5",children:"New"})]}),r.map((a,l)=>a.type==="header"?e.jsx("div",{className:"bg-accent-blue/5 text-accent-blue font-bold font-mono text-xs leading-snug px-2",children:a.left},l):e.jsxs("div",{className:"flex",style:{minHeight:"1.25rem"},children:[e.jsx(Ge,{code:a.type==="replace"||a.type==="delete"?"- "+a.left:a.left,lang:t,kind:a.type==="replace"||a.type==="delete"?"remove":"context"}),e.jsx(Ge,{code:a.type==="replace"||a.type==="add"?"+ "+a.right:a.right,lang:t,kind:a.type==="replace"||a.type==="add"?"add":"context"})]},l))]})}function hn(s,t,n){const r=Math.max(t.length,n.length);for(let a=0;a<r;a++){const l=a<t.length?t[a]??"":"",o=a<n.length?n[a]??"":"";s.push({left:l,right:o,type:a<t.length&&a<n.length?"replace":a<t.length?"delete":"add"})}}function rt(s){const t=p.useRef(null),n=p.useRef(0);return p.useEffect(()=>{if(!s){n.current=0;return}n.current=Date.now();const r=t.current;if(!r)return;const a=()=>{const o=Math.floor((Date.now()-n.current)/1e3),d=o>=60?`${Math.floor(o/60)}m ${o%60}s`:`${o}s`;r.textContent=d};a();const l=setInterval(a,1e3);return()=>clearInterval(l)},[s]),t}const bn=["FileEditTool","FileWriteTool","EditTool","NotebookEditTool","Write","Edit","WriteTool","FileCreateTool"],kn=/\b(write|edit|save|create|update|modify|patch)\b/i,yn=/\b(read|open|cat|view|list|ls|dir|find|grep|glob|search)\b/i;function wn(s){return bn.includes(s)?!0:kn.test(s)&&!yn.test(s)}function Nn(s){return typeof s=="string"?s:s&&typeof s=="object"?JSON.stringify(s,null,2):String(s??"")}function En(s){if(typeof s!="string"&&s)return s.filePath||s.path||s.file||s.file_path}const at=p.memo(function({toolCall:t,defaultCollapsed:n=!0}){const[r,a]=p.useState(n),l=t.status==="running",o=rt(l),d=t.result!==void 0&&t.result!==null,i=t.status==="error",c=wn(t.name),u=d?Nn(t.result):"",g=typeof t.args=="object"&&t.args?En(t.args):void 0,f=t.duration??0,m=f>0?f>=60?`${Math.floor(f/60)}m ${f%60}s`:`${f}s`:"",k=l?"bg-accent-blue":i?"bg-accent-red":"bg-accent-green";return e.jsxs("div",{className:"rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-row",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>a(!r),children:[l?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${k}`}),e.jsx("span",{className:"text-xs text-dark-muted shrink-0",children:"🔧"}),e.jsx("span",{className:"font-medium text-[13px] text-dark-text truncate",children:t.name}),l&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(se,{size:10}),e.jsx("span",{ref:o,children:"0s"})]}),!l&&m&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(se,{size:10}),e.jsx("span",{children:m})]}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${r?"":"rotate-180"}`,children:e.jsx(ee,{size:13})})]}),!r&&e.jsxs("div",{className:"ml-4 pb-1 pl-3 border-l-2 border-dark-border/30 space-y-1",children:[e.jsxs("div",{className:"py-0.5 px-2",children:[e.jsx("div",{className:"text-[10px] text-dark-muted mb-0.5",children:"参数"}),e.jsx("pre",{className:"text-[11px] font-mono bg-dark-bg border border-dark-border p-2 rounded overflow-x-auto max-h-24 overflow-y-auto custom-scrollbar",children:typeof t.args=="string"?t.args:JSON.stringify(t.args,null,2)})]}),d&&e.jsxs("div",{className:"py-0.5 px-2",children:[e.jsx("div",{className:`text-[10px] mb-0.5 ${i?"text-accent-red":"text-accent-green"}`,children:i?"错误":"结果"}),c&&u?e.jsx(cn,{filePath:g,content:u}):e.jsx("pre",{className:`text-[11px] font-mono bg-dark-bg border border-dark-border p-2 rounded overflow-x-auto max-h-48 overflow-y-auto custom-scrollbar whitespace-pre-wrap break-all ${i?"text-accent-red":"text-accent-green"}`,children:u})]})]})]})}),vn=p.memo(function({text:t,maxLength:n=300,preformatted:r=!1}){const[a,l]=p.useState(!1);return t.length>n?e.jsxs("div",{children:[r?e.jsx("pre",{className:"text-xs font-mono bg-dark-bg p-1.5 rounded overflow-x-auto custom-scrollbar mt-1 text-accent-green",children:a?t:t.slice(0,n)+"..."}):e.jsx("div",{className:"text-dark-text leading-snug",children:a?t:t.slice(0,n)+"..."}),e.jsx("button",{onClick:d=>{d.stopPropagation(),l(!a)},className:"mt-1 text-[10px] px-2 py-0.5 rounded bg-dark-hover text-accent-blue hover:bg-dark-border transition-colors",children:a?"收起":"展开"})]}):r?e.jsx("pre",{className:"text-xs font-mono bg-dark-bg p-1.5 rounded overflow-x-auto custom-scrollbar mt-1 text-accent-green",children:t}):e.jsx("div",{className:"text-dark-text leading-snug",children:t})}),jn=p.memo(function({step:t,defaultCollapsed:n=!0}){const[r,a]=p.useState(n),[l,o]=p.useState(!0),d=t.status==="running",i=rt(d),c=t.description||t.thought||t.result||t.action||t.toolCalls&&t.toolCalls.length>0,u=t.duration??0,g=u>0?u>=60?`${Math.floor(u/60)}m ${u%60}s`:`${u}s`:"",f={pending:"bg-dark-muted/40",running:"bg-accent-blue",success:"bg-accent-green",error:"bg-accent-red",warning:"bg-accent-yellow"}[t.status]||"bg-dark-muted/40";return e.jsxs("div",{className:"rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"step-row",children:[e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>c&&a(!r),children:[d?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`w-2 h-2 shrink-0 rounded-full ${f} ${t.status==="pending"?"opacity-60":""}`}),e.jsx("span",{className:"text-[13px] text-dark-text truncate",children:t.title}),d&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(se,{size:10}),e.jsx("span",{ref:i,children:"0s"})]}),!d&&g&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(se,{size:10}),e.jsx("span",{children:g})]}),c&&e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${r?"":"rotate-180"}`,children:e.jsx(ee,{size:13})})]}),!r&&c&&e.jsxs("div",{className:"ml-4 pb-1 pl-3 border-l-2 border-dark-border/30 space-y-1",children:[t.description&&e.jsx("div",{className:"text-dark-muted py-0.5 px-2 text-xs",children:t.description}),t.thought&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-blue/40 bg-accent-blue/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-blue cursor-pointer hover:opacity-80 select-none",onClick:()=>o(!l),children:[l?e.jsx(Re,{size:12}):e.jsx(ee,{size:12}),e.jsx("span",{children:"🧠 思考"}),l&&e.jsxs("span",{className:"text-[10px] text-dark-muted truncate max-w-[200px]",children:[t.thought.slice(0,80).replace(/\n/g," "),"..."]})]}),!l&&e.jsx("div",{className:"text-dark-muted italic whitespace-pre-wrap leading-snug mt-1",children:t.thought.replace(/\n\s*\n+/g,`
7
+ `)})]}),t.action&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-yellow/40 bg-accent-yellow/5 rounded-r",children:[e.jsx("div",{className:"flex items-center gap-1 text-accent-yellow mb-0.5",children:"⚡ 执行"}),e.jsx("div",{className:"text-dark-text leading-snug font-mono text-[11px]",children:t.action})]}),t.toolCalls&&t.toolCalls.length>0&&t.toolCalls.map(m=>e.jsx("div",{className:"px-1 py-0.5",children:e.jsx(at,{toolCall:m})},m.id)),t.result&&e.jsxs("div",{className:"py-0.5 px-2 text-xs border-l-2 border-accent-green/40 bg-accent-green/5 rounded-r",children:[e.jsx("div",{className:"flex items-center gap-1 text-accent-green mb-0.5",children:"✓ 结果"}),e.jsx(vn,{text:t.result,maxLength:500})]})]})]})}),Sn=p.memo(function({steps:t,isGenerating:n}){const{t:r}=F(),[a,l]=p.useState(n),o=p.useRef(n);p.useEffect(()=>{o.current&&!n&&l(!1),o.current=n},[n]);const d=t.length,i=n||t.some(m=>m.status==="running"),c=[...t].reverse().find(m=>m.status==="running"),u=t[t.length-1],g=(c==null?void 0:c.title)||(u==null?void 0:u.title)||"",f=`${d} ${r(d===1?"chat.stepCount":"chat.stepCountPlural")}`;return e.jsxs("div",{className:"mb-1 rounded-lg border border-dark-border/50 transition-colors","data-testid":"turn-group",children:[e.jsxs("button",{className:"flex w-full items-center gap-2 px-2 py-1 text-left cursor-pointer select-none hover:bg-dark-surface/40",onClick:()=>l(!a),"data-testid":"turn-group-toggle",children:[e.jsx("span",{className:"shrink-0 text-dark-muted/60 transition-transform",children:a?e.jsx(ee,{size:13}):e.jsx(Re,{size:13})}),i?e.jsx("span",{className:"inline-block w-3 h-3 shrink-0 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:"w-2 h-2 shrink-0 rounded-full bg-accent-green"}),e.jsx("span",{className:"text-xs text-dark-muted",children:i?`${r("chat.runningSteps")} ${f}…`:f}),i&&g&&e.jsxs("span",{className:"min-w-0 flex-1 truncate pl-1 text-xs text-dark-muted/70",children:["· ",g]})]}),a&&e.jsx("div",{className:"ml-3 pb-1 pl-3 border-l-2 border-dark-border/30 space-y-0.5",children:t.map(m=>e.jsx(jn,{step:m},m.id))})]})}),ye=15,An=p.memo(function({approval:t,onResolved:n}){const{t:r}=F("hook"),[a,l]=p.useState(!1),[o,d]=p.useState(ye),i=p.useRef(null),c=t.status==="pending",{level:u,reasonKey:g}=Xt(t.toolName,t.askPayload),f=Vt[u];p.useEffect(()=>{if(c)return d(ye),i.current=setInterval(()=>{d(A=>A<=1?(i.current&&clearInterval(i.current),0):A-1)},1e3),()=>{i.current&&clearInterval(i.current)}},[c,t.approvalId]),p.useEffect(()=>{o===0&&c&&!a&&k()},[o]);const m=Yt(t.toolName,t.askPayload),k=p.useCallback(()=>{!c||a||(l(!0),i.current&&clearInterval(i.current),U.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"approved"))},[c,a,t.approvalId,n]),w=p.useCallback(()=>{!c||a||(l(!0),i.current&&clearInterval(i.current),U.send({type:"hook_deny",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"denied"))},[c,a,t.approvalId,n]),y=p.useCallback(()=>{if(!c||a)return;l(!0),i.current&&clearInterval(i.current),Pe.getState().addToSessionAllowList(t.toolName),U.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"approved")},[c,a,t.approvalId,t.toolName,n]),E=p.useCallback(()=>{!c||a||(l(!0),i.current&&clearInterval(i.current),Pe.getState().setAutoMode(!0),ne.getState().setAuto(!0),U.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"approved"))},[c,a,t.approvalId,n]);if(!c){const A=t.status==="approved";return e.jsx("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs ${A?"bg-accent-green/10 border border-accent-green/30 text-accent-green":"bg-accent-red/10 border border-accent-red/30 text-accent-red"}`,children:A?e.jsxs(e.Fragment,{children:[e.jsx(Qe,{size:14}),e.jsxs("span",{children:[r("alreadyAllowed"),t.toolName]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{size:14}),e.jsxs("span",{children:[r("alreadyDenied"),t.toolName]})]})})}const h=o/ye*100,S=o<=5,I=[{id:"allow",index:1,label:r("optionAllow"),hint:r("optionAllowHint"),action:k},{id:"deny",index:2,label:r("optionDeny"),hint:r("optionDenyHint"),action:w},{id:"allow_session",index:3,label:r("optionAllowAlways"),hint:r("optionAllowAlwaysHint",{tool:t.toolName}),action:y},{id:"auto_mode",index:4,label:r("optionAutoMode"),hint:r("optionAutoModeHint"),action:E}];return e.jsxs("div",{className:`bg-dark-bg border rounded-lg overflow-hidden ${f.border}`,children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 ${f.bg} border-b ${f.border}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border ${f.badge}`,children:[f.icon," ",u]}),e.jsx(Et,{size:14,className:f.text}),e.jsx("span",{className:"text-xs font-medium text-dark-text",children:r("permissionRequest")}),e.jsx("span",{className:"text-[10px] text-dark-muted ml-auto",children:r(g)}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[e.jsx(se,{size:11,className:S?"text-accent-red":"text-dark-muted"}),e.jsxs("span",{className:`text-[11px] font-mono ${S?"text-accent-red animate-pulse":"text-dark-muted"}`,children:[o,"s"]}),e.jsx("div",{className:"w-10 h-1 bg-dark-border rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-1000 ${S?"bg-accent-red":o<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${h}%`}})})]})]}),e.jsxs("div",{className:"px-3 py-2.5 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-dark-muted shrink-0",children:r("tool")}),e.jsx("code",{className:"text-accent-blue font-mono text-xs bg-dark-surface px-1.5 py-0.5 rounded",children:t.toolName})]}),m&&e.jsx("div",{className:"bg-dark-surface rounded border border-dark-border p-2 max-h-24 overflow-y-auto custom-scrollbar",children:e.jsx("pre",{className:"text-[11px] font-mono text-dark-text whitespace-pre-wrap break-all leading-relaxed",children:m})}),(u==="CRITICAL"||u==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-[11px] px-2 py-1 rounded ${f.bg} ${f.text}`,children:[e.jsx(re,{size:12}),e.jsx("span",{children:r(u==="CRITICAL"?"highRiskWarning":"mediumRiskConfirm")})]}),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-0.5 pt-1",children:I.map(A=>e.jsxs("button",{onClick:A.action,disabled:a,className:"w-full text-left px-2 py-1.5 rounded hover:bg-dark-hover transition-colors disabled:opacity-50 group",children:[e.jsxs("div",{className:"flex items-baseline gap-1.5",children:[e.jsxs("span",{className:"text-xs text-dark-muted font-mono shrink-0",children:[A.index,"."]}),e.jsx("span",{className:"text-xs text-dark-text group-hover:text-white transition-colors",children:A.label})]}),e.jsx("div",{className:"text-[10px] text-dark-muted/60 ml-5 mt-0.5",children:A.hint})]},A.id))}),e.jsx("div",{className:"text-[10px] text-dark-muted/50 pt-0.5 border-t border-dark-border/50",children:r("clickToSelect")})]})]})]})}),ce={xlsx:{icon:Te,label:"Excel"},xls:{icon:Te,label:"Excel"},csv:{icon:Ae,label:"CSV"},docx:{icon:Ae,label:"Word"},text:{icon:Ie,label:"文本"}};function qe(s){return!s&&s!==0?"—":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`}const Tn=p.memo(function({job:t}){var g,f;const{t:n}=F(),{stage:r}=t,a=p.useCallback(m=>{Q.files.download(m).then(k=>{k.success||K.error(k.error||n("fileJob.downloadFailed"))})},[n]),l=p.useMemo(()=>t.attachments||[],[t.attachments]),o=p.useMemo(()=>t.parsedFiles||[],[t.parsedFiles]),d=p.useMemo(()=>t.mapping||[],[t.mapping]),i=p.useMemo(()=>t.result||[],[t.result]),c=t.renderProgress??(r==="rendering"?0:100),u=t.parseProgress??(r==="parsing"?0:100);return e.jsxs("div",{className:"mt-2 rounded-xl border border-dark-border bg-dark-surface/60 overflow-hidden max-w-2xl",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3.5 py-2.5 border-b border-dark-border/60 bg-dark-surface",children:[r==="complete"?e.jsx(Se,{size:15,className:"text-accent-green shrink-0"}):r==="error"?e.jsx(re,{size:15,className:"text-accent-red shrink-0"}):e.jsx(pe,{size:15,className:"text-accent-blue animate-spin shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-dark-text",children:Cn(r,n)}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-[10px] font-mono text-dark-muted/60",children:t.jobId})]}),e.jsxs("div",{className:"px-3.5 py-3 space-y-3",children:[l.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map((m,k)=>{const w=ce[m.kind]||ce.text,y=w.icon;return e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-dark-border bg-dark-bg px-2.5 py-1.5",children:[e.jsx(y,{size:14,className:"text-accent-blue shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs text-dark-text truncate max-w-[160px]",children:m.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[qe(m.size)," · ",w.label,m.role&&m.role!=="unknown"&&e.jsxs("span",{className:H("ml-1",m.role==="data"?"text-accent-green":"text-accent-purple"),children:["· ",m.role==="data"?n("fileJob.roleData"):n("fileJob.roleTemplate")]})]})]})]},`${m.fileName}-${k}`)})}),r==="parsing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-dark-muted",children:n("fileJob.parsing",{file:((g=l[0])==null?void 0:g.fileName)||((f=o[0])==null?void 0:f.fileName)||""})}),e.jsx(Be,{value:u,size:"sm",showLabel:!0})]}),o.length>0&&r!=="error"&&e.jsxs("div",{className:"space-y-1.5",children:[o.map(m=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(Se,{size:13,className:"text-accent-green shrink-0"}),e.jsx("span",{className:"truncate",children:m.fileName}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:n("fileJob.parsedSummary",{rows:m.rowCount,fields:m.fields.length})})]},m.fileName)),o[0]&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[o[0].fields.slice(0,12).map(m=>e.jsx("span",{className:"rounded bg-dark-bg border border-dark-border/60 px-1.5 py-0.5 text-[10px] font-mono text-dark-muted",children:m},m)),o[0].fields.length>12&&e.jsxs("span",{className:"text-[10px] text-dark-muted/60",children:["+",o[0].fields.length-12]})]})]}),d.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"text-[11px] text-dark-muted",children:n("fileJob.mappingTitle")}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-dark-border",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-dark-bg text-dark-muted",children:[e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:n("fileJob.templatePlaceholder")}),e.jsx("th",{className:"px-2 py-1.5"}),e.jsx("th",{className:"text-left px-2.5 py-1.5 font-medium",children:n("fileJob.dataField")})]})}),e.jsx("tbody",{children:d.slice(0,8).map(m=>e.jsxs("tr",{className:"border-t border-dark-border/50",children:[e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-purple",children:"{{"+m.placeholder+"}}"}),e.jsx("td",{className:"px-2 py-1.5 text-dark-muted",children:e.jsx(vt,{size:11})}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-blue",children:m.field})]},m.placeholder))})]})}),d.length>8&&e.jsx("div",{className:"text-[10px] text-dark-muted/60",children:n("fileJob.mappingMore",{n:d.length-8})})]}),r==="rendering"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-dark-muted",children:n("fileJob.rendering",{current:t.currentRow||0,total:t.totalRows||0})}),e.jsx(Be,{value:c,size:"sm",variant:"warning",showLabel:!0})]}),i.length>0&&r==="complete"&&e.jsx("div",{className:"space-y-1.5",children:i.map(m=>{const w=(ce[m.format]||ce.text).icon,y=m.failedRows.length>0;return e.jsxs("div",{className:"rounded-lg border border-dark-border bg-dark-bg px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(w,{size:15,className:"text-accent-green shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs text-dark-text truncate",children:m.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[qe(m.size)," · ",m.successCount,"/",m.rowCount," 行",y&&e.jsxs("span",{className:"text-accent-red",children:[" · ",m.failedRows.length," 行失败"]})]})]}),e.jsxs("button",{onClick:()=>a(m.path),className:"flex items-center gap-1 rounded-md bg-accent-blue/10 text-accent-blue px-2 py-1 text-[11px] hover:bg-accent-blue/20 transition-colors",title:n("fileJob.download"),children:[e.jsx(jt,{size:12}),n("fileJob.download")]})]}),y&&e.jsxs("div",{className:"mt-1.5 space-y-0.5 border-t border-dark-border/50 pt-1.5",children:[m.failedRows.slice(0,3).map(E=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-red",children:[e.jsx(St,{size:10,className:"shrink-0"}),e.jsxs("span",{children:["#",E.index+1]}),e.jsx("span",{className:"truncate",children:E.error})]},E.index)),m.failedRows.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted/70",children:["+",m.failedRows.length-3," 行"]})]})]},m.path)})}),r==="error"&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-accent-red/30 bg-accent-red/5 px-3 py-2.5",children:[e.jsx(re,{size:15,className:"text-accent-red shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-xs font-medium text-accent-red",children:t.error||n("fileJob.error")}),t.errorDetail&&e.jsx("div",{className:"mt-0.5 text-[11px] text-dark-muted break-words",children:t.errorDetail})]})]})]})]})});function Cn(s,t){switch(s){case"uploaded":return t("fileJob.stageUploaded");case"parsing":return t("fileJob.stageParsing");case"mapping":return t("fileJob.stageMapping");case"rendering":return t("fileJob.stageRendering");case"complete":return t("fileJob.stageComplete");case"error":return t("fileJob.stageError");default:return t("fileJob.stageUploaded")}}const We={auth:{icon:Ct,color:"text-accent-red"},rate_limit:{icon:Me,color:"text-accent-yellow"},timeout:{icon:Me,color:"text-accent-yellow"},network:{icon:Tt,color:"text-accent-yellow"},model:{icon:At,color:"text-accent-red"},tool:{icon:re,color:"text-accent-yellow"},unknown:{icon:re,color:"text-accent-red"}},_n=p.memo(function({error:t,onRetry:n}){const{t:r}=F(),[a,l]=p.useState(!1),o=We[t.category]||We.unknown,d=o.icon,i=()=>{window.dispatchEvent(new CustomEvent("switch-tab",{detail:"models"}))};return e.jsxs("div",{className:"mt-2 max-w-2xl overflow-hidden rounded-xl border border-accent-red/30 bg-dark-surface",children:[e.jsxs("div",{className:"flex items-start gap-3 px-3.5 py-3",children:[e.jsx(d,{size:18,className:H("shrink-0 mt-0.5",o.color)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:t.summary}),t.detail&&t.detail!==t.summary&&e.jsx("div",{className:"mt-0.5 text-[11px] text-dark-muted/80 break-words",children:t.detail.slice(0,160)}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[t.retryable&&n&&e.jsxs("button",{onClick:n,className:"flex items-center gap-1 rounded-md bg-accent-blue/10 text-accent-blue px-2 py-1 text-[11px] hover:bg-accent-blue/20 transition-colors",children:[e.jsx(me,{size:11}),r("errorCard.retry")]}),t.category==="auth"&&e.jsxs("button",{onClick:i,className:"flex items-center gap-1 rounded-md bg-dark-hover text-dark-text px-2 py-1 text-[11px] hover:bg-dark-border transition-colors",children:[e.jsx(_t,{size:11}),r("errorCard.modelSettings")]}),t.detail&&e.jsxs("button",{onClick:()=>l(c=>!c),className:"flex items-center gap-0.5 text-[11px] text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(ee,{size:11,className:H("transition-transform",a&&"rotate-180")}),r("errorCard.details")]})]})]})]}),a&&t.detail&&e.jsx("div",{className:"border-t border-dark-border/60 bg-dark-bg px-3.5 py-2.5 text-[11px] font-mono text-dark-muted break-words max-h-40 overflow-y-auto custom-scrollbar",children:t.detail})]})});function we({onClick:s,title:t,children:n,danger:r=!1}){return e.jsx("button",{onClick:s,title:t,"aria-label":t,className:`inline-flex items-center justify-center rounded p-1 transition-colors ${r?"text-dark-muted hover:text-accent-red hover:bg-accent-red/10":"text-dark-muted hover:text-dark-text hover:bg-dark-hover"}`,children:n})}function Ke({message:s,sessionId:t,onRegenerate:n,onDeleteMessage:r}){const{t:a}=F(),[l,o]=p.useState(!1),d=p.useRef(null);p.useEffect(()=>()=>{d.current&&clearTimeout(d.current)},[]);const i=p.useCallback(async()=>{try{await navigator.clipboard.writeText(s.content||s.thinking||""),o(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>o(!1),2e3)}catch(c){console.error("Failed to copy message:",c)}},[s.content,s.thinking]);return t?e.jsxs(e.Fragment,{children:[e.jsx(we,{onClick:i,title:a("chat.copyMessage"),children:l?e.jsx(Qe,{size:12,className:"text-accent-green"}):e.jsx(Ve,{size:12})}),s.type==="assistant"&&n&&e.jsx(we,{onClick:()=>n(s.id),title:a("chat.regenerate"),children:e.jsx(me,{size:12})}),r&&e.jsx(we,{onClick:()=>r(s.id),title:a("chat.deleteMessage"),danger:!0,children:e.jsx(Rt,{size:12})})]}):null}function Ze({ts:s,align:t,children:n}){const{i18n:r}=F(),a=r.language==="en"?"en-US":"zh-CN";return e.jsx("div",{className:"relative h-0 select-none",children:e.jsxs("div",{className:`absolute top-1 flex items-center gap-0.5 text-[10.5px] leading-none whitespace-nowrap opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 transition-opacity duration-150 ${t==="right"?"right-0":"left-0"}`,children:[n,e.jsx("span",{className:"pl-1 text-[10px] text-dark-muted/50",children:new Date(s).toLocaleTimeString(a,{hour:"2-digit",minute:"2-digit"})})]})})}const Rn=p.memo(function({message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a}){var k,w,y;const{t:l}=F(),o=z(E=>{var S;if(!n||!E.generatingSessions.includes(n))return!1;const h=E.messagesBySession[n];return h?((S=h[h.length-1])==null?void 0:S.id)===t.id:!1}),[d,i]=p.useState(!o),c=p.useRef(o);p.useEffect(()=>{c.current&&!o&&i(!0),c.current=o},[o]);const u=t.type==="user",g=t.type==="system",f=p.useCallback((E,h)=>{if(!n)return;const I=z.getState().getMessages(n),A=I.findIndex(B=>B.id===t.id);if(A===-1)return;const R=I[A];if(!R)return;const O={...R,hookApproval:R.hookApproval?{...R.hookApproval,status:h}:void 0},$=[...I];$[A]=O,z.setState({messagesBySession:{...z.getState().messagesBySession,[n]:$}})},[n,t.id]);if(t.deleted)return null;if(u)return e.jsx("div",{className:"group flex justify-end animate-fade-in-up px-1",children:e.jsxs("div",{className:"max-w-[92%] md:max-w-[78%]",children:[e.jsx("div",{className:"rounded-2xl rounded-br-md border border-dark-border/70 bg-dark-surface px-4 py-2.5 shadow-sm",children:e.jsx("div",{className:"text-dark-text whitespace-pre-wrap break-words leading-relaxed text-sm",children:(k=t.content)==null?void 0:k.replace(/\n{3,}/g,`
8
+
9
+ `)})}),e.jsx(Ze,{ts:t.timestamp,align:"right",children:e.jsx(Ke,{message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a})})]})});if(g)return e.jsx("div",{className:"flex justify-center animate-fade-in-up px-1 py-1",children:e.jsx("div",{className:"text-[11px] text-dark-muted bg-dark-surface border border-dark-border/60 rounded-full px-3.5 py-1 max-w-[90%] text-center",children:t.content})});const m=!t.hookApproval&&!!(t.thinking&&t.thinking.trim()||t.steps&&t.steps.length>0||t.toolCalls&&t.toolCalls.length>0);return e.jsx("div",{className:"group flex animate-fade-in-up px-1",children:e.jsxs("div",{className:"w-full max-w-full",children:[e.jsx(Ze,{ts:t.timestamp,align:"left",children:e.jsx(Ke,{message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a})}),e.jsxs("div",{className:m?"pt-7":"",children:[t.steps&&t.steps.length>0&&!t.hookApproval?e.jsx(Sn,{steps:t.steps,isGenerating:o}):e.jsxs(e.Fragment,{children:[t.thinking&&!t.hookApproval&&e.jsxs("div",{className:"mb-1",children:[e.jsxs("button",{className:"flex items-center gap-1.5 cursor-pointer select-none py-0.5 text-xs",onClick:()=>i(!d),"data-testid":"thinking-toggle",children:[e.jsx(Re,{size:12,className:`text-dark-muted transition-transform ${d?"":"rotate-90"}`}),e.jsx("span",{className:o?"text-accent-blue/90 animate-pulse":"text-dark-muted",children:o?`${l("chat.thinking")}…`:l("chat.thoughtProcess")})]}),!d&&e.jsx("div",{className:"mt-1 text-xs text-dark-muted whitespace-pre-wrap break-words border-l-2 border-dark-border/40 pl-3 max-h-64 overflow-y-auto custom-scrollbar",children:t.thinking.replace(/\n{3,}/g,`
10
+
11
+ `)})]}),t.toolCalls&&t.toolCalls.length>0&&!t.hookApproval&&e.jsx("div",{className:"mb-1 space-y-0.5",children:t.toolCalls.map(E=>e.jsx(at,{toolCall:E},E.id))})]}),t.content?e.jsx("div",{className:"leading-relaxed",children:e.jsx(tn,{content:t.content.replace(/\n{3,}/g,`
12
+
13
+ `)})}):!t.thinking&&!t.hookApproval&&((w=t.steps)!=null&&w.length)?null:!t.thinking&&!t.hookApproval&&!((y=t.steps)!=null&&y.length)&&o?e.jsxs("div",{className:"flex items-center gap-3 py-1 text-xs text-dark-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),l("chat.thinking"),"..."]}):null,t.summary&&!o&&e.jsx("div",{className:"mt-1.5 text-[11px] text-dark-muted/70","data-testid":"turn-summary",children:Wt(t.summary)}),t.fileJob&&e.jsx("div",{className:"mt-3",children:e.jsx(Tn,{job:t.fileJob})}),t.errorCard&&e.jsx("div",{className:"mt-3",children:e.jsx(_n,{error:t.errorCard,onRetry:n&&r?()=>r(t.id):void 0})}),t.hookApproval&&e.jsx("div",{className:"mt-3 border-l-2 border-accent-yellow/50 pl-3",children:e.jsx(An,{approval:t.hookApproval,onResolved:f})})]})]})})}),In=p.memo(function({messages:t,isGenerating:n,sessionId:r,onSendSuggestion:a,onRegenerate:l,onDeleteMessage:o}){const{t:d}=F(),i=p.useRef(null),[c,u]=p.useState(!0),g=p.useRef(n);g.current=n;const f=p.useCallback(()=>{const y=i.current;if(!y)return;const E=y.scrollHeight-y.scrollTop-y.clientHeight;u(E<50)},[]),m=p.useCallback(()=>{const y=i.current;y&&(y.scrollTop=y.scrollHeight)},[]);p.useEffect(()=>{n&&(u(!0),m())},[n,m]),p.useEffect(()=>{c&&m()},[t,c,m]);const k=p.useMemo(()=>t.filter(y=>!y.deleted),[t]),w=p.useMemo(()=>[{icon:It,label:d("chat.suggestionCode"),prompt:d("chat.suggestionCodePrompt")},{icon:Ot,label:d("chat.suggestionAnalyze"),prompt:d("chat.suggestionAnalyzePrompt")},{icon:Lt,label:d("chat.suggestionAutomate"),prompt:d("chat.suggestionAutomatePrompt")}],[d]);return e.jsxs("div",{ref:i,onScroll:f,className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar",children:[k.length===0?e.jsx("div",{className:"flex min-h-[55vh] items-center justify-center p-6",children:e.jsxs("div",{className:"w-full max-w-xl px-4 text-center",children:[e.jsx("img",{src:"/logo.svg",alt:"deepseekcode",className:"w-14 h-14 mx-auto mb-5 rounded-2xl shadow-md"}),e.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-2",children:d("chat.welcome")}),e.jsx("p",{className:"text-dark-muted text-sm mb-8",children:d("chat.welcomeDesc")}),a&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5 text-left",children:w.map(y=>e.jsxs("button",{onClick:()=>a(y.prompt),className:"group w-full rounded-xl border border-dark-border bg-dark-surface px-3.5 py-3 text-left transition-all duration-150 hover:border-accent-blue/40 hover:shadow-md hover:-translate-y-px",children:[e.jsx(y.icon,{size:16,"aria-hidden":"true",className:"text-accent-blue mb-2"}),e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:y.label}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-dark-muted line-clamp-2",children:y.prompt})]},y.label))})]})}):e.jsx("div",{className:"flex flex-col",children:k.map(y=>e.jsx("div",{className:"px-4 py-2",children:e.jsx(Rn,{message:y,sessionId:r,onRegenerate:l,onDeleteMessage:o})},y.id))}),n&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted py-3 px-5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),e.jsx("span",{children:d("chat.thinkingEllipsis")})]})]})}),On={plan:"border-accent-blue/30 text-accent-blue bg-accent-blue/10","auto-plan":"border-accent-cyan/30 text-accent-cyan bg-accent-cyan/10",act:"border-accent-green/30 text-accent-green bg-accent-green/10","auto-act":"border-accent-yellow/30 text-accent-yellow bg-accent-yellow/10",goal:"border-accent-purple/30 text-accent-purple bg-accent-purple/10","auto-goal":"border-accent-red/30 text-accent-red bg-accent-red/10",normal:"border-accent-green/30 text-accent-green"},Ln=p.memo(function(){const{t}=F(),n=ne(i=>i.mode),r=ne(i=>i.setBaseMode),a=ne(i=>i.toggleAuto),l=n==="normal"?"act":n,o=Jt(l),d=Ce(l);return e.jsxs("div",{className:"flex items-center gap-1",children:[Kt.map(i=>{const c=o===i,u=Zt[i],g=n!=="normal"&&c?On[n]??"border-dark-border text-dark-muted":"border-dark-border text-dark-muted hover:bg-dark-hover";return e.jsx("button",{type:"button",onClick:()=>r(i),className:H("px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",g),title:t("chat.clickToSwitchMode"),"aria-pressed":c,children:u.label},i)}),e.jsxs("button",{type:"button",role:"switch","aria-checked":d,onClick:()=>a(),className:H("flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",d?"border-accent-yellow/40 text-accent-yellow bg-accent-yellow/10":"border-dark-border text-dark-muted hover:bg-dark-hover"),title:t("plan.autoApprove"),children:[e.jsx(me,{size:11,className:H(d?"text-accent-yellow":"text-dark-muted")}),e.jsx("span",{children:t("plan.autoApprove")})]})]})});function Dn({isOpen:s,files:t,selectedIndex:n,query:r,isSearching:a,onSelect:l,onHover:o,selectedCount:d=0,onFinish:i}){return s?e.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-dark-surface border border-dark-border rounded-lg shadow-xl overflow-hidden z-50",children:[e.jsxs("div",{className:"max-h-60 overflow-y-auto custom-scrollbar",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 text-[11px] text-dark-muted border-b border-dark-border bg-dark-bg",children:[e.jsx("span",{className:"font-medium text-dark-text",children:r?`@${r}`:"@ file"}),e.jsxs("span",{className:"opacity-70 flex items-center gap-2",children:[d>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded-full bg-accent-blue/20 text-accent-blue font-medium",children:["已选 ",d]}),e.jsx("span",{children:"↑↓ 选择 · Enter 插入(可连续多选)· Esc 关闭"})]})]}),t.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-dark-muted text-xs flex flex-col items-center gap-1",children:a?e.jsxs(e.Fragment,{children:[e.jsx(pe,{size:16,className:"animate-spin"}),e.jsx("span",{children:"搜索文件中..."})]}):e.jsx("span",{children:"未找到匹配的文件"})}):t.map((c,u)=>e.jsxs("button",{onClick:()=>l(c),onMouseEnter:()=>o(u),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left text-xs transition-colors border-l-2 ${u===n?"bg-accent-blue/20 text-accent-blue border-accent-blue":"hover:bg-dark-hover text-dark-text border-transparent"}`,children:[c.type==="directory"?e.jsx(Dt,{size:12,className:"text-accent-yellow shrink-0"}):e.jsx(Ie,{size:12,className:"text-dark-muted shrink-0"}),e.jsx("span",{className:"truncate",children:c.name}),e.jsx("span",{className:"text-[10px] text-dark-muted truncate ml-auto",children:c.path})]},c.id||c.path))]}),i&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-t border-dark-border bg-dark-bg",children:[e.jsx("span",{className:"text-[10px] text-dark-muted",children:d>0?`已选 ${d} 个文件`:"Enter 插入 · 可连续多选"}),e.jsx("button",{onClick:i,className:"px-3 py-1 text-[11px] rounded bg-accent-blue text-white hover:opacity-90 transition-opacity",children:"完成引用"})]})]}):null}const Fn=800,Je=/\[Pasted text #(\d+)(?:\s*\+\d+ lines?)?\]/g;let $n=0;const it=new Map;function Mn(s){const t=++$n;return it.set(t,s),t}function Pn(s){return s.length>Fn||ot(s)>0}function ot(s){return(s.match(/\r\n|\r|\n/g)||[]).length}function zn(s){const t=Mn(s),n=ot(s);return n===0?{id:t,label:`[Pasted text #${t}]`}:{id:t,label:`[Pasted text #${t} +${n} lines]`}}function Bn(s){return Je.lastIndex=0,s.replace(Je,(t,n)=>{const r=parseInt(n,10),a=it.get(r);return a!==void 0?a:t})}function Un(){return typeof window<"u"&&!!window.__TAURI__}async function Hn(){const s=window.__TAURI__;if(!s)return null;try{const t=await s.core.invoke("pick_files");return Array.isArray(t)?t.map(n=>String(n)).filter(Boolean):null}catch(t){return console.warn("[native] pick_files failed, falling back to browser picker:",t),null}}const Xe=/\.(xlsx|xls|csv|docx|txt|md)$/i,Gn=".deepseekcode/attachments",qn=50*1024*1024,de=10,Wn=s=>/\.xlsx?$/i.test(s)?Te:/\.(csv|docx|txt|md)$/i.test(s)?Ae:Ie,Ne=3e3,Ye=5,Ee=50;function Kn(s,t){const n=s.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return{active:!1,query:"",start:-1};const a=n.slice(r+1);return/^[\p{L}\p{N}_\-./]*$/u.test(a)?{active:!0,query:a,start:r}:{active:!1,query:"",start:-1}}const Zn=p.memo(function({sessionId:t,onSend:n,onStop:r,onPause:a,onResume:l}){const{t:o}=F(),d=z(x=>{var b;return((b=x.sessionInputs)==null?void 0:b[t])??""}),i=z(x=>x.setSessionInput),c=z(x=>{var b;return((b=x.generatingSessions)==null?void 0:b.includes(t))??!1}),u=z(x=>{var b;return((b=x.pausedSessions)==null?void 0:b.includes(t))??!1}),g=p.useRef(null),f=p.useRef(null),m=p.useRef(!1),[k,w]=p.useState([]),[y,E]=p.useState(!1),[h,S]=p.useState(!1),[I,A]=p.useState(""),[R,O]=p.useState([]),[$,B]=p.useState(0),[xe,ae]=p.useState(!1),[ge,_]=p.useState(0),M=p.useRef(-1),Z=p.useRef(new Set),q=p.useRef(null),J=p.useRef(null),P=p.useRef([]),G=p.useRef(!1);p.useEffect(()=>{Z.current=new Set,G.current=!1,S(!1),A(""),O([]),_(0)},[t]);const ie=p.useDeferredValue(d),Oe=ze(x=>x.estimateTokens),fe=p.useMemo(()=>Oe(ie),[ie,Oe]),lt=ze(x=>x.model),W=p.useCallback(x=>{i(t,x)},[t,i]),Le=p.useCallback(()=>{const x=g.current;x&&(x.style.height="auto",x.style.height=Math.min(x.scrollHeight,200)+"px")},[]);p.useEffect(()=>{Le()},[d,k.length,Le]);const he=p.useCallback(()=>{if(q.current)return Promise.resolve(q.current);if(J.current)return J.current;ae(!0);const x=(async()=>{try{const b=await Q.files.list(),N=b.success&&b.data?b.data[0]:void 0;if(!N)return q.current=[],[];const T=[],v=new Set,j=async(C,L)=>{if(L>Ye||T.length>=Ne)return;const Y=[];for(const D of C||[]){if(T.length>=Ne)return;const V=D.path.replace(/\\/g,"/");v.has(V)||(v.add(V),D.type==="file"?T.push({...D,path:V}):D.children&&D.children.length>0?await j(D.children,L+1):L<Ye&&Y.push(D))}if(Y.length===0)return;const le=await Promise.all(Y.map(async D=>{var V;try{const ke=await Q.files.list(D.path.replace(/\\/g,"/"));return ke.success&&ke.data?((V=ke.data[0])==null?void 0:V.children)||[]:[]}catch{return[]}}));for(const D of le){if(T.length>=Ne)return;await j(D,L+1)}};return await j(N.children,1),q.current=T,T}catch{return q.current=[],[]}finally{J.current=null,ae(!1)}})();return J.current=x,x},[]),De=p.useCallback(async(x,b)=>{if(G.current){const C=M.current;if(C<0||b<C){G.current=!1,S(!1);return}const L=x.slice(C,b);if(/\s/.test(L)){G.current=!1,S(!1);return}M.current=C,A(L),S(!0),B(0);const Y=await he();P.current=Y;const le=L.toLowerCase();O(Y.filter(D=>!le||D.path.toLowerCase().includes(le)).slice(0,Ee));return}const N=Kn(x,b);if(!N.active){h&&S(!1);return}M.current=N.start,A(N.query),S(!0),B(0);const T=await he();P.current=T;const v=N.query.toLowerCase(),j=T.filter(C=>!v||C.path.toLowerCase().includes(v)).slice(0,Ee);O(j)},[h,he]),ct=p.useCallback(x=>{const b=x.target.value,N=x.target.selectionStart??b.length;W(b),De(b,N)},[W,De]),be=p.useCallback(x=>{const b=g.current,N=d,T=M.current>=0?M.current:(b==null?void 0:b.selectionStart)??N.length,v=Math.min(N.length,T+1+I.length),j=`@${x.path} `,C=N.slice(0,T)+j+N.slice(v);Z.current.add(x.path),W(C),S(!0),A(""),O(P.current.slice(0,Ee)),B(0),_(Z.current.size),M.current=T+j.length,G.current=!0,requestAnimationFrame(()=>{b==null||b.focus(),b&&(b.selectionStart=b.selectionEnd=T+j.length)})},[d,I,W]),te=p.useCallback(()=>{G.current=!1,S(!1),A(""),_(0)},[]),X=p.useCallback(x=>{const b=Array.from(x);w(N=>{const T=de-N.length,v=N.slice();for(const j of b.slice(0,T)){if(!Xe.test(j.name)){K.warning(o("fileJob.unsupportedType",{name:j.name}));continue}if(j.size>qn){K.error(o("fileJob.fileTooLarge",{name:j.name}));continue}if(v.some(C=>C.name===j.name)){K.warning(o("fileJob.duplicateFile",{name:j.name}));continue}v.push({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,file:j,name:j.name,size:j.size,uploading:!1})}return v.length>=de&&K.warning(o("fileJob.maxAttachments",{n:de})),v})},[o]),dt=p.useCallback(x=>{x.target.files&&x.target.files.length>0&&(X(x.target.files),x.target.value="")},[X]),ut=p.useCallback(async()=>{var x;if(Un()){const b=await Hn();if(!b||b.length===0)return;const N=await Q.fileJob.importPaths(b);if(N.success&&Array.isArray(N.data)){const T=N.data.filter(v=>Xe.test(v.name)).map(v=>({id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,name:v.name,size:v.size,uploading:!1,path:v.path.replace(/\\/g,"/")}));w(v=>{const j=de-v.length;return[...v,...T.slice(0,j)]})}else K.error(N.error||o("fileJob.importFailed"))}else(x=f.current)==null||x.click()},[o]),pt=p.useCallback(x=>{w(b=>b.filter(N=>N.id!==x))},[]),mt=p.useCallback(x=>{x.preventDefault(),E(!0)},[]),xt=p.useCallback(x=>{x.preventDefault(),E(!1)},[]),gt=p.useCallback(x=>{x.preventDefault(),E(!1),x.dataTransfer.files&&x.dataTransfer.files.length>0&&X(x.dataTransfer.files)},[X]),Fe=p.useCallback(async()=>{var b;if(k.length===0)return"";const x=[];for(const N of k){if(N.path){x.push(`<attachment path="${N.path}" />`);continue}if(!N.file)continue;w(j=>j.map(C=>C.id===N.id?{...C,uploading:!0,error:void 0}:C));const T=`${Gn}/${N.name}`,v=await Q.files.upload(N.file,T);if(v.success&&((b=v.data)!=null&&b.path)){const j=v.data.path.replace(/\\/g,"/");w(C=>C.map(L=>L.id===N.id?{...L,uploading:!1,path:j}:L)),x.push(`<attachment path="${j}" />`)}else w(j=>j.map(C=>C.id===N.id?{...C,uploading:!1,error:v.error||o("fileJob.uploadFailed")}:C)),K.error(`${N.name}: ${v.error||o("fileJob.uploadFailed")}`)}return x.length>0?`${x.join(`
14
+ `)}
15
+
16
+ `:""},[k,o]),ft=p.useCallback(x=>{const b=x.clipboardData.getData("text/plain");if(x.clipboardData.files&&x.clipboardData.files.length>0){x.preventDefault(),X(x.clipboardData.files);return}if(!b||!Pn(b))return;x.preventDefault();const{label:N}=zn(b),T=g.current;if(!T)return;const v=T.selectionStart,j=T.selectionEnd,C=T.value,L=C.slice(0,v)+N+C.slice(j);W(L),requestAnimationFrame(()=>{T.selectionStart=T.selectionEnd=v+N.length})},[W,X]),oe=p.useCallback(async()=>{const x=Bn(d);G.current=!1,S(!1);const b=x.trim(),N=k.length>0;if(!b&&!N)return;const T=Array.from(Z.current).filter(C=>x.includes(`@${C}`));let v="";if(N){if(k.some(C=>C.uploading)){K.warning(o("fileJob.stillUploading"));return}v=await Fe()}const j=(v+x).trim();!j&&!N||(n(j||v.trim(),T.length>0?T:void 0),W(""),w([]),Z.current=new Set,_(0))},[d,k,n,W,Fe,o]),ht=p.useCallback(x=>{if(!x.nativeEvent.isComposing){if(h&&R.length>0){if(x.key==="ArrowDown"){x.preventDefault(),B(b=>(b+1)%R.length);return}if(x.key==="ArrowUp"){x.preventDefault(),B(b=>(b-1+R.length)%R.length);return}if(x.key==="Enter"&&!x.shiftKey&&!x.ctrlKey&&!x.metaKey){const b=R[$];b&&(x.preventDefault(),be(b));return}if(x.key==="Escape"){x.preventDefault(),te();return}}else if(h&&x.key==="Escape"){x.preventDefault(),te();return}if(x.key==="Escape"&&c){x.preventDefault(),u?l():a();return}if(x.key==="Enter"&&(x.ctrlKey||x.metaKey)){x.preventDefault(),oe();return}x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),oe())}},[c,u,oe,a,l,h,R,$,be,te]),bt=p.useCallback(()=>{m.current=!0},[]),kt=p.useCallback(()=>{m.current=!1},[]),$e=fe>8e3,yt=d.trim().length>0||k.length>0;return e.jsxs("div",{className:"shrink-0 px-3 sm:px-4 pb-3 pt-2 bg-dark-bg",onDragOver:mt,onDragLeave:xt,onDrop:gt,children:[k.length>0&&e.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:k.map(x=>{const b=Wn(x.name);return e.jsxs("div",{className:H("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-xs transition-colors",x.error?"border-accent-red/40 bg-accent-red/5 text-accent-red":x.uploading?"border-accent-blue/40 bg-accent-blue/5 text-accent-blue":"border-dark-border bg-dark-surface text-dark-text"),children:[x.uploading?e.jsx(pe,{size:13,className:"animate-spin"}):e.jsx(b,{size:13}),e.jsx("span",{className:"max-w-[140px] truncate",children:x.name}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:x.size>1024*1024?`${(x.size/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(x.size/1024))} KB`}),!x.uploading&&e.jsx("button",{onClick:()=>pt(x.id),className:"rounded p-0.5 text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors","aria-label":o("a11y.close"),children:e.jsx(ue,{size:11})})]},x.id)})}),y&&e.jsx("div",{className:"mb-2 rounded-2xl border-2 border-dashed border-accent-blue/50 bg-accent-blue/5 py-3 text-center text-xs text-accent-blue",children:o("fileJob.dropHint")}),e.jsxs("div",{className:"relative rounded-2xl border border-dark-border bg-dark-surface shadow-sm transition-all duration-150 focus-within:border-accent-blue/50 focus-within:ring-4 focus-within:ring-accent-blue/10",children:[h&&e.jsx("div",{onMouseDown:x=>x.preventDefault(),"aria-hidden":!h,children:e.jsx(Dn,{isOpen:h,files:R,selectedIndex:$,query:I,isSearching:xe,onSelect:be,onHover:B,selectedCount:ge,onFinish:te})}),e.jsx("textarea",{ref:g,value:d,onChange:ct,onKeyDown:ht,onPaste:ft,onBlur:()=>{h&&te()},onCompositionStart:bt,onCompositionEnd:kt,placeholder:o(c?"chat.generatingPlaceholder":"chat.inputPlaceholder"),rows:1,disabled:c&&!u,"aria-label":"Message input",className:`w-full bg-transparent px-4 pt-3.5 pb-2 text-sm text-dark-text placeholder-dark-muted/60
17
+ resize-none focus:outline-none min-h-[44px] max-h-[40vh] leading-relaxed
18
+ disabled:opacity-50 disabled:cursor-not-allowed`}),e.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-2.5",children:[e.jsx(Ln,{}),e.jsx("span",{className:"text-[11px] text-dark-muted/80 font-mono truncate max-w-[10rem] hidden sm:block",children:lt||""}),e.jsx("div",{className:"flex-1"}),fe>0&&d.length>0&&e.jsxs("span",{className:`text-[10px] tabular-nums ${$e?"text-accent-red font-medium":"text-dark-muted/60"}`,children:["~",fe," tokens",$e?` · ${o("chat.nearLimit")}`:""]}),!c&&e.jsx("button",{onClick:()=>void ut(),className:"flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text",title:o("fileJob.attach"),"aria-label":o("fileJob.attach"),children:e.jsx(Ft,{size:15,"aria-hidden":"true"})}),e.jsx("input",{ref:f,type:"file",multiple:!0,accept:".xlsx,.xls,.csv,.docx,.txt,.md",className:"hidden",onChange:dt}),c?e.jsxs("div",{className:"flex items-center gap-1.5",children:[u?e.jsx("button",{onClick:l,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-green text-white transition-all hover:opacity-85 active:scale-95",title:o("chat.resumeGen"),"aria-label":o("chat.resumeGen"),children:e.jsx($t,{size:14,"aria-hidden":"true"})}):e.jsx("button",{onClick:a,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-yellow text-white transition-all hover:opacity-85 active:scale-95",title:o("chat.pauseGen"),"aria-label":o("chat.pauseGen"),children:e.jsx(Mt,{size:14,"aria-hidden":"true"})}),e.jsx("button",{onClick:r,className:"flex h-8 w-8 items-center justify-center rounded-full bg-accent-red text-white transition-all hover:opacity-85 active:scale-95",title:o("chat.stopGen"),"aria-label":o("chat.stopGen"),children:e.jsx(Pt,{size:13,"aria-hidden":"true"})})]}):e.jsx("button",{onClick:()=>void oe(),disabled:!yt,className:`flex h-8 w-8 items-center justify-center rounded-full bg-dark-text text-dark-bg transition-all
19
+ hover:opacity-80 active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed`,title:o("chat.sendBtn"),"aria-label":o("chat.sendBtn"),children:e.jsx(zt,{size:15,"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"mt-1.5 hidden sm:flex items-center justify-center gap-3 text-[10px] text-dark-muted/50 select-none",children:[e.jsx("span",{children:o("chat.shiftEnter")}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:o("chat.escHint")})]})]})}),Jn=p.memo(function(){const{t}=F(),[n,r]=p.useState(0),[a,l]=p.useState(0),o=p.useCallback(()=>{const d=U.getReconnectState();r(d.reconnecting?d.attempts:0),l(d.maxAttempts)},[]);return p.useEffect(()=>{const d=U.onReconnectAttempt((f,m)=>{r(f),l(m)}),i=U.onReconnectSuccess(()=>{r(0),l(0)}),c=U.onReconnectGiveUp(()=>r(0)),u=U.onClose(o),g=U.onOpen(o);return o(),()=>{d(),i(),c(),u(),g()}},[o]),n<=0?null:e.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-2 text-xs text-accent-yellow bg-accent-yellow/10 border-b border-accent-yellow/20 select-none",role:"status","aria-live":"polite",children:[e.jsx(me,{size:13,className:"animate-spin shrink-0"}),e.jsx("span",{children:t("reconnect.reconnecting",{attempt:n,max:a})}),e.jsx("span",{className:"hidden sm:inline text-[10px] text-accent-yellow/70",children:t("reconnect.hint")})]})}),ve="dsc-auto-access-banner-dismissed",Xn=p.memo(function(){const{t}=F(),n=ne(d=>d.mode),[r,a]=p.useState(()=>localStorage.getItem(ve)==="1");p.useEffect(()=>{Ce(n==="normal"?"act":n)||localStorage.getItem(ve)==="1"&&a(!1)},[n]);const l=p.useCallback(d=>{d&&localStorage.setItem(ve,"1"),a(!0)},[]);return!(n!=="normal"&&Ce(n))||r?null:e.jsxs("div",{className:"flex items-start gap-2 px-4 py-2 text-[11px] leading-snug text-accent-yellow bg-accent-yellow/10 border-b border-accent-yellow/20 select-none",role:"note",children:[e.jsx(Bt,{size:14,className:"shrink-0 mt-0.5 text-accent-yellow"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"font-medium",children:t("autoAccess.title")}),e.jsxs("span",{className:"text-accent-yellow/80",children:[" ",t("autoAccess.desc")]})]}),e.jsx("button",{onClick:()=>l(!1),className:"shrink-0 rounded p-0.5 text-accent-yellow/70 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors",title:t("autoAccess.dismiss"),"aria-label":t("autoAccess.dismiss"),children:e.jsx(ue,{size:12})}),e.jsx("button",{onClick:()=>l(!0),className:"shrink-0 rounded px-1.5 py-0.5 text-[10px] text-accent-yellow/70 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors whitespace-nowrap",children:t("autoAccess.neverShow")})]})}),Yn={pending:{color:"text-gray-400",bg:"bg-gray-500/10",label:"Pending"},running:{color:"text-blue-400",bg:"bg-blue-500/10",label:"Running"},completed:{color:"text-green-400",bg:"bg-green-500/10",label:"Done"},failed:{color:"text-red-400",bg:"bg-red-500/10",label:"Failed"},skipped:{color:"text-gray-500",bg:"bg-gray-500/5",label:"Skipped"}},Vn=({status:s})=>s==="running"?e.jsx(pe,{size:12,className:"animate-spin text-accent-blue"}):s==="completed"?e.jsx(Se,{size:12,className:"text-accent-green"}):s==="failed"?e.jsx(Ht,{size:12,className:"text-accent-red"}):s==="skipped"?e.jsx(Gt,{size:12,className:"text-dark-muted"}):e.jsx(qt,{size:12,className:"text-dark-muted"}),Qn=p.memo(function({sessionId:t,defaultExpanded:n,onClose:r}){const{t:a}=F(),[l,o]=p.useState(n??!1),[d,i]=p.useState(null),c=_e(m=>m.getTasksForSession(t)),u=p.useMemo(()=>{const m=c.length,k=c.filter(h=>h.status==="completed").length,w=c.filter(h=>h.status==="running").length,y=c.filter(h=>h.status==="failed").length,E=m>0?Math.round(k/m*100):0;return{total:m,completed:k,running:w,failed:y,progress:E}},[c]),g=p.useMemo(()=>{const m={pending:[],running:[],completed:[],failed:[]};return c.forEach(k=>{const w=k.status==="skipped"?"pending":k.status;m[w].push(k)}),m},[c]);if(c.length===0)return e.jsx("div",{className:"text-xs text-dark-muted py-4 text-center",children:a("chat.noTasks")});const f=[...g.running,...g.failed,...g.pending.slice(0,5),...g.completed.slice(-3)];return e.jsxs("div",{className:"min-w-[220px] border border-dark-border rounded bg-dark-bg/70",children:[e.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1.5 hover:bg-dark-hover transition-colors cursor-pointer",onClick:()=>o(!l),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(et,{size:14,className:"text-accent-blue shrink-0"}),e.jsx("span",{className:"text-xs font-medium text-dark-text",children:"Task Board"}),e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0",children:[u.completed,"/",u.total]}),e.jsx("div",{className:"w-16 h-1.5 bg-dark-surface rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${u.running>0?"bg-accent-blue":u.failed>0?"bg-accent-red":"bg-accent-green"}`,style:{width:`${u.progress}%`}})}),u.running>0&&e.jsx("span",{className:"w-1.5 h-1.5 bg-accent-blue rounded-full animate-pulse shrink-0"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[r&&l&&e.jsx("span",{role:"button",tabIndex:0,onClick:m=>{m.stopPropagation(),r()},onKeyDown:m=>{m.key==="Enter"&&(m.stopPropagation(),r())},className:"p-0.5 rounded hover:bg-dark-hover transition-colors cursor-pointer",title:"Hide task panel",children:e.jsx(ue,{size:12,className:"text-dark-muted"})}),l?e.jsx(Ut,{size:14,className:"text-dark-muted"}):e.jsx(ee,{size:14,className:"text-dark-muted"})]})]}),l&&e.jsxs("div",{className:"px-2 pb-2 max-h-[260px] overflow-y-auto custom-scrollbar space-y-1.5",children:[f.map(m=>e.jsx(ts,{task:m,isSelected:m.id===d,onClick:()=>i(d===m.id?null:m.id)},m.id)),g.pending.length>5&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[g.pending.length-5," more pending tasks"]}),g.completed.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[g.completed.length-3," more completed tasks"]})]})]})}),es=(s,t)=>{if(!s)return"";const n=(t||Date.now())-s;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`},ts=p.memo(function({task:t,isSelected:n,onClick:r}){const a=Yn[t.status];return e.jsxs("div",{onClick:r,className:`rounded border p-2 cursor-pointer transition-all ${a.bg} border-dark-border
20
+ ${n?"ring-1 ring-accent-blue":"hover:border-dark-muted/40"}
21
+ ${t.status==="running"?"border-l-2 border-l-accent-blue":"border-l-2 border-l-transparent"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Vn,{status:t.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-dark-text truncate",children:t.title}),e.jsx("span",{className:`text-[10px] ${a.color} shrink-0`,children:a.label})]}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-dark-muted",children:[e.jsx("span",{children:t.agentType||t.source}),t.startedAt&&e.jsx("span",{children:es(t.startedAt,t.completedAt)})]})]})]}),t.status==="running"&&t.progress!==void 0&&e.jsx("div",{className:"mt-1.5",children:e.jsx("div",{className:"w-full h-1 bg-dark-bg rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent-blue rounded-full transition-all duration-500",style:{width:`${t.progress}%`}})})}),n&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-dark-border space-y-1",children:[t.description&&e.jsx("p",{className:"text-[10px] text-dark-muted",children:t.description}),t.error&&e.jsx("p",{className:"text-[10px] text-red-400",children:t.error}),t.result&&e.jsx("p",{className:"text-[10px] text-green-400",children:t.result}),t.dependencies&&t.dependencies.length>0&&e.jsxs("p",{className:"text-[10px] text-dark-muted",children:[t.dependencies.length," dependencies"]})]})]})}),ls=p.memo(function({tabs:t,activeSessionId:n,onSend:r,onStop:a,onPause:l,onResume:o,activeTab:d,setActiveTab:i,createNewSession:c,clearMessages:u,setTheme:g,toggleTerminal:f,setLogs:m,setUnreadLogs:k,showTaskBoard:w=!0,onToggleTaskBoard:y,onRegenerate:E,onDeleteMessage:h}){const S=z(_=>n?_.messagesBySession[n]||[]:[]),I=z(_=>n?_.generatingSessions.includes(n):!1),A=z(_=>n?_.pausedSessions.includes(n):!1),R=_e(_=>n?_.getTasksForSession(n):[]);p.useEffect(()=>{if(!n)return;let _=!1;return Q.tasks.list().then(M=>{if(_||!M.success||!Array.isArray(M.data))return;const Z={PENDING:"pending",RUNNING:"running",COMPLETED:"completed",FAILED:"failed",CANCELLED:"skipped"},q=Date.now(),J=M.data.map(P=>{const G=new Date(P.createdAt).getTime()||q,ie=new Date(P.updatedAt).getTime()||q;return{id:P.id,sessionId:n,title:P.title,status:Z[P.status]||"pending",source:"task",description:P.description,progress:P.progress,createdAt:G,updatedAt:ie,raw:P}});_e.getState().setTasks(n,J,"task")}).catch(()=>{}),()=>{_=!0}},[n]);const O=t.find(_=>_.id===n)||null,$=R.length>0,B=p.useCallback((_,M)=>{n&&r(n,_,M)},[r,n]),xe=p.useCallback(_=>{n&&r(n,_)},[r,n]),ae=p.useCallback(_=>{n&&E&&E(n,_)},[E,n]),ge=p.useCallback(_=>{n&&h&&h(n,_)},[h,n]);return e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[e.jsx(Jn,{}),e.jsx(Xn,{}),O&&e.jsxs(e.Fragment,{children:[e.jsx(In,{messages:S,isGenerating:I,isPaused:A,sessionId:O.id,onSendSuggestion:xe,onRegenerate:E?ae:void 0,onDeleteMessage:h?ge:void 0}),e.jsx(Zn,{sessionId:O.id,onSend:B,onStop:()=>a(O.id),onPause:()=>l(O.id),onResume:()=>o(O.id)})]})]}),n&&w&&$&&e.jsx("div",{className:"w-80 shrink-0 border-l border-dark-border overflow-hidden flex flex-col min-h-0 max-lg:hidden",children:e.jsx(Qn,{sessionId:n,defaultExpanded:!0,onClose:y})}),n&&!w&&$&&e.jsxs("button",{onClick:y,className:"fixed bottom-6 right-6 z-40 bg-accent-blue text-white rounded-full px-3 py-2 shadow-lg hover:opacity-90 transition-opacity flex items-center gap-1.5 text-xs",children:[e.jsx(et,{size:14}),"Task Board"]})]})});export{ls as SessionGrid};
@@ -1,3 +1,3 @@
1
- import{j as e}from"./markdown-BUScHEtT.js";import{r,p as U,F as ee,o as te,ad as se,B as ae,y as _,aE as re,aF as G,aG as ne,aH as oe,aI as le,aA as ce,aJ as ie,aK as de,aL as ue,I as xe}from"./icons-uody4X-4.js";import{a as y,t as i,e as H,g as me,c as he,T as ge,D as pe,w as K,n as O}from"./index-futMRNcm.js";import"./react-vendor-C5NlWs7r.js";import"./state-DKyBAq9j.js";const D=r.memo(function({title:d,subtitle:s,enabled:c,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between p-3 bg-dark-bg rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:d}),e.jsx("div",{className:"text-xs text-dark-muted",children:s})]}),e.jsx("button",{onClick:()=>l(!c),className:`relative w-12 h-6 rounded-full transition-colors ${c?"bg-accent-green":"bg-dark-border"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${c?"left-7":"left-1"}`})})]})});function be(o){return o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`}function fe(o){return new Date(o).toLocaleString()}function ke(){const[o,d]=r.useState([]),[s,c]=r.useState(null),[l,p]=r.useState(""),[b,v]=r.useState(""),[m,n]=r.useState(!1),[g,T]=r.useState(!1),N=r.useCallback(async()=>{n(!0);try{const a=await y.config.files.list();a.success&&Array.isArray(a.data)&&d(a.data)}catch{i.error("Failed to load config files")}finally{n(!1)}},[]),I=r.useCallback(async a=>{try{const S=await y.config.files.read(a);if(S.success&&S.data){const f=S.data;c(f.name),p(f.content),v(f.content)}}catch{i.error(`Failed to read ${a}`)}},[]);r.useEffect(()=>{N()},[N]);const L=r.useCallback(async()=>{if(s){T(!0);try{const a=await y.config.files.write(s,l);a.success?(v(l),i.success(`${s} saved`),N()):i.error(a.error||"Failed to save")}catch{i.error("Failed to save file")}finally{T(!1)}}},[s,l,N]),C=l!==b,M=(s==null?void 0:s.endsWith(".yaml"))||(s==null?void 0:s.endsWith(".yml")),E=s==null?void 0:s.endsWith(".json"),z=a=>M?a.replace(/(#.*)$/,'<span class="text-dark-muted">$1</span>').replace(/^(\s*)([\w-]+)(:)/,'$1<span class="text-accent-blue">$2</span>$3').replace(/:\s+(true|false|null|~)(\s*)$/,': <span class="text-accent-purple">$1</span>$2').replace(/:\s+(\d+\.?\d*)(\s*)$/,': <span class="text-accent-green">$1</span>$2').replace(/:\s+"([^"]*)"(\s*)$/,': <span class="text-accent-yellow">"$1"</span>$2'):E?a.replace(/(\s*"[^"]*")(\s*:)/g,'<span class="text-accent-blue">$1</span>$2').replace(/:\s+(true|false|null)/g,': <span class="text-accent-purple">$1</span>').replace(/:\s+(\d+\.?\d*)/g,': <span class="text-accent-green">$1</span>').replace(/:\s+"([^"]*)"/g,': <span class="text-accent-yellow">"$1"</span>'):a;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-dark-text",children:"Config Files"}),e.jsx("button",{onClick:N,disabled:m,className:"p-1.5 rounded hover:bg-dark-hover transition-colors text-dark-muted",title:"Refresh file list",children:e.jsx(U,{size:14,className:m?"animate-spin":""})})]}),o.length===0&&!m&&e.jsx("p",{className:"text-xs text-dark-muted",children:"No config files found in ~/.agent/"}),o.length>0&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-48 shrink-0 space-y-0.5 max-h-[300px] overflow-y-auto custom-scrollbar",children:o.map(a=>e.jsxs("button",{onClick:()=>I(a.name),className:`w-full text-left px-2.5 py-1.5 rounded text-xs flex items-center gap-2 transition-colors ${s===a.name?"bg-accent-blue/10 text-accent-blue":"text-dark-text hover:bg-dark-hover"}`,children:[e.jsx(ee,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:a.name}),!a.editable&&e.jsx("span",{className:"text-[10px] text-dark-muted shrink-0",title:"Read-only",children:"read"})]},a.name))}),s?e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx("span",{className:"text-dark-text font-medium",children:s}),o.find(a=>a.name===s)&&e.jsxs("span",{children:[be(o.find(a=>a.name===s).size)," · ",fe(o.find(a=>a.name===s).modified)]}),C&&e.jsxs("span",{className:"text-accent-yellow flex items-center gap-1",children:[e.jsx(te,{size:10}),"unsaved changes"]})]}),e.jsxs("button",{onClick:L,disabled:!C||g,className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs transition-all ${C?"bg-accent-blue text-white hover:opacity-90":"bg-dark-hover text-dark-muted cursor-not-allowed"}`,children:[e.jsx(se,{size:12}),g?"Saving...":"Save"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"w-full h-[260px] p-3 rounded-lg bg-dark-bg border border-dark-border font-mono text-xs leading-relaxed overflow-auto custom-scrollbar pointer-events-none",dangerouslySetInnerHTML:{__html:l.split(`
2
- `).map(z).join(`
3
- `)||"&nbsp;"}}),e.jsx("textarea",{value:l,onChange:a=>p(a.target.value),className:"absolute inset-0 w-full h-full p-3 rounded-lg bg-transparent border border-dark-border font-mono text-xs leading-relaxed resize-none overflow-auto custom-scrollbar text-transparent caret-dark-text focus:outline-none focus:border-accent-blue/50",style:{color:"transparent"},spellCheck:!1})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-dark-muted",children:"Select a file to edit"})]})]})}const ve=r.memo(function({nameKey:d,descriptionKey:s,colors:c,isSelected:l,onClick:p}){const{t:b}=H(),v=["bg","surface","border","text","muted","accentBlue","accentGreen","accentRed","accentYellow","accentPurple"];return e.jsxs("button",{onClick:p,className:`relative flex flex-col items-center rounded-xl p-2 transition-all focus:outline-none focus:ring-2 focus:ring-accent-blue/50 ${l?"ring-2 ring-accent-blue/60 bg-dark-bg border border-accent-blue/40 shadow-sm":"border border-dark-border hover:border-accent-blue/30 bg-dark-bg hover:shadow-sm"}`,title:b(s),"aria-pressed":l,"aria-label":b(d),children:[e.jsx("div",{className:"flex gap-[2px] rounded-md overflow-hidden w-full h-8 mb-1.5 border border-dark-border/40",children:v.map(m=>e.jsx("div",{className:"flex-1",style:{backgroundColor:c[m]},title:m},m))}),e.jsx("span",{className:`text-[11px] font-medium truncate w-full text-center ${l?"text-accent-blue":"text-dark-text"}`,children:b(d)}),l&&e.jsx("span",{className:"absolute top-1 right-1 w-4 h-4 bg-accent-blue rounded-full flex items-center justify-center shadow-sm",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:e.jsx("path",{d:"M1.5 4L3.5 6L6.5 2",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}),W=[{key:"bg",labelKey:"settings.colorBg"},{key:"surface",labelKey:"settings.colorSurface"},{key:"border",labelKey:"settings.colorBorder"},{key:"text",labelKey:"settings.colorText"},{key:"muted",labelKey:"settings.colorMuted"},{key:"accentBlue",labelKey:"settings.colorAccentBlue"},{key:"accentGreen",labelKey:"settings.colorAccentGreen"},{key:"accentRed",labelKey:"settings.colorAccentRed"},{key:"accentYellow",labelKey:"settings.colorAccentYellow"},{key:"accentPurple",labelKey:"settings.colorAccentPurple"}],je={language:["language","lang","Chinese","中文","English","en","zh"],theme:["theme","dark","light","color","palette","custom"],advanced:["advanced","yolo","auto","swarm","workspace","guard","bypass"],provider:["provider","model","api","key","openai","anthropic","deepseek"],configFiles:["config","file","yaml","json","editor"],system:["system","server","uptime","restart","reboot"],about:["about","version","info"]},Te=r.memo(function({onNavigate:d}){const{t:s}=H(),{theme:c,setTheme:l,themePresetId:p,setThemePreset:b,language:v,setLanguage:m,yolo:n,setYoloEnabled:g,autoSwarm:T,setAutoSwarmEnabled:N,workspaceGuardBypass:I,setWorkspaceGuardBypass:L,customTheme:C,customThemeEnabled:M,setCustomTheme:E,setCustomThemeEnabled:z,resetCustomTheme:a}=me(),S=he(t=>t.activeSessionId),[f,Y]=r.useState(M),q=r.useMemo(()=>c==="dark"?"dark":c==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[c]),J=r.useMemo(()=>Object.values(ge),[]),[P,Q]=r.useState(0),[j,F]=r.useState(!1),[A,R]=r.useState(!1),[$,B]=r.useState(""),k=r.useCallback(t=>{if(!$.trim())return!0;const x=$.toLowerCase().trim();return(je[t]??[]).some(h=>h.toLowerCase().includes(x))},[$]);r.useEffect(()=>{let t=!0;const x=async()=>{try{const h=await y.system.status();t&&h.success&&h.data&&Q(h.data.uptime)}catch{}};x();const u=setInterval(x,j?2e3:1e4);return()=>{t=!1,clearInterval(u)}},[j]);const Z=r.useCallback(async()=>{if(window.confirm("Restart the server? All active sessions will be disconnected.")){F(!0);try{const t=await y.system.restart();t.success?i.info("Server restarting..."):(i.error(t.error||"Restart failed"),F(!1))}catch{i.error("Failed to send restart request"),F(!1)}}},[]),V=r.useCallback(async()=>{if(window.confirm("Shut down the server? This will stop the entire backend process.")&&window.confirm("Are you sure? All active sessions and unsaved work will be lost.")){R(!0);try{const t=await y.system.shutdown();t.success?i.info("Server shutting down..."):(i.error(t.error||"Shutdown failed"),R(!1))}catch{i.error("Failed to send shutdown request"),R(!1)}}},[]);r.useEffect(()=>{j&&P<1e4&&(F(!1),i.success("Server restarted"))},[P,j]);const X=t=>{const x=Math.floor(t/1e3),u=Math.floor(x/60),h=Math.floor(u/60);return h>0?`${h}h ${u%60}m`:u>0?`${u}m ${x%60}s`:`${x}s`};return e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar p-4 bg-transparent",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-4 rounded-xl border border-dark-border bg-dark-surface p-3",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 shrink-0",children:[e.jsx(ae,{size:18,className:"text-accent-blue"}),s("settings.title")]}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(_,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted pointer-events-none"}),e.jsx("input",{type:"text",value:$,onChange:t=>B(t.target.value),placeholder:"Search settings...",className:"w-full bg-dark-bg border border-dark-border rounded-lg pl-9 pr-3 py-1.5 text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),$&&e.jsx("button",{onClick:()=>B(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-dark-text text-xs p-1 rounded",children:"×"})]})]}),e.jsxs("div",{className:"space-y-5 max-w-3xl",children:[k("language")&&e.jsx(w,{icon:re,iconColor:"text-accent-blue",title:s("settings.language"),children:e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(t=>e.jsx("button",{onClick:()=>m(t),className:`px-4 py-2 rounded-lg transition-all ${v===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="zh-CN"?"settings.languageZh":"settings.languageEn")},t))})}),k("theme")&&e.jsxs(w,{icon:G,iconColor:"text-accent-purple",title:s("settings.theme"),children:[e.jsx("div",{className:"flex gap-2 mb-4",children:["dark","light","auto"].map(t=>e.jsx("button",{onClick:()=>l(t),className:`px-4 py-2 rounded-lg transition-all ${c===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="dark"?"settings.themeDark":t==="light"?"settings.themeLight":"settings.themeAuto")},t))}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-text mb-2",children:s("settings.themePresets")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2",children:J.map(t=>{if(!t)return null;const x=(p||pe)===t.id,u=q==="dark"?t.dark:t.light;return e.jsx(ve,{id:t.id,nameKey:t.nameKey,descriptionKey:t.descriptionKey,colors:u,isSelected:x,onClick:()=>b(t.id)},t.id)})})]}),e.jsxs("div",{className:"pt-4 border-t border-dark-border",children:[e.jsxs("button",{onClick:()=>{const t=!f;Y(t),z(t)},className:"flex items-center gap-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(G,{size:14}),e.jsx("span",{children:s("settings.customOverrides")}),e.jsx("span",{className:`w-8 h-4 rounded-full transition-colors ${f?"bg-accent-blue":"bg-dark-border"}`,children:e.jsx("span",{className:`block w-3 h-3 rounded-full bg-white transition-transform mt-0.5 ${f?"ml-4":"ml-0.5"}`})})]}),f&&e.jsx("p",{className:"text-[10px] text-dark-muted mt-1 mb-2",children:s("settings.customOverridesHint")}),f&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flex gap-1 mb-3 rounded-lg overflow-hidden h-6",children:W.map(({key:t})=>e.jsx("div",{className:"flex-1",style:{backgroundColor:C[t]},title:t},t))}),e.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:W.map(({key:t,labelKey:x})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:C[t],onChange:u=>E({[t]:u.target.value}),className:"w-8 h-8 rounded border border-dark-border cursor-pointer bg-transparent p-0.5 shrink-0"}),e.jsx("span",{className:"text-xs text-dark-muted flex-1 truncate",children:s(x)}),e.jsx("input",{type:"text",value:C[t],onChange:u=>{const h=u.target.value;/^#[0-9a-fA-F]{0,6}$/.test(h)&&E({[t]:h})},className:"w-16 bg-dark-bg border border-dark-border rounded px-1 py-0.5 text-xs text-dark-text font-mono text-center",maxLength:7})]},t))}),e.jsx("button",{onClick:a,className:"mt-2 text-xs text-dark-muted hover:text-accent-red transition-colors",children:s("settings.resetColors")})]})]})]}),k("provider")&&e.jsxs(w,{icon:ne,iconColor:"text-accent-yellow",title:"Provider & Models",children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Configure AI providers, API keys, and model settings. Add or remove providers like OpenAI, Anthropic, DeepSeek, and more."}),e.jsxs("button",{onClick:()=>d==null?void 0:d("models"),className:"flex items-center gap-2 px-4 py-2 bg-accent-blue text-white rounded-lg hover:opacity-90 transition-opacity text-sm w-fit",children:[e.jsx(oe,{size:14}),"Manage Providers & Models"]})]}),k("context")&&e.jsx(w,{icon:le,iconColor:"text-accent-blue",title:"Max Context",children:e.jsx(we,{})}),k("advanced")&&e.jsx(w,{icon:ce,iconColor:"text-accent-yellow",title:s("settings.advancedFeatures"),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{title:s("settings.yoloMode"),subtitle:s("settings.yoloDesc"),enabled:n.enabled,onChange:t=>{g(t),K.send({type:"toggle_yolo",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.autoSwarm"),subtitle:s("settings.autoSwarmDesc"),enabled:T.enabled,onChange:t=>{N(t),K.send({type:"toggle_auto_swarm",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.workspaceGuard"),subtitle:s("settings.workspaceGuardDesc"),enabled:I,onChange:t=>{L(t),K.send({type:"toggle_workspace_guard",sessionId:S||"",data:t?"true":"false"})}})]})}),k("configFiles")&&e.jsx(w,{icon:ie,iconColor:"text-accent-green",title:"Config Files (~/.agent/)",children:e.jsx(ke,{})}),k("system")&&e.jsx(w,{icon:de,iconColor:"text-dark-muted",title:"System",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-dark-muted",children:"Server Uptime"}),e.jsx("span",{className:"text-dark-text font-mono",children:X(P)})]}),e.jsxs("button",{onClick:Z,disabled:j,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${j?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(U,{size:14,className:j?"animate-spin":""}),j?"Restarting...":"Restart Server"]}),e.jsxs("button",{onClick:V,disabled:A,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${A?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(ue,{size:14,className:A?"animate-pulse":""}),A?"Shutting Down...":"Shutdown Server"]})]})}),k("about")&&e.jsx(w,{icon:xe,iconColor:"text-accent-blue",title:s("settings.about"),children:e.jsxs("div",{className:"text-sm text-dark-muted space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-dark-text",children:"DeepSeekCode Web"})," v1.0.0"]}),e.jsx("p",{children:s("settings.aboutDesc")}),e.jsx("p",{className:"text-xs",children:"Powered by React + TypeScript + TailwindCSS"})]})}),$.trim()&&!["language","theme","provider","advanced","configFiles","system","about"].some(k)&&e.jsxs("div",{className:"text-center py-12 text-dark-muted",children:[e.jsx(_,{size:32,className:"mx-auto mb-2 opacity-40"}),e.jsxs("p",{className:"text-sm",children:["No settings match “",$,"”"]})]})]})]})});function we(){const o=O(n=>n.maxContextTokens),d=O(n=>n.setMaxContextTokens),[s,c]=r.useState(String(o)),[l,p]=r.useState(!1),b=[32e3,64e3,128e3,256e3,512e3,1e6,2e6],v=async()=>{const n=parseInt(s,10);if(!(isNaN(n)||n<1e3)){p(!0),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}p(!1)}},m=n=>n>=1e6?(n/1e6).toFixed(0)+"M":(n/1e3).toFixed(0)+"K";return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Set the maximum context window (in tokens) for your AI model. This controls how the progress bar and usage percentage are calculated."}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"number",value:s,onChange:n=>c(n.target.value),min:1e3,max:1e7,step:1e3,className:"w-32 bg-dark-bg border border-dark-border rounded-lg px-3 py-1.5 text-sm text-dark-text font-mono focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),e.jsx("span",{className:"text-sm text-dark-muted",children:"tokens"}),e.jsx("button",{onClick:v,disabled:l,className:"px-3 py-1.5 rounded-lg text-sm bg-accent-blue text-white hover:opacity-90 transition-opacity disabled:opacity-50",children:l?"Saving...":"Apply"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(n=>e.jsx("button",{onClick:async()=>{c(String(n)),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}},className:"px-3 py-1 rounded-lg text-xs transition-all",children:m(n)},n))}),e.jsxs("p",{className:"text-xs text-dark-muted mt-2",children:["Current: ",e.jsx("span",{className:"font-mono text-dark-text",children:parseInt(s,10).toLocaleString()})," tokens"]})]})}function w({icon:o,iconColor:d,title:s,children:c}){return e.jsxs("div",{className:"rounded-xl border border-dark-border bg-dark-surface p-4",children:[e.jsxs("h3",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(o,{size:16,className:d}),s]}),c]})}export{Te as SettingsPanel};
1
+ import{j as e}from"./markdown-hmVtvQNZ.js";import{r,R as U,F as ee,A as te,ad as se,w as ae,u as _,aF as re,aG as G,aH as ne,aI as oe,aJ as le,aB as ce,aK as ie,aL as de,aM as ue,I as xe}from"./icons-CjRO1znb.js";import{a as y,t as i,e as H,g as me,c as he,T as ge,D as pe,w as K,o as O}from"./index-CAwHhr7A.js";import"./react-vendor-Dp4P972X.js";import"./state-C_jK7HTi.js";const D=r.memo(function({title:d,subtitle:s,enabled:c,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between p-3 bg-dark-bg rounded-lg",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:d}),e.jsx("div",{className:"text-xs text-dark-muted",children:s})]}),e.jsx("button",{onClick:()=>l(!c),className:`relative w-12 h-6 rounded-full transition-colors ${c?"bg-accent-green":"bg-dark-border"}`,children:e.jsx("span",{className:`absolute top-1 w-4 h-4 bg-white rounded-full transition-transform ${c?"left-7":"left-1"}`})})]})});function be(o){return o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`}function fe(o){return new Date(o).toLocaleString()}function ke(){const[o,d]=r.useState([]),[s,c]=r.useState(null),[l,p]=r.useState(""),[b,v]=r.useState(""),[m,n]=r.useState(!1),[g,T]=r.useState(!1),N=r.useCallback(async()=>{n(!0);try{const a=await y.config.files.list();a.success&&Array.isArray(a.data)&&d(a.data)}catch{i.error("Failed to load config files")}finally{n(!1)}},[]),M=r.useCallback(async a=>{try{const S=await y.config.files.read(a);if(S.success&&S.data){const f=S.data;c(f.name),p(f.content),v(f.content)}}catch{i.error(`Failed to read ${a}`)}},[]);r.useEffect(()=>{N()},[N]);const I=r.useCallback(async()=>{if(s){T(!0);try{const a=await y.config.files.write(s,l);a.success?(v(l),i.success(`${s} saved`),N()):i.error(a.error||"Failed to save")}catch{i.error("Failed to save file")}finally{T(!1)}}},[s,l,N]),C=l!==b,L=(s==null?void 0:s.endsWith(".yaml"))||(s==null?void 0:s.endsWith(".yml")),E=s==null?void 0:s.endsWith(".json"),R=a=>L?a.replace(/(#.*)$/,'<span class="text-dark-muted">$1</span>').replace(/^(\s*)([\w-]+)(:)/,'$1<span class="text-accent-blue">$2</span>$3').replace(/:\s+(true|false|null|~)(\s*)$/,': <span class="text-accent-purple">$1</span>$2').replace(/:\s+(\d+\.?\d*)(\s*)$/,': <span class="text-accent-green">$1</span>$2').replace(/:\s+"([^"]*)"(\s*)$/,': <span class="text-accent-yellow">"$1"</span>$2'):E?a.replace(/(\s*"[^"]*")(\s*:)/g,'<span class="text-accent-blue">$1</span>$2').replace(/:\s+(true|false|null)/g,': <span class="text-accent-purple">$1</span>').replace(/:\s+(\d+\.?\d*)/g,': <span class="text-accent-green">$1</span>').replace(/:\s+"([^"]*)"/g,': <span class="text-accent-yellow">"$1"</span>'):a;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-medium text-dark-text",children:"Config Files"}),e.jsx("button",{onClick:N,disabled:m,className:"p-1.5 rounded hover:bg-dark-hover transition-colors text-dark-muted",title:"Refresh file list",children:e.jsx(U,{size:14,className:m?"animate-spin":""})})]}),o.length===0&&!m&&e.jsx("p",{className:"text-xs text-dark-muted",children:"No config files found in ~/.agent/"}),o.length>0&&e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-48 shrink-0 space-y-0.5 max-h-[300px] overflow-y-auto custom-scrollbar",children:o.map(a=>e.jsxs("button",{onClick:()=>M(a.name),className:`w-full text-left px-2.5 py-1.5 rounded text-xs flex items-center gap-2 transition-colors ${s===a.name?"bg-accent-blue/10 text-accent-blue":"text-dark-text hover:bg-dark-hover"}`,children:[e.jsx(ee,{size:12,className:"shrink-0"}),e.jsx("span",{className:"truncate flex-1",children:a.name}),!a.editable&&e.jsx("span",{className:"text-[10px] text-dark-muted shrink-0",title:"Read-only",children:"read"})]},a.name))}),s?e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx("span",{className:"text-dark-text font-medium",children:s}),o.find(a=>a.name===s)&&e.jsxs("span",{children:[be(o.find(a=>a.name===s).size)," · ",fe(o.find(a=>a.name===s).modified)]}),C&&e.jsxs("span",{className:"text-accent-yellow flex items-center gap-1",children:[e.jsx(te,{size:10}),"unsaved changes"]})]}),e.jsxs("button",{onClick:I,disabled:!C||g,className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs transition-all ${C?"bg-accent-blue text-white hover:opacity-90":"bg-dark-hover text-dark-muted cursor-not-allowed"}`,children:[e.jsx(se,{size:12}),g?"Saving...":"Save"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx("pre",{className:"w-full h-[260px] p-3 rounded-lg bg-dark-bg border border-dark-border font-mono text-xs leading-relaxed overflow-auto custom-scrollbar pointer-events-none",dangerouslySetInnerHTML:{__html:l.split(`
2
+ `).map(R).join(`
3
+ `)||"&nbsp;"}}),e.jsx("textarea",{value:l,onChange:a=>p(a.target.value),className:"absolute inset-0 w-full h-full p-3 rounded-lg bg-transparent border border-dark-border font-mono text-xs leading-relaxed resize-none overflow-auto custom-scrollbar text-transparent caret-dark-text focus:outline-none focus:border-accent-blue/50",style:{color:"transparent"},spellCheck:!1})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-dark-muted",children:"Select a file to edit"})]})]})}const ve=r.memo(function({nameKey:d,descriptionKey:s,colors:c,isSelected:l,onClick:p}){const{t:b}=H(),v=["bg","surface","border","text","muted","accentBlue","accentGreen","accentRed","accentYellow","accentPurple"];return e.jsxs("button",{onClick:p,className:`relative flex flex-col items-center rounded-xl p-2 transition-all focus:outline-none focus:ring-2 focus:ring-accent-blue/50 ${l?"ring-2 ring-accent-blue/60 bg-dark-bg border border-accent-blue/40 shadow-sm":"border border-dark-border hover:border-accent-blue/30 bg-dark-bg hover:shadow-sm"}`,title:b(s),"aria-pressed":l,"aria-label":b(d),children:[e.jsx("div",{className:"flex gap-[2px] rounded-md overflow-hidden w-full h-8 mb-1.5 border border-dark-border/40",children:v.map(m=>e.jsx("div",{className:"flex-1",style:{backgroundColor:c[m]},title:m},m))}),e.jsx("span",{className:`text-[11px] font-medium truncate w-full text-center ${l?"text-accent-blue":"text-dark-text"}`,children:b(d)}),l&&e.jsx("span",{className:"absolute top-1 right-1 w-4 h-4 bg-accent-blue rounded-full flex items-center justify-center shadow-sm",children:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",children:e.jsx("path",{d:"M1.5 4L3.5 6L6.5 2",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]})}),W=[{key:"bg",labelKey:"settings.colorBg"},{key:"surface",labelKey:"settings.colorSurface"},{key:"border",labelKey:"settings.colorBorder"},{key:"text",labelKey:"settings.colorText"},{key:"muted",labelKey:"settings.colorMuted"},{key:"accentBlue",labelKey:"settings.colorAccentBlue"},{key:"accentGreen",labelKey:"settings.colorAccentGreen"},{key:"accentRed",labelKey:"settings.colorAccentRed"},{key:"accentYellow",labelKey:"settings.colorAccentYellow"},{key:"accentPurple",labelKey:"settings.colorAccentPurple"}],je={language:["language","lang","Chinese","中文","English","en","zh"],theme:["theme","dark","light","color","palette","custom"],advanced:["advanced","yolo","auto","swarm","workspace","guard","bypass"],provider:["provider","model","api","key","openai","anthropic","deepseek"],configFiles:["config","file","yaml","json","editor"],system:["system","server","uptime","restart","reboot"],about:["about","version","info"]},Te=r.memo(function({onNavigate:d}){const{t:s}=H(),{theme:c,setTheme:l,themePresetId:p,setThemePreset:b,language:v,setLanguage:m,yolo:n,setYoloEnabled:g,autoSwarm:T,setAutoSwarmEnabled:N,workspaceGuardBypass:M,setWorkspaceGuardBypass:I,customTheme:C,customThemeEnabled:L,setCustomTheme:E,setCustomThemeEnabled:R,resetCustomTheme:a}=me(),S=he(t=>t.activeSessionId),[f,Y]=r.useState(L),q=r.useMemo(()=>c==="dark"?"dark":c==="light"?"light":window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",[c]),J=r.useMemo(()=>Object.values(ge),[]),[z,Q]=r.useState(0),[j,F]=r.useState(!1),[A,P]=r.useState(!1),[$,B]=r.useState(""),k=r.useCallback(t=>{if(!$.trim())return!0;const x=$.toLowerCase().trim();return(je[t]??[]).some(h=>h.toLowerCase().includes(x))},[$]);r.useEffect(()=>{let t=!0;const x=async()=>{try{const h=await y.system.status();t&&h.success&&h.data&&Q(h.data.uptime)}catch{}};x();const u=setInterval(x,j?2e3:1e4);return()=>{t=!1,clearInterval(u)}},[j]);const Z=r.useCallback(async()=>{if(window.confirm("Restart the server? All active sessions will be disconnected.")){F(!0);try{const t=await y.system.restart();t.success?i.info("Server restarting..."):(i.error(t.error||"Restart failed"),F(!1))}catch{i.error("Failed to send restart request"),F(!1)}}},[]),V=r.useCallback(async()=>{if(window.confirm("Shut down the server? This will stop the entire backend process.")&&window.confirm("Are you sure? All active sessions and unsaved work will be lost.")){P(!0);try{const t=await y.system.shutdown();t.success?i.info("Server shutting down..."):(i.error(t.error||"Shutdown failed"),P(!1))}catch{i.error("Failed to send shutdown request"),P(!1)}}},[]);r.useEffect(()=>{j&&z<1e4&&(F(!1),i.success("Server restarted"))},[z,j]);const X=t=>{const x=Math.floor(t/1e3),u=Math.floor(x/60),h=Math.floor(u/60);return h>0?`${h}h ${u%60}m`:u>0?`${u}m ${x%60}s`:`${x}s`};return e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar p-4 bg-transparent",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4 gap-4 rounded-xl border border-dark-border bg-dark-surface p-3",children:[e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2 shrink-0",children:[e.jsx(ae,{size:18,className:"text-accent-blue"}),s("settings.title")]}),e.jsxs("div",{className:"relative flex-1 max-w-xs",children:[e.jsx(_,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-dark-muted pointer-events-none"}),e.jsx("input",{type:"text",value:$,onChange:t=>B(t.target.value),placeholder:"Search settings...",className:"w-full bg-dark-bg border border-dark-border rounded-lg pl-9 pr-3 py-1.5 text-sm text-dark-text placeholder-dark-muted focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),$&&e.jsx("button",{onClick:()=>B(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-dark-muted hover:text-dark-text text-xs p-1 rounded",children:"×"})]})]}),e.jsxs("div",{className:"space-y-5 max-w-3xl",children:[k("language")&&e.jsx(w,{icon:re,iconColor:"text-accent-blue",title:s("settings.language"),children:e.jsx("div",{className:"flex gap-2",children:["zh-CN","en"].map(t=>e.jsx("button",{onClick:()=>m(t),className:`px-4 py-2 rounded-lg transition-all ${v===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="zh-CN"?"settings.languageZh":"settings.languageEn")},t))})}),k("theme")&&e.jsxs(w,{icon:G,iconColor:"text-accent-purple",title:s("settings.theme"),children:[e.jsx("div",{className:"flex gap-2 mb-4",children:["dark","light","auto"].map(t=>e.jsx("button",{onClick:()=>l(t),className:`px-4 py-2 rounded-lg transition-all ${c===t?"bg-accent-blue text-white":"bg-dark-hover text-dark-text hover:bg-dark-border"}`,children:s(t==="dark"?"settings.themeDark":t==="light"?"settings.themeLight":"settings.themeAuto")},t))}),e.jsxs("div",{className:"mb-4",children:[e.jsx("h4",{className:"text-xs font-semibold text-dark-text mb-2",children:s("settings.themePresets")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2",children:J.map(t=>{if(!t)return null;const x=(p||pe)===t.id,u=q==="dark"?t.dark:t.light;return e.jsx(ve,{id:t.id,nameKey:t.nameKey,descriptionKey:t.descriptionKey,colors:u,isSelected:x,onClick:()=>b(t.id)},t.id)})})]}),e.jsxs("div",{className:"pt-4 border-t border-dark-border",children:[e.jsxs("button",{onClick:()=>{const t=!f;Y(t),R(t)},className:"flex items-center gap-2 text-sm text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(G,{size:14}),e.jsx("span",{children:s("settings.customOverrides")}),e.jsx("span",{className:`w-8 h-4 rounded-full transition-colors ${f?"bg-accent-blue":"bg-dark-border"}`,children:e.jsx("span",{className:`block w-3 h-3 rounded-full bg-white transition-transform mt-0.5 ${f?"ml-4":"ml-0.5"}`})})]}),f&&e.jsx("p",{className:"text-[10px] text-dark-muted mt-1 mb-2",children:s("settings.customOverridesHint")}),f&&e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flex gap-1 mb-3 rounded-lg overflow-hidden h-6",children:W.map(({key:t})=>e.jsx("div",{className:"flex-1",style:{backgroundColor:C[t]},title:t},t))}),e.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:W.map(({key:t,labelKey:x})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:C[t],onChange:u=>E({[t]:u.target.value}),className:"w-8 h-8 rounded border border-dark-border cursor-pointer bg-transparent p-0.5 shrink-0"}),e.jsx("span",{className:"text-xs text-dark-muted flex-1 truncate",children:s(x)}),e.jsx("input",{type:"text",value:C[t],onChange:u=>{const h=u.target.value;/^#[0-9a-fA-F]{0,6}$/.test(h)&&E({[t]:h})},className:"w-16 bg-dark-bg border border-dark-border rounded px-1 py-0.5 text-xs text-dark-text font-mono text-center",maxLength:7})]},t))}),e.jsx("button",{onClick:a,className:"mt-2 text-xs text-dark-muted hover:text-accent-red transition-colors",children:s("settings.resetColors")})]})]})]}),k("provider")&&e.jsxs(w,{icon:ne,iconColor:"text-accent-yellow",title:"Provider & Models",children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Configure AI providers, API keys, and model settings. Add or remove providers like OpenAI, Anthropic, DeepSeek, and more."}),e.jsxs("button",{onClick:()=>d==null?void 0:d("models"),className:"flex items-center gap-2 px-4 py-2 bg-accent-blue text-white rounded-lg hover:opacity-90 transition-opacity text-sm w-fit",children:[e.jsx(oe,{size:14}),"Manage Providers & Models"]})]}),k("context")&&e.jsx(w,{icon:le,iconColor:"text-accent-blue",title:"Max Context",children:e.jsx(we,{})}),k("advanced")&&e.jsx(w,{icon:ce,iconColor:"text-accent-yellow",title:s("settings.advancedFeatures"),children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(D,{title:s("settings.yoloMode"),subtitle:s("settings.yoloDesc"),enabled:n.enabled,onChange:t=>{g(t),K.send({type:"toggle_yolo",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.autoSwarm"),subtitle:s("settings.autoSwarmDesc"),enabled:T.enabled,onChange:t=>{N(t),K.send({type:"toggle_auto_swarm",sessionId:S||"",data:t?"true":"false"})}}),e.jsx(D,{title:s("settings.workspaceGuard"),subtitle:s("settings.workspaceGuardDesc"),enabled:M,onChange:t=>{I(t),K.send({type:"toggle_workspace_guard",sessionId:S||"",data:t?"true":"false"})}})]})}),k("configFiles")&&e.jsx(w,{icon:ie,iconColor:"text-accent-green",title:"Config Files (~/.agent/)",children:e.jsx(ke,{})}),k("system")&&e.jsx(w,{icon:de,iconColor:"text-dark-muted",title:"System",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-dark-muted",children:"Server Uptime"}),e.jsx("span",{className:"text-dark-text font-mono",children:X(z)})]}),e.jsxs("button",{onClick:Z,disabled:j,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${j?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(U,{size:14,className:j?"animate-spin":""}),j?"Restarting...":"Restart Server"]}),e.jsxs("button",{onClick:V,disabled:A,className:`flex items-center gap-2 px-4 py-2 rounded-lg text-sm transition-all ${A?"bg-dark-hover text-dark-muted cursor-wait":"bg-accent-red/10 text-accent-red hover:bg-accent-red/20 border border-accent-red/30"}`,children:[e.jsx(ue,{size:14,className:A?"animate-pulse":""}),A?"Shutting Down...":"Shutdown Server"]})]})}),k("about")&&e.jsx(w,{icon:xe,iconColor:"text-accent-blue",title:s("settings.about"),children:e.jsxs("div",{className:"text-sm text-dark-muted space-y-2",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-dark-text",children:"DeepSeekCode Web"})," v1.0.0"]}),e.jsx("p",{children:s("settings.aboutDesc")}),e.jsx("p",{className:"text-xs",children:"Powered by React + TypeScript + TailwindCSS"})]})}),$.trim()&&!["language","theme","provider","advanced","configFiles","system","about"].some(k)&&e.jsxs("div",{className:"text-center py-12 text-dark-muted",children:[e.jsx(_,{size:32,className:"mx-auto mb-2 opacity-40"}),e.jsxs("p",{className:"text-sm",children:["No settings match “",$,"”"]})]})]})]})});function we(){const o=O(n=>n.maxContextTokens),d=O(n=>n.setMaxContextTokens),[s,c]=r.useState(String(o)),[l,p]=r.useState(!1),b=[32e3,64e3,128e3,256e3,512e3,1e6,2e6],v=async()=>{const n=parseInt(s,10);if(!(isNaN(n)||n<1e3)){p(!0),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}p(!1)}},m=n=>n>=1e6?(n/1e6).toFixed(0)+"M":(n/1e3).toFixed(0)+"K";return e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-dark-muted mb-3",children:"Set the maximum context window (in tokens) for your AI model. This controls how the progress bar and usage percentage are calculated."}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("input",{type:"number",value:s,onChange:n=>c(n.target.value),min:1e3,max:1e7,step:1e3,className:"w-32 bg-dark-bg border border-dark-border rounded-lg px-3 py-1.5 text-sm text-dark-text font-mono focus:border-accent-blue/60 focus:ring-2 focus:ring-accent-blue/15 outline-none transition-all"}),e.jsx("span",{className:"text-sm text-dark-muted",children:"tokens"}),e.jsx("button",{onClick:v,disabled:l,className:"px-3 py-1.5 rounded-lg text-sm bg-accent-blue text-white hover:opacity-90 transition-opacity disabled:opacity-50",children:l?"Saving...":"Apply"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(n=>e.jsx("button",{onClick:async()=>{c(String(n)),d(n);try{await y.config.provider.save({contextWindow:n}),i.success("Context window saved")}catch(g){i.error("Failed to save context window: "+(g instanceof Error?g.message:"Unknown error"))}},className:"px-3 py-1 rounded-lg text-xs transition-all",children:m(n)},n))}),e.jsxs("p",{className:"text-xs text-dark-muted mt-2",children:["Current: ",e.jsx("span",{className:"font-mono text-dark-text",children:parseInt(s,10).toLocaleString()})," tokens"]})]})}function w({icon:o,iconColor:d,title:s,children:c}){return e.jsxs("div",{className:"rounded-xl border border-dark-border bg-dark-surface p-4",children:[e.jsxs("h3",{className:"font-medium mb-3 flex items-center gap-2",children:[e.jsx(o,{size:16,className:d}),s]}),c]})}export{Te as SettingsPanel};