@deepseekcode/cli 1.0.29 → 1.0.31

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 (33) hide show
  1. package/README.md +159 -99
  2. package/dist/cli.js +1504 -1477
  3. package/package.json +2 -2
  4. package/web/dist/assets/AutomationView-InguWZFs.js +1 -0
  5. package/web/dist/assets/{ChannelConfigView-DG4_15oh.js → ChannelConfigView-egYtlZj-.js} +3 -3
  6. package/web/dist/assets/ConnectorsView-5Ii67NnU.js +1 -0
  7. package/web/dist/assets/{FileTreeView-DPA2dhx_.js → FileTreeView-BT45_XVy.js} +1 -1
  8. package/web/dist/assets/{HookConfigView-BJnvqm3N.js → HookConfigView-DYF8WoqD.js} +1 -1
  9. package/web/dist/assets/ModelsView-C_hShQeY.js +1 -0
  10. package/web/dist/assets/{PluginsView-DxIWxsB-.js → PluginsView-CFAStd5I.js} +1 -1
  11. package/web/dist/assets/SessionGrid-BGpz0-op.css +1 -0
  12. package/web/dist/assets/SessionGrid-aZvfkGsH.js +42 -0
  13. package/web/dist/assets/SettingsPanel-DpXhjWLN.js +4 -0
  14. package/web/dist/assets/{SkillsView-Cpr_kpor.js → SkillsView-DqLfpF41.js} +1 -1
  15. package/web/dist/assets/{TemplatesTab-Cvyxqayr.js → TemplatesTab-CQy-UXLH.js} +1 -1
  16. package/web/dist/assets/{TerminalView-DTN8hmcS.js → TerminalView-DFjhMeyT.js} +1 -1
  17. package/web/dist/assets/{ThreeScene-CukEnQe-.js → ThreeScene-Zhjwe9nT.js} +1 -1
  18. package/web/dist/assets/{ToolsView-D_FET-NB.js → ToolsView-D3HqxE7K.js} +1 -1
  19. package/web/dist/assets/{icons-Cu8fYt4q.js → icons-Di-qMB6n.js} +124 -109
  20. package/web/dist/assets/index-BbLAiXis.css +1 -0
  21. package/web/dist/assets/index-CWqFf5l2.js +484 -0
  22. package/web/dist/assets/{markdown-Bym7wmT0.js → markdown-D-c9V8Xq.js} +1 -1
  23. package/web/dist/assets/{panels-BEKHl5l-.js → panels-CpHTincc.js} +1 -1
  24. package/web/dist/assets/{react-vendor-D76F8wnc.js → react-vendor-DU8XgZt2.js} +1 -1
  25. package/web/dist/assets/{state-CZakZ3-m.js → state-D2vcUGVk.js} +1 -1
  26. package/web/dist/index.html +7 -7
  27. package/web/dist/assets/AutomationView-BJSLQ2Ka.js +0 -1
  28. package/web/dist/assets/ConnectorsView-ByedXSa-.js +0 -1
  29. package/web/dist/assets/ModelsView-BBbmRxwR.js +0 -1
  30. package/web/dist/assets/SessionGrid-D-1XpCZg.js +0 -39
  31. package/web/dist/assets/SettingsPanel-ivpxRR6O.js +0 -4
  32. package/web/dist/assets/index-C7rIgpwO.js +0 -484
  33. package/web/dist/assets/index-CYAcRfnc.css +0 -1
@@ -1,39 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ThreeScene-CukEnQe-.js","assets/markdown-Bym7wmT0.js","assets/icons-Cu8fYt4q.js","assets/ThreeScene-DvOrMIoG.css"])))=>i.map(i=>d[i]);
2
- import{j as e,r as ws}from"./markdown-Bym7wmT0.js";import{a as i,g as vs,af as jn,aQ as Ns,O as rt,F as nt,T as js,aO as Ss,_ as Sn,ak as Ae,d as we,K as je,ae as Es,a1 as Tt,aA as Se,X as Re,aR as Nt,E as En,$ as Ce,l as jt,L as Fe,u as Rt,aS as St,aH as As,D as Cs,k as Ts,aT as An,aw as Rs,aU as Ut,aV as Is,h as We,al as _s,i as Cn,aW as Ms,aX as Ds,aY as $s,b as Ls,aq as Os,aZ as Fs,aG as Ps,a_ as zs,a0 as Gt,B as Bs,ap as Hs,a$ as Us,n as Tn,aN as It,aM as Gs,a6 as Rn,ab as qs,a2 as In,b0 as Ws,b1 as Ks,ag as Js,b2 as Xs,f as Vs,S as Ys,t as Zs,b3 as Le,y as Qs,b4 as er,m as tr,b5 as nr,p as sr,q as rr,j as ar}from"./icons-Cu8fYt4q.js";import{D as ir,d as ne,u as q,h as Je,i as _n,o as Mn,j as Ke,k as Dn,w as ce,l as Et,b as Ee,R as $n,a as xe,t as oe,m as or,s as lr,r as cr,f as st,n as be,p as dr,q as ur,_ as pr,W as xr,v as mr,x as At,c as et,y as Ge,z as Ln,A as hr,E as fr,F as gr,G as br,M as kr,H as yr,J as wr,K as On,L as vr,N as Nr,O as Ze,Q as jr,S as Fn}from"./index-C7rIgpwO.js";import{r as Sr}from"./react-vendor-D76F8wnc.js";import{n as qt,s as Er,S as Ar}from"./sttLanguages-BNRptAQA.js";import"./state-CZakZ3-m.js";import"./panels-BEKHl5l-.js";class Cr extends ir{tokenize(t){return t.slice()}join(t){return t}removeEmpty(t){return t}}const Tr=new Cr;function Rr(s,t,n){return Tr.diff(s,t,n)}function Wt({value:s,max:t=100,size:n="md",variant:r="default",showLabel:a=!1,className:o}){const d=Math.min(Math.max(s/t*100,0),100),u={sm:"h-1",md:"h-2",lg:"h-3"},c={default:"bg-accent-blue",success:"bg-accent-green",warning:"bg-accent-yellow",error:"bg-accent-red"};return e.jsxs("div",{className:ne("w-full",o),children:[e.jsx("div",{className:ne("w-full bg-dark-border rounded-full overflow-hidden",u[n]),children:e.jsx("div",{className:ne("h-full rounded-full transition-all duration-300",c[r]),style:{width:`${d}%`}})}),a&&e.jsxs("span",{className:"text-xs text-dark-muted mt-1",children:[Math.round(d),"%"]})]})}function Pn(s){const t=i.useRef(null),n=i.useRef(0);return i.useEffect(()=>{if(!s){n.current=0;return}n.current=Date.now();const r=t.current;if(!r)return;const a=()=>{const d=Math.floor((Date.now()-n.current)/1e3),u=d>=60?`${Math.floor(d/60)}m ${d%60}s`:`${d}s`;r.textContent=u};a();const o=setInterval(a,1e3);return()=>clearInterval(o)},[s]),t}var Ir=ws();const Kt=vs(Ir);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 o={};o[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",o)}});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.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;var Jt={},Xt;function _r(){return Xt||(Xt=1,(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)),Jt}_r();(function(s){var t=s.util.clone(s.languages.javascript),n=/(?:\s|\/\/.*(?!.)|\/\*(?:[^*]|\*(?!\/))\*\/)/.source,r=/(?:\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])*\})/.source,a=/(?:\{<S>*\.{3}(?:[^{}]|<BRACES>)*\})/.source;function o(c,l){return c=c.replace(/<S>/g,function(){return n}).replace(/<BRACES>/g,function(){return r}).replace(/<SPREAD>/g,function(){return a}),RegExp(c,l)}a=o(a).source,s.languages.jsx=s.languages.extend("markup",t),s.languages.jsx.tag.pattern=o(/<\/?(?:[\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:o(/<SPREAD>/.source),inside:s.languages.jsx}},s.languages.jsx.tag),s.languages.insertBefore("inside","special-attr",{script:{pattern:o(/=<BRACES>/.source),alias:"language-javascript",inside:{"script-punctuation":{pattern:/^=(?=\{)/,alias:"punctuation"},rest:s.languages.jsx}}},s.languages.jsx.tag);var d=function(c){return c?typeof c=="string"?c:typeof c.content=="string"?c.content:c.content.map(d).join(""):""},u=function(c){for(var l=[],p=0;p<c.length;p++){var x=c[p],f=!1;if(typeof x!="string"&&(x.type==="tag"&&x.content[0]&&x.content[0].type==="tag"?x.content[0].content[0].content==="</"?l.length>0&&l[l.length-1].tagName===d(x.content[0].content[1])&&l.pop():x.content[x.content.length-1].content==="/>"||l.push({tagName:d(x.content[0].content[1]),openedBraces:0}):l.length>0&&x.type==="punctuation"&&x.content==="{"?l[l.length-1].openedBraces++:l.length>0&&l[l.length-1].openedBraces>0&&x.type==="punctuation"&&x.content==="}"?l[l.length-1].openedBraces--:f=!0),(f||typeof x=="string")&&l.length>0&&l[l.length-1].openedBraces===0){var g=d(x);p<c.length-1&&(typeof c[p+1]=="string"||c[p+1].type==="plain-text")&&(g+=d(c[p+1]),c.splice(p+1,1)),p>0&&(typeof c[p-1]=="string"||c[p-1].type==="plain-text")&&(g=d(c[p-1])+g,c.splice(p-1,1),p--),c[p]=new s.Token("plain-text",g,null,g)}x.content&&typeof x.content!="string"&&u(x.content)}};s.hooks.add("after-tokenize",function(c){c.language!=="jsx"&&c.language!=="tsx"||u(c.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"],o=r.variable[1].inside,d=0;d<a.length;d++)o[a[d]]=s.languages.bash[a[d]];s.languages.sh=s.languages.bash,s.languages.shell=s.languages.bash})(Prism);var Vt={},Yt;function Mr(){return Yt||(Yt=1,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),Vt}Mr();(function(s){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(p){return p=p.replace(/<inner>/g,function(){return t}),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+p+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,a=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,function(){return r}),o=/\|?[ \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+o+"(?:"+a+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+a+o+")(?:"+a+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:s.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+a+")"+o+"$"),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(p){["url","bold","italic","strike","code-snippet"].forEach(function(x){p!==x&&(s.languages.markdown[p].inside.content.inside[x]=s.languages.markdown[x])})}),s.hooks.add("after-tokenize",function(p){if(p.language!=="markdown"&&p.language!=="md")return;function x(f){if(!(!f||typeof f=="string"))for(var g=0,b=f.length;g<b;g++){var y=f[g];if(y.type!=="code"){x(y.content);continue}var v=y.content[1],h=y.content[3];if(v&&h&&v.type==="code-language"&&h.type==="code-block"&&typeof v.content=="string"){var A=v.content.replace(/\b#/g,"sharp").replace(/\b\+\+/g,"pp");A=(/[a-z][\w-]*/i.exec(A)||[""])[0].toLowerCase();var D="language-"+A;h.alias?typeof h.alias=="string"?h.alias=[h.alias,D]:h.alias.push(D):h.alias=[D]}}}x(p.tokens)}),s.hooks.add("wrap",function(p){if(p.type==="code-block"){for(var x="",f=0,g=p.classes.length;f<g;f++){var b=p.classes[f],y=/language-(.+)/.exec(b);if(y){x=y[1];break}}var v=s.languages[x];if(v)p.content=s.highlight(l(p.content),v,x);else if(x&&x!=="none"&&s.plugins.autoloader){var h="md-"+new Date().valueOf()+"-"+Math.floor(Math.random()*1e16);p.attributes.id=h,s.plugins.autoloader.loadLanguages(x,function(){var A=document.getElementById(h);A&&(A.innerHTML=s.highlight(A.textContent,s.languages[x],x))})}}});var d=RegExp(s.languages.markup.tag.pattern.source,"gi"),u={amp:"&",lt:"<",gt:">",quot:'"'},c=String.fromCodePoint||String.fromCharCode;function l(p){var x=p.replace(d,"");return x=x.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi,function(f,g){if(g=g.toLowerCase(),g[0]==="#"){var b;return g[1]==="x"?b=parseInt(g.slice(2),16):b=Number(g.slice(1)),c(b)}else{var y=u[g];return y||f}}),x}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}),o=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function d(u,c){c=(c||"").replace(/m/g,"")+"m";var l=/([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g,function(){return r}).replace(/<<value>>/g,function(){return u});return RegExp(l,c)}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+"|"+o+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:d(/\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:d(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:d(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:d(o),lookbehind:!0,greedy:!0},number:{pattern:d(/[+-]?(?: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:/[;[\]()`,.]/};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"];var Zt={},Qt;function Dr(){return Qt||(Qt=1,(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)),Zt}Dr();var en={},tn;function $r(){return tn||(tn=1,(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)),en}$r();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;var nn={},sn;function Lr(){return sn||(sn=1,(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)),nn}Lr();(function(s){function t(n,r){return"___"+n.toUpperCase()+r+"___"}Object.defineProperties(s.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,a,o){if(n.language===r){var d=n.tokenStack=[];n.code=n.code.replace(a,function(u){if(typeof o=="function"&&!o(u))return u;for(var c=d.length,l;n.code.indexOf(l=t(r,c))!==-1;)++c;return d[c]=u,l}),n.grammar=s.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language!==r||!n.tokenStack)return;n.grammar=s.languages[r];var a=0,o=Object.keys(n.tokenStack);function d(u){for(var c=0;c<u.length&&!(a>=o.length);c++){var l=u[c];if(typeof l=="string"||l.content&&typeof l.content=="string"){var p=o[a],x=n.tokenStack[p],f=typeof l=="string"?l:l.content,g=t(r,p),b=f.indexOf(g);if(b>-1){++a;var y=f.substring(0,b),v=new s.Token(r,s.tokenize(x,n.grammar),"language-"+r,x),h=f.substring(b+g.length),A=[];y&&A.push.apply(A,d([y])),A.push(v),h&&A.push.apply(A,d([h])),typeof l=="string"?u.splice.apply(u,[c,1].concat(A)):l.content=A}}else l.content&&d(l.content)}return u}d(n.tokens)}}})})(Prism);var rn={},an;function Or(){return an||(an=1,(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}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,o=/[{}\[\](),:;]/;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:o};var d={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:s.languages.php},u=[{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:d}},{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:d}}];s.languages.insertBefore("php","variable",{string:u,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:u,"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:o}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),s.hooks.add("before-tokenize",function(c){if(/<\?/.test(c.code)){var l=/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;s.languages["markup-templating"].buildPlaceholders(c,"php",l)}}),s.hooks.add("after-tokenize",function(c){s.languages["markup-templating"].tokenizePlaceholders(c,"php")})})(Prism)),rn}Or();var on={},ln;function Fr(){return ln||(ln=1,(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)),on}Fr();const Pr=.4;function cn(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 o=s.codePointAt(n)>65535?2:1;t.push(s.slice(n,n+o)),n+=o}}return t}function zr(s,t){const n=Rr(cn(s),cn(t)),r=s.length+t.length;let a=0;const o=[],d=[];let u=0,c=0;for(const l of n){const p=l.value.reduce((x,f)=>x+f.length,0);l.removed?(a+=p,o.push({start:u,end:u+p}),u+=p):l.added?(a+=p,d.push({start:c,end:c+p}),c+=p):(u+=p,c+=p)}return r>0&&a/r>Pr?[[],[]]:[o,d]}function zn(s){const t=[];let n=null;for(const r of s.split(`
3
- `)){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 Bn(s){let t=s.oldStart,n=s.newStart;const r=[];for(const a of s.lines){const o=a[0]==="+"||a[0]==="-"?a[0]:" ",d=a.slice(1);let u=null,c=null;o==="-"?u=t++:(o==="+"||(u=t++),c=n++),r.push({marker:o,code:d,oldLine:u,newLine:c})}return r}const Br=i.memo(function({filePath:t,content:n,language:r}){if(!n&&!t)return null;const[a,o]=i.useState("unified"),[d,u]=i.useState(!1),c=Hr(t,r),l=(n==null?void 0:n.includes("@@"))||(n==null?void 0:n.includes("+++"))||(n==null?void 0:n.includes("---")),p=l?Ur(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"}),p&&e.jsxs("span",{className:"text-xs ml-2 flex gap-2",children:[e.jsxs("span",{className:"text-green-400",children:["+",p.additions]}),e.jsxs("span",{className:"text-red-400",children:["-",p.deletions]})]}),e.jsx("span",{className:"text-xs text-dark-muted ml-auto",children:c}),l&&e.jsxs("div",{className:"flex gap-0.5 ml-2",children:[e.jsx("button",{onClick:()=>o("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:()=>o("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:()=>u(!d),className:"text-xs text-dark-muted hover:text-dark-fg ml-1",children:d?"▶":"▼"})]}),!d&&e.jsxs("div",{className:"bg-dark-bg overflow-x-auto max-h-96 overflow-y-auto custom-scrollbar",children:[l?a==="unified"?Kr(n||"",c):Jr(n||"",c):e.jsx("pre",{className:"text-xs font-mono p-2 text-dark-fg whitespace-pre-wrap",children:n||"(no content)"}),p&&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:["+",p.additions," additions"]}),e.jsxs("span",{className:"text-red-400",children:["-",p.deletions," deletions"]}),e.jsxs("span",{children:[p.hunks," hunks"]})]})]})]})});function Hr(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 Ur(s){const t=s.split(`
4
- `);let n=0,r=0,a=0;for(const o of t)o.startsWith("@@")?a++:o.startsWith("+")&&!o.startsWith("+++")?n++:o.startsWith("-")&&!o.startsWith("---")&&r++;return{additions:n,deletions:r,hunks:a,filesChanged:1}}function Gr(s){const t=[],n=(a,o)=>{if(!o)return;const d=t[t.length-1];d&&d.type===a?d.text+=o:t.push({type:a,text:o})},r=(a,o)=>{if(typeof a=="string"){n(o,a);return}const d=a.type||o;if(typeof a.content=="string"){n(d,a.content);return}for(const u of a.content)r(u,d)};for(const a of s)r(a,"");return t}function Hn(s,t){const n=Kt.languages[t];if(!n)return[{type:"",text:s}];try{return Gr(Kt.tokenize(s,n))}catch{return[{type:"",text:s}]}}function qr(s,t){if(t.length===0)return s.map(a=>({...a,word:!1}));const n=[];let r=0;for(const a of s){const o=r,d=r+a.text.length;let u=0;for(const c of t){const l=Math.max(0,c.start-o),p=Math.min(a.text.length,c.end-o);p<=0||l>=a.text.length||(l>u&&n.push({type:a.type,text:a.text.slice(u,l),word:!1}),n.push({type:a.type,text:a.text.slice(l,p),word:!0}),u=p)}u<a.text.length&&n.push({type:a.type,text:a.text.slice(u),word:!1}),r=d}return n}function Wr({code:s,marker:t,lang:n,ranges:r}){const a=t==="-"?[{type:"",text:s}]:Hn(s,n),o=qr(a,r),d=t==="+"?"bg-green-900/30":t==="-"?"bg-red-900/30":"",u=t==="+"?"bg-green-700/60":"bg-red-700/60";return e.jsx("span",{className:`flex-1 whitespace-pre-wrap px-2 ${d}`,children:o.length===0?" ":o.map((c,l)=>e.jsx("span",{className:[c.type?`token ${c.type}`:"",c.word&&t!==" "?u:""].join(" "),children:c.text},l))})}function Kr(s,t){const n=zn(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 o of n){const d=Bn(o);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:["@@ -",o.oldStart,",",o.oldLines," +",o.newStart,",",o.newLines," @@"]})]},a++));const u=new Map;for(let c=0;c<d.length;){if(d[c].marker!=="-"){c++;continue}const l=c;for(;c<d.length&&d[c].marker==="-";)c++;const p=c;for(;c<d.length&&d[c].marker==="+";)c++;const x=Math.min(p-l,c-p);for(let f=0;f<x;f++){const[g,b]=zr(d[l+f].code,d[p+f].code);u.set(l+f,g),u.set(p+f,b)}}for(let c=0;c<d.length;c++){const l=d[c],p=l.marker==="+",x=l.marker==="-",f=p?"bg-green-900/30":x?"bg-red-900/30":"",g=l.marker==="-"?l.oldLine:l.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} ${p?"text-green-400":x?"text-red-400":"text-dark-muted"}`,children:[l.marker===" "?"":l.marker,g??""]}),e.jsx(Wr,{code:l.code,marker:l.marker,lang:t,ranges:u.get(c)??[]})]},a++))}}return e.jsx("div",{children:r})}function dn({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}]:Hn(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((o,d)=>e.jsx("span",{className:o.type?`token ${o.type}`:"",children:o.text},d))})}function Jr(s,t){const n=zn(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 o=Bn(a);r.push({left:`@@ -${a.oldStart},${a.oldLines} +${a.newStart},${a.newLines} @@`,right:"",type:"header"});let d=[],u=[];const c=()=>{(d.length>0||u.length>0)&&(Xr(r,d,u),d=[],u=[])};for(const l of o)l.marker==="-"?d.push(l.code):l.marker==="+"?u.push(l.code):(c(),r.push({left:l.code,right:l.code,type:"context"}));c()}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,o)=>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},o):e.jsxs("div",{className:"flex",style:{minHeight:"1.25rem"},children:[e.jsx(dn,{code:a.type==="replace"||a.type==="delete"?"- "+a.left:a.left,lang:t,kind:a.type==="replace"||a.type==="delete"?"remove":"context"}),e.jsx(dn,{code:a.type==="replace"||a.type==="add"?"+ "+a.right:a.right,lang:t,kind:a.type==="replace"||a.type==="add"?"add":"context"})]},o))]})}function Xr(s,t,n){const r=Math.max(t.length,n.length);for(let a=0;a<r;a++){const o=a<t.length?t[a]??"":"",d=a<n.length?n[a]??"":"";s.push({left:o,right:d,type:a<t.length&&a<n.length?"replace":a<t.length?"delete":"add"})}}function Oe(s,t){let n=null;if(typeof s=="string")try{const r=JSON.parse(s);r&&typeof r=="object"&&!Array.isArray(r)&&(n=r)}catch{return""}else s&&typeof s=="object"&&!Array.isArray(s)&&(n=s);if(!n)return"";for(const r of t){const a=n[r];if(typeof a=="string"&&a)return a}return""}function Ie(s){return typeof s=="string"?s:s&&typeof s=="object"?JSON.stringify(s,null,2):String(s??"")}function Vr(s){for(const t of s.split(`
5
- `)){const n=t.trim();if(n)return n}return""}function Te({label:s,tone:t="text-dark-muted",children:n}){return e.jsxs("div",{className:"px-2 py-1",children:[e.jsx("div",{className:`mb-0.5 text-[10px] ${t}`,children:s}),e.jsx("div",{className:"max-h-56 overflow-y-auto custom-scrollbar rounded border border-dark-border bg-dark-bg",children:n})]})}function Yr({toolCall:s}){const{t}=q(),n=Oe(s.args,["command","cmd","script"]),r=s.status==="error",a=Ie(s.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[n&&e.jsx(Te,{label:t("step.params"),children:e.jsxs("pre",{className:"tv-pre",children:[e.jsx("span",{className:"select-none text-accent-green",children:"$ "}),n]})}),s.result!==void 0&&s.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}function Zr({toolCall:s}){const t=Je(s.args),n=Ie(s.result),r=s.diff||(n&&(n.includes("@@")||n.includes("+++")||n.includes("---"))?n:void 0);return!r&&!n?e.jsx(Un,{toolCall:s}):e.jsx("div",{className:"px-2 py-1",children:e.jsx(Br,{filePath:t,content:r||n})})}function Qr({toolCall:s}){const{t}=q(),n=Je(s.args),r=s.status==="error",a=Ie(s.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[n&&e.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1 font-mono text-[10.5px] text-accent-blue",title:n,children:e.jsx("span",{className:"truncate",children:n})}),s.result!==void 0&&s.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}const un=20,ea=/\b(grep|search_contents)\b/i;function ta(s){return s===""?0:s.split(`
6
- `).length}function na({toolCall:s}){const{t}=q(),n=Oe(s.args,["pattern","query","regex"]),r=s.status==="error",a=s.result!==void 0&&s.result!==null,o=a?Ie(s.result):"",d=a?ta(o):0,u=ea.test(s.name),c=s.noTruncate!==!0&&u&&a&&!r&&d>un,[l,p]=i.useState(!1),x=c&&!l?o.split(`
7
- `).slice(0,un).join(`
8
- `)+`
9
- ${t("toolCall.linesTotal",{n:d})}`:o;return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[n&&e.jsx("div",{className:"flex items-center gap-1.5 px-2 pt-1 text-[10.5px] text-dark-muted",children:e.jsx("span",{className:"font-mono text-accent-blue",children:n})}),a&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:x})}),c&&e.jsx("div",{className:"px-2 pb-1",children:e.jsx("button",{type:"button","data-testid":"grep-result-toggle",onClick:()=>p(f=>!f),className:"text-[10px] text-accent-blue hover:underline",children:l?t("toolCall.collapse"):t("toolCall.expandAll",{n:d})})})]})}function sa({toolCall:s}){const{t}=q(),n=Oe(s.args,["url","query"]),r=s.status==="error",a=Ie(s.result);return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[n&&e.jsx("div",{className:"truncate px-2 pt-1 font-mono text-[10.5px] text-accent-blue",title:n,children:n}),s.result!==void 0&&s.result!==null&&e.jsx(Te,{label:t(r?"step.error":"step.result"),tone:r?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${r?"text-accent-red":""}`,children:a})})]})}function Un({toolCall:s}){const{t}=q(),n=s.status==="error",r=s.result!==void 0&&s.result!==null;return e.jsxs("div",{className:"space-y-0.5 py-0.5",children:[e.jsx(Te,{label:t("step.params"),children:e.jsx("pre",{className:"tv-pre",children:typeof s.args=="string"?s.args:JSON.stringify(s.args,null,2)})}),r&&e.jsx(Te,{label:t(n?"step.error":"step.result"),tone:n?"text-accent-red":"text-accent-green",children:e.jsx("pre",{className:`tv-pre ${n?"text-accent-red":""}`,children:Ie(s.result)})})]})}const ra=/(?:^|[_\W])(bash|powershell|pwsh|cmd|command|shell|exec|terminal)(?:[_\W]|$)/i,aa=/(?:^|[_\W])(read|cat|view|open)(?:[_\W]|$)/i,ia=/(?:^|[_\W])(grep|glob|search|find|list)(?:[_\W]|$)/i,oa=/(?:^|[_\W])(webfetch|websearch|fetch|web|http|curl|url)(?:[_\W]|$)/i;function _t(s){return _n(s)?"diff":ra.test(s)?"terminal":oa.test(s)?"web":ia.test(s)?"search":aa.test(s)?"read":"generic"}function la(s,t){const n=_t(s);let r="";switch(n){case"terminal":r=Oe(t,["command","cmd","script"]);break;case"diff":case"read":r=Je(t)??"";break;case"search":r=Oe(t,["pattern","query","regex","glob"]);break;case"web":r=Oe(t,["url","query"]);break;default:try{const o=typeof t=="string"?JSON.parse(t):t;r=o&&typeof o=="object"?JSON.stringify(o):String(t??"")}catch{r=typeof t=="string"?t:""}}const a=r.replace(/\s+/g," ").trim();return a.length>64?`${a.slice(0,63)}…`:a}function ca({toolCall:s}){switch(_t(s.name)){case"terminal":return e.jsx(Yr,{toolCall:s});case"diff":return e.jsx(Zr,{toolCall:s});case"read":return e.jsx(Qr,{toolCall:s});case"search":return e.jsx(na,{toolCall:s});case"web":return e.jsx(sa,{toolCall:s});default:return e.jsx(Un,{toolCall:s})}}const da={terminal:Ss,diff:js,read:nt,search:rt,web:Ns,generic:jn},pn=i.memo(function({toolCall:t,defaultCollapsed:n=!0}){const r=t.status==="running",a=Pn(r),o=t.result!==void 0&&t.result!==null,d=t.status==="error",u=_n(t.name),c=o?Ie(t.result):"",l=Je(t.args),p=la(t.name,t.args),x=d&&o?Vr(c):"",[f,g]=i.useState(n),b=t.duration??0,y=b>0?b>=60?`${Math.floor(b/60)}m ${b%60}s`:`${b}s`:"",v=r?"bg-accent-blue":d?"bg-accent-red":"bg-accent-green",h=r?"running":d?"error":"success",A=da[_t(t.name)];return e.jsxs("div",{className:"tl-row group rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-row",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>g(!f),"data-testid":"toolcall-row-header",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:r?e.jsx("span",{className:"inline-block h-3 w-3 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`tl-node ${v}`,"data-status":h})}),e.jsx("span",{className:`shrink-0 ${d?"text-accent-red":"text-dark-muted"}`,children:e.jsx(A,{size:12,"aria-hidden":"true"})}),e.jsx("span",{className:`font-medium text-[13px] shrink-0 truncate ${r?"text-shimmer":"text-dark-text"}`,children:t.name}),d&&x?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0 text-dark-muted/50",children:"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-[11px] text-accent-red",title:c,children:x})]}):p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"shrink-0 text-dark-muted/50",children:"·"}),e.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-dark-muted",title:p,children:p})]}):e.jsx("span",{className:"min-w-0 flex-1"}),u&&l&&!d&&e.jsxs("button",{type:"button",onClick:D=>{D.stopPropagation(),Mn(l)},className:`flex max-w-[16rem] shrink-0 items-center gap-1 truncate rounded-full border border-dark-border/70 px-2 py-0.5 text-[11px] font-mono text-accent-blue
10
- transition-colors hover:border-accent-blue/40 hover:bg-dark-hover`,title:l,children:[e.jsx(Sn,{size:10,className:"shrink-0"}),e.jsx("span",{className:"truncate",children:l})]}),r&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[11px] tabular-nums text-accent-blue",children:[e.jsx(Ae,{size:10}),e.jsx("span",{ref:a,children:"0s"})]}),!r&&y&&e.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-[10px] tabular-nums text-dark-muted",children:[e.jsx(Ae,{size:10}),e.jsx("span",{children:y})]}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${f?"opacity-0 group-hover:opacity-100":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!f&&e.jsx("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25",children:e.jsx(ca,{toolCall:t})})]})}),Mt=i.memo(function({toolCalls:t,label:n,defaultCollapsed:r=!0}){const{t:a}=q(),[o,d]=i.useState(r),u=i.useMemo(()=>{const y=new Map;for(const v of t)y.set(v.name,(y.get(v.name)??0)+1);return[...y.entries()].sort((v,h)=>h[1]-v[1])},[t]),c=i.useMemo(()=>t.some(y=>y.status==="running")?"running":t.some(y=>y.status==="error")?"error":"completed",[t]);if(t.length===0)return null;if(t.length===1){const y=t[0];return e.jsx(pn,{toolCall:y})}const p=u.slice(0,3),x=u.length-p.length,f=t.reduce((y,v)=>y+(v.duration??0),0),g=f>=60?`${Math.floor(f/60)}m ${f%60}s`:f>=1?`${f}s`:"",b=c==="running"?"bg-accent-blue":c==="error"?"bg-accent-red":"bg-accent-green";return e.jsxs("div",{className:"tl-row group rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"toolcall-group",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>d(!o),"data-testid":"toolcall-group-toggle",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:c==="running"?e.jsx("span",{className:"inline-block w-3 h-3 rounded-full border-2 border-accent-blue border-r-transparent animate-spin"}):e.jsx("span",{className:`tl-node ${b}`,"data-status":c==="error"?"error":"success"})}),e.jsx("span",{className:"text-dark-muted shrink-0",children:e.jsx(jn,{size:12,"aria-hidden":"true"})}),e.jsx("span",{className:"font-medium text-[13px] text-dark-text shrink-0","data-testid":"toolcall-group-count",children:a("activity.toolCallCount",{count:t.length})}),p.map(([y,v])=>e.jsxs("span",{className:"shrink-0 rounded-full bg-dark-muted/10 px-1.5 py-px text-[10.5px] font-mono text-dark-muted",children:[y," ×",v]},y)),x>0&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:a("activity.toolNamesMore",{count:x})}),g&&e.jsx("span",{className:"shrink-0 text-[10px] text-dark-muted tabular-nums",children:g}),e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${o?"opacity-0 group-hover:opacity-100":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!o&&e.jsxs("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25 space-y-0.5",children:[e.jsx("div",{className:"px-2 pt-0.5 text-[10px] uppercase tracking-wide text-dark-muted/60",children:n??a("activity.evidence")}),t.map(y=>e.jsx(pn,{toolCall:y},y.id))]})]})}),ua=i.memo(function({text:t,maxLength:n=300,preformatted:r=!1}){const{t:a}=q(),[o,d]=i.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:o?t:t.slice(0,n)+"..."}):e.jsx("div",{className:"text-dark-text leading-snug",children:o?t:t.slice(0,n)+"..."}),e.jsx("button",{onClick:c=>{c.stopPropagation(),d(!o)},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(o?"common.collapse_short":"common.expand")})]}):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})}),pa=i.memo(function({step:t,defaultCollapsed:n=!0}){const{t:r}=q(),[a,o]=i.useState(n),[d,u]=i.useState(!0),c=t.status==="running",l=Pn(c),p=t.description||t.thought||t.result||t.action||t.toolCalls&&t.toolCalls.length>0,x=t.duration??0,f=x>0?x>=60?`${Math.floor(x/60)}m ${x%60}s`:`${x}s`:"";return e.jsxs("div",{className:"tl-row rounded-lg transition-colors hover:bg-dark-surface/40","data-testid":"step-row",children:[e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>p&&o(!a),children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx("span",{className:"tl-node","data-status":t.status})}),e.jsx("span",{className:`text-[13px] truncate ${c?"text-shimmer":"text-dark-text"}`,children:t.title}),c&&e.jsxs("span",{className:"text-[11px] text-accent-blue shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{ref:l,children:"0s"})]}),!c&&f&&e.jsxs("span",{className:"text-[10px] text-dark-muted shrink-0 flex items-center gap-1 tabular-nums",children:[e.jsx(Ae,{size:10}),e.jsx("span",{children:f})]}),p&&e.jsx("span",{className:`ml-auto shrink-0 text-dark-muted/60 transition-transform ${a?"":"rotate-180"}`,children:e.jsx(we,{size:13})})]}),!a&&p&&e.jsxs("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25 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-purple/40 bg-accent-purple/5 rounded-r",children:[e.jsxs("div",{className:"flex items-center gap-1 text-accent-purple cursor-pointer hover:opacity-80 select-none",onClick:()=>u(!d),children:[d?e.jsx(je,{size:12}):e.jsx(we,{size:12}),e.jsx(Es,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.thinking")}),d&&e.jsxs("span",{className:"text-[10px] text-dark-muted truncate max-w-[200px]",children:[t.thought.slice(0,80).replace(/\n/g," "),"..."]})]}),!d&&e.jsx("div",{className:"text-dark-muted italic whitespace-pre-wrap leading-snug mt-1",children:t.thought.replace(/\n\s*\n+/g,`
11
- `)})]}),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.jsxs("div",{className:"flex items-center gap-1 text-accent-yellow mb-0.5",children:[e.jsx(Tt,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.action")})]}),e.jsx("div",{className:"text-dark-text leading-snug font-mono text-[11px]",children:t.action})]}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"px-1 py-0.5",children:e.jsx(Mt,{toolCalls:t.toolCalls})}),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.jsxs("div",{className:"flex items-center gap-1 text-accent-green mb-0.5",children:[e.jsx(Se,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:r("step.result")})]}),e.jsx(ua,{text:t.result,maxLength:500})]})]})]})}),xa=i.memo(function({steps:t,isGenerating:n}){const{t:r}=q(),[a,o]=i.useState(n),d=i.useRef(n);i.useEffect(()=>{d.current&&!n&&o(!1),d.current=n},[n]);const u=t.length,c=n||t.some(g=>g.status==="running"),l=[...t].reverse().find(g=>g.status==="running"),p=t[t.length-1],x=(l==null?void 0:l.title)||(p==null?void 0:p.title)||"",f=`${u} ${r(u===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:()=>o(!a),"data-testid":"turn-group-toggle",children:[e.jsx("span",{className:"shrink-0 text-dark-muted/60 transition-transform",children:a?e.jsx(we,{size:13}):e.jsx(je,{size:13})}),c?e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx("span",{className:"tl-node bg-accent-blue","data-status":"running"})}):e.jsx("span",{className:"w-2 h-2 shrink-0 rounded-full bg-accent-green"}),e.jsx("span",{className:`text-xs ${c?"text-shimmer":"text-dark-muted"}`,children:c?`${r("chat.runningSteps")} ${f}…`:f}),c&&x&&e.jsxs("span",{className:"min-w-0 flex-1 truncate pl-1 text-xs text-dark-muted/70",children:["· ",x]})]}),a&&e.jsx("div",{className:"ml-[15px] pb-1 pl-3 border-l border-dark-border/25 space-y-0.5",children:t.map(g=>e.jsx(pa,{step:g},g.id))})]})});function Gn(s){const t=s??"";let n=t,r=null,a=null;try{const o=JSON.parse(t);if(o&&typeof o=="object")if("payload"in o){a=typeof o.toolName=="string"?o.toolName:null;const d=o.payload;typeof d=="string"?n=d:d&&typeof d=="object"?(r=d,n=JSON.stringify(d,null,2)):n=""}else Array.isArray(o)||(r=o)}catch{n=t}if(!r&&n.length>0&&/^[\s]*[{[]/.test(n))try{const o=JSON.parse(n);o&&typeof o=="object"&&!Array.isArray(o)&&(r=o)}catch{}return{toolName:a,payloadText:n,args:r}}const Dt=/\b(bash|shell|exec|cmd|powershell|terminal)\b/i,qn=/write_file|write|save|create|upload|deploy|publish/i,Wn=/edit_file|edit|patch|apply|update|replace/i,Kn=/read_file|read|view|cat|open|list|dir\b/i,ma=/file_delete|delete|remove|unlink|\brm\b|\bdel\b/i,ha=/\b(glob|find|locate)\b/i,fa=/\b(grep|rg|search_contents)\b/i,ga=/web_search|search_web|browse/i,Jn=/web_fetch|fetch|http|curl|wget|download|request|api/i,ba=/git|commit|merge|rebase|push|checkout/i,ka=/install|uninstall|npm|pnpm|yarn|pip|cargo|gem|apt|brew|choco/i,$t=/send_message|send_file|message|notify|post/i;function Xn(s){const t=s.toLowerCase();return Dt.test(t)?"verbRunCommand":ga.test(t)?"verbSearchWeb":qn.test(t)?"verbWriteFile":Wn.test(t)?"verbEditFile":ma.test(t)?"verbDeleteFile":Kn.test(t)?"verbReadFile":fa.test(t)?"verbSearchContents":ha.test(t)?"verbFindFiles":Jn.test(t)?"verbFetchUrl":ba.test(t)?"verbGit":ka.test(t)?"verbInstall":$t.test(t)?"verbSendMessage":"verbRunTool"}function pt(s,t){const n=(s??"").replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t-1)}…`:n}function ya(s){if(!s)return null;for(const t of["file_path","filePath","path","file","target"]){const n=s[t];if(typeof n=="string"&&n.length>0)return n}return null}function Vn(s,t){const{payloadText:n,args:r}=Gn(t),a=s.toLowerCase();if(Dt.test(a))return"";const o=ya(r);if(o)return o;const d=n.match(/(?:file_path|path|file)["\s:=]+([^\s",}]+)/i);if(d!=null&&d[1])return d[1];if(Jn.test(a)&&typeof(r==null?void 0:r.url)=="string"&&r.url)return pt(r.url,48);if($t.test(a)){const u=typeof(r==null?void 0:r.text)=="string"?r.text:typeof(r==null?void 0:r.message)=="string"?r.message:n;return pt(u,48)}return pt(n,48)}function Yn(s,t){const{payloadText:n,args:r}=Gn(t),a=s.toLowerCase();if(Dt.test(a)){const o=typeof(r==null?void 0:r.command)=="string"?r.command:n;return o?{text:o,mono:!0}:null}if(qn.test(a)||Wn.test(a)){const o=typeof(r==null?void 0:r.content)=="string"?r.content:typeof(r==null?void 0:r.data)=="string"?r.data:"";if(o)return{text:o,mono:!0};if(r){const d=xn(r);if(d)return{text:d,mono:!0}}return n?{text:n,mono:!0}:null}if($t.test(a)){const o=typeof(r==null?void 0:r.text)=="string"?r.text:typeof(r==null?void 0:r.message)=="string"?r.message:n;return o?{text:o,mono:!1}:null}if(Kn.test(a))return null;if(r){const o=xn(r);if(o)return{text:o,mono:!0}}return n?{text:n,mono:!0}:null}function xn(s){return s?Object.entries(s).filter(([,t])=>t!=null).map(([t,n])=>{let r=typeof n=="string"?n:JSON.stringify(n);return r.length>96&&(r=`${r.slice(0,95)}…`),`${t}=${r.replace(/\n/g," ")}`}).join(" "):""}function Zn(s,t){const n=Ke(t);return n?{path:n,external:!0}:{key:"scopeLocal",external:!1}}function Qn({pre:s,obj:t}){return e.jsxs("span",{className:"min-w-0 text-sm text-dark-muted",children:[e.jsx("span",{children:s}),t&&e.jsx("b",{className:"font-semibold text-dark-text",children:t})]})}const xt=5,mt=420;function Ct({text:s,mono:t=!0}){const{t:n}=q("hook"),[r,a]=i.useState(!1),o=s.split(`
12
- `),d=o.length>xt||s.length>mt;let u=s;!r&&d&&(u=o.slice(0,xt).join(`
13
- `),u.length>mt&&(u=`${u.slice(0,mt).trimEnd()}…`));const c=r?n("showLess"):o.length>xt?n("showAllLines",{n:o.length}):n("showAll");return e.jsxs("div",{className:`rounded-lg border border-dark-border bg-dark-surface p-2.5 text-xs leading-relaxed break-all whitespace-pre-wrap ${t?"font-mono":""} text-dark-text`,children:[u,d&&e.jsx("button",{type:"button",onClick:()=>a(l=>!l),className:"mt-1 block text-[11px] text-accent-blue hover:underline",children:c})]})}const ht=15,wa=i.memo(function({approval:t,onResolved:n}){const{t:r}=q("hook"),[a,o]=i.useState(!1),[d,u]=i.useState(ht),c=i.useRef(null),l=t.status==="pending",{level:p,reasonKey:x}=Dn(t.toolName,t.askPayload),f=$n[p],g=Yn(t.toolName,t.askPayload),b=Zn(t.toolName,t.askPayload),y=Ke(t.askPayload)!==null;i.useEffect(()=>{if(l)return u(ht),c.current=setInterval(()=>{u(S=>S<=1?(c.current&&clearInterval(c.current),0):S-1)},1e3),()=>{c.current&&clearInterval(c.current)}},[l,t.approvalId]),i.useEffect(()=>{const S=(t.timeoutMs??15e3)>0;d===0&&l&&!a&&S&&v()},[d]);const v=i.useCallback(()=>{!l||a||(o(!0),c.current&&clearInterval(c.current),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"approved"))},[l,a,t.approvalId,n]),h=i.useCallback(()=>{!l||a||(o(!0),c.current&&clearInterval(c.current),ce.send({type:"hook_deny",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"denied"))},[l,a,t.approvalId,n]),A=i.useCallback(()=>{if(!l||a)return;o(!0),c.current&&clearInterval(c.current);const S=Et.getState(),L=Ke(t.askPayload);L?(S.addToSessionAllowList(t.toolName,L),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId,sessionAllow:!0})})):(S.addToSessionAllowList(t.toolName),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})})),n==null||n(t.approvalId,"approved")},[l,a,t.approvalId,t.toolName,t.askPayload,n]),D=i.useCallback(()=>{!l||a||(o(!0),c.current&&clearInterval(c.current),Et.getState().setAutoMode(!0),Ee.getState().setAuto(!0),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:t.approvalId})}),n==null||n(t.approvalId,"approved"))},[l,a,t.approvalId,n]);if(!l){const S=t.status==="approved";return e.jsx("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg text-xs ${S?"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:S?e.jsxs(e.Fragment,{children:[e.jsx(Se,{size:14}),e.jsxs("span",{children:[r("alreadyAllowed"),t.toolName]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14}),e.jsxs("span",{children:[r("alreadyDenied"),t.toolName]})]})})}const R=d/ht*100,I=d<=5,F=[{id:"allow",index:1,label:r("optionAllow"),hint:r("optionAllowHint"),action:v,kind:"primary"},{id:"allow_session",index:3,label:r("optionAllowAlways"),hint:y?r("optionAllowPathHint"):r("optionAllowAlwaysHint",{tool:t.toolName}),action:A,kind:"secondary"},{id:"auto_mode",index:4,label:r("optionAutoMode"),hint:r("optionAutoModeHint"),action:D,kind:"secondary"},{id:"deny",index:2,label:r("optionDeny"),hint:r("optionDenyHint"),action:h,kind:"danger"}],j={primary:"bg-accent-blue text-white hover:opacity-90 shadow-sm",secondary:"border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover",danger:"text-dark-muted hover:bg-red-500/10 hover:text-red-400"};return e.jsxs("div",{className:`bg-dark-bg border rounded-xl overflow-hidden ${b.external?"border-amber-500/40":f.border}`,children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 border-b ${f.bg} ${b.external?"border-amber-500/30":f.border}`,children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${rc.badge}",children:[f.icon," ",p]}),e.jsx("span",{className:"flex-none w-6 h-6 rounded-md bg-accent-blue/10 text-accent-blue inline-flex items-center justify-center",children:e.jsx(Nt,{size:13})}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(Qn,{pre:r(Xn(t.toolName)),obj:Vn(t.toolName,t.askPayload)})}),b.external&&b.path?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/30 shrink-0",title:b.path,children:[e.jsx(En,{size:10}),b.path.length>32?`${b.path.slice(0,31)}…`:b.path]}):e.jsx("span",{className:"text-[10px] text-dark-muted/60 shrink-0",children:r("scopeLocal")}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-1 shrink-0",children:[e.jsx(Ae,{size:11,className:I?"text-accent-red":"text-dark-muted"}),e.jsxs("span",{className:`text-[11px] font-mono ${I?"text-accent-red animate-pulse":"text-dark-muted"}`,children:[d,"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 ${I?"bg-accent-red":d<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${R}%`}})})]})]}),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}),e.jsx("span",{className:"text-[10px] text-dark-muted/50",children:r(x)})]}),g&&e.jsx(Ct,{text:g.text,mono:g.mono}),(p==="CRITICAL"||p==="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(Ce,{size:12}),e.jsx("span",{children:r(p==="CRITICAL"?"highRiskWarning":"mediumRiskConfirm")})]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:F.map(S=>e.jsxs("button",{onClick:S.action,disabled:a,className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs transition-colors disabled:opacity-50 ${j[S.kind]}`,children:[e.jsx("span",{className:`text-[9px] font-mono rounded px-0.5 ${S.kind==="primary"?"bg-white/20":"bg-dark-surface text-dark-muted"}`,children:S.index}),e.jsx("span",{children:S.label}),e.jsx("span",{className:`text-[10px] ${S.kind==="primary"?"text-white/70":"text-dark-muted/60"} hidden sm:inline`,children:S.hint})]},S.id))}),e.jsx("div",{className:"text-[10px] text-dark-muted/50 pt-0.5 border-t border-dark-border/50",children:r("clickToSelect")})]})]})}),Qe={xlsx:{icon:St},xls:{icon:St},csv:{icon:nt},docx:{icon:nt},text:{icon:Rt}};function mn(s){return!s&&s!==0?"—":s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/1024/1024).toFixed(2)} MB`}const va=i.memo(function({job:t}){var f,g;const{t:n}=q(),{stage:r}=t,a=i.useCallback(b=>{switch(b){case"xlsx":case"xls":return"Excel";case"csv":return"CSV";case"docx":return"Word";default:return n("fileJob.kindText")}},[n]),o=i.useCallback(b=>{xe.files.download(b).then(y=>{y.success||oe.error(y.error||n("fileJob.downloadFailed"))})},[n]),d=i.useMemo(()=>t.attachments||[],[t.attachments]),u=i.useMemo(()=>t.parsedFiles||[],[t.parsedFiles]),c=i.useMemo(()=>t.mapping||[],[t.mapping]),l=i.useMemo(()=>t.result||[],[t.result]),p=t.renderProgress??(r==="rendering"?0:100),x=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(jt,{size:15,className:"text-accent-green shrink-0"}):r==="error"?e.jsx(Ce,{size:15,className:"text-accent-red shrink-0"}):e.jsx(Fe,{size:15,className:"text-accent-blue animate-spin shrink-0"}),e.jsx("span",{className:"text-[13px] font-medium text-dark-text",children:Na(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:[d.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:d.map((b,y)=>{const h=(Qe[b.kind]||Qe.text).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(h,{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:b.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[mn(b.size)," · ",a(b.kind),b.role&&b.role!=="unknown"&&e.jsxs("span",{className:ne("ml-1",b.role==="data"?"text-accent-green":"text-accent-purple"),children:["· ",b.role==="data"?n("fileJob.roleData"):n("fileJob.roleTemplate")]})]})]})]},`${b.fileName}-${y}`)})}),r==="parsing"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-xs text-dark-muted",children:n("fileJob.parsing",{file:((f=d[0])==null?void 0:f.fileName)||((g=u[0])==null?void 0:g.fileName)||""})}),e.jsx(Wt,{value:x,size:"sm",showLabel:!0})]}),u.length>0&&r!=="error"&&e.jsxs("div",{className:"space-y-1.5",children:[u.map(b=>e.jsxs("div",{className:"flex items-center gap-2 text-xs text-dark-muted",children:[e.jsx(jt,{size:13,className:"text-accent-green shrink-0"}),e.jsx("span",{className:"truncate",children:b.fileName}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:n("fileJob.parsedSummary",{rows:b.rowCount,fields:b.fields.length})})]},b.fileName)),u[0]&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[u[0].fields.slice(0,12).map(b=>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:b},b)),u[0].fields.length>12&&e.jsxs("span",{className:"text-[10px] text-dark-muted/60",children:["+",u[0].fields.length-12]})]})]}),c.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:c.slice(0,8).map(b=>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:"{{"+b.placeholder+"}}"}),e.jsx("td",{className:"px-2 py-1.5 text-dark-muted",children:e.jsx(As,{size:11})}),e.jsx("td",{className:"px-2.5 py-1.5 font-mono text-accent-blue",children:b.field})]},b.placeholder))})]})}),c.length>8&&e.jsx("div",{className:"text-[10px] text-dark-muted/60",children:n("fileJob.mappingMore",{n:c.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(Wt,{value:p,size:"sm",variant:"warning",showLabel:!0})]}),l.length>0&&r==="complete"&&e.jsx("div",{className:"space-y-1.5",children:l.map(b=>{const v=(Qe[b.format]||Qe.text).icon,h=b.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(v,{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:b.fileName}),e.jsxs("div",{className:"text-[10px] text-dark-muted",children:[mn(b.size)," · ",n("fileJob.rowsDone",{done:b.successCount,total:b.rowCount}),h&&e.jsxs("span",{className:"text-accent-red",children:[" · ",n("fileJob.rowsFailed",{n:b.failedRows.length})]})]})]}),e.jsxs("button",{onClick:()=>Mn(b.path),className:"flex items-center gap-1 rounded-md bg-dark-surface border border-dark-border text-dark-muted px-2 py-1 text-[11px] hover:bg-dark-hover hover:text-dark-text transition-colors",title:n("chat.previewInPanel"),children:[e.jsx(Sn,{size:12}),n("chat.previewInPanel")]}),e.jsxs("button",{onClick:()=>o(b.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(Cs,{size:12}),n("fileJob.download")]})]}),h&&e.jsxs("div",{className:"mt-1.5 space-y-0.5 border-t border-dark-border/50 pt-1.5",children:[b.failedRows.slice(0,3).map(A=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-red",children:[e.jsx(Ts,{size:10,className:"shrink-0"}),e.jsxs("span",{children:["#",A.index+1]}),e.jsx("span",{className:"truncate",children:A.error})]},A.index)),b.failedRows.length>3&&e.jsx("div",{className:"text-[10px] text-dark-muted/70",children:n("fileJob.moreRows",{n:b.failedRows.length-3})})]})]},b.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(Ce,{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 Na(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 hn={auth:{icon:Is,color:"text-accent-red"},rate_limit:{icon:Ut,color:"text-accent-yellow"},timeout:{icon:Ut,color:"text-accent-yellow"},network:{icon:Rs,color:"text-accent-yellow"},model:{icon:An,color:"text-accent-red"},tool:{icon:Ce,color:"text-accent-yellow"},unknown:{icon:Ce,color:"text-accent-red"}},ja=i.memo(function({error:t,onRetry:n}){const{t:r}=q(),[a,o]=i.useState(!1),d=hn[t.category]||hn.unknown,u=d.icon,c=()=>{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(u,{size:18,className:ne("shrink-0 mt-0.5",d.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(We,{size:11}),r("errorCard.retry")]}),t.category==="auth"&&e.jsxs("button",{onClick:c,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(_s,{size:11}),r("errorCard.modelSettings")]}),t.detail&&e.jsxs("button",{onClick:()=>o(l=>!l),className:"flex items-center gap-0.5 text-[11px] text-dark-muted hover:text-dark-text transition-colors",children:[e.jsx(we,{size:11,className:ne("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 Sa(s){const t=s.replace(/\\/g,"/");return t.slice(t.lastIndexOf("/")+1)||s}function Ea({status:s}){switch(s){case"completed":return e.jsx(Se,{size:13,className:"shrink-0 text-accent-green","data-testid":"activity-status-completed"});case"failed":return e.jsx(Re,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-failed"});case"running":return e.jsx("span",{className:"tl-node bg-accent-blue","data-status":"running","data-testid":"activity-status-running"});case"waiting_user":return e.jsx(Ds,{size:13,className:"shrink-0 text-accent-yellow","data-testid":"activity-status-waiting"});case"blocked":return e.jsx(Ms,{size:13,className:"shrink-0 text-accent-red","data-testid":"activity-status-blocked"});case"paused":return e.jsx(Cn,{size:13,className:"shrink-0 text-dark-300","data-testid":"activity-status-paused"});default:return e.jsx("span",{className:"inline-block w-2 h-2 shrink-0 rounded-full bg-dark-border"})}}const Aa=i.memo(function({activity:t,toolCalls:n,onAnswer:r}){const{t:a}=q(),[o,d]=i.useState(t.status==="running"),u=i.useRef(t.status);i.useEffect(()=>{(u.current==="running"||u.current==="waiting_user"||u.current==="paused")&&(t.status==="completed"||t.status==="failed")&&d(!1),u.current=t.status},[t.status]);const c=i.useMemo(()=>{for(const b of n){const y=Je(b.args);if(y)return y}},[n]),l=t.endedAt?t.endedAt-t.startedAt:Date.now()-t.startedAt,p=l>=6e4?`${Math.round(l/6e4)}m`:l>=1500?`${Math.round(l/1e3)}s`:"",x=t.status==="waiting_user",f=t.status==="blocked",g=t.status==="paused";return e.jsxs("div",{className:`tl-row rounded-lg transition-colors ${x?"border border-accent-yellow/25 bg-accent-yellow/5":f?"border border-accent-red/25 bg-accent-red/5":"hover:bg-dark-surface/40"}`,"data-testid":"activity-row",children:[!x&&!f&&e.jsx("span",{className:"tl-line","aria-hidden":"true"}),e.jsxs("div",{className:"relative flex items-center gap-2 px-2 py-1 cursor-pointer select-none",onClick:()=>d(b=>!b),"data-testid":"activity-row-toggle",children:[e.jsx("span",{className:"flex h-3 w-3 shrink-0 items-center justify-center",children:e.jsx(Ea,{status:t.status})}),e.jsx("span",{className:`min-w-0 text-[13px] font-medium truncate ${t.status==="running"?"text-shimmer":"text-dark-text"}`,children:t.title}),t.phase!=="analysis"&&e.jsx("span",{className:"status-pill","data-tone":"neutral","data-testid":"activity-phase",children:a(`activity.phase.${t.phase}`)}),c&&e.jsx("span",{className:"shrink-0 max-w-[14rem] truncate rounded-full border border-dark-border/70 px-2 py-0.5 font-mono text-[10.5px] text-accent-blue",children:Sa(c)}),n.length>1&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:a("activity.evidenceMore",{count:n.length-1})}),p&&e.jsx("span",{className:"shrink-0 text-[10.5px] text-dark-muted",children:p}),x&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-accent-yellow",children:a("activity.waitingUser")}),f&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-accent-red",title:t.blockedReason?a("activity.blocked",{reason:t.blockedReason}):void 0,children:a("activity.blocked",{reason:t.blockedReason??""})}),g&&e.jsx("span",{className:"ml-auto shrink-0 text-[11px] text-dark-300",children:a("activity.paused")}),x&&r&&e.jsx("button",{type:"button",onClick:b=>{b.stopPropagation(),r(t.id)},className:"shrink-0 rounded border border-accent-yellow/40 px-1.5 py-0.5 text-[10.5px] text-accent-yellow hover:bg-accent-yellow/10",children:a("activity.viewAndAnswer")}),!x&&n.length>0&&e.jsx(we,{size:12,className:`ml-auto shrink-0 text-dark-muted transition-transform ${o?"rotate-180":""}`})]}),o&&n.length>0&&e.jsx("div",{className:"relative ml-[15px] pb-1 pl-3 border-l border-dark-border/25",children:e.jsx(Mt,{toolCalls:n})})]})});function Ca(s){for(const t of s.split(`
14
- `)){const n=t.trim();if(n)return n}return""}function Ta(s){var n;const t=s.split(`
15
- `);for(let r=t.length-1;r>=0;r--){const a=(n=t[r])==null?void 0:n.trim();if(a)return a}return""}function es({index:s,text:t,isStreaming:n,collapsed:r,onToggle:a}){const{t:o}=q(),d=r?n?Ta(t):Ca(t):"";return e.jsxs("div",{children:[e.jsxs("button",{className:"flex w-full cursor-pointer select-none items-center gap-1.5 py-0.5 text-left text-xs",onClick:()=>a(s),"data-testid":"thinking-toggle",children:[e.jsx(je,{size:12,className:`shrink-0 text-dark-muted transition-transform ${r?"":"rotate-90"}`}),e.jsx("span",{className:`shrink-0 ${n?"text-shimmer":"text-dark-muted"}`,children:n?`${o("chat.thinking")}…`:o("chat.thoughtProcess")}),d&&e.jsx("span",{"data-testid":"thinking-summary",className:"min-w-0 flex-1 truncate text-dark-muted/60",title:d,children:d})]}),!r&&e.jsx("div",{"data-testid":"thinking-body",className:"mt-1 whitespace-pre-wrap break-words border-l border-dark-border/25 pl-3 text-xs text-dark-muted",children:t.replace(/\n{3,}/g,`
16
-
17
- `)})]})}const Ra=i.memo(function({message:t,sessionId:n,isGenerating:r,onAnswer:a}){const o=or(v=>lr(v,n,t.id)),d=i.useMemo(()=>o.length>0?o:!t.toolCalls||t.toolCalls.length===0?[]:cr(n??"",t),[o,t,n]),u=i.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[c,l]=i.useState({}),p=!r||!!t.content;i.useEffect(()=>{p&&l(v=>{const h={...v};for(const A of u)h[A.index]=!0;return h})},[p,u]);const x=i.useMemo(()=>{let v=Number.MIN_SAFE_INTEGER;for(const h of u)v=Math.max(v,h.index);for(const h of t.toolCalls??[])v=Math.max(v,h.index??Number.MIN_SAFE_INTEGER);return v},[u,t.toolCalls]),f=v=>r&&!t.content&&v===x,g=v=>{const h=c[v]??(!!t.content||!r);l(A=>({...A,[v]:!h}))},b=i.useMemo(()=>{const v=[];for(const h of u)v.push({key:`thinking-${h.index}`,index:h.index,kind:"thinking",block:h});for(const h of d)v.push({key:`activity-${h.id}`,index:h.blockRange[0],kind:"activity",activity:h});return v.sort((h,A)=>h.index-A.index),v},[u,d]),y=i.useMemo(()=>{const v={},h=t.toolCalls??[];for(const A of d)v[A.id]=A.toolCallIds.map(D=>h.find(R=>R.id===D)).filter(D=>!!D);return v},[d,t.toolCalls]);return b.length===0?null:e.jsx("div",{className:"mb-1 space-y-0.5","data-testid":"agent-activity-feed",children:b.map(v=>v.kind==="thinking"&&v.block?e.jsx(es,{index:v.block.index,text:v.block.text,isStreaming:f(v.block.index),collapsed:c[v.block.index]??(!!t.content||!r),onToggle:g},v.key):v.activity?e.jsx(Aa,{activity:v.activity,toolCalls:y[v.activity.id]??[],onAnswer:a},v.key):null)})}),ts=5,Ia=30,_a=["让我","我先","我现在","我发现","我注意到","我决定","我重新","我重试","我继续","我现在要","让我现在","let me","let's","i should","i need","i will","i'll","i am","i notice","i see","i try","i retry","i think","i continue","i re-","now i","first i","first, i"];function Ma(s){const t=s.charCodeAt(0);return t>=19968&&t<=40959}function Da(s){let t="",n=!1;for(const r of s)r===" "||r===" "||r===" "?(n||(t+=" "),n=!0):(t+=r,n=!1);return t}function $a(s){return s>=97&&s<=122||s>=48&&s<=57||s===95}function ns(s){const t=Da(s.trimStart().toLowerCase());return _a.some(n=>{if(!t.startsWith(n))return!1;const r=t[n.length];return r===void 0||Ma(n)||n==="i re-"?!0:!$a(r.charCodeAt(0))})}function La(s){if(!s)return!1;const t=s.split(/\r?\n/).slice(0,Ia);let n=0;for(const r of t)if(r.trim())if(ns(r)){if(n++,n>=ts)return!0}else return!1;return!1}function Oa(s,t){if(!s)return{body:s||"",absorbed:""};if(!La(s))return{body:s,absorbed:""};const n=s.split(/\r?\n/);let r=0,a=0;for(const d of n){if(!d.trim()){a++;continue}if(ns(d)){r++,a++;continue}break}if(r<ts)return{body:s,absorbed:""};let o=0;for(const d of n.slice(0,a)){if(o+=d.length,o>=s.length)break;s.startsWith(`\r
18
- `,o)?o+=2:(s[o]===`
19
- `||s[o]==="\r")&&(o+=1)}return{body:s.slice(o),absorbed:s.slice(0,o)}}function ft({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 fn({message:s,sessionId:t,onRegenerate:n,onDeleteMessage:r}){const{t:a}=q(),[o,d]=i.useState(!1),u=i.useRef(null);i.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]);const c=i.useCallback(async()=>{try{await navigator.clipboard.writeText(s.content||s.thinking||""),d(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>d(!1),2e3)}catch(l){console.error("Failed to copy message:",l)}},[s.content,s.thinking]);return t?e.jsxs(e.Fragment,{children:[e.jsx(ft,{onClick:c,title:a("chat.copyMessage"),children:o?e.jsx(Se,{size:12,className:"text-accent-green"}):e.jsx(Ls,{size:12})}),s.type==="assistant"&&n&&e.jsx(ft,{onClick:()=>n(s.id),title:a("chat.regenerate"),children:e.jsx(We,{size:12})}),r&&e.jsx(ft,{onClick:()=>r(s.id),title:a("chat.deleteMessage"),danger:!0,children:e.jsx(Os,{size:12})})]}):null}function gn({ts:s,children:t}){const{i18n:n}=q(),r=n.language==="en"?"en-US":"zh-CN";return e.jsxs("div",{className:"absolute bottom-2 left-3 select-none z-10 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",children:[e.jsx("span",{className:"pr-1 text-[10px] text-dark-muted/50",children:new Date(s).toLocaleTimeString(r,{hour:"2-digit",minute:"2-digit"})}),t]})}function Fa(s,t){const n=[];for(const r of s)n.push({key:`thinking-${r.index}`,index:r.index,kind:"thinking",block:r});for(const r of t??[])n.push({key:`tool-${r.id}`,index:r.index??Number.MAX_SAFE_INTEGER,kind:"tool",toolCall:r});return n.sort((r,a)=>r.index-a.index),n}const Pa=i.memo(function({message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a}){var R,I,F;const{t:o}=q(),d=st(j=>j.developerView),u=be(j=>{var L;if(!n||!j.generatingSessions.includes(n))return!1;const S=j.messagesBySession[n];return S?((L=S[S.length-1])==null?void 0:L.id)===t.id:!1}),c=i.useMemo(()=>t.thinkingBlocks&&t.thinkingBlocks.length>0?t.thinkingBlocks:t.thinking?[{index:Number.MIN_SAFE_INTEGER,text:t.thinking}]:[],[t.thinkingBlocks,t.thinking]),[l,p]=i.useState({}),x=!u||!!t.content;i.useEffect(()=>{x&&p(j=>{const S={...j};for(const L of c)S[L.index]=!0;return S})},[x,c]);const f=i.useMemo(()=>Fa(c,t.toolCalls),[c,t.toolCalls]),g=i.useMemo(()=>{var L;if(!t.content)return"";if(!(!!t.thinking||(((L=t.thinkingBlocks)==null?void 0:L.length)??0)>0))return t.content;const{body:S}=Oa(t.content);return S||t.content},[t.content,t.thinking,t.thinkingBlocks]),b=i.useMemo(()=>{const j=[];for(const S of f)if(S.kind==="thinking"&&S.block)j.push({key:S.key,kind:"thinking",block:S.block});else if(S.kind==="tool"&&S.toolCall){const L=j[j.length-1];L&&L.kind==="tools"?L.toolCalls.push(S.toolCall):j.push({key:`tools-${S.key}`,kind:"tools",toolCalls:[S.toolCall]})}return j},[f]),y=i.useMemo(()=>{let j=Number.MIN_SAFE_INTEGER;for(const S of c)j=Math.max(j,S.index);for(const S of t.toolCalls??[])j=Math.max(j,S.index??Number.MIN_SAFE_INTEGER);return j},[c,t.toolCalls]),v=i.useCallback(j=>{const S=l[j]??(!!t.content||!u);p(L=>({...L,[j]:!S}))},[u,t.content,l]),h=t.type==="user",A=t.type==="system",D=i.useCallback((j,S)=>{if(!n)return;const C=be.getState().getMessages(n),P=C.findIndex(K=>K.id===t.id);if(P===-1)return;const W=C[P];if(!W)return;const Y={...W,hookApproval:W.hookApproval?{...W.hookApproval,status:S}:void 0},H=[...C];H[P]=Y,be.setState({messagesBySession:{...be.getState().messagesBySession,[n]:H}})},[n,t.id]);return t.deleted?null:h?e.jsxs("div",{className:"chat-msg","data-role":"user",children:[e.jsx("div",{className:"chat-avatar","aria-hidden":!0,children:e.jsx($s,{size:14,strokeWidth:2.4})}),e.jsx("div",{className:"max-w-[78%] flex flex-col",children:e.jsxs("div",{className:"group relative inline-block self-end rounded-2xl border border-dark-border/40 bg-dark-surface px-4 py-2.5 text-dark-text shadow-sm",style:{borderBottomRightRadius:"0.375rem"},children:[e.jsx(gn,{ts:t.timestamp,children:e.jsx(fn,{message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a})}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed text-[14.5px]",children:(R=t.content)==null?void 0:R.replace(/\n{3,}/g,`
20
-
21
- `)})]})})]}):A?e.jsx("div",{className:"chat-msg","data-role":"system",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})}):e.jsxs("div",{className:"chat-msg","data-role":"assistant",children:[e.jsx("div",{className:"chat-avatar","aria-hidden":!0,children:e.jsx(An,{size:14,strokeWidth:2.4})}),e.jsxs("div",{className:"chat-card group",children:[e.jsx(gn,{ts:t.timestamp,children:e.jsx(fn,{message:t,sessionId:n,onRegenerate:r,onDeleteMessage:a})}),t.steps&&t.steps.length>0&&!t.hookApproval?e.jsx(xa,{steps:t.steps,isGenerating:u}):d?e.jsx(e.Fragment,{children:b.length>0&&!t.hookApproval&&e.jsx("div",{className:"mb-2 space-y-1",children:b.map(j=>j.kind==="thinking"?e.jsx(es,{index:j.block.index,text:j.block.text,isStreaming:u&&!t.content&&j.block.index===y,collapsed:l[j.block.index]??(!!t.content||!u),onToggle:v},j.key):e.jsx(Mt,{toolCalls:j.toolCalls},j.key))})}):e.jsx(Ra,{message:t,sessionId:n,isGenerating:u}),t.content?e.jsx("div",{className:"leading-relaxed",children:e.jsx(dr,{content:g.replace(/\n{3,}/g,`
22
-
23
- `)})}):c.length===0&&!t.hookApproval&&((I=t.steps)!=null&&I.length)?null:c.length===0&&!t.hookApproval&&!((F=t.steps)!=null&&F.length)&&u?e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-dark-muted","data-testid":"thinking-typing",children:[e.jsxs("span",{className:"chat-typing-dots",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsxs("span",{children:[o("chat.thinking"),"…"]})]}):null,t.summary&&!u&&e.jsx("div",{className:"mt-1.5 text-[11px] text-dark-muted/70","data-testid":"turn-summary",children:ur(t.summary)}),t.fileJob&&e.jsx("div",{className:"mt-3",children:e.jsx(va,{job:t.fileJob})}),t.errorCard&&e.jsx("div",{className:"mt-3",children:e.jsx(ja,{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(wa,{approval:t.hookApproval,onResolved:D})})]})]})});function za(s,t=28){const n=s.replace(/\s+/g," ").trim();return n.length>t?`${n.slice(0,t)}…`:n}const Ba="cubic-bezier(0.34, 1.56, 0.64, 1)",Ha=i.memo(function({items:t,activeId:n,onJump:r}){const{t:a}=q(),[o,d]=i.useState(!1),u=i.useRef(null),c=i.useCallback(()=>{u.current&&window.clearTimeout(u.current),d(!0)},[]),l=i.useCallback(()=>{u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>d(!1),180)},[]);return t.length===0?null:e.jsx("div",{role:"list","aria-label":a("chat.messageRail"),className:"pointer-events-none absolute right-4 top-1/2 z-30 hidden -translate-y-1/2 md:block",children:e.jsxs("div",{onMouseEnter:c,onMouseLeave:l,"data-testid":"rail-trigger",className:"pointer-events-auto relative flex items-center py-3",children:[e.jsxs("div",{"aria-hidden":!o,inert:!o,"data-testid":"rail-panel",className:`absolute right-full top-1/2 flex w-72 -translate-y-1/2 origin-right flex-col overflow-hidden rounded-xl border border-dark-border/70 bg-dark-bg/90 shadow-xl shadow-black/10 backdrop-blur-xl transition-all duration-300 ${o?"translate-x-0 scale-100 opacity-100":"pointer-events-none translate-x-4 scale-95 opacity-0"}`,style:{transitionTimingFunction:o?Ba:"ease"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-dark-border/60 px-3 py-2",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-[0.08em] text-dark-muted",children:[e.jsx(Fs,{size:12,className:"text-accent-blue","aria-hidden":"true"}),a("chat.messageIndex")]}),e.jsx("span",{className:"rounded-full bg-dark-hover px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-dark-muted",children:t.length})]}),e.jsx("div",{className:"max-h-[55vh] overflow-y-auto p-1.5 custom-scrollbar",children:t.map((p,x)=>{const f=p.id===n;return e.jsxs("button",{type:"button",role:"listitem",onClick:()=>r(p.id),title:p.content,"aria-current":f?"true":void 0,tabIndex:o?0:-1,className:`group/item flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-all duration-200 ${o?"translate-x-0 opacity-100":"translate-x-2 opacity-0"} ${f?"bg-accent-blue/10":"hover:bg-dark-hover"}`,style:{transitionDelay:o?`${Math.min(x*24,264)}ms`:"0ms"},children:[e.jsx("span",{className:`mt-px flex h-4 w-4 shrink-0 items-center justify-center rounded text-[10px] font-semibold tabular-nums transition-colors duration-200 ${f?"bg-accent-blue text-white":"bg-dark-hover text-dark-muted group-hover/item:bg-dark-border/80 group-hover/item:text-dark-text"}`,children:x+1}),e.jsx("span",{className:"min-w-0 flex-1",children:e.jsx("span",{"data-testid":"rail-entry-content",className:`block break-words text-xs leading-snug line-clamp-2 group-hover/item:line-clamp-none transition-colors duration-200 ${f?"font-medium text-accent-blue":"text-dark-text/90"}`,children:p.content})}),e.jsx(je,{size:12,"aria-hidden":"true",className:"mt-0.5 shrink-0 -translate-x-1 text-dark-muted/50 opacity-0 transition-all duration-200 group-hover/item:translate-x-0 group-hover/item:opacity-100"})]},p.id)})})]}),e.jsx("div",{"data-testid":"rail-dots",className:"flex flex-col items-end gap-1",children:t.map((p,x)=>{const f=za(p.content),g=p.id===n;return e.jsx("button",{type:"button",role:"listitem",onClick:()=>r(p.id),title:p.content,"aria-label":`${x+1}. ${f}`,"aria-current":g?"true":void 0,className:"group/dot pointer-events-auto flex h-6 w-5 items-center justify-center rounded-full transition-colors duration-200 hover:bg-dark-surface/80",children:e.jsx("span",{className:g?"h-2 w-2 rounded-full bg-accent-blue ring-2 ring-accent-blue/25 transition-all duration-300 ease-out group-hover/dot:scale-125":"h-1.5 w-1.5 rounded-full bg-dark-muted/35 transition-all duration-300 ease-out group-hover/dot:scale-150 group-hover/dot:bg-dark-muted"})},p.id)})})]})})}),Ua=i.lazy(()=>pr(()=>import("./ThreeScene-CukEnQe-.js"),__vite__mapDeps([0,1,2,3])));function Ga(){try{const s=document.createElement("canvas");return!!(s.getContext("webgl2")??s.getContext("webgl"))}catch{return!1}}function qa(){return i.useMemo(Ga,[])?e.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 overflow-hidden [&_.threeui-background]:bg-transparent",children:[e.jsx(i.Suspense,{fallback:null,children:e.jsx(Ua,{})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-black/30 via-transparent to-black/40"})]}):null}const gt=24;function Wa({label:s}){const t=i.useRef(Date.now()),n=i.useRef(null),[r,a]=i.useState(!1);return i.useEffect(()=>{const o=window.setTimeout(()=>a(!0),15e3);return()=>window.clearTimeout(o)},[]),i.useEffect(()=>{if(!r)return;const o=()=>{const u=n.current;if(!u)return;const c=Math.floor((Date.now()-t.current)/1e3);u.textContent=c>=60?`${Math.floor(c/60)}m ${c%60}s`:`${c}s`};o();const d=window.setInterval(o,1e3);return()=>window.clearInterval(d)},[r]),e.jsxs("div",{className:"mx-auto flex max-w-[46rem] items-center gap-2 px-4 py-3 text-xs text-dark-muted sm:px-6",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.2s"}}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-accent-blue animate-blink",style:{animationDelay:"0.4s"}})]}),e.jsx("span",{className:"text-shimmer",children:s}),r&&e.jsxs("span",{className:"flex items-center gap-1 tabular-nums text-dark-muted/70",children:[e.jsx(Ae,{size:10}),e.jsx("span",{ref:n,children:"15s"})]})]})}const Ka=i.memo(function({messages:t,isGenerating:n,sessionId:r,onSendSuggestion:a,onRegenerate:o,onDeleteMessage:d}){const{t:u}=q(),c=i.useRef(null),l=i.useRef(new Map),[p,x]=i.useState(!0),[f,g]=i.useState(null),[b,y]=i.useState(null),[v,h]=i.useState(0),A=i.useRef(null),D=i.useRef(!1),R=i.useRef(null),I=i.useRef(n);I.current=n;const F=i.useMemo(()=>t.filter(N=>!N.deleted),[t]),j=i.useMemo(()=>{if(!n)return!1;const N=F[F.length-1];return!(!N||N.type!=="assistant"||N.content||N.steps&&N.steps.length>0)},[n,F]),S=i.useMemo(()=>F.filter(N=>N.type==="user").map(N=>({id:N.id,content:N.content})),[F]),L=i.useMemo(()=>S.map(N=>N.id),[S]),C=i.useCallback(N=>{if(N){const $=N.dataset.mid;$&&l.current.set($,N)}},[]);i.useEffect(()=>{const N=new Set(L);for(const $ of l.current.keys())N.has($)||l.current.delete($)},[L]);const P=i.useCallback(()=>{const N=c.current;if(!N||L.length===0){g(null);return}const $=N.getBoundingClientRect(),te=$.top+$.height*.35;let X=L[0]??null;for(const ae of L){const J=l.current.get(ae);if(!(!J||!J.isConnected))if(J.getBoundingClientRect().top<=te)X=ae;else break}N.scrollHeight-N.scrollTop-N.clientHeight<gt&&(X=L[L.length-1]??X),g(X)},[L]),W=i.useCallback(()=>{const N=c.current;if(!N)return;const $=N.scrollHeight-N.scrollTop-N.clientHeight;D.current?$>=gt&&(D.current=!1):x($<gt),P()},[P]);i.useEffect(()=>{P()},[t,P]);const Y=i.useCallback(N=>{const $=c.current,te=l.current.get(N);if(!$||!te||!te.isConnected)return;x(!1),y(N),h(fe=>fe+1),A.current&&window.clearTimeout(A.current),A.current=window.setTimeout(()=>y(null),1600);const X=$.getBoundingClientRect(),ae=te.getBoundingClientRect(),J=$.scrollTop+(ae.top-X.top)-$.clientHeight/2+ae.height/2;R.current&&window.clearTimeout(R.current),D.current=!0,$.scrollTo({top:Math.max(0,J),behavior:"smooth"});const he=()=>{D.current=!1};"onscrollend"in $&&$.addEventListener("scrollend",he,{once:!0}),R.current=window.setTimeout(()=>{D.current=!1},1500)},[]);i.useEffect(()=>()=>{A.current&&window.clearTimeout(A.current),R.current&&window.clearTimeout(R.current)},[]);const H=i.useCallback(()=>{R.current&&window.clearTimeout(R.current),D.current=!1;const N=c.current;N&&(N.scrollTop=N.scrollHeight)},[]),K=i.useCallback(()=>{R.current&&window.clearTimeout(R.current),D.current=!1,x(!0);const N=c.current;N&&N.scrollTo({top:N.scrollHeight,behavior:"smooth"})},[]);i.useEffect(()=>{n&&(x(!0),H())},[n,H]);const ee=i.useMemo(()=>{var $,te,X;const N=F[F.length-1];return`${F.length}:${(N==null?void 0:N.id)??""}:${(($=N==null?void 0:N.content)==null?void 0:$.length)??0}:${((te=N==null?void 0:N.toolCalls)==null?void 0:te.length)??0}:${((X=N==null?void 0:N.thinkingBlocks)==null?void 0:X.length)??0}`},[F]),se=i.useRef(ee);i.useEffect(()=>{if(!p){se.current=ee;return}ee!==se.current&&(se.current=ee,H())},[ee,p,H]);const de=i.useMemo(()=>[{icon:Ps,label:u("chat.suggestionCode"),prompt:u("chat.suggestionCodePrompt")},{icon:rt,label:u("chat.suggestionAnalyze"),prompt:u("chat.suggestionAnalyzePrompt")},{icon:Tt,label:u("chat.suggestionAutomate"),prompt:u("chat.suggestionAutomatePrompt")}],[u]);return e.jsxs("div",{className:"relative flex-1 min-h-0",children:[e.jsxs("div",{ref:c,onScroll:W,className:"h-full overflow-y-auto custom-scrollbar",children:[F.length===0?e.jsxs("div",{className:"relative flex min-h-[55vh] items-center justify-center px-4 py-10 sm:px-6",children:[e.jsx(qa,{}),e.jsxs("div",{className:"relative w-full max-w-2xl px-1 text-center",children:[e.jsx("div",{className:"chat-empty-orb",children:e.jsx("img",{src:"/logo.svg",alt:"deepseekcode",className:"relative h-10 w-10"})}),e.jsx("h2",{className:"text-xl font-semibold tracking-tight mb-2",children:u("chat.welcome")}),e.jsx("p",{className:"text-dark-muted text-sm mb-8",children:u("chat.welcomeDesc")}),a&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5 text-left",children:de.map(N=>e.jsxs("button",{onClick:()=>a(N.prompt),className:"ui-card-interactive group w-full px-4 py-3.5 text-left",children:[e.jsx(N.icon,{size:16,"aria-hidden":"true",className:"text-accent-blue mb-2"}),e.jsx("div",{className:"text-[13px] font-medium text-dark-text",children:N.label}),e.jsx("div",{className:"mt-0.5 text-[11px] leading-snug text-dark-muted line-clamp-2",children:N.prompt})]},N.label))})]})]}):e.jsx("div",{className:"chat-stack flex flex-col pb-8 pt-5",children:F.map((N,$)=>{const te=F[$-1],X=te?te.type===N.type?"mt-2":"mt-5":"";return e.jsxs("div",{"data-mid":N.id,ref:C,className:`relative w-full ${X}`,children:[b===N.id&&e.jsx("div",{className:"animate-rail-flash pointer-events-none absolute inset-0"},v),e.jsx(Pa,{message:N,sessionId:r,onRegenerate:o,onDeleteMessage:d})]},N.id)})}),n&&!j&&e.jsx(Wa,{label:u("chat.thinkingEllipsis")},r)]}),S.length>0&&e.jsx(Ha,{items:S,activeId:f,onJump:Y}),!p&&F.length>0&&e.jsx("button",{type:"button",onClick:K,title:u("chat.backToBottom"),"aria-label":u("chat.backToBottom"),className:"absolute bottom-5 right-5 z-20 flex h-8 w-8 animate-fade-in-up items-center justify-center rounded-full border border-dark-border/70 bg-dark-surface/90 text-dark-muted shadow-lg backdrop-blur transition-all duration-200 hover:scale-110 hover:text-dark-text hover:shadow-xl",children:e.jsx(we,{size:15})})]})}),Ja={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"},Xa=i.memo(function(){const{t}=q(),n=Ee(c=>c.mode),r=Ee(c=>c.setBaseMode),a=Ee(c=>c.toggleAuto),o=n==="normal"?"act":n,d=et(o),u=At(o);return e.jsxs("div",{className:"flex items-center gap-1",children:[xr.map(c=>{const l=d===c,p=mr[c],x=n!=="normal"&&l?Ja[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(c),className:ne("px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",x),title:t("chat.clickToSwitchMode"),"aria-pressed":l,children:p.label},c)}),e.jsxs("button",{type:"button",role:"switch","aria-checked":u,onClick:()=>a(),className:ne("flex items-center gap-1 px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",u?"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(We,{size:11,className:ne(u?"text-accent-yellow":"text-dark-muted")}),e.jsx("span",{children:t("plan.autoApprove")})]})]})}),bn={off:{labelKey:"chat.effortOff",color:"text-dark-muted"},low:{labelKey:"chat.effortLow",color:"text-accent-green"},medium:{labelKey:"chat.effortMedium",color:"text-accent-yellow"},high:{labelKey:"chat.effortHigh",color:"text-accent-red"},extra_high:{labelKey:"chat.effortExtraHigh",color:"text-accent-purple"},max:{labelKey:"chat.effortMax",color:"text-accent-blue"}},Va=i.memo(function(){const{t}=q(),n=Ge(w=>w.model),r=Ge(w=>w.modelRef),a=Ge(w=>w.setModel),o=Ge(w=>w.setModelRef),d=Ee(w=>w.mode),u=st(w=>w.effort),c=st(w=>w.setEffort),[l,p]=i.useState([]),[x,f]=i.useState(!1),g=i.useRef(null),[b,y]=i.useState("global"),v=Ln(w=>w.activeSessionId),[h,A]=i.useState(!1),[D,R]=i.useState(""),[I,F]=i.useState(""),[j,S]=i.useState([]),[L,C]=i.useState(new Set),[P,W]=i.useState("none"),[Y,H]=i.useState(!1),[K,ee]=i.useState(null),[se,de]=i.useState(null),N=i.useMemo(()=>Array.from(new Set(l.map(w=>w.provider))),[l]),$=i.useCallback(async()=>{try{const w=await xe.models.list();w.success&&w.data&&Array.isArray(w.data.models)&&p(w.data.models.filter(G=>G.enabled!==!1))}catch{}},[]),te=i.useCallback(()=>{var G,O;const w=hr(r)||((G=l.find(me=>me.isGlobalDefault))==null?void 0:G.provider)||((O=l[0])==null?void 0:O.provider)||"";R(w),F(""),ee(null),A(!0)},[r,l]),X=i.useCallback(()=>{A(!1),S([]),ee(null)},[]),ae=i.useCallback(async(w,G)=>{if(w){H(!0),ee(null);try{const O=await xe.models.byProvider(w,G||void 0);O.success&&O.data?(S(O.data.models||[]),C(new Set(O.data.existing||[])),W(O.data.source)):(S([]),C(new Set),ee(O.error||t("chat.loadModelsFailed")))}catch{S([]),C(new Set),ee(t("chat.loadModelsFailed"))}finally{H(!1)}}},[t]);i.useEffect(()=>{if(!h)return;const w=setTimeout(()=>{ae(D,I)},I?300:0);return()=>clearTimeout(w)},[h,D,I,ae]),i.useEffect(()=>{$()},[$]),i.useEffect(()=>{const w=()=>{$()};return window.addEventListener("models-updated",w),()=>window.removeEventListener("models-updated",w)},[$]);const J=i.useCallback(()=>f(!1),[]);i.useEffect(()=>{if(!x)return;const w=O=>{g.current&&!g.current.contains(O.target)&&J()},G=O=>{O.key==="Escape"&&J()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",G),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",G)}},[x,J]);const he=async w=>{if(J(),b==="session"){if(!v)return;try{(await xe.models.setSessionModel(v,w.provider,w.id)).success&&(a(w.id),o(`${w.provider}:${w.id}`))}catch{}return}const G=et(d==="normal"?"act":d),O=`${w.provider}:${w.id}`,me=G==="plan"?{plan:O}:G==="goal"?{goal:O}:{global:O,act:O};try{(await xe.models.setDefaults(me)).success&&(a(w.id),o(`${w.provider}:${w.id}`),await $())}catch{}},fe=async w=>{const G=L.has(w.id),O=`${D}:${w.id}`;de(w.id);try{if(!G){const Pe=await xe.models.create({provider:D,model:{id:w.id,name:w.name||w.id}});if(!Pe.success){ee(Pe.error||t("chat.addModelFailed"));return}}const me=et(d==="normal"?"act":d),pe=me==="plan"?{plan:O}:me==="goal"?{goal:O}:{global:O,act:O},Xe=await xe.models.setDefaults(pe);Xe.success?(a(w.id),o(O),X(),await $()):ee(Xe.error||t("chat.switchModelFailed"))}catch{ee(t("chat.addModelFailed"))}finally{de(null)}},ge=et(d==="normal"?"act":d),ke=ge==="plan"?"isPlanDefault":ge==="goal"?"isGoalDefault":"isActDefault",E=w=>{const G=`${w.provider}:${w.id}`;if(r)return r===G;if(n===G)return!0;if(n!==w.id)return!1;const O=l.filter(pe=>pe.id===w.id);return O.length<=1?!0:(O.find(pe=>pe[ke]===!0)??O.find(pe=>pe.isGlobalDefault)??O[0])===w},M=l.some(w=>w[ke]===!0),B=l.find(w=>w.isGlobalDefault),ie=async()=>{J();const w=ge==="plan"?{plan:null}:ge==="goal"?{goal:null}:{act:null};try{(await xe.models.setDefaults(w)).success&&(B?(a(B.id),o(`${B.provider}:${B.id}`)):(a(""),o("")),await $())}catch{}},le=i.useMemo(()=>fr(l),[l]),ue=gr(n,r),ve=bn[u];return e.jsxs("div",{className:"relative",ref:g,children:[e.jsxs("button",{type:"button",onClick:()=>f(w=>!w),className:"flex items-center gap-1 px-2 py-0.5 rounded-full border border-dark-border text-dark-muted whitespace-nowrap transition-colors hover:bg-dark-hover cursor-pointer",title:ue||t("chat.clickToSelectModel"),"aria-haspopup":"listbox","aria-expanded":x,children:[e.jsx(zs,{size:12,className:"shrink-0"}),e.jsx("span",{className:"font-medium max-w-[8rem] truncate",children:ue||t("chat.selectModel")}),e.jsx("span",{className:"h-3 w-px bg-dark-border shrink-0","aria-hidden":"true"}),e.jsx(Gt,{size:12,className:`shrink-0 ${ve.color}`}),e.jsx("span",{className:`text-xs font-medium ${ve.color}`,children:t(ve.labelKey)}),e.jsx(we,{size:12,className:ne("transition-transform",x&&"rotate-180")})]}),x&&e.jsxs("div",{role:"listbox","aria-label":t("chat.selectModel"),className:"absolute bottom-full left-0 mb-1 z-50 min-w-[260px] bg-dark-surface border border-dark-border rounded-lg shadow-xl overflow-hidden",children:[e.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-dark-muted border-b border-dark-border",children:t("chat.selectModel")}),e.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-dark-border",children:[{key:"global",label:t("chat.applyScopeGlobal")},{key:"session",label:t("chat.applyScopeSession")}].map(({key:w,label:G})=>e.jsx("button",{type:"button",onClick:()=>y(w),title:w==="session"?t("chat.sessionScopeHint"):void 0,className:ne("text-[11px] px-2 py-0.5 rounded-full border transition-colors cursor-pointer",b===w?"border-accent-blue text-accent-blue bg-accent-blue/10 font-medium":"border-dark-border text-dark-muted hover:text-dark-text hover:bg-dark-hover"),children:G},w))}),h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-2 py-1.5 border-b border-dark-border flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:X,title:t("chat.backToModels"),"aria-label":t("chat.backToModels"),className:"p-1 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text shrink-0",children:e.jsx(Bs,{size:12})}),N.length>1?e.jsx("select",{value:D,onChange:w=>R(w.target.value),"aria-label":t("chat.selectProvider"),className:"max-w-[9rem] min-w-0 bg-dark-surface text-dark-text text-xs px-1.5 py-1 rounded border border-dark-border focus:outline-none focus:border-accent-blue",children:N.map(w=>e.jsx("option",{value:w,children:w},w))}):e.jsx("span",{className:"flex-1 min-w-0 text-xs font-medium text-dark-text truncate",children:D||t("chat.noConfiguredProviders")}),e.jsx("input",{value:I,onChange:w=>F(w.target.value),placeholder:t("chat.searchModels"),"aria-label":t("chat.searchModels"),className:"flex-1 min-w-0 bg-dark-bg text-dark-text text-xs px-2 py-1 rounded border border-dark-border placeholder-dark-muted/60 focus:outline-none focus:border-accent-blue"})]}),e.jsx("div",{className:"py-1 max-h-[32vh] overflow-y-auto custom-scrollbar",children:Y?e.jsxs("div",{className:"px-3 py-2 text-xs text-dark-muted flex items-center gap-1.5",children:[e.jsx(Hs,{size:11,className:"animate-spin"}),t("chat.loadingModels")]}):K?e.jsx("div",{className:"px-3 py-2 text-xs text-accent-red",children:K}):D?j.length===0?e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t(I?"chat.noModelsFound":"chat.noProviderModels")}):e.jsxs(e.Fragment,{children:[P!=="none"&&e.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-[10px] text-dark-muted/70",children:t(P==="provider-api"?"chat.modelsSourceProviderApi":"chat.modelsSourceCatalog")}),j.map(w=>{const G=L.has(w.id),O=r===`${D}:${w.id}`;return e.jsxs("button",{type:"button",role:"option","aria-selected":O,onClick:()=>fe(w),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-dark-hover",children:[e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs font-medium text-dark-text truncate",children:w.name||w.id}),O&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green shrink-0",children:t("chat.currentModel")})]}),e.jsx("span",{className:"block text-[10px] text-dark-muted truncate mt-0.5",children:w.id})]}),G?e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-green/20 text-accent-green shrink-0",children:t("chat.alreadyAdded")}):e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue shrink-0 whitespace-nowrap",children:se===w.id?t("chat.addingModel"):t("chat.addAndSwitch")})]},w.id)})]}):e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("chat.noConfiguredProviders")})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"py-1 max-h-[32vh] overflow-y-auto custom-scrollbar",children:[M&&e.jsx("button",{type:"button",role:"option","aria-selected":!1,onClick:ie,title:t("chat.followGlobalDefaultHint"),className:"w-full flex items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-dark-hover border-b border-dark-border/60",children:e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"text-xs font-semibold text-accent-green flex items-center gap-1.5",children:[e.jsx(Us,{size:11}),t("chat.followGlobalDefault")]}),e.jsx("span",{className:"block text-[10px] text-dark-muted mt-0.5 truncate",children:B?B.name||B.id:t("chat.noGlobalDefault")})]})}),le.map(([w,G])=>e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-dark-border/60 bg-dark-bg/40",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-dark-muted truncate",children:w}),e.jsx("span",{className:"text-[10px] text-dark-muted/70",children:G.length})]}),G.map(O=>{const me=E(O);return e.jsx("button",{type:"button",role:"option","aria-selected":me,onClick:()=>he(O),className:ne("w-full flex items-center gap-2 px-3 py-2 text-left transition-colors",me?"bg-dark-hover":"hover:bg-dark-hover"),children:e.jsxs("span",{className:"flex-1 min-w-0",children:[e.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:ne("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",me?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Se,{size:11,strokeWidth:3})}),e.jsx("span",{className:"text-xs font-semibold text-dark-text truncate",children:O.name||O.id})]}),e.jsxs("span",{className:"flex items-center gap-1 mt-0.5 flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-dark-muted truncate",children:O.id}),O.isGlobalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-green/20 text-accent-green",children:t("chat.globalDefault")}),O.isPlanDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-blue/20 text-accent-blue",children:t("chat.planDefault")}),O.isActDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-yellow/20 text-accent-yellow",children:t("chat.actDefault")}),O.isGoalDefault&&e.jsx("span",{className:"text-[10px] px-1 rounded bg-accent-purple/20 text-accent-purple",children:t("chat.goalDefault")})]})]})},`${O.provider}:${O.id}`)})]},w)),l.length===0&&e.jsx("div",{className:"px-3 py-2 text-xs text-dark-muted",children:t("chat.noEnabledModels")})]}),e.jsxs("button",{type:"button",onClick:te,className:"w-full flex items-center gap-2 px-3 py-2 text-left border-t border-dark-border/60 text-[11px] font-medium text-accent-blue transition-colors hover:bg-dark-hover",children:[e.jsx(rt,{size:11}),t("chat.browseMoreModels")]})]}),e.jsx("div",{className:"border-t border-dark-border","aria-hidden":"true"}),e.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold uppercase tracking-wide text-dark-muted border-b border-dark-border flex items-center gap-1",children:[e.jsx(Gt,{size:11}),t("chat.effort")]}),e.jsx("div",{className:"py-1",children:br.map(w=>{const G=bn[w],O=w===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":O,onClick:()=>{c(w),J()},className:ne("w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors",O?"bg-dark-hover":"hover:bg-dark-hover"),children:[e.jsx("span",{className:ne("flex h-4 w-4 items-center justify-center rounded border transition-colors shrink-0",O?"border-accent-green bg-accent-green/20 text-accent-green":"border-dark-border text-transparent"),children:e.jsx(Se,{size:11,strokeWidth:3})}),e.jsx("span",{className:`text-xs font-medium ${O?G.color:"text-dark-text"}`,children:t(G.labelKey)})]},w)})})]})]})});var Ya=Sr();function Za(s,t){if(!s)return t;const n=s.includes("\\")?"\\":"/";return s.endsWith(n)?s+t:s+n+t}function Qa(s){const t=s.replace(/[\\/]+$/,""),n=Math.max(t.lastIndexOf("\\"),t.lastIndexOf("/"));return n===-1?t:t.slice(n+1)}function ei({initial:s,onClose:t,onConfirm:n}){const{t:r}=q(),[a,o]=i.useState(s),[d,u]=i.useState(null),[c,l]=i.useState([]),[p,x]=i.useState(!1),[f,g]=i.useState(""),[b,y]=i.useState(s),v=i.useRef(null),h=i.useCallback(async R=>{x(!0),g("");try{const I=await xe.dirs.list(R);if(!I.success||!I.data){g(I.error||r("chat.dirPickerLoadError"));return}o(I.data.path),u(I.data.parent),l(I.data.dirs||[]),y(I.data.path)}catch(I){g(I instanceof Error?I.message:r("chat.dirPickerLoadError"))}finally{x(!1)}},[r]);i.useEffect(()=>{h(s)},[s,h]),i.useEffect(()=>{var R;(R=v.current)==null||R.focus()},[]),i.useEffect(()=>{const R=I=>{I.key==="Escape"&&(I.preventDefault(),I.stopPropagation(),t())};return document.addEventListener("keydown",R),document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",R),document.body.style.overflow=""}},[t]);const A=i.useCallback(()=>{const R=b.trim();R&&h(R)},[b,h]),D=i.useCallback(()=>{d&&h(d)},[d,h]);return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center overflow-hidden p-4",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),e.jsxs("div",{className:"relative w-full max-w-lg mx-4 bg-dark-surface border border-dark-border rounded-xl shadow-2xl animate-fade-in flex flex-col max-h-[70vh]",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-dark-border shrink-0",children:[e.jsxs("span",{className:"flex items-center gap-2 text-[13px] font-semibold text-dark-text",children:[e.jsx(Tn,{size:15,className:"text-accent-blue","aria-hidden":"true"}),r("chat.dirPickerTitle")]}),e.jsx("button",{type:"button",onClick:t,className:"rounded p-1 text-dark-muted hover:bg-dark-hover hover:text-dark-text transition-colors","aria-label":r("a11y.close"),children:e.jsx(Re,{size:15,"aria-hidden":"true"})})]}),e.jsxs("div",{className:"p-4 flex flex-col gap-3 min-h-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Gs,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60","aria-hidden":"true"}),e.jsx("input",{ref:v,value:b,onChange:R=>y(R.target.value),onKeyDown:R=>{R.key==="Enter"&&A()},placeholder:r("chat.dirPickerEnterPath"),spellCheck:!1,className:`w-full rounded-lg border border-dark-border bg-dark-bg pl-8 pr-2.5 py-1.5 text-xs font-mono text-dark-text
24
- placeholder-dark-muted/50 focus:outline-none focus:border-accent-blue/50 focus:ring-2 focus:ring-accent-blue/10`})]}),e.jsx("button",{type:"button",onClick:A,disabled:p||!b.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted
25
- hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:r("chat.dirPickerGo")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex-1 truncate font-mono text-[11px] text-dark-muted bg-dark-bg rounded-md px-2 py-1 border border-dark-border",title:a,children:a||r("chat.noWorkspaceDir")}),e.jsxs("button",{type:"button",onClick:()=>void D(),disabled:p||!a,className:`shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-[11px] text-dark-muted
26
- hover:bg-dark-hover hover:text-dark-text disabled:opacity-40 transition-colors`,children:[e.jsx(Rn,{size:12,"aria-hidden":"true"}),r("chat.dirPickerUp")]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto custom-scrollbar rounded-lg border border-dark-border bg-dark-bg divide-y divide-dark-border/60",children:p?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-dark-muted",children:[e.jsx(Fe,{size:14,className:"animate-spin","aria-hidden":"true"}),r("chat.loading")]}):f?e.jsx("div",{className:"px-3 py-4 text-xs text-accent-red",children:f}):c.length===0?e.jsx("div",{className:"px-3 py-4 text-xs text-dark-muted/60 text-center",children:r("chat.dirPickerNoDirs")}):c.map(R=>{const I=Za(a,R);return e.jsxs("button",{type:"button",onClick:()=>void h(I),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs text-dark-text
27
- hover:bg-dark-hover transition-colors group`,children:[e.jsx(It,{size:13,className:"shrink-0 text-accent-yellow/80 group-hover:text-accent-yellow","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:R}),e.jsx(je,{size:12,className:"shrink-0 ml-auto text-dark-muted/40","aria-hidden":"true"})]},R)})}),e.jsx("button",{type:"button",onClick:()=>n(a),disabled:!a||p,className:`w-full rounded-lg bg-accent-blue/90 text-white text-xs font-medium py-2
28
- hover:bg-accent-blue disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:r("chat.dirPickerConfirm")})]})]})]})}const ti=i.memo(function({workspaceDir:t,onSelect:n}){const{t:r}=q(),a=st(x=>x.recentDirs),[o,d]=i.useState(!1),[u,c]=i.useState(!1),l=i.useRef(null);i.useEffect(()=>{if(!o)return;const x=g=>{l.current&&!l.current.contains(g.target)&&d(!1)},f=g=>{g.key==="Escape"&&d(!1)};return document.addEventListener("mousedown",x),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",x),document.removeEventListener("keydown",f)}},[o]);const p=i.useCallback(x=>{var g;const f=((g=x==null?void 0:x.trim)==null?void 0:g.call(x))||"";f&&(d(!1),c(!1),n(f))},[n]);return e.jsxs("div",{className:"relative shrink-0",ref:l,children:[e.jsxs("button",{type:"button",onClick:()=>d(x=>!x),className:ne("flex items-center gap-1 max-w-[180px] px-2 py-0.5 rounded-full border text-xs whitespace-nowrap transition-colors cursor-pointer",o?"border-accent-blue/40 text-accent-blue bg-accent-blue/10":"border-dark-border text-dark-muted hover:bg-dark-hover hover:text-dark-text"),title:r("chat.clickToSwitchDir"),"aria-label":r("chat.clickToSwitchDir"),"aria-expanded":o,"aria-haspopup":"menu",children:[e.jsx(Tn,{size:12,className:"shrink-0 text-accent-blue/80","aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:t?Qa(t):r("chat.noWorkspaceDir")}),e.jsx(we,{size:11,className:ne("shrink-0 transition-transform",o&&"rotate-180"),"aria-hidden":"true"})]}),o&&e.jsxs("div",{role:"menu",className:"absolute bottom-full left-0 mb-2 w-72 max-w-[calc(100vw-1.5rem)] rounded-xl border border-dark-border bg-dark-surface shadow-2xl z-40 overflow-hidden animate-fade-in",children:[e.jsx("div",{className:"px-3 pt-2.5 pb-1 text-[10px] font-semibold uppercase tracking-wide text-dark-muted/50 select-none",children:r("chat.recentDirs")}),a.length===0?e.jsx("div",{className:"px-3 pb-2 text-[11px] text-dark-muted/50 select-none",children:r("chat.noRecentDirs")}):e.jsx("div",{className:"max-h-56 overflow-y-auto custom-scrollbar",children:a.map(x=>{const f=x===t;return e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>p(x),className:ne("w-full flex items-center gap-2 px-3 py-1.5 text-left text-xs transition-colors group",f?"text-accent-blue bg-accent-blue/5":"text-dark-text hover:bg-dark-hover"),title:x,children:[e.jsx(It,{size:12,className:ne("shrink-0",f?"text-accent-blue":"text-accent-yellow/80 group-hover:text-accent-yellow"),"aria-hidden":"true"}),e.jsx("span",{className:"truncate font-mono text-[11px]",children:x}),f&&e.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-accent-blue",children:"✓"})]},x)})}),e.jsx("div",{className:"border-t border-dark-border"}),e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{d(!1),c(!0)},className:"w-full flex items-center gap-2 px-3 py-2 text-left text-xs text-accent-blue hover:bg-dark-hover transition-colors",children:[e.jsx(je,{size:13,"aria-hidden":"true"}),r("chat.chooseOtherDir")]})]}),u&&Ya.createPortal(e.jsx(ei,{initial:t||"",onClose:()=>c(!1),onConfirm:p}),document.body)]})});function ni({isOpen:s,files:t,selectedIndex:n,query:r,isSearching:a,onSelect:o,onHover:d,selectedCount:u=0,onFinish:c}){const{t:l}=q();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:[u>0&&e.jsx("span",{className:"px-1.5 py-0.5 rounded-full bg-accent-blue/20 text-accent-blue font-medium",children:l("chat.selectedCountShort",{n:u})}),e.jsx("span",{children:l("chat.fileMentionHelpMulti")})]})]}),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(Fe,{size:16,className:"animate-spin"}),e.jsx("span",{children:l("chat.searchingFiles")})]}):e.jsx("span",{children:l("chat.noMatchingFiles")})}):t.map((p,x)=>e.jsxs("button",{onClick:()=>o(p),onMouseEnter:()=>d(x),className:`w-full px-3 py-1.5 flex items-center gap-2 text-left text-xs transition-colors border-l-2 ${x===n?"bg-accent-blue/20 text-accent-blue border-accent-blue":"hover:bg-dark-hover text-dark-text border-transparent"}`,children:[p.type==="directory"?e.jsx(It,{size:12,className:"text-accent-yellow shrink-0"}):e.jsx(Rt,{size:12,className:"text-dark-muted shrink-0"}),e.jsx("span",{className:"truncate",children:p.name}),e.jsx("span",{className:"text-[10px] text-dark-muted truncate ml-auto",children:p.path})]},p.id||p.path))]}),c&&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:u>0?l("chat.selectedFilesCount",{n:u}):l("chat.enterInsertMulti")}),e.jsx("button",{onClick:c,className:"px-3 py-1 text-[11px] rounded bg-accent-blue text-white hover:opacity-90 transition-opacity",children:l("chat.finishMention")})]})]}):null}function si({open:s,onClose:t,onSelect:n}){const{t:r}=q(),[a,o]=i.useState([]),[d,u]=i.useState(!1),[c,l]=i.useState("");i.useEffect(()=>{s&&(l(""),u(!0),xe.skills.list().then(x=>{const f=Array.isArray(x.data)?x.data:[];o(f.filter(g=>g.enabled!==!1))}).catch(()=>o([])).finally(()=>u(!1)))},[s]);const p=i.useMemo(()=>{const x=c.trim().toLowerCase();return x?a.filter(f=>[f.id,f.name,f.description,f.category,...f.tags||[]].join(" ").toLowerCase().includes(x)):a},[a,c]);return e.jsx(kr,{isOpen:s,onClose:t,title:r("skills.pickTitle"),size:"lg",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border focus-within:border-accent-blue",children:[e.jsx(rt,{size:14,className:"text-dark-muted shrink-0"}),e.jsx("input",{value:c,onChange:x=>l(x.target.value),placeholder:r("skills.pickPlaceholder"),autoFocus:!0,className:"flex-1 bg-transparent outline-none text-sm placeholder-dark-muted/60"}),d&&e.jsx(We,{size:13,className:"animate-spin text-dark-muted"})]}),d?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(We,{size:20,className:"animate-spin text-accent-blue"})}):p.length===0?e.jsx("div",{className:"text-center py-12 text-sm text-dark-muted",children:r("skills.pickEmpty")}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:p.map(x=>e.jsxs("button",{onClick:()=>n(x),className:"text-left rounded-lg border border-dark-border p-3 flex flex-col gap-1 transition-colors hover:border-accent-blue/50 hover:bg-dark-hover",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 min-w-0",children:[e.jsxs("span",{className:"font-medium text-sm truncate",children:[x.icon||"⭐"," ",x.name]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted shrink-0",children:x.injection||"lazy"})]}),e.jsxs("div",{className:"text-xs text-dark-muted truncate font-mono",children:["$",x.id]}),x.description&&e.jsx("div",{className:"text-xs text-dark-muted line-clamp-2",children:x.description}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-dark-bg border border-dark-border text-dark-muted truncate",children:x.category||"—"}),e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx(Tt,{size:11}),r("skills.pickUse")]})]})]},x.id))})]})})}const ri=800,qe=/\[Pasted text #(\d+)(?:\s*\+\d+ lines?)?\]/g;let ai=0;const at=new Map;function ii(s){const t=++ai;return at.set(t,s),t}function oi(s){at.delete(s)}function li(s){return s.length>ri||ss(s)>0}function ss(s){return(s.match(/\r\n|\r|\n/g)||[]).length}function ci(s){const t=ii(s),n=ss(s);return n===0?{id:t,label:`[Pasted text #${t}]`}:{id:t,label:`[Pasted text #${t} +${n} lines]`}}function di(s){return qe.lastIndex=0,s.replace(qe,(t,n)=>{const r=parseInt(n,10),a=at.get(r);return a!==void 0?a:t})}function ui(s){qe.lastIndex=0;const t=[];let n;for(;(n=qe.exec(s))!==null;){const r=n[1];r!==void 0&&t.push(parseInt(r,10))}return qe.lastIndex=0,t}function pi(s){for(const t of s)at.delete(t)}function xi(s){const t=s.match(/\[Pasted text #\d+(?:\s*\+\d+ lines?)?\]$/);return t?t[0]??null:null}function mi(s){const t=s.match(/^\[Pasted text #\d+(?:\s*\+\d+ lines?)?\]/);return t?t[0]??null:null}function kn(s){const t=s.match(/#(\d+)/);t&&oi(parseInt(t[1]??"",10))}const tt=16e3;function bt(){const s=["audio/webm;codecs=opus","audio/webm","audio/mp4"];if(typeof MediaRecorder>"u")return"";for(const t of s)if(MediaRecorder.isTypeSupported(t))return t;return""}async function hi(s){if(s.sampleRate===tt&&s.numberOfChannels===1)return s.getChannelData(0);const t=Math.max(1,Math.ceil(s.length*tt/s.sampleRate)),n=new OfflineAudioContext(1,t,tt),r=n.createBufferSource();return r.buffer=s,r.connect(n.destination),r.start(0),(await n.startRendering()).getChannelData(0)}function fi(s,t){const n=new ArrayBuffer(44+s.length*2),r=new DataView(n),a=(d,u)=>{for(let c=0;c<u.length;c++)r.setUint8(d+c,u.charCodeAt(c))};a(0,"RIFF"),r.setUint32(4,36+s.length*2,!0),a(8,"WAVE"),a(12,"fmt "),r.setUint32(16,16,!0),r.setUint16(20,1,!0),r.setUint16(22,1,!0),r.setUint32(24,t,!0),r.setUint32(28,t*2,!0),r.setUint16(32,2,!0),r.setUint16(34,16,!0),a(36,"data"),r.setUint32(40,s.length*2,!0);let o=44;for(let d=0;d<s.length;d++){const u=Math.max(-1,Math.min(1,s[d]??0));r.setInt16(o,u<0?u*32768:u*32767,!0),o+=2}return n}function gi(s){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>{const a=String(r.result||""),o=a.indexOf(",");t(o>=0?a.slice(o+1):a)},r.onerror=()=>n(r.error),r.readAsDataURL(s)})}function bi(s){const[t,n]=i.useState("idle"),[r,a]=i.useState(0),o=i.useRef(null),d=i.useRef(null),u=i.useRef([]),c=i.useRef(null),l=i.useRef(0),p=i.useCallback(()=>{var y;(y=d.current)==null||y.getTracks().forEach(v=>v.stop()),d.current=null},[]),x=i.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=null)},[]);i.useEffect(()=>()=>{x(),o.current&&o.current.state!=="inactive"&&o.current.stop(),p()},[x,p]);const f=i.useCallback(async()=>{if(t!=="idle")return;if(typeof MediaRecorder>"u")throw new Error("当前浏览器不支持语音输入(需要 MediaRecorder)。请使用 Chrome/Edge/Firefox 或桌面版。");let y;try{y=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0}})}catch(h){throw h instanceof DOMException&&h.name==="NotAllowedError"?new Error("麦克风权限被拒绝。请在浏览器地址栏允许麦克风权限后重试。"):new Error("无法访问麦克风:"+(h instanceof Error?h.message:String(h)))}d.current=y,u.current=[];const v=new MediaRecorder(y,bt()?{mimeType:bt()}:void 0);v.ondataavailable=h=>{h.data&&h.data.size>0&&u.current.push(h.data)},o.current=v,v.start(),l.current=Date.now(),a(0),n("recording"),c.current=setInterval(()=>a(Date.now()-l.current),100)},[t]),g=i.useCallback(async()=>{var h;const y=o.current;if(!y||y.state==="inactive")throw new Error("当前没有进行中的录音。");const v=new Promise(A=>{y.onstop=()=>A()});y.stop(),await v,x(),p(),o.current=null,n("transcribing");try{const A=new Blob(u.current,{type:bt()||"audio/webm"});u.current=[];const D=await A.arrayBuffer(),R=new AudioContext;let I;try{I=await R.decodeAudioData(D)}finally{R.close()}if(I.duration<.25)return n("idle"),"";const j=await hi(I),S=fi(j,tt),L=await gi(new Blob([S],{type:"audio/wav"})),C=await xe.stt.transcribe(s,L,"wav");if(!C.success)throw new Error(C.error||"语音转写失败");return((h=C.data)==null?void 0:h.text)??""}finally{n("idle")}},[s,x,p]),b=i.useCallback(()=>{const y=o.current;y&&y.state!=="inactive"&&y.stop(),o.current=null,u.current=[],x(),p(),n("idle")},[x,p]);return{state:t,elapsedMs:r,start:f,stop:g,cancel:b}}const ki=({isOpen:s,commands:t,selectedIndex:n,filter:r,onSelect:a,onHover:o,containerRef:d})=>{const{t:u}=q();return!s||t.length===0?null:e.jsxs("div",{ref:d,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 max-h-72 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}`:u("slashCommands.quickCommands")}),e.jsx("span",{className:"opacity-70",children:u("slashCommands.help")})]}),t.map((c,l)=>e.jsxs("button",{"data-index":l,onClick:()=>a(c),onMouseEnter:()=>o(l),className:`w-full px-3 py-2 flex items-start gap-3 text-left transition-colors border-l-2 ${l===n?"bg-accent-blue/10 border-accent-blue":"border-transparent hover:bg-dark-hover"}`,children:[e.jsx("span",{className:"text-lg leading-none shrink-0","aria-hidden":"true",children:c.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-dark-text",children:["/",c.name]}),c.args&&e.jsx("span",{className:"text-xs text-dark-muted",children:c.args}),!c.local&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-accent-blue/20 text-accent-blue shrink-0",children:u("slashCommands.backend")})]}),e.jsx("div",{className:"text-xs text-dark-muted truncate",children:c.description})]}),l===n&&e.jsx(qs,{size:14,className:"text-dark-muted shrink-0 mt-0.5","aria-hidden":"true"})]},c.id))]})},rs=["xlsx","xls","csv","docx","txt","md","mdx","rst","adoc","ts","tsx","js","jsx","mjs","cjs","mts","cts","json","jsonc","yaml","yml","toml","xml","html","css","scss","less","py","rb","go","rs","java","kt","swift","c","h","cpp","hpp","cc","cs","sh","bash","zsh","ps1","bat","cmd","sql","graphql","proto","vue","svelte","astro","env","gitignore","gitattributes","editorconfig"],yi=new RegExp(`(?:\\.(${rs.join("|")})|dockerfile|makefile)$`,"i"),as=["png","jpg","jpeg","webp","gif","bmp","svg"],wi=new RegExp(`\\.(${as.join("|")})$`,"i"),vi=10*1024*1024,Ni=rs.map(s=>`.${s}`).join(",")+",.Dockerfile,.Makefile,"+as.map(s=>`.${s}`).join(","),ji=".deepseekcode/attachments",Si=50*1024*1024,kt=10,Ei=s=>/\.xlsx?$/i.test(s)?St:/\.(csv|docx|txt|md|mdx|rst|adoc|json|jsonc|yaml|yml|toml|xml|html|css|scss|less|env|gitignore|gitattributes|editorconfig)$/i.test(s)?nt:/\.(ts|tsx|js|jsx|mjs|cjs|mts|cts|py|rb|go|rs|java|kt|swift|c|h|cpp|hpp|cc|cs|sh|bash|zsh|ps1|bat|cmd|sql|graphql|proto|vue|svelte|astro|dockerfile|makefile)$/i.test(s)?Zs:Rt,yt=3e3,yn=5,wt=50;function Ai(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}}function Ci(s,t){const n=s.lastIndexOf(`
29
- `,t-1)+1,r=s.slice(n,t);return r.startsWith("/")?/\s/.test(r)?{active:!1,query:""}:{active:!0,query:r.slice(1)}:{active:!1,query:""}}const Ti=i.memo(function({sessionId:t,onSend:n,onStop:r,onPause:a,onResume:o,slashOptions:d,workspaceDir:u,onWorkspaceSelect:c}){const{t:l}=q(),p=be(m=>{var k;return((k=m.sessionInputs)==null?void 0:k[t])??""}),x=be(m=>m.setSessionInput),f=be(m=>{var k;return((k=m.generatingSessions)==null?void 0:k.includes(t))??!1}),g=be(m=>{var k;return((k=m.pausedSessions)==null?void 0:k.includes(t))??!1}),b=i.useRef(null),y=i.useRef(null),v=i.useRef(!1),[h,A]=i.useState([]),[D,R]=i.useState(!1),[I,F]=i.useState(!1),j=i.useCallback(m=>{x(t,m)},[t,x]),[S,L]=i.useState(()=>{try{return qt(localStorage.getItem("dsc.stt.lang"))}catch{return"en"}}),[C,P]=i.useState(!1),W=i.useRef(null),Y=i.useCallback(m=>{L(m);try{localStorage.setItem("dsc.stt.lang",m)}catch{}P(!1)},[]);i.useEffect(()=>{if(!C)return;const m=T=>{W.current&&!W.current.contains(T.target)&&P(!1)},k=T=>{T.key==="Escape"&&P(!1)};return document.addEventListener("mousedown",m),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",k)}},[C]);const H=bi(S),K=i.useRef(null),ee=i.useCallback(async()=>{var m;try{if(!K.current){const _=await xe.stt.status();_.success&&_.data&&(K.current=_.data)}const k=K.current;if(!k)return!0;if(k.service!=="ok"&&k.service!=="stopped")return oe.warning(l("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1;const T=(m=k.backends)==null?void 0:m[S];return T&&!T.installed?(oe.warning(l("stt.backendMissing")),window.dispatchEvent(new CustomEvent("switch-tab",{detail:{tab:"settings",section:"stt"}})),!1):!0}catch{return!0}},[l,S]);i.useEffect(()=>{const m=()=>{K.current=null};return window.addEventListener("stt-backends-changed",m),()=>window.removeEventListener("stt-backends-changed",m)},[]),i.useEffect(()=>{const m=k=>{var _;const T=qt((_=k.detail)==null?void 0:_.lang);L(T)};return window.addEventListener("stt-lang-changed",m),()=>window.removeEventListener("stt-lang-changed",m)},[]);const se=i.useCallback(m=>{const k=b.current,T=(k==null?void 0:k.selectionStart)??p.length,_=p.slice(0,T)+m+p.slice(T);j(_),requestAnimationFrame(()=>{k==null||k.focus();const U=T+m.length;k&&(k.selectionStart=k.selectionEnd=U)})},[p,j]),de=i.useCallback(async()=>{if(H.state==="recording"){try{const k=await H.stop();k?se(k):oe.info(l("stt.noSpeech"))}catch(k){oe.error(k instanceof Error?k.message:String(k))}return}if(!(H.state!=="idle"||!await ee()))try{await H.start()}catch(k){oe.error(k instanceof Error?k.message:String(k))}},[H,se,ee,l]),N=yr(d),{isOpen:$,filter:te,filteredCommands:X,selectedIndex:ae,setSelectedIndex:J,selectNext:he,selectPrev:fe,executeCommand:ge,openMenu:ke,closeMenu:E,setFilter:M,allCommands:B,containerRef:ie}=N,[le,ue]=i.useState(!1),[ve,w]=i.useState(""),[G,O]=i.useState([]),[me,pe]=i.useState(0),[Xe,Pe]=i.useState(!1),[os,ze]=i.useState(0),_e=i.useRef(-1),Me=i.useRef(new Set),Be=i.useRef(null),Ve=i.useRef(null),it=i.useRef([]),Ne=i.useRef(!1);i.useEffect(()=>{Me.current=new Set,Ne.current=!1,ue(!1),w(""),O([]),ze(0),E()},[t,E]);const Lt=i.useDeferredValue(p),Ot=Ge(m=>m.estimateTokens),ot=i.useMemo(()=>Ot(Lt),[Lt,Ot]),Ft=i.useCallback(()=>{const m=b.current;m&&(m.style.height="auto",m.style.height=Math.min(m.scrollHeight,200)+"px")},[]);i.useEffect(()=>{Ft()},[p,h.length,Ft]);const lt=i.useCallback(()=>{if(Be.current)return Promise.resolve(Be.current);if(Ve.current)return Ve.current;Pe(!0);const m=(async()=>{try{const k=await xe.files.list(),T=k.success&&k.data?k.data[0]:void 0;if(!T)return Be.current=[],[];const _=[],U=new Set,z=async(V,re)=>{if(re>yn||_.length>=yt)return;const Q=[];for(const Z of V||[]){if(_.length>=yt)return;const $e=Z.path.replace(/\\/g,"/");U.has($e)||(U.add($e),Z.type==="file"?_.push({...Z,path:$e}):Z.children&&Z.children.length>0?await z(Z.children,re+1):re<yn&&Q.push(Z))}if(Q.length===0)return;const ye=await Promise.all(Q.map(async Z=>{var $e;try{const ut=await xe.files.list(Z.path.replace(/\\/g,"/"));return ut.success&&ut.data?(($e=ut.data[0])==null?void 0:$e.children)||[]:[]}catch{return[]}}));for(const Z of ye){if(_.length>=yt)return;await z(Z,re+1)}};return await z(T.children,1),Be.current=_,_}catch{return Be.current=[],[]}finally{Ve.current=null,Pe(!1)}})();return Ve.current=m,m},[]),Pt=i.useCallback(async(m,k)=>{if(Ne.current){const V=_e.current;if(V<0||k<V){Ne.current=!1,ue(!1);return}const re=m.slice(V,k);if(/\s/.test(re)){Ne.current=!1,ue(!1);return}_e.current=V,w(re),ue(!0),pe(0);const Q=await lt();it.current=Q;const ye=re.toLowerCase();O(Q.filter(Z=>!ye||Z.path.toLowerCase().includes(ye)).slice(0,wt));return}const T=Ai(m,k);if(!T.active){le&&ue(!1);return}_e.current=T.start,w(T.query),ue(!0),pe(0);const _=await lt();it.current=_;const U=T.query.toLowerCase(),z=_.filter(V=>!U||V.path.toLowerCase().includes(U)).slice(0,wt);O(z)},[le,lt]),ls=i.useCallback(m=>{const k=m.target.value,T=m.target.selectionStart??k.length;j(k),Pt(k,T);const _=Ci(k,T);_.active?($||ke(),M(_.query),J(0)):$&&E()},[j,Pt,$,ke,M,J,E]),ct=i.useCallback(m=>{const k=b.current,T=p,_=_e.current>=0?_e.current:(k==null?void 0:k.selectionStart)??T.length,U=Math.min(T.length,_+1+ve.length),z=`@${m.path} `,V=T.slice(0,_)+z+T.slice(U);Me.current.add(m.path),j(V),ue(!0),w(""),O(it.current.slice(0,wt)),pe(0),ze(Me.current.size),_e.current=_+z.length,Ne.current=!0,requestAnimationFrame(()=>{k==null||k.focus(),k&&(k.selectionStart=k.selectionEnd=_+z.length)})},[p,ve,j]),He=i.useCallback(()=>{Ne.current=!1,ue(!1),w(""),ze(0)},[]),dt=i.useCallback(m=>{if(!m.args){const z=ge(m,"");z!=null&&z.message&&(z.success?oe.success(z.message):oe.error(z.message)),j("");return}const k=b.current,T=(k==null?void 0:k.selectionStart)??p.length,_=p.lastIndexOf(`
30
- `,T-1)+1,U=p.slice(0,_)+`/${m.name} `+p.slice(T);j(U),E(),requestAnimationFrame(()=>{k==null||k.focus();const z=_+m.name.length+2;k&&(k.selectionStart=k.selectionEnd=z)})},[p,j,ge,E]),cs=i.useCallback(m=>{const k=b.current,T=(k==null?void 0:k.selectionStart)??p.length,_=`$${m.id} `,U=p.slice(0,T)+_+p.slice(T);j(U),F(!1),Ne.current=!1,ue(!1),w(""),requestAnimationFrame(()=>{k==null||k.focus();const z=T+_.length;k&&(k.selectionStart=k.selectionEnd=z)})},[p,j]),zt=i.useCallback(m=>new Promise((k,T)=>{const _=new FileReader;_.onload=()=>k(String(_.result??"")),_.onerror=()=>T(new Error("Failed to read image")),_.readAsDataURL(m)}),[]),De=i.useCallback(m=>{const k=Array.from(m);A(T=>{const _=kt-T.length,U=T.slice();for(const z of k.slice(0,_)){const V=wi.test(z.name);if(!V&&!yi.test(z.name)){oe.warning(l("fileJob.unsupportedType",{name:z.name}));continue}if(z.size>(V?vi:Si)){oe.error(l("fileJob.fileTooLarge",{name:z.name}));continue}if(U.some(Q=>Q.name===z.name)){oe.warning(l("fileJob.duplicateFile",{name:z.name}));continue}const re={id:`att-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,file:z,name:z.name,size:z.size,uploading:!1};V&&zt(z).then(Q=>{A(ye=>ye.map(Z=>Z.id===re.id?{...Z,imageDataUri:Q}:Z))}).catch(()=>{A(Q=>Q.filter(ye=>ye.id!==re.id)),oe.error(l("fileJob.uploadFailed",{name:z.name}))}),U.push(re)}return U.length>=kt&&oe.warning(l("fileJob.maxAttachments",{n:kt})),U})},[l,zt]),ds=i.useCallback(m=>{m.target.files&&m.target.files.length>0&&(De(m.target.files),m.target.value="")},[De]),us=i.useCallback(()=>{var m;(m=y.current)==null||m.click()},[]),ps=i.useCallback(m=>{A(k=>k.filter(T=>T.id!==m))},[]),xs=i.useCallback(m=>{m.preventDefault(),R(!0)},[]),ms=i.useCallback(m=>{m.preventDefault(),R(!1)},[]),hs=i.useCallback(m=>{m.preventDefault(),R(!1),m.dataTransfer.files&&m.dataTransfer.files.length>0&&De(m.dataTransfer.files)},[De]),Bt=i.useCallback(async()=>{var k;if(h.length===0)return"";const m=[];for(const T of h){if(T.imageDataUri)continue;if(T.path){m.push(`<attachment path="${T.path}" />`);continue}if(!T.file)continue;A(z=>z.map(V=>V.id===T.id?{...V,uploading:!0,error:void 0}:V));const _=`${ji}/${T.name}`,U=await xe.files.upload(T.file,_);if(U.success&&((k=U.data)!=null&&k.path)){const z=U.data.path.replace(/\\/g,"/");A(V=>V.map(re=>re.id===T.id?{...re,uploading:!1,path:z}:re)),m.push(`<attachment path="${z}" />`)}else A(z=>z.map(V=>V.id===T.id?{...V,uploading:!1,error:U.error||l("fileJob.uploadFailed")}:V)),oe.error(`${T.name}: ${U.error||l("fileJob.uploadFailed")}`)}return m.length>0?`${m.join(`
31
- `)}
32
-
33
- `:""},[h,l]),fs=i.useCallback(m=>{const k=m.clipboardData.getData("text/plain");if(m.clipboardData.files&&m.clipboardData.files.length>0){m.preventDefault(),De(m.clipboardData.files);return}if(!k||!li(k))return;m.preventDefault();const{label:T}=ci(k),_=b.current;if(!_)return;const U=_.selectionStart,z=_.selectionEnd,V=_.value,re=V.slice(0,U)+T+V.slice(z);j(re),requestAnimationFrame(()=>{_.selectionStart=_.selectionEnd=U+T.length})},[j,De]),Ye=i.useCallback(async()=>{const m=di(p);pi(ui(m)),Ne.current=!1,ue(!1),E();const k=m.trim(),T=h.length>0;if(!k&&!T)return;const _=m.trim();if(_.startsWith("/")&&!T){const Q=wr(_);if(Q){const ye=B.find(Z=>Z.name===Q.command);if(ye){const Z=ge(ye,Q.args);Z!=null&&Z.message&&(Z.success?oe.success(Z.message):oe.error(Z.message)),j(""),A([]),Me.current=new Set,ze(0);return}oe.error(l("slashCommands.unknownCommand",{cmd:`/${Q.command}`}));return}}const U=Array.from(Me.current).filter(Q=>m.includes(`@${Q}`));let z="";if(T){if(h.some(Q=>Q.uploading)){oe.warning(l("fileJob.stillUploading"));return}z=await Bt()}const V=(z+m).trim();if(!V&&!T)return;const re=h.filter(Q=>Q.imageDataUri).map(Q=>Q.imageDataUri);n(V||z.trim(),U.length>0?U:void 0,re.length>0?re:void 0),j(""),A([]),Me.current=new Set,ze(0)},[p,h,n,j,Bt,l,E,B,ge]),gs=i.useCallback(m=>{if(!m.nativeEvent.isComposing){if((m.key==="Backspace"||m.key==="Delete")&&!m.ctrlKey&&!m.metaKey&&!m.altKey&&!m.shiftKey){const k=b.current;if(k&&k.selectionStart===k.selectionEnd){const T=k.selectionStart,_=k.value;if(m.key==="Backspace"&&T>0){const U=xi(_.slice(0,T));if(U){m.preventDefault(),j(_.slice(0,T-U.length)+_.slice(T)),kn(U),requestAnimationFrame(()=>{k.focus();const z=T-U.length;k.selectionStart=k.selectionEnd=z});return}}else if(m.key==="Delete"&&T<_.length){const U=mi(_.slice(T));if(U){m.preventDefault(),j(_.slice(0,T)+_.slice(T+U.length)),kn(U),requestAnimationFrame(()=>{k.focus(),k.selectionStart=k.selectionEnd=T});return}}}}if(le&&G.length>0){if(m.key==="ArrowDown"){m.preventDefault(),pe(k=>(k+1)%G.length);return}if(m.key==="ArrowUp"){m.preventDefault(),pe(k=>(k-1+G.length)%G.length);return}if(m.key==="Enter"&&!m.shiftKey&&!m.ctrlKey&&!m.metaKey){const k=G[me];k&&(m.preventDefault(),ct(k));return}if(m.key==="Escape"){m.preventDefault(),He();return}}else if(le&&m.key==="Escape"){m.preventDefault(),He();return}if($&&X.length>0){if(m.key==="ArrowDown"){m.preventDefault(),he();return}if(m.key==="ArrowUp"){m.preventDefault(),fe();return}if(m.key==="Enter"&&!m.shiftKey&&!m.ctrlKey&&!m.metaKey){const k=X[ae];k&&(m.preventDefault(),dt(k));return}if(m.key==="Escape"){m.preventDefault(),E();return}}else if($&&m.key==="Escape"){m.preventDefault(),E();return}if(m.key==="Escape"&&f){m.preventDefault(),g?o():a();return}if(m.key==="Enter"&&(m.ctrlKey||m.metaKey)){m.preventDefault(),Ye();return}m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),Ye())}},[f,g,Ye,a,o,le,G,me,ct,He,$,X,ae,he,fe,dt,E,j]),bs=i.useCallback(()=>{v.current=!0},[]),ks=i.useCallback(()=>{v.current=!1},[]),Ht=ot>8e3,ys=p.trim().length>0||h.length>0;return e.jsxs("div",{className:"chat-composer-shell shrink-0 px-3 pb-3 pt-2 sm:px-4",onDragOver:xs,onDragLeave:ms,onDrop:hs,children:[h.length>0&&e.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:h.map(m=>{const k=Ei(m.name);return e.jsxs("div",{className:ne("flex items-center gap-1.5 rounded-lg border px-2 py-1 text-xs transition-colors",m.error?"border-accent-red/40 bg-accent-red/5 text-accent-red":m.uploading?"border-accent-blue/40 bg-accent-blue/5 text-accent-blue":"border-dark-border bg-dark-surface text-dark-text"),children:[m.imageDataUri?e.jsx("img",{src:m.imageDataUri,alt:m.name,className:"h-6 w-6 rounded object-cover",title:l("fileJob.imagePreview")}):m.uploading?e.jsx(Fe,{size:13,className:"animate-spin"}):e.jsx(k,{size:13}),e.jsx("span",{className:"max-w-[140px] truncate",children:m.name}),e.jsx("span",{className:"text-[10px] text-dark-muted",children:m.size>1024*1024?`${(m.size/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(m.size/1024))} KB`}),!m.uploading&&e.jsx("button",{onClick:()=>ps(m.id),className:"rounded p-0.5 text-dark-muted hover:text-accent-red hover:bg-accent-red/10 transition-colors","aria-label":l("a11y.close"),children:e.jsx(Re,{size:11})})]},m.id)})}),D&&e.jsx("div",{className:"mb-2 rounded-xl border-2 border-dashed border-accent-blue/50 bg-accent-blue/5 py-3 text-center text-xs text-accent-blue",children:l("fileJob.dropHint")}),e.jsxs("div",{className:"chat-composer-card relative rounded-xl border transition-all duration-150",children:[le&&e.jsx("div",{onMouseDown:m=>m.preventDefault(),"aria-hidden":!le,children:e.jsx(ni,{isOpen:le,files:G,selectedIndex:me,query:ve,isSearching:Xe,onSelect:ct,onHover:pe,selectedCount:os,onFinish:He})}),$&&e.jsx("div",{onMouseDown:m=>m.preventDefault(),"aria-hidden":!$,children:e.jsx(ki,{isOpen:$,commands:X,selectedIndex:ae,filter:te,onSelect:dt,onHover:J,containerRef:ie})}),e.jsx("textarea",{ref:b,value:p,onChange:ls,onKeyDown:gs,onPaste:fs,onBlur:()=>{le&&He(),E()},onCompositionStart:bs,onCompositionEnd:ks,placeholder:l(f?"chat.generatingPlaceholder":"chat.inputPlaceholder"),rows:1,disabled:f&&!g,"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
34
- resize-none focus:outline-none min-h-[44px] max-h-[40vh] leading-relaxed
35
- disabled:opacity-50 disabled:cursor-not-allowed`}),e.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-2.5",children:[c&&e.jsx(ti,{workspaceDir:u,onSelect:c}),e.jsx(Xa,{}),e.jsx("span",{className:"hidden sm:block",children:e.jsx(Va,{})}),e.jsx("div",{className:"flex-1"}),ot>0&&p.length>0&&e.jsxs("span",{className:`text-[10px] tabular-nums ${Ht?"text-accent-red font-medium":"text-dark-muted/60"}`,children:["~",ot," tokens",Ht?` · ${l("chat.nearLimit")}`:""]}),!f&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("div",{ref:W,className:"relative",children:[e.jsxs("button",{onClick:()=>P(m=>!m),disabled:H.state!=="idle",className:`flex h-8 items-center justify-center gap-0.5 rounded-full px-2 text-[11px] font-semibold text-dark-muted transition-colors
36
- hover:bg-dark-hover hover:text-dark-text disabled:opacity-40`,title:l("stt.langToggle"),"aria-label":l("stt.langToggle"),"aria-haspopup":"listbox","aria-expanded":C,children:[Er(S).short,e.jsx(In,{size:11,"aria-hidden":"true"})]}),C&&e.jsxs("div",{role:"listbox","aria-label":l("stt.langToggle"),className:"absolute bottom-full right-0 mb-2 z-50 w-44 rounded-lg border border-dark-border bg-dark-surface shadow-lg py-1 max-h-72 overflow-auto custom-scrollbar",children:[Ar.map(m=>e.jsxs("button",{role:"option","aria-selected":m.code===S,onClick:()=>Y(m.code),className:ne("flex w-full items-center justify-between gap-2 px-3 py-1.5 text-xs transition-colors",m.code===S?"text-accent-blue bg-accent-blue/10":"text-dark-text hover:bg-dark-hover"),children:[e.jsx("span",{className:"font-medium",children:m.label}),e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-dark-muted",children:[m.code==="zh"?"FunASR":"Whisper",m.code===S&&e.jsx(Se,{size:12,"aria-hidden":"true"})]})]},m.code)),e.jsx("div",{className:"mt-1 border-t border-dark-border px-3 pt-1.5 pb-0.5 text-[10px] leading-relaxed text-dark-muted/70",children:l("stt.multiHint")})]})]}),e.jsx("button",{onClick:()=>void de(),disabled:H.state==="transcribing",className:ne("flex h-8 w-8 items-center justify-center rounded-full text-dark-muted transition-colors",H.state==="recording"?"bg-accent-red/15 text-accent-red animate-pulse":"hover:bg-dark-hover hover:text-dark-text","disabled:opacity-40 disabled:cursor-not-allowed"),title:H.state==="recording"?l("stt.stopTitle"):l("stt.title"),"aria-label":H.state==="recording"?l("stt.stopTitle"):l("stt.title"),children:H.state==="transcribing"?e.jsx(Fe,{size:15,className:"animate-spin","aria-hidden":"true"}):H.state==="recording"?e.jsx(Ws,{size:15,"aria-hidden":"true"}):e.jsx(Ks,{size:15,"aria-hidden":"true"})}),H.state==="recording"&&e.jsxs("span",{className:"text-[10px] tabular-nums text-accent-red","aria-hidden":"true",children:[(H.elapsedMs/1e3).toFixed(0),"s"]})]}),!f&&e.jsx("button",{onClick:()=>F(!0),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:l("skills.pickTitle"),"aria-label":l("skills.pickTitle"),children:e.jsx(Js,{size:15,"aria-hidden":"true"})}),!f&&e.jsx("button",{onClick:()=>void us(),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:l("fileJob.attach"),"aria-label":l("fileJob.attach"),children:e.jsx(Xs,{size:15,"aria-hidden":"true"})}),e.jsx("input",{ref:y,type:"file",multiple:!0,accept:Ni,className:"hidden",onChange:ds}),f?e.jsxs("div",{className:"flex items-center gap-1.5",children:[g?e.jsx("button",{onClick:o,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:l("chat.resumeGen"),"aria-label":l("chat.resumeGen"),children:e.jsx(Vs,{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:l("chat.pauseGen"),"aria-label":l("chat.pauseGen"),children:e.jsx(Cn,{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:l("chat.stopGen"),"aria-label":l("chat.stopGen"),children:e.jsx(Ys,{size:13,"aria-hidden":"true"})})]}):e.jsx("button",{onClick:()=>void Ye(),disabled:!ys,className:`flex h-8 w-8 items-center justify-center rounded-full bg-dark-text text-dark-bg transition-all
37
- hover:opacity-80 active:scale-95 disabled:opacity-25 disabled:cursor-not-allowed`,title:l("chat.sendBtn"),"aria-label":l("chat.sendBtn"),children:e.jsx(Rn,{size:15,"aria-hidden":"true"})})]})]}),e.jsxs("div",{className:"mt-1.5 hidden select-none items-center justify-center gap-3 text-[10px] text-dark-muted/55 sm:flex",children:[e.jsx("span",{children:l("chat.shiftEnter")}),e.jsx("span",{"aria-hidden":"true",children:"·"}),e.jsx("span",{children:l("chat.escHint")})]}),e.jsx(si,{open:I,onClose:()=>F(!1),onSelect:cs})]})}),Ri=15e3,Ii=300;function is(s){const{t}=q();return i.useMemo(()=>{const n=t("chat.askOtherLabel"),r=t("chat.askProceedLabel"),a=s.options||[],o=a.some(p=>p.label===n),d=a.some(p=>p.label===r),u=[...a];d||u.push({label:r,description:t("chat.askProceedDesc")}),o||u.push({label:n,description:t("chat.askCustomDesc")});const c=o?u.findIndex(p=>p.label===n):u.length-1,l=d?u.findIndex(p=>p.label===r):u.length-(o?1:2);return{allItems:u,otherIdx:c,proceedIdx:l,displayItems:u}},[s,t])}function wn({item:s,answered:t,selectedIdx:n,multiSelected:r,customInput:a,showCustomInput:o,onSelect:d,onToggleMulti:u,onProceed:c,onEnterCustom:l,onCancelCustom:p,onSubmitCustom:x,onCustomChange:f,inputRef:g}){const{t:b}=q(),{otherIdx:y,proceedIdx:v,displayItems:h}=is(s),A=!!s.multiSelect,D=R=>{if(R===v){c();return}if(R===y){l();return}if(A){u(R);return}d(R)};return e.jsxs("div",{className:"flex flex-col gap-2 max-h-64 overflow-y-auto",children:[h.map((R,I)=>{const F=n===I,j=r.has(I),S=I===y;return e.jsxs("div",{children:[e.jsxs("button",{type:"button",className:`w-full text-left px-3 py-2 rounded-md text-sm transition-colors ${F?"bg-blue-50 dark:bg-blue-900/20 border border-blue-300 dark:border-blue-700":"bg-gray-50 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-750"}`,onClick:()=>D(I),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center text-[10px] ${j?"bg-blue-600 border-blue-600 text-white":"border-gray-400 dark:border-gray-500"}`,children:j&&e.jsx(Se,{size:10})}),e.jsxs("span",{className:`font-medium ${F?"text-blue-700 dark:text-blue-300":"text-gray-800 dark:text-gray-200"}`,children:[A?"":`${I+1}. `,R.label]}),I===v&&e.jsx("span",{className:"text-xs text-emerald-600 dark:text-emerald-400",children:b("chat.askDirectTag")}),S&&e.jsx("span",{className:"text-xs text-gray-400",children:b("chat.askCustomTag")})]}),R.description&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5 ml-6",children:R.description})]}),S&&F&&o&&e.jsxs("div",{className:"mt-2 ml-4",children:[e.jsx("textarea",{ref:g,className:"w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-2 focus:ring-blue-500 resize-none",rows:3,value:a,onChange:L=>f(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),x()),L.key==="Escape"&&p()},placeholder:b("chat.askAnswerPlaceholder"),autoFocus:!0}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-3 py-1 text-xs font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700",onClick:x,children:[e.jsx(Le,{size:12}),b("chat.askSubmit")]}),e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-3 py-1 text-xs font-medium text-gray-600 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600",onClick:p,children:[e.jsx(Re,{size:12}),b("common.cancel")]})]})]})]},`opt-${I}`)}),t&&e.jsx("div",{className:"text-xs text-emerald-600 dark:text-emerald-400 font-medium",children:b("chat.askAnswered")})]})}function _i({isOpen:s,onClose:t}){const{t:n}=q(),[r,a]=i.useState(null),[o,d]=i.useState(-1),[u,c]=i.useState(new Set),[l,p]=i.useState(""),[x,f]=i.useState(!1),[g,b]=i.useState(!1),[y,v]=i.useState(0),[h,A]=i.useState([]),[D,R]=i.useState(!1),I=i.useRef(null),F=i.useRef(null),j=i.useMemo(()=>r?r.questions&&r.questions.length>0?r.questions:[{question:r.question,header:r.header,options:r.options,multiSelect:r.multiSelect}]:[],[r]),S=j.length>1,L=i.useCallback(E=>{a(E),d(E.multiSelect?-1:0),c(new Set),p(""),f(!1),b(!1),v(0),R(!1);const M=E.questions&&E.questions.length>0?E.questions:[E];A(M.map(()=>null))},[]);i.useEffect(()=>{F.current=r}),i.useEffect(()=>{if(s){const E=window.__pendingQuestion;E&&L(E)}},[s,L]),i.useEffect(()=>{const E=M=>{var ue;const B=M.detail,ie=((ue=F.current)==null?void 0:ue.questionId)??null;if(B&&ie&&B!==ie)return;const le=ie;b(!0),setTimeout(()=>{var w;const ve=((w=F.current)==null?void 0:w.questionId)??null;le&&ve&&ve!==le||(t(),a(null),b(!1))},Ii)};return window.addEventListener("ask-question-dismiss",E),()=>window.removeEventListener("ask-question-dismiss",E)},[t]),i.useEffect(()=>{if(!g)return;const E=setTimeout(()=>b(!1),Ri);return()=>clearTimeout(E)},[g]),i.useEffect(()=>{const E=()=>{const M=window.__pendingQuestion;M&&L(M)};return window.addEventListener("ask-question-required",E),()=>window.removeEventListener("ask-question-required",E)},[L]),i.useEffect(()=>{d(0),c(new Set),p(""),f(!1)},[y,D,r]);const C=j[y]||null,{allItems:P,otherIdx:W}=is(C||{question:""}),Y=i.useCallback((E,M)=>{g||!r||(b(!0),ce.send({type:"question_answer",sessionId:ce.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answer:E,selectedOptions:M})}))},[g,r]),H=i.useCallback(()=>{g||!r||(b(!0),ce.send({type:"question_answer",sessionId:ce.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answers:j.map((E,M)=>h[M]||{answer:n("chat.askUnansweredValue")})})}))},[g,r,j,h,n]),K=i.useCallback((E,M,B)=>{A(ie=>{const le=ie.slice();return le[E]={answer:M,selectedOptions:B},le}),E<j.length-1?v(E+1):R(!0)},[j.length]),ee=i.useCallback(E=>{if(g||!r)return;const M=P[E];M&&(d(E),Y(M.label,[M.label]))},[g,r,P,Y]),se=i.useCallback(()=>{if(g||!r||o<0)return;const E=P[o];E&&Y(E.label,[E.label])},[g,r,o,P,Y]),de=i.useCallback(()=>{if(g||o<0)return;const E=P[o];E&&K(y,E.label,[E.label])},[g,o,P,K,y]),N=i.useCallback(E=>{if(g)return;const M=P[E];M&&K(y,M.label,[M.label])},[g,P,K,y]),$=i.useCallback(E=>{g||c(M=>{const B=new Set(M);return B.has(E)?B.delete(E):B.add(E),B})},[g]),te=i.useCallback(()=>{if(g)return;const E=[...u].map(M=>{var B;return((B=P[M])==null?void 0:B.label)||""});S?K(y,E.join(", "),E):Y(E.join(", "),E)},[g,u,P,S,K,y,Y]),X=i.useCallback(()=>{if(g)return;const E=n("chat.askProceedLabel");S?K(y,E,[E]):Y(E,[E])},[g,S,K,y,Y,n]),ae=i.useCallback(()=>{g||(d(W),f(!0),setTimeout(()=>{var E;return(E=I.current)==null?void 0:E.focus()},100))},[g,W]),J=i.useCallback(()=>{f(!1),p("")},[]),he=i.useCallback(()=>{if(g)return;const E=l||n("chat.askEmptyInputValue");S?K(y,E):Y(E)},[g,l,S,K,y,Y,n]),fe=i.useCallback(()=>{g||!r||(b(!0),ce.send({type:"question_answer",sessionId:ce.getSessionId()??void 0,data:JSON.stringify({questionId:r.questionId,answers:j.map(()=>({answer:"(cancelled)"}))})}))},[g,r,j]),ge=i.useCallback(()=>{if(!g){if(S){if(x){f(!1),p("");return}if(D){R(!1),v(j.length-1);return}fe();return}if(x){f(!1),p("");return}Y("(cancelled)")}},[g,S,x,D,j.length,fe,Y]);if(!s||!r)return null;const ke=h.filter(E=>!E).length;return e.jsx(On,{isOpen:s,onClose:ge,title:r.header||n(S?"chat.askBatchTitle":"chat.askSingleTitle"),badge:e.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-accent-blue shrink-0",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-blue animate-pulse"}),n("chat.askPendingBadge"),S?` · ${h.filter(Boolean).length}/${j.length}`:""]}),collapsedSummary:e.jsx("span",{className:"truncate",children:(C==null?void 0:C.question)||r.question}),maxHeight:"50vh",children:S?e.jsxs("div",{className:"flex flex-col gap-4",children:[r.autoResolutionMs&&r.autoResolutionMs>0&&e.jsx("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-1.5",children:n("chat.askAutoContinue",{seconds:Math.max(1,Math.round(r.autoResolutionMs/1e3))})}),e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[j.map((E,M)=>{const B=!!h[M],ie=!D&&y===M;return e.jsxs("button",{type:"button",onClick:()=>{v(M),R(!1)},className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${ie?"bg-blue-600 text-white":B?"bg-emerald-50 dark:bg-emerald-900/20 text-emerald-700 dark:text-emerald-300":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:["Q",M+1," ",B?"✓":""]},`nav-${M}`)}),e.jsx("button",{type:"button",onClick:()=>R(!0),className:`px-2 py-1 rounded-md text-xs font-medium transition-colors ${D?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"}`,children:n("chat.askSubmit")})]}),D?e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:n("chat.askReviewTitle")}),j.map((E,M)=>{const B=h[M];return e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed min-w-0",children:[e.jsxs("span",{className:"font-medium",children:[M+1,". "]}),E.question]}),e.jsx("div",{className:`text-xs shrink-0 max-w-[45%] text-right break-words ${B?"text-emerald-600 dark:text-emerald-400":"text-amber-600 dark:text-amber-400"}`,children:B?B.answer:n("chat.askNotAnswered")})]},`rev-${M}`)}),ke>0&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-2",children:[e.jsx(Ce,{size:14}),n("chat.askUnansweredWarning",{count:ke})]}),e.jsxs("div",{className:"flex gap-2 mt-1",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50",onClick:H,disabled:g,children:[e.jsx(Le,{size:14}),n("chat.askSubmitAll")]}),e.jsx("button",{type:"button",className:"inline-flex items-center gap-1 px-4 py-2 text-sm font-medium text-gray-600 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 rounded-md hover:bg-gray-200 dark:hover:bg-gray-600",onClick:()=>{R(!1),v(j.length-1)},disabled:g,children:n("chat.askBackToEdit")})]})]}):C?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed min-w-0",children:C.question}),e.jsxs("div",{className:"flex gap-1 shrink-0",children:[e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700 disabled:opacity-40",onClick:()=>{v(E=>Math.max(0,E-1)),R(!1)},disabled:y===0,children:[e.jsx(Qs,{size:12}),n("chat.askPrevQuestion")]}),y<j.length-1?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-800 rounded-md hover:bg-gray-200 dark:hover:bg-gray-700",onClick:()=>{v(E=>Math.min(j.length-1,E+1)),R(!1)},children:[n("chat.askNextQuestion"),e.jsx(je,{size:12})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-0.5 px-2 py-1 text-xs font-medium text-blue-700 dark:text-blue-300 bg-blue-50 dark:bg-blue-900/20 rounded-md hover:bg-blue-100 dark:hover:bg-blue-900/30",onClick:()=>R(!0),children:[n("chat.askViewSubmit"),e.jsx(je,{size:12})]})]})]}),e.jsx(wn,{item:C,answered:!!h[y],selectedIdx:o,multiSelected:u,customInput:l,showCustomInput:x,onSelect:N,onToggleMulti:$,onProceed:X,onEnterCustom:ae,onCancelCustom:J,onSubmitCustom:he,onCustomChange:p,inputRef:I}),!x&&e.jsx("div",{className:"flex items-center gap-2",children:C.multiSelect?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:te,disabled:g||u.size===0,children:[e.jsx(Le,{size:14}),n("chat.askFinishQuestion",{count:u.size})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:de,disabled:g||o<0,children:[e.jsx(Le,{size:14}),n("chat.askConfirmQuestion")]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:x?e.jsx("span",{children:n("chat.askEnterHint")}):C.multiSelect?e.jsx("span",{children:n("chat.askMultiHintBatch")}):e.jsx("span",{children:n("chat.askSingleHintBatch")})})]}):null]}):e.jsxs("div",{className:"flex flex-col gap-4",children:[r.autoResolutionMs&&r.autoResolutionMs>0&&e.jsx("div",{className:"flex items-center gap-2 text-xs text-amber-600 dark:text-amber-400 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700 rounded-md px-3 py-1.5",children:n("chat.askAutoContinue",{seconds:Math.max(1,Math.round(r.autoResolutionMs/1e3))})}),e.jsx("div",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:r.question}),e.jsx(wn,{item:j[0],answered:!1,selectedIdx:o,multiSelected:u,customInput:l,showCustomInput:x,onSelect:ee,onToggleMulti:$,onProceed:X,onEnterCustom:ae,onCancelCustom:J,onSubmitCustom:he,onCustomChange:p,inputRef:I}),!x&&e.jsx("div",{className:"flex items-center gap-2",children:r.multiSelect?e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:te,disabled:g||u.size===0,children:[e.jsx(Le,{size:14}),n("chat.askSubmitSelected",{count:u.size})]}):e.jsxs("button",{type:"button",className:"inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:se,disabled:g||o<0,children:[e.jsx(Le,{size:14}),n("chat.askSubmit")]})}),e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500",children:g?e.jsx("span",{children:n("chat.askSubmitting")}):x?e.jsx("span",{children:n("chat.askEnterHint")}):r.multiSelect?e.jsx("span",{children:n("chat.askMultiHintSingle")}):e.jsx("span",{children:n("chat.askSingleHintSingle")})})]})})}const Ue=15;function Mi({isOpen:s,onCloseModal:t}){const{t:n}=q("hook"),r=Et(),a=r.pendingApprovals,o=r.autoMode,d=r.setAutoMode,[u,c]=i.useState(0),[l,p]=i.useState(!1),[x,f]=i.useState(Ue),[g,b]=i.useState(!0),y=i.useRef(null),v=i.useRef(!1);i.useEffect(()=>{if(a.length!==0){if(o){a.forEach(M=>{ce.send({type:"hook_allow",data:JSON.stringify({approvalId:M.approvalId})})}),r.clearApprovals();return}c(M=>Math.min(M,a.length-1))}},[a.length,o]);const h=a[u]??null,A=a.length>0&&h!==null,D=a.length,R=A?D-u-1:0;i.useEffect(()=>{if(!(!A||l||!s||!h))return f(Ue),y.current=setInterval(()=>{f(M=>M<=1?(y.current&&clearInterval(y.current),0):M-1)},1e3),()=>{y.current&&clearInterval(y.current)}},[A,l,s,h==null?void 0:h.approvalId]);const I=h?Dn(h.toolName,h.askPayload):{level:"MEDIUM",reasonKey:"risk_default"},F=$n[I.level],j=vr[I.level==="CRITICAL"?"critical":I.level==="HIGH"?"high":I.level==="LOW"?"low":"medium"],S=h?Yn(h.toolName,h.askPayload):null,L=h?Nr(h.toolName,h.askPayload):null,C=h?{verb:Xn(h.toolName),target:Vn(h.toolName,h.askPayload)}:null,P=h?Ke(h.askPayload)!==null:!1,W=h?Zn(h.toolName,h.askPayload):null,Y=x/Ue*100,H=x<=5,K=jr(Ue-x),ee=i.useCallback((M,B)=>{const ie=Ln.getState().activeSessionId;ie&&be.getState().updateHookApprovalStatus(ie,M,B)},[]),se=i.useCallback(M=>{h&&(M&&ee(h.approvalId,M),p(!0),setTimeout(()=>{r.removeApproval(h.approvalId),c(0),p(!1),v.current=!1,f(Ue)},200))},[h==null?void 0:h.approvalId,r,ee]),de=i.useCallback(()=>{!h||l||v.current||(v.current=!0,y.current&&clearInterval(y.current),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:h.approvalId})}),se("approved"))},[h,se,l]),N=i.useCallback(()=>{!h||l||v.current||(v.current=!0,y.current&&clearInterval(y.current),ce.send({type:"hook_deny",data:JSON.stringify({approvalId:h.approvalId})}),se("denied"))},[h,se,l]),$=i.useCallback(()=>{if(!h||l||v.current)return;v.current=!0,y.current&&clearInterval(y.current);const M=Ke(h.askPayload);M?(r.addToSessionAllowList(h.toolName,M),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:h.approvalId,sessionAllow:!0})})):(r.addToSessionAllowList(h.toolName),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:h.approvalId})})),se("approved")},[h,se,r,l]),te=i.useCallback(()=>{!h||l||v.current||(v.current=!0,y.current&&clearInterval(y.current),d(!0),Ee.getState().setAuto(!0),ce.send({type:"hook_allow",data:JSON.stringify({approvalId:h.approvalId})}),se("approved"))},[h,se,l,d]),X=((h==null?void 0:h.timeoutMs)??15e3)>0,ae=(h==null?void 0:h.timeoutAction)==="deny"?N:de;if(i.useEffect(()=>{x===0&&s&&!l&&h&&X&&ae()},[x,s,l,h,ae,X]),i.useEffect(()=>{if(!s||!g)return;const M=B=>{const ie=B.target;ie&&typeof ie.closest=="function"&&ie.closest('input, textarea, select, [contenteditable="true"]')||(B.key==="Escape"?(B.preventDefault(),B.stopPropagation(),N()):B.key==="Enter"?(B.preventDefault(),de()):B.key==="1"?de():B.key==="2"?N():B.key==="3"?$():B.key==="4"&&te())};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[s,g,de,N,$,te]),!A||!h)return null;const J=n("optionAllowHint"),he=n("optionDenyHint"),fe=P?n("optionAllowPathHint"):n("optionAllowAlwaysHint",{tool:h.toolName}),ge=n("optionAutoModeHint"),ke=(S==null?void 0:S.text)??L??null,E=ke?e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("code",{className:"font-mono text-[11px] bg-dark-surface text-accent-blue px-1 py-0.5 rounded shrink-0",children:h.toolName}),e.jsx("span",{className:"truncate",children:ke})]}):null;return e.jsx(On,{isOpen:s,onClose:()=>t==null?void 0:t(),title:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nt,{className:"w-4 h-4 text-yellow-400"}),e.jsx("span",{children:n("hookApproval")}),e.jsxs("span",{className:"text-xs text-dark-muted",children:["(",u+1,"/",D,")"]})]}),badge:e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-bold border shrink-0 ${F.badge}`,children:[F.icon," ",I.level]}),collapsedSummary:E,onExpandedChange:b,maxHeight:"50vh",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded-lg ${F.bg} border ${F.border}`,children:[e.jsxs("span",{className:`px-1.5 py-0.5 rounded text-xs font-bold border ${F.badge}`,children:[F.icon," ",I.level]}),e.jsx("span",{className:"text-xs text-dark-muted truncate",children:n(I.reasonKey)}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto shrink-0",children:[e.jsx(Ae,{size:12,className:H?"text-accent-red":"text-dark-muted"}),e.jsx("span",{className:`text-xs font-mono ${H?"text-accent-red animate-pulse":"text-dark-muted"}`,children:X?`${x}s`:"∞"}),e.jsx("div",{className:"w-12 h-1.5 bg-dark-border rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all duration-700 ${H?"bg-accent-red":x<=8?"bg-accent-yellow":"bg-accent-green"}`,style:{width:`${Y}%`}})})]})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:"flex-none w-7 h-7 rounded-lg bg-accent-blue/10 text-accent-blue inline-flex items-center justify-center",children:e.jsx(Nt,{size:15})}),C&&e.jsx(Qn,{pre:n(C.verb),obj:C.target})]}),W&&(W.external&&W.path?e.jsxs("span",{className:"flex items-center gap-1 text-[11px] px-1.5 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/30 shrink-0",title:W.path,children:[e.jsx(En,{size:10}),n("scopeExternal"),": ",W.path.length>48?`${W.path.slice(0,47)}…`:W.path]}):e.jsx("span",{className:"text-[11px] text-dark-muted/60 shrink-0",children:n("scopeLocal")}))]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-dark-muted shrink-0",children:n("tool")}),e.jsx("code",{className:"text-accent-blue font-mono text-xs bg-dark-surface px-1.5 py-0.5 rounded truncate",children:h.toolName}),e.jsx("span",{className:"text-dark-muted/50",children:K}),e.jsx("span",{className:"text-dark-muted/50",children:j.label}),h.timeoutAction&&e.jsxs("span",{className:`text-xs ${h.timeoutAction==="deny"?"text-accent-red":"text-accent-green"}`,children:["timeout: ",X?`${h.timeoutAction==="allow"?"auto-allow":"auto-deny"}${h.timeoutMs?` (${(h.timeoutMs/1e3).toFixed(0)}s)`:""}`:n("timeoutWaitUser")]})]}),S?e.jsx(Ct,{text:S.text,mono:S.mono}):L?e.jsx(Ct,{text:L}):null,(I.level==="CRITICAL"||I.level==="HIGH")&&e.jsxs("div",{className:`flex items-center gap-1.5 text-xs px-2 py-1.5 rounded ${F.bg} ${F.text}`,children:[e.jsx(Ce,{size:13}),e.jsx("span",{children:I.level==="CRITICAL"?n("highRiskWarning"):n("mediumRiskConfirm")})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("button",{onClick:de,disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-accent-blue text-white text-sm font-medium hover:opacity-90 shadow-sm transition-all disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono bg-white/20 rounded px-1",children:"1"}),e.jsx("span",{children:Ze.allow.label}),e.jsx("span",{className:"text-[11px] text-white/70 hidden sm:inline",children:J})]}),e.jsxs("button",{onClick:$,disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted bg-dark-surface rounded px-1",children:"3"}),e.jsx("span",{children:Ze.allow_session.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:fe})]}),e.jsxs("button",{onClick:te,disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg border border-dark-border bg-dark-bg text-dark-text hover:bg-dark-hover text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted bg-dark-surface rounded px-1",children:"4"}),e.jsx("span",{children:Ze.auto.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:ge})]}),e.jsx("span",{className:"flex-1"}),e.jsxs("button",{onClick:N,disabled:l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-dark-muted hover:bg-red-500/10 hover:text-red-400 text-sm transition-colors disabled:opacity-50",children:[e.jsx("span",{className:"text-[10px] font-mono text-dark-muted/60 rounded px-1",children:"2"}),e.jsx("span",{children:Ze.deny.label}),e.jsx("span",{className:"text-[11px] text-dark-muted/60 hidden sm:inline",children:he})]})]}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-dark-muted/60",children:[e.jsx("span",{children:n("shortcutHint")}),e.jsx("span",{children:R>0?n("morePending",{n:R}):n("lastItem")})]})]})})}const vt="dsc-auto-access-banner-dismissed",Di=i.memo(function(){const{t}=q(),n=Ee(u=>u.mode),[r,a]=i.useState(()=>localStorage.getItem(vt)==="1");i.useEffect(()=>{At(n==="normal"?"act":n)||localStorage.getItem(vt)==="1"&&a(!1)},[n]);const o=i.useCallback(u=>{u&&localStorage.setItem(vt,"1"),a(!0)},[]);return!(n!=="normal"&&At(n))||r?null:e.jsxs("div",{className:"flex items-center gap-1.5 px-4 py-1 text-[10.5px] leading-snug text-accent-yellow/75 bg-accent-yellow/[0.05] border-b border-accent-yellow/10 select-none",role:"note",title:t("autoAccess.desc"),children:[e.jsx(er,{size:11,className:"shrink-0 text-accent-yellow/70"}),e.jsxs("div",{className:"min-w-0 flex-1 truncate",children:[e.jsx("span",{className:"font-medium",children:t("autoAccess.title")}),e.jsxs("span",{className:"text-accent-yellow/60",children:[" · ",t("autoAccess.desc")]})]}),e.jsx("button",{onClick:()=>o(!1),className:"shrink-0 rounded p-0.5 text-accent-yellow/50 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors",title:t("autoAccess.dismiss"),"aria-label":t("autoAccess.dismiss"),children:e.jsx(Re,{size:11})}),e.jsx("button",{onClick:()=>o(!0),className:"shrink-0 rounded px-1 py-px text-[9.5px] text-accent-yellow/50 hover:text-accent-yellow hover:bg-accent-yellow/10 transition-colors whitespace-nowrap",children:t("autoAccess.neverShow")})]})}),vn=24,Nn=240,$i={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"}},Li=({status:s})=>s==="running"?e.jsx(Fe,{size:12,className:"animate-spin text-accent-blue"}):s==="completed"?e.jsx(jt,{size:12,className:"text-accent-green"}):s==="failed"?e.jsx(sr,{size:12,className:"text-accent-red"}):s==="skipped"?e.jsx(rr,{size:12,className:"text-dark-muted"}):e.jsx(ar,{size:12,className:"text-dark-muted"}),Oi=i.memo(function({sessionId:t,defaultExpanded:n,onClose:r}){const{t:a}=q(),[o,d]=i.useState(n??!1),[u,c]=i.useState(null),l=Fn(C=>C.getTasksForSession(t)),[p,x]=i.useState(null),f=i.useRef(null),g=i.useRef(!1),b=i.useRef(null),y=i.useCallback(C=>{var P;C.button===0&&(C.target.closest("[data-taskboard-close]")||(g.current=!1,f.current={y:C.clientY,expanded:o,bodyHeight:((P=b.current)==null?void 0:P.offsetHeight)??0},C.currentTarget.setPointerCapture(C.pointerId)))},[o]),v=i.useCallback(C=>{const P=f.current;P&&(Math.abs(C.clientY-P.y)>4&&(g.current=!0),x(C.clientY-P.y))},[]),h=i.useCallback(C=>{const P=f.current;if(!P)return;const W=C.clientY-P.y;P.expanded&&W<-vn?d(!1):!P.expanded&&W>vn&&d(!0),f.current=null,x(null),setTimeout(()=>{g.current=!1},0)},[]),A=i.useCallback(()=>{if(g.current){g.current=!1;return}d(C=>!C)},[]),D=i.useCallback(C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),d(P=>!P))},[]),R=p!==null,I=i.useMemo(()=>{const C=f.current;return p===null||!C?null:C.expanded?Math.min(Nn,Math.max(0,C.bodyHeight+p)):Math.min(Nn,Math.max(0,p))},[p]),F=i.useMemo(()=>{const C=l.length,P=l.filter(K=>K.status==="completed").length,W=l.filter(K=>K.status==="running").length,Y=l.filter(K=>K.status==="failed").length,H=C>0?Math.round(P/C*100):0;return{total:C,completed:P,running:W,failed:Y,progress:H}},[l]),j=i.useMemo(()=>{const C={pending:[],running:[],completed:[],failed:[]};return l.forEach(P=>{const W=P.status==="skipped"?"pending":P.status;C[W].push(P)}),C},[l]),S=[...j.running,...j.failed,...j.pending.slice(0,5),...j.completed.slice(-3)],L=o||R;return l.length===0?null:e.jsxs("div",{className:"w-full shrink-0 mb-2 border border-dark-border rounded-lg bg-dark-bg/70 overflow-hidden",children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-expanded":o,onClick:A,onKeyDown:D,onPointerDown:y,onPointerMove:v,onPointerUp:h,onPointerCancel:h,onLostPointerCapture:h,className:"w-full flex items-center justify-between px-2.5 py-1.5 hover:bg-dark-hover transition-colors cursor-pointer select-none touch-none",title:a("chat.taskBoardDragHint"),children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(tr,{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:[F.completed,"/",F.total]}),F.total>0&&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 ${F.running>0?"bg-accent-blue":F.failed>0?"bg-accent-red":"bg-accent-green"}`,style:{width:`${F.progress}%`}})}),F.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&&e.jsx("span",{role:"button",tabIndex:0,"data-taskboard-close":!0,onClick:C=>{C.stopPropagation(),r()},onKeyDown:C=>{C.key==="Enter"&&(C.stopPropagation(),r())},className:"p-0.5 rounded hover:bg-dark-hover transition-colors cursor-pointer",title:"Hide task drawer",children:e.jsx(Re,{size:12,className:"text-dark-muted"})}),e.jsx(nr,{size:12,className:"text-dark-muted/40 shrink-0","aria-hidden":"true"}),o?e.jsx(In,{size:14,className:"text-dark-muted"}):e.jsx(we,{size:14,className:"text-dark-muted"})]})]}),L&&e.jsx("div",{ref:b,className:"border-t border-dark-border",style:I!==null?{height:I,overflow:"hidden"}:void 0,children:l.length===0?e.jsx("div",{className:"text-xs text-dark-muted py-4 text-center",children:a("chat.noTasks")}):e.jsxs("div",{className:"px-2.5 py-2 max-h-[240px] overflow-y-auto custom-scrollbar space-y-1.5",children:[S.map(C=>e.jsx(Pi,{task:C,isSelected:C.id===u,onClick:()=>c(u===C.id?null:C.id)},C.id)),j.pending.length>5&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[j.pending.length-5," more pending tasks"]}),j.completed.length>3&&e.jsxs("div",{className:"text-[10px] text-dark-muted text-center",children:[j.completed.length-3," more completed tasks"]})]})})]})}),Fi=(s,t)=>{if(!s)return"";const n=(t||Date.now())-s;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`},Pi=i.memo(function({task:t,isSelected:n,onClick:r}){const a=$i[t.status];return e.jsxs("div",{onClick:r,className:`rounded border p-2 cursor-pointer transition-all ${a.bg} border-dark-border
38
- ${n?"ring-1 ring-accent-blue":"hover:border-dark-muted/40"}
39
- ${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(Li,{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:Fi(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"]})]})]})}),Ki=i.memo(function({tabs:t,activeSessionId:n,onSend:r,onStop:a,onPause:o,onResume:d,activeTab:u,setActiveTab:c,createNewSession:l,clearMessages:p,setTheme:x,setThemePreset:f,toggleTerminal:g,setLogs:b,setUnreadLogs:y,showTaskBoard:v=!0,onToggleTaskBoard:h,onRegenerate:A,onDeleteMessage:D,hookDrawerOpen:R,onCloseHookDrawer:I,questionDrawerOpen:F,onCloseQuestionDrawer:j,workspaceDir:S,onWorkspaceSelect:L}){const C=i.useMemo(()=>({setActiveTab:c,createNewSession:l,clearMessages:p,setTheme:x,setThemePreset:f,toggleTerminal:g,setLogs:b,setUnreadLogs:y}),[c,l,p,x,f,g,b,y]),P=be(N=>n?N.messagesBySession[n]||[]:[]),W=be(N=>n?N.generatingSessions.includes(n):!1),Y=be(N=>n?N.pausedSessions.includes(n):!1),H=t.find(N=>N.id===n)||null;i.useEffect(()=>{if(!n)return;let N=!1;return xe.tasks.list(n).then($=>{if(N||!$.success||!Array.isArray($.data))return;const te={PENDING:"pending",RUNNING:"running",COMPLETED:"completed",FAILED:"failed",CANCELLED:"skipped"},X=Date.now(),ae=$.data.filter(J=>J.sessionId===n).map(J=>{const he=new Date(J.createdAt).getTime()||X,fe=new Date(J.updatedAt).getTime()||X;return{id:J.id,sessionId:n,title:J.title,status:te[J.status]||"pending",source:"task",description:J.description,progress:J.progress,createdAt:he,updatedAt:fe,raw:J}});Fn.getState().setTasks(n,ae,"task")}).catch(()=>{}),()=>{N=!0}},[n]);const K=i.useCallback((N,$)=>{n&&r(n,N,$)},[r,n]),ee=i.useCallback(N=>{n&&r(n,N)},[r,n]),se=i.useCallback(N=>{n&&A&&A(n,N)},[A,n]),de=i.useCallback(N=>{n&&D&&D(n,N)},[D,n]);return e.jsx("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(Di,{}),H&&e.jsxs(e.Fragment,{children:[e.jsx(Ka,{messages:P,isGenerating:W,isPaused:Y,sessionId:H.id,onSendSuggestion:ee,onRegenerate:A?se:void 0,onDeleteMessage:D?de:void 0}),e.jsx(Mi,{isOpen:!!R,onCloseModal:I}),e.jsx(_i,{isOpen:!!F,onClose:j??(()=>{})}),v&&e.jsx(Oi,{sessionId:H.id,defaultExpanded:!1,onClose:h},H.id),e.jsx(Ti,{sessionId:H.id,onSend:K,onStop:()=>a(H.id),onPause:()=>o(H.id),onResume:()=>d(H.id),slashOptions:C,workspaceDir:S,onWorkspaceSelect:L})]})]})})});export{Ki as SessionGrid};