linkshell-cli 0.5.23 → 0.5.25

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.
@@ -81,7 +81,7 @@ Error generating stack: `+s.message+`
81
81
  ]`,k={scope:"string",variants:[m,d,p,x]},w={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},_=["false","null","true"],b=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],v=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],T={keyword:b,literal:(W=>{const G=[];return W.forEach(K=>{G.push(K),K.toLowerCase()===K?G.push(K.toUpperCase()):G.push(K.toLowerCase())}),G})(_),built_in:v},M=W=>W.map(G=>G.replace(/\|\d+$/,"")),N={variants:[{match:[/new/,n.concat(S,"+"),n.concat("(?!",M(v).join("\\b|"),"\\b)"),l],scope:{1:"keyword",4:"title.class"}}]},O=n.concat(a,"\\b(?!\\()"),R={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),O],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[l,n.concat(/::/,n.lookahead(/(?!class\b)/)),O],scope:{1:"title.class",3:"variable.constant"}},{match:[l,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[l,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},L={scope:"attr",match:n.concat(a,n.lookahead(":"),n.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:T,contains:[L,f,R,e.C_BLOCK_COMMENT_MODE,k,w,N]},H={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",M(b).join("\\b|"),"|",M(v).join("\\b|"),"\\b)"),a,n.concat(S,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(H);const q=[L,R,e.C_BLOCK_COMMENT_MODE,k,w,N],F={begin:n.concat(/#\[\s*\\?/,n.either(l,u)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:_,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:_,keyword:["new","array"]},contains:["self",...q]},...q,{scope:"meta",variants:[{match:l},{match:u}]}]};return{case_insensitive:!1,keywords:T,contains:[F,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},o,{scope:"variable.language",match:/\$this\b/},f,H,R,{match:[/const/,/\s/,a],scope:{1:"keyword",3:"variable.constant"}},N,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:T,contains:["self",F,f,R,e.C_BLOCK_COMMENT_MODE,k,w]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},k,w]}}function yM(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function xM(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function SM(e){const n=e.regex,r=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),a=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],o={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:a,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},h={className:"meta",begin:/^(>>>|\.\.\.) /},d={className:"subst",begin:/\{/,end:/\}/,keywords:o,illegal:/#/},m={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,h],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,h],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,h,m,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,h,m,d]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,m,d]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,m,d]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",S=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,k=`\\b|${a.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${S}))[eE][+-]?(${x})[jJ]?(?=${k})`},{begin:`(${S})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${k})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${k})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${k})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${k})`},{begin:`\\b(${x})[jJ](?=${k})`}]},_={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:o,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:["self",h,w,p,e.HASH_COMMENT_MODE]}]};return d.contains=[p,w,h],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:o,illegal:/(<\/|\?)|=>/,contains:[h,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,_,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,r],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,r,/\s*/,/\(\s*/,r,/\s*\)/]},{match:[/\bclass/,/\s+/,r]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[w,b,p]}]}}function EM(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function wM(e){const n=e.regex,r=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,a=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),l=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,u=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:r,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:r},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[l,a]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,a]},{scope:{1:"punctuation",2:"number"},match:[u,a]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,a]}]},{scope:{3:"operator"},match:[r,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:l},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:u},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function CM(e){const n=e.regex,r="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",a=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),l=n.concat(a,/(::\w+)*/),f={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},o={className:"doctag",begin:"@[A-Za-z]+"},h={begin:"#<",end:">"},d=[e.COMMENT("#","$",{contains:[o]}),e.COMMENT("^=begin","^=end",{contains:[o],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],m={className:"subst",begin:/#\{/,end:/\}/,keywords:f},p={className:"string",contains:[e.BACKSLASH_ESCAPE,m],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,m]})]}]},x="[1-9](_?[0-9])*|0",S="[0-9](_?[0-9])*",k={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${S}))?([eE][+-]?(${S})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},w={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:f}]},N=[p,{variants:[{match:[/class\s+/,l,/\s+<\s+/,l]},{match:[/\b(class|module)\s+/,l]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:f},{match:[/(include|extend)\s+/,l],scope:{2:"title.class"},keywords:f},{relevance:0,match:[l,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:a,scope:"title.class"},{match:[/def/,/\s+/,r],scope:{1:"keyword",3:"title.function"},contains:[w]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:r}],relevance:0},k,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:f},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,m],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(h,d),relevance:0}].concat(h,d);m.contains=N,w.contains=N;const z=[{begin:/^\s*=>/,starts:{end:"$",contains:N}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:f,contains:N}}];return d.unshift(h),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:f,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(z).concat(d).concat(N)}}function kM(e){const n=e.regex,r=/(r#)?/,a=n.concat(r,e.UNDERSCORE_IDENT_RE),l=n.concat(r,e.IDENT_RE),u={className:"title.function.invoke",relevance:0,begin:n.concat(/\b/,/(?!let|for|while|if|else|match\b)/,l,n.lookahead(/\s*\(/))},f="([ui](8|16|32|64|128|size)|f(32|64))?",o=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],h=["true","false","Some","None","Ok","Err"],d=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],m=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:m,keyword:o,literal:h,built_in:d},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+f},{begin:"\\b0o([0-7_]+)"+f},{begin:"\\b0x([A-Fa-f0-9_]+)"+f},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+f}],relevance:0},{begin:[/fn/,/\s+/,a],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,a],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,a,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,a],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:d,type:m}},{className:"punctuation",begin:"->"},u]}}const TM=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),AM=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],NM=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],RM=[...AM,...NM],MM=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),OM=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),DM=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),LM=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function IM(e){const n=TM(e),r=DM,a=OM,l="@[a-z-]+",u="and or not only",o={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,n.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+RM.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+a.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+r.join("|")+")"},o,{begin:/\(/,end:/\)/,contains:[n.CSS_NUMBER_MODE]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+LM.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[n.BLOCK_COMMENT,o,n.HEXCOLOR,n.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.IMPORTANT,n.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:l,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:u,attribute:MM.join(" ")},contains:[{begin:l,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},o,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.HEXCOLOR,n.CSS_NUMBER_MODE]},n.FUNCTION_DISPATCH]}}function BM(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function PM(e){const n=e.regex,r=e.COMMENT("--","$"),a={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},l={begin:/"/,end:/"/,contains:[{match:/""/}]},u=["true","false","unknown"],f=["double precision","large object","with timezone","without timezone"],o=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],h=["add","asc","collation","desc","final","first","last","view"],d=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],m=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],x=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],S=m,k=[...d,...h].filter(M=>!m.includes(M)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},_={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:n.concat(/\b/,n.either(...S),/\s*\(/),relevance:0,keywords:{built_in:S}};function v(M){return n.concat(/\b/,n.either(...M.map(N=>N.replace(/\s+/,"\\s+"))),/\b/)}const y={scope:"keyword",match:v(x),relevance:0};function T(M,{exceptions:N,when:O}={}){const R=O;return N=N||[],M.map(L=>L.match(/\|\d+$/)||N.includes(L)?L:R(L)?`${L}|0`:L)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:T(k,{when:M=>M.length<3}),literal:u,type:o,built_in:p},contains:[{scope:"type",match:v(f)},y,b,w,a,l,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,r,_]}}function jy(e){return e?typeof e=="string"?e:e.source:null}function bo(e){return jt("(?=",e,")")}function jt(...e){return e.map(r=>jy(r)).join("")}function zM(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function On(...e){return"("+(zM(e).capture?"":"?:")+e.map(a=>jy(a)).join("|")+")"}const Lf=e=>jt(/\b/,e,/\w$/.test(e)?/\b/:/\B/),jM=["Protocol","Type"].map(Lf),Lv=["init","self"].map(Lf),UM=["Any","Self"],pd=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Iv=["false","nil","true"],HM=["assignment","associativity","higherThan","left","lowerThan","none","right"],FM=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Bv=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],Uy=On(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),Hy=On(Uy,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),md=jt(Uy,Hy,"*"),Fy=On(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Sc=On(Fy,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Ni=jt(Fy,Sc,"*"),ac=jt(/[A-Z]/,Sc,"*"),$M=["attached","autoclosure",jt(/convention\(/,On("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",jt(/objc\(/,Ni,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],qM=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function KM(e){const n={match:/\s+/,relevance:0},r=e.COMMENT("/\\*","\\*/",{contains:["self"]}),a=[e.C_LINE_COMMENT_MODE,r],l={match:[/\./,On(...jM,...Lv)],className:{2:"keyword"}},u={match:jt(/\./,On(...pd)),relevance:0},f=pd.filter(we=>typeof we=="string").concat(["_|0"]),o=pd.filter(we=>typeof we!="string").concat(UM).map(Lf),h={variants:[{className:"keyword",match:On(...o,...Lv)}]},d={$pattern:On(/\b\w+/,/#\w+/),keyword:f.concat(FM),literal:Iv},m=[l,u,h],p={match:jt(/\./,On(...Bv)),relevance:0},x={className:"built_in",match:jt(/\b/,On(...Bv),/(?=\()/)},S=[p,x],k={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:md},{match:`\\.(\\.|${Hy})+`}]},_=[k,w],b="([0-9]_*)+",v="([0-9a-fA-F]_*)+",y={className:"number",relevance:0,variants:[{match:`\\b(${b})(\\.(${b}))?([eE][+-]?(${b}))?\\b`},{match:`\\b0x(${v})(\\.(${v}))?([pP][+-]?(${b}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},T=(we="")=>({className:"subst",variants:[{match:jt(/\\/,we,/[0\\tnr"']/)},{match:jt(/\\/,we,/u\{[0-9a-fA-F]{1,8}\}/)}]}),M=(we="")=>({className:"subst",match:jt(/\\/,we,/[\t ]*(?:[\r\n]|\r\n)/)}),N=(we="")=>({className:"subst",label:"interpol",begin:jt(/\\/,we,/\(/),end:/\)/}),O=(we="")=>({begin:jt(we,/"""/),end:jt(/"""/,we),contains:[T(we),M(we),N(we)]}),R=(we="")=>({begin:jt(we,/"/),end:jt(/"/,we),contains:[T(we),N(we)]}),L={className:"string",variants:[O(),O("#"),O("##"),O("###"),R(),R("#"),R("##"),R("###")]},z=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],H={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:z},q=we=>{const ke=jt(we,/\//),Tt=jt(/\//,we);return{begin:ke,end:Tt,contains:[...z,{scope:"comment",begin:`#(?!.*${Tt})`,end:/$/}]}},F={scope:"regexp",variants:[q("###"),q("##"),q("#"),H]},W={match:jt(/`/,Ni,/`/)},G={className:"variable",match:/\$\d+/},K={className:"variable",match:`\\$${Sc}+`},ne=[W,G,K],Q={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:qM,contains:[..._,y,L]}]}},I={scope:"keyword",match:jt(/@/,On(...$M),bo(On(/\(/,/\s+/)))},A={scope:"meta",match:jt(/@/,Ni)},B=[Q,I,A],$={match:bo(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:jt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Sc,"+")},{className:"type",match:ac,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:jt(/\s+&\s+/,bo(ac)),relevance:0}]},P={begin:/</,end:/>/,keywords:d,contains:[...a,...m,...B,k,$]};$.contains.push(P);const oe={match:jt(Ni,/\s*:/),keywords:"_|0",relevance:0},ye={begin:/\(/,end:/\)/,relevance:0,keywords:d,contains:["self",oe,...a,F,...m,...S,..._,y,L,...ne,...B,$]},pe={begin:/</,end:/>/,keywords:"repeat each",contains:[...a,$]},J={begin:On(bo(jt(Ni,/\s*:/)),bo(jt(Ni,/\s+/,Ni,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Ni}]},j={begin:/\(/,end:/\)/,keywords:d,contains:[J,...a,...m,..._,y,L,...B,$,ye],endsParent:!0,illegal:/["']/},me={match:[/(func|macro)/,/\s+/,On(W.match,Ni,md)],className:{1:"keyword",3:"title.function"},contains:[pe,j,n],illegal:[/\[/,/%/]},ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[pe,j,n],illegal:/\[|%/},ee={match:[/operator/,/\s+/,md],className:{1:"keyword",3:"title"}},le={begin:[/precedencegroup/,/\s+/,ac],className:{1:"keyword",3:"title"},contains:[$],keywords:[...HM,...Iv],end:/}/},Ce={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},He={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ee={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Ni,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:d,contains:[pe,...m,{begin:/:/,end:/\{/,keywords:d,contains:[{scope:"title.class.inherited",match:ac},...m],relevance:0}]};for(const we of L.variants){const ke=we.contains.find(Fe=>Fe.label==="interpol");ke.keywords=d;const Tt=[...m,...S,..._,y,L,...ne];ke.contains=[...Tt,{begin:/\(/,end:/\)/,contains:["self",...Tt]}]}return{name:"Swift",keywords:d,contains:[...a,me,ce,Ce,He,Ee,ee,le,{beginKeywords:"import",end:/$/,contains:[...a],relevance:0},F,...m,...S,..._,y,L,...ne,...B,$,ye]}}const Ec="[A-Za-z$_][0-9A-Za-z$_]*",$y=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],qy=["true","false","null","undefined","NaN","Infinity"],Ky=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Gy=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vy=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Wy=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Yy=[].concat(Vy,Ky,Gy);function GM(e){const n=e.regex,r=(Q,{after:I})=>{const A="</"+Q[0].slice(1);return Q.input.indexOf(A,I)!==-1},a=Ec,l={begin:"<>",end:"</>"},u=/<[A-Za-z0-9\\._:-]+\s*\/>/,f={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(Q,I)=>{const A=Q[0].length+Q.index,B=Q.input[A];if(B==="<"||B===","){I.ignoreMatch();return}B===">"&&(r(Q,{after:A})||I.ignoreMatch());let $;const P=Q.input.substring(A);if($=P.match(/^\s*=/)){I.ignoreMatch();return}if(($=P.match(/^\s+extends\s+/))&&$.index===0){I.ignoreMatch();return}}},o={$pattern:Ec,keyword:$y,literal:qy,built_in:Yy,"variable.language":Wy},h="[0-9](_?[0-9])*",d=`\\.(${h})`,m="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${m})((${d})|\\.)?|(${d}))[eE][+-]?(${h})\\b`},{begin:`\\b(${m})\\b((${d})\\b|\\.)?|(${d})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},S={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},k={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},_={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},v={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},y=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,S,k,w,_,{match:/\$\d+/},p];x.contains=y.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(y)});const T=[].concat(v,x.contains),M=T.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(T)}]),N={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:M},O={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,n.concat(a,"(",n.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},R={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Ky,...Gy]}},L={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[N],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function q(Q){return n.concat("(?!",Q.join("|"),")")}const F={match:n.concat(/\b/,q([...Vy,"super","import"].map(Q=>`${Q}\\s*\\(`)),a,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},W={begin:n.concat(/\./,n.lookahead(n.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},G={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},N]},K="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(K)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[N]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:R},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),L,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,S,k,w,_,v,{match:/\$\d+/},p,R,{scope:"attr",match:a+n.lookahead(":"),relevance:0},ne,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[v,e.REGEXP_MODE,{className:"function",begin:K,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:l.begin,end:l.end},{match:u},{begin:f.begin,"on:begin":f.isTrulyOpeningTag,end:f.end}],subLanguage:"xml",contains:[{begin:f.begin,end:f.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[N,e.inherit(e.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},W,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[N]},F,H,O,G,{match:/\$[(.]/}]}}function VM(e){const n=e.regex,r=GM(e),a=Ec,l=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],u={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},f={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:l},contains:[r.exports.CLASS_REFERENCE]},o={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},h=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],d={$pattern:Ec,keyword:$y.concat(h),literal:qy,built_in:Yy.concat(l),"variable.language":Wy},m={className:"meta",begin:"@"+a},p=(w,_,b)=>{const v=w.contains.findIndex(y=>y.label===_);if(v===-1)throw new Error("can not find mode to replace");w.contains.splice(v,1,b)};Object.assign(r.keywords,d),r.exports.PARAMS_CONTAINS.push(m);const x=r.contains.find(w=>w.scope==="attr"),S=Object.assign({},x,{match:n.concat(a,n.lookahead(/\s*\?:/))});r.exports.PARAMS_CONTAINS.push([r.exports.CLASS_REFERENCE,x,S]),r.contains=r.contains.concat([m,u,f,S]),p(r,"shebang",e.SHEBANG()),p(r,"use_strict",o);const k=r.contains.find(w=>w.label==="func.def");return k.relevance=0,Object.assign(r,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),r}function WM(e){const n=e.regex,r={className:"string",begin:/"(""|[^/n])"C\b/},a={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},l=/\d{1,2}\/\d{1,2}\/\d{4}/,u=/\d{4}-\d{1,2}-\d{1,2}/,f=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,o=/\d{1,2}(:\d{1,2}){1,2}/,h={className:"literal",variants:[{begin:n.concat(/# */,n.either(u,l),/ *#/)},{begin:n.concat(/# */,o,/ *#/)},{begin:n.concat(/# */,f,/ *#/)},{begin:n.concat(/# */,n.either(u,l),/ +/,n.either(f,o),/ *#/)}]},d={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},m={className:"label",begin:/^\w+:/},p=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[r,a,h,d,m,p,x,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[x]}]}}function YM(e){e.regex;const n=e.COMMENT(/\(;/,/;\)/);n.contains.push("self");const r=e.COMMENT(/;;/,/$/),a=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],l={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},u={className:"variable",begin:/\$[\w_]+/},f={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},o={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},h={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},d={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:a},contains:[r,n,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},u,f,l,e.QUOTE_STRING_MODE,h,d,o]}}function ZM(e){const n=e.regex,r=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),a=/[\p{L}0-9._:-]+/u,l={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},u={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},f=e.inherit(u,{begin:/\(/,end:/\)/}),o=e.inherit(e.APOS_STRING_MODE,{className:"string"}),h=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:a,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[l]},{begin:/'/,end:/'/,contains:[l]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[u,h,o,f,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[u,f,h,o]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},l,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[h]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[d],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[d],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:n.concat(/</,n.lookahead(n.concat(r,n.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:r,relevance:0,starts:d}]},{className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(r,/>/))),contains:[{className:"name",begin:r,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function XM(e){const n="true false yes no null",r="[\\w#;/?:@&=+$,.~*'()[\\]]+",a={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},l={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},u={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},f={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,l]},o=e.inherit(f,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},S={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},k={begin:/\{/,end:/\}/,contains:[S],illegal:"\\n",relevance:0},w={begin:"\\[",end:"\\]",contains:[S],illegal:"\\n",relevance:0},_=[a,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+r},{className:"type",begin:"!<"+r+">"},{className:"type",begin:"!"+r},{className:"type",begin:"!!"+r},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},k,w,u,f],b=[..._];return b.pop(),b.push(o),S.contains=b,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:_}}const QM={arduino:DR,bash:LR,c:IR,cpp:BR,csharp:PR,css:GR,diff:VR,go:WR,graphql:YR,ini:ZR,java:XR,javascript:nM,json:iM,kotlin:sM,less:fM,lua:pM,makefile:mM,markdown:gM,objectivec:_M,perl:vM,php:bM,"php-template":yM,plaintext:xM,python:SM,"python-repl":EM,r:wM,ruby:CM,rust:kM,scss:IM,shell:BM,sql:PM,swift:KM,typescript:VM,vbnet:WM,wasm:YM,xml:ZM,yaml:XM};var gd,Pv;function JM(){if(Pv)return gd;Pv=1;function e(Z){return Z instanceof Map?Z.clear=Z.delete=Z.set=function(){throw new Error("map is read-only")}:Z instanceof Set&&(Z.add=Z.clear=Z.delete=function(){throw new Error("set is read-only")}),Object.freeze(Z),Object.getOwnPropertyNames(Z).forEach(_e=>{const Re=Z[_e],Ze=typeof Re;(Ze==="object"||Ze==="function")&&!Object.isFrozen(Re)&&e(Re)}),Z}class n{constructor(_e){_e.data===void 0&&(_e.data={}),this.data=_e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function r(Z){return Z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function a(Z,..._e){const Re=Object.create(null);for(const Ze in Z)Re[Ze]=Z[Ze];return _e.forEach(function(Ze){for(const Ut in Ze)Re[Ut]=Ze[Ut]}),Re}const l="</span>",u=Z=>!!Z.scope,f=(Z,{prefix:_e})=>{if(Z.startsWith("language:"))return Z.replace("language:","language-");if(Z.includes(".")){const Re=Z.split(".");return[`${_e}${Re.shift()}`,...Re.map((Ze,Ut)=>`${Ze}${"_".repeat(Ut+1)}`)].join(" ")}return`${_e}${Z}`};class o{constructor(_e,Re){this.buffer="",this.classPrefix=Re.classPrefix,_e.walk(this)}addText(_e){this.buffer+=r(_e)}openNode(_e){if(!u(_e))return;const Re=f(_e.scope,{prefix:this.classPrefix});this.span(Re)}closeNode(_e){u(_e)&&(this.buffer+=l)}value(){return this.buffer}span(_e){this.buffer+=`<span class="${_e}">`}}const h=(Z={})=>{const _e={children:[]};return Object.assign(_e,Z),_e};class d{constructor(){this.rootNode=h(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(_e){this.top.children.push(_e)}openNode(_e){const Re=h({scope:_e});this.add(Re),this.stack.push(Re)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(_e){return this.constructor._walk(_e,this.rootNode)}static _walk(_e,Re){return typeof Re=="string"?_e.addText(Re):Re.children&&(_e.openNode(Re),Re.children.forEach(Ze=>this._walk(_e,Ze)),_e.closeNode(Re)),_e}static _collapse(_e){typeof _e!="string"&&_e.children&&(_e.children.every(Re=>typeof Re=="string")?_e.children=[_e.children.join("")]:_e.children.forEach(Re=>{d._collapse(Re)}))}}class m extends d{constructor(_e){super(),this.options=_e}addText(_e){_e!==""&&this.add(_e)}startScope(_e){this.openNode(_e)}endScope(){this.closeNode()}__addSublanguage(_e,Re){const Ze=_e.root;Re&&(Ze.scope=`language:${Re}`),this.add(Ze)}toHTML(){return new o(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(Z){return Z?typeof Z=="string"?Z:Z.source:null}function x(Z){return w("(?=",Z,")")}function S(Z){return w("(?:",Z,")*")}function k(Z){return w("(?:",Z,")?")}function w(...Z){return Z.map(Re=>p(Re)).join("")}function _(Z){const _e=Z[Z.length-1];return typeof _e=="object"&&_e.constructor===Object?(Z.splice(Z.length-1,1),_e):{}}function b(...Z){return"("+(_(Z).capture?"":"?:")+Z.map(Ze=>p(Ze)).join("|")+")"}function v(Z){return new RegExp(Z.toString()+"|").exec("").length-1}function y(Z,_e){const Re=Z&&Z.exec(_e);return Re&&Re.index===0}const T=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(Z,{joinWith:_e}){let Re=0;return Z.map(Ze=>{Re+=1;const Ut=Re;let $t=p(Ze),De="";for(;$t.length>0;){const X=T.exec($t);if(!X){De+=$t;break}De+=$t.substring(0,X.index),$t=$t.substring(X.index+X[0].length),X[0][0]==="\\"&&X[1]?De+="\\"+String(Number(X[1])+Ut):(De+=X[0],X[0]==="("&&Re++)}return De}).map(Ze=>`(${Ze})`).join(_e)}const N=/\b\B/,O="[a-zA-Z]\\w*",R="[a-zA-Z_]\\w*",L="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",q="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",F=(Z={})=>{const _e=/^#![ ]*\//;return Z.binary&&(Z.begin=w(_e,/.*\b/,Z.binary,/\b.*/)),a({scope:"meta",begin:_e,end:/$/,relevance:0,"on:begin":(Re,Ze)=>{Re.index!==0&&Ze.ignoreMatch()}},Z)},W={begin:"\\\\[\\s\\S]",relevance:0},G={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[W]},K={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[W]},ne={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},Q=function(Z,_e,Re={}){const Ze=a({scope:"comment",begin:Z,end:_e,contains:[]},Re);Ze.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Ut=b("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return Ze.contains.push({begin:w(/[ ]+/,"(",Ut,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ze},I=Q("//","$"),A=Q("/\\*","\\*/"),B=Q("#","$"),$={scope:"number",begin:L,relevance:0},P={scope:"number",begin:z,relevance:0},oe={scope:"number",begin:H,relevance:0},ye={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[W,{begin:/\[/,end:/\]/,relevance:0,contains:[W]}]},pe={scope:"title",begin:O,relevance:0},J={scope:"title",begin:R,relevance:0},j={begin:"\\.\\s*"+R,relevance:0};var ce=Object.freeze({__proto__:null,APOS_STRING_MODE:G,BACKSLASH_ESCAPE:W,BINARY_NUMBER_MODE:oe,BINARY_NUMBER_RE:H,COMMENT:Q,C_BLOCK_COMMENT_MODE:A,C_LINE_COMMENT_MODE:I,C_NUMBER_MODE:P,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(Z){return Object.assign(Z,{"on:begin":(_e,Re)=>{Re.data._beginMatch=_e[1]},"on:end":(_e,Re)=>{Re.data._beginMatch!==_e[1]&&Re.ignoreMatch()}})},HASH_COMMENT_MODE:B,IDENT_RE:O,MATCH_NOTHING_RE:N,METHOD_GUARD:j,NUMBER_MODE:$,NUMBER_RE:L,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:K,REGEXP_MODE:ye,RE_STARTERS_RE:q,SHEBANG:F,TITLE_MODE:pe,UNDERSCORE_IDENT_RE:R,UNDERSCORE_TITLE_MODE:J});function ee(Z,_e){Z.input[Z.index-1]==="."&&_e.ignoreMatch()}function le(Z,_e){Z.className!==void 0&&(Z.scope=Z.className,delete Z.className)}function Ce(Z,_e){_e&&Z.beginKeywords&&(Z.begin="\\b("+Z.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",Z.__beforeBegin=ee,Z.keywords=Z.keywords||Z.beginKeywords,delete Z.beginKeywords,Z.relevance===void 0&&(Z.relevance=0))}function He(Z,_e){Array.isArray(Z.illegal)&&(Z.illegal=b(...Z.illegal))}function Ee(Z,_e){if(Z.match){if(Z.begin||Z.end)throw new Error("begin & end are not supported with match");Z.begin=Z.match,delete Z.match}}function we(Z,_e){Z.relevance===void 0&&(Z.relevance=1)}const ke=(Z,_e)=>{if(!Z.beforeMatch)return;if(Z.starts)throw new Error("beforeMatch cannot be used with starts");const Re=Object.assign({},Z);Object.keys(Z).forEach(Ze=>{delete Z[Ze]}),Z.keywords=Re.keywords,Z.begin=w(Re.beforeMatch,x(Re.begin)),Z.starts={relevance:0,contains:[Object.assign(Re,{endsParent:!0})]},Z.relevance=0,delete Re.beforeMatch},Tt=["of","and","for","in","not","or","if","then","parent","list","value"],Fe="keyword";function At(Z,_e,Re=Fe){const Ze=Object.create(null);return typeof Z=="string"?Ut(Re,Z.split(" ")):Array.isArray(Z)?Ut(Re,Z):Object.keys(Z).forEach(function($t){Object.assign(Ze,At(Z[$t],_e,$t))}),Ze;function Ut($t,De){_e&&(De=De.map(X=>X.toLowerCase())),De.forEach(function(X){const de=X.split("|");Ze[de[0]]=[$t,Me(de[0],de[1])]})}}function Me(Z,_e){return _e?Number(_e):pn(Z)?0:1}function pn(Z){return Tt.includes(Z.toLowerCase())}const Nt={},Ot=Z=>{console.error(Z)},wt=(Z,..._e)=>{console.log(`WARN: ${Z}`,..._e)},ue=(Z,_e)=>{Nt[`${Z}/${_e}`]||(console.log(`Deprecated as of ${Z}. ${_e}`),Nt[`${Z}/${_e}`]=!0)},xe=new Error;function Ie(Z,_e,{key:Re}){let Ze=0;const Ut=Z[Re],$t={},De={};for(let X=1;X<=_e.length;X++)De[X+Ze]=Ut[X],$t[X+Ze]=!0,Ze+=v(_e[X-1]);Z[Re]=De,Z[Re]._emit=$t,Z[Re]._multi=!0}function $e(Z){if(Array.isArray(Z.begin)){if(Z.skip||Z.excludeBegin||Z.returnBegin)throw Ot("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),xe;if(typeof Z.beginScope!="object"||Z.beginScope===null)throw Ot("beginScope must be object"),xe;Ie(Z,Z.begin,{key:"beginScope"}),Z.begin=M(Z.begin,{joinWith:""})}}function Je(Z){if(Array.isArray(Z.end)){if(Z.skip||Z.excludeEnd||Z.returnEnd)throw Ot("skip, excludeEnd, returnEnd not compatible with endScope: {}"),xe;if(typeof Z.endScope!="object"||Z.endScope===null)throw Ot("endScope must be object"),xe;Ie(Z,Z.end,{key:"endScope"}),Z.end=M(Z.end,{joinWith:""})}}function Gt(Z){Z.scope&&typeof Z.scope=="object"&&Z.scope!==null&&(Z.beginScope=Z.scope,delete Z.scope)}function ht(Z){Gt(Z),typeof Z.beginScope=="string"&&(Z.beginScope={_wrap:Z.beginScope}),typeof Z.endScope=="string"&&(Z.endScope={_wrap:Z.endScope}),$e(Z),Je(Z)}function Qt(Z){function _e(De,X){return new RegExp(p(De),"m"+(Z.case_insensitive?"i":"")+(Z.unicodeRegex?"u":"")+(X?"g":""))}class Re{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(X,de){de.position=this.position++,this.matchIndexes[this.matchAt]=de,this.regexes.push([de,X]),this.matchAt+=v(X)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const X=this.regexes.map(de=>de[1]);this.matcherRe=_e(M(X,{joinWith:"|"}),!0),this.lastIndex=0}exec(X){this.matcherRe.lastIndex=this.lastIndex;const de=this.matcherRe.exec(X);if(!de)return null;const Be=de.findIndex((gt,Nn)=>Nn>0&&gt!==void 0),Ke=this.matchIndexes[Be];return de.splice(0,Be),Object.assign(de,Ke)}}class Ze{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(X){if(this.multiRegexes[X])return this.multiRegexes[X];const de=new Re;return this.rules.slice(X).forEach(([Be,Ke])=>de.addRule(Be,Ke)),de.compile(),this.multiRegexes[X]=de,de}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(X,de){this.rules.push([X,de]),de.type==="begin"&&this.count++}exec(X){const de=this.getMatcher(this.regexIndex);de.lastIndex=this.lastIndex;let Be=de.exec(X);if(this.resumingScanAtSamePosition()&&!(Be&&Be.index===this.lastIndex)){const Ke=this.getMatcher(0);Ke.lastIndex=this.lastIndex+1,Be=Ke.exec(X)}return Be&&(this.regexIndex+=Be.position+1,this.regexIndex===this.count&&this.considerAll()),Be}}function Ut(De){const X=new Ze;return De.contains.forEach(de=>X.addRule(de.begin,{rule:de,type:"begin"})),De.terminatorEnd&&X.addRule(De.terminatorEnd,{type:"end"}),De.illegal&&X.addRule(De.illegal,{type:"illegal"}),X}function $t(De,X){const de=De;if(De.isCompiled)return de;[le,Ee,ht,ke].forEach(Ke=>Ke(De,X)),Z.compilerExtensions.forEach(Ke=>Ke(De,X)),De.__beforeBegin=null,[Ce,He,we].forEach(Ke=>Ke(De,X)),De.isCompiled=!0;let Be=null;return typeof De.keywords=="object"&&De.keywords.$pattern&&(De.keywords=Object.assign({},De.keywords),Be=De.keywords.$pattern,delete De.keywords.$pattern),Be=Be||/\w+/,De.keywords&&(De.keywords=At(De.keywords,Z.case_insensitive)),de.keywordPatternRe=_e(Be,!0),X&&(De.begin||(De.begin=/\B|\b/),de.beginRe=_e(de.begin),!De.end&&!De.endsWithParent&&(De.end=/\B|\b/),De.end&&(de.endRe=_e(de.end)),de.terminatorEnd=p(de.end)||"",De.endsWithParent&&X.terminatorEnd&&(de.terminatorEnd+=(De.end?"|":"")+X.terminatorEnd)),De.illegal&&(de.illegalRe=_e(De.illegal)),De.contains||(De.contains=[]),De.contains=[].concat(...De.contains.map(function(Ke){return vn(Ke==="self"?De:Ke)})),De.contains.forEach(function(Ke){$t(Ke,de)}),De.starts&&$t(De.starts,X),de.matcher=Ut(de),de}if(Z.compilerExtensions||(Z.compilerExtensions=[]),Z.contains&&Z.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return Z.classNameAliases=a(Z.classNameAliases||{}),$t(Z)}function En(Z){return Z?Z.endsWithParent||En(Z.starts):!1}function vn(Z){return Z.variants&&!Z.cachedVariants&&(Z.cachedVariants=Z.variants.map(function(_e){return a(Z,{variants:null},_e)})),Z.cachedVariants?Z.cachedVariants:En(Z)?a(Z,{starts:Z.starts?a(Z.starts):null}):Object.isFrozen(Z)?a(Z):Z}var Wt="11.11.1";class rn extends Error{constructor(_e,Re){super(_e),this.name="HTMLInjectionError",this.html=Re}}const sn=r,Ii=a,rr=Symbol("nomatch"),zr=7,ei=function(Z){const _e=Object.create(null),Re=Object.create(null),Ze=[];let Ut=!0;const $t="Could not find the language '{}', did you forget to load/include a language module?",De={disableAutodetect:!0,name:"Plain text",contains:[]};let X={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:m};function de(Te){return X.noHighlightRe.test(Te)}function Be(Te){let Ge=Te.className+" ";Ge+=Te.parentNode?Te.parentNode.className:"";const rt=X.languageDetectRe.exec(Ge);if(rt){const Rt=Rn(rt[1]);return Rt||(wt($t.replace("{}",rt[1])),wt("Falling back to no-highlight mode for this block.",Te)),Rt?rt[1]:"no-highlight"}return Ge.split(/\s+/).find(Rt=>de(Rt)||Rn(Rt))}function Ke(Te,Ge,rt){let Rt="",Zt="";typeof Ge=="object"?(Rt=Te,rt=Ge.ignoreIllegals,Zt=Ge.language):(ue("10.7.0","highlight(lang, code, ...args) has been deprecated."),ue("10.7.0",`Please use highlight(code, options) instead.
82
82
  https://github.com/highlightjs/highlight.js/issues/2277`),Zt=Te,Rt=Ge),rt===void 0&&(rt=!0);const $n={code:Rt,language:Zt};ji("before:highlight",$n);const gi=$n.result?$n.result:gt($n.language,$n.code,rt);return gi.code=$n.code,ji("after:highlight",gi),gi}function gt(Te,Ge,rt,Rt){const Zt=Object.create(null);function $n(Oe,ze){return Oe.keywords[ze]}function gi(){if(!nt.keywords){an.addText(Mt);return}let Oe=0;nt.keywordPatternRe.lastIndex=0;let ze=nt.keywordPatternRe.exec(Mt),et="";for(;ze;){et+=Mt.substring(Oe,ze.index);const xt=qn.case_insensitive?ze[0].toLowerCase():ze[0],on=$n(nt,xt);if(on){const[ni,$r]=on;if(an.addText(et),et="",Zt[xt]=(Zt[xt]||0)+1,Zt[xt]<=zr&&(ms+=$r),ni.startsWith("_"))et+=ze[0];else{const _i=qn.classNameAliases[ni]||ni;ti(ze[0],_i)}}else et+=ze[0];Oe=nt.keywordPatternRe.lastIndex,ze=nt.keywordPatternRe.exec(Mt)}et+=Mt.substring(Oe),an.addText(et)}function bn(){if(Mt==="")return;let Oe=null;if(typeof nt.subLanguage=="string"){if(!_e[nt.subLanguage]){an.addText(Mt);return}Oe=gt(nt.subLanguage,Mt,!0,ga[nt.subLanguage]),ga[nt.subLanguage]=Oe._top}else Oe=It(Mt,nt.subLanguage.length?nt.subLanguage:null);nt.relevance>0&&(ms+=Oe.relevance),an.__addSublanguage(Oe._emitter,Oe.language)}function wn(){nt.subLanguage!=null?bn():gi(),Mt=""}function ti(Oe,ze){Oe!==""&&(an.startScope(ze),an.addText(Oe),an.endScope())}function Ur(Oe,ze){let et=1;const xt=ze.length-1;for(;et<=xt;){if(!Oe._emit[et]){et++;continue}const on=qn.classNameAliases[Oe[et]]||Oe[et],ni=ze[et];on?ti(ni,on):(Mt=ni,gi(),Mt=""),et++}}function pa(Oe,ze){return Oe.scope&&typeof Oe.scope=="string"&&an.openNode(qn.classNameAliases[Oe.scope]||Oe.scope),Oe.beginScope&&(Oe.beginScope._wrap?(ti(Mt,qn.classNameAliases[Oe.beginScope._wrap]||Oe.beginScope._wrap),Mt=""):Oe.beginScope._multi&&(Ur(Oe.beginScope,ze),Mt="")),nt=Object.create(Oe,{parent:{value:nt}}),nt}function Hr(Oe,ze,et){let xt=y(Oe.endRe,et);if(xt){if(Oe["on:end"]){const on=new n(Oe);Oe["on:end"](ze,on),on.isMatchIgnored&&(xt=!1)}if(xt){for(;Oe.endsParent&&Oe.parent;)Oe=Oe.parent;return Oe}}if(Oe.endsWithParent)return Hr(Oe.parent,ze,et)}function Fc(Oe){return nt.matcher.regexIndex===0?(Mt+=Oe[0],1):(Fr=!0,0)}function In(Oe){const ze=Oe[0],et=Oe.rule,xt=new n(et),on=[et.__beforeBegin,et["on:begin"]];for(const ni of on)if(ni&&(ni(Oe,xt),xt.isMatchIgnored))return Fc(ze);return et.skip?Mt+=ze:(et.excludeBegin&&(Mt+=ze),wn(),!et.returnBegin&&!et.excludeBegin&&(Mt=ze)),pa(et,Oe),et.returnBegin?0:ze.length}function ma(Oe){const ze=Oe[0],et=Ge.substring(Oe.index),xt=Hr(nt,Oe,et);if(!xt)return rr;const on=nt;nt.endScope&&nt.endScope._wrap?(wn(),ti(ze,nt.endScope._wrap)):nt.endScope&&nt.endScope._multi?(wn(),Ur(nt.endScope,Oe)):on.skip?Mt+=ze:(on.returnEnd||on.excludeEnd||(Mt+=ze),wn(),on.excludeEnd&&(Mt=ze));do nt.scope&&an.closeNode(),!nt.skip&&!nt.subLanguage&&(ms+=nt.relevance),nt=nt.parent;while(nt!==xt.parent);return xt.starts&&pa(xt.starts,Oe),on.returnEnd?0:ze.length}function qo(){const Oe=[];for(let ze=nt;ze!==qn;ze=ze.parent)ze.scope&&Oe.unshift(ze.scope);Oe.forEach(ze=>an.openNode(ze))}let or={};function Ui(Oe,ze){const et=ze&&ze[0];if(Mt+=Oe,et==null)return wn(),0;if(or.type==="begin"&&ze.type==="end"&&or.index===ze.index&&et===""){if(Mt+=Ge.slice(ze.index,ze.index+1),!Ut){const xt=new Error(`0 width match regex (${Te})`);throw xt.languageName=Te,xt.badRule=or.rule,xt}return 1}if(or=ze,ze.type==="begin")return In(ze);if(ze.type==="illegal"&&!rt){const xt=new Error('Illegal lexeme "'+et+'" for mode "'+(nt.scope||"<unnamed>")+'"');throw xt.mode=nt,xt}else if(ze.type==="end"){const xt=ma(ze);if(xt!==rr)return xt}if(ze.type==="illegal"&&et==="")return Mt+=`
83
83
  `,1;if(lr>1e5&&lr>ze.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Mt+=et,et.length}const qn=Rn(Te);if(!qn)throw Ot($t.replace("{}",Te)),new Error('Unknown language: "'+Te+'"');const Ko=Qt(qn);let Ei="",nt=Rt||Ko;const ga={},an=new X.__emitter(X);qo();let Mt="",ms=0,Hi=0,lr=0,Fr=!1;try{if(qn.__emitTokens)qn.__emitTokens(Ge,an);else{for(nt.matcher.considerAll();;){lr++,Fr?Fr=!1:nt.matcher.considerAll(),nt.matcher.lastIndex=Hi;const Oe=nt.matcher.exec(Ge);if(!Oe)break;const ze=Ge.substring(Hi,Oe.index),et=Ui(ze,Oe);Hi=Oe.index+et}Ui(Ge.substring(Hi))}return an.finalize(),Ei=an.toHTML(),{language:Te,value:Ei,relevance:ms,illegal:!1,_emitter:an,_top:nt}}catch(Oe){if(Oe.message&&Oe.message.includes("Illegal"))return{language:Te,value:sn(Ge),illegal:!0,relevance:0,_illegalBy:{message:Oe.message,index:Hi,context:Ge.slice(Hi-100,Hi+100),mode:Oe.mode,resultSoFar:Ei},_emitter:an};if(Ut)return{language:Te,value:sn(Ge),illegal:!1,relevance:0,errorRaised:Oe,_emitter:an,_top:nt};throw Oe}}function Nn(Te){const Ge={value:sn(Te),illegal:!1,relevance:0,_top:De,_emitter:new X.__emitter(X)};return Ge._emitter.addText(Te),Ge}function It(Te,Ge){Ge=Ge||X.languages||Object.keys(_e);const rt=Nn(Te),Rt=Ge.filter(Rn).filter(fa).map(wn=>gt(wn,Te,!1));Rt.unshift(rt);const Zt=Rt.sort((wn,ti)=>{if(wn.relevance!==ti.relevance)return ti.relevance-wn.relevance;if(wn.language&&ti.language){if(Rn(wn.language).supersetOf===ti.language)return 1;if(Rn(ti.language).supersetOf===wn.language)return-1}return 0}),[$n,gi]=Zt,bn=$n;return bn.secondBest=gi,bn}function pi(Te,Ge,rt){const Rt=Ge&&Re[Ge]||rt;Te.classList.add("hljs"),Te.classList.add(`language-${Rt}`)}function Bi(Te){let Ge=null;const rt=Be(Te);if(de(rt))return;if(ji("before:highlightElement",{el:Te,language:rt}),Te.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Te);return}if(Te.children.length>0&&(X.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(Te)),X.throwUnescapedHTML))throw new rn("One of your code blocks includes unescaped HTML.",Te.innerHTML);Ge=Te;const Rt=Ge.textContent,Zt=rt?Ke(Rt,{language:rt,ignoreIllegals:!0}):It(Rt);Te.innerHTML=Zt.value,Te.dataset.highlighted="yes",pi(Te,rt,Zt.language),Te.result={language:Zt.language,re:Zt.relevance,relevance:Zt.relevance},Zt.secondBest&&(Te.secondBest={language:Zt.secondBest.language,relevance:Zt.secondBest.relevance}),ji("after:highlightElement",{el:Te,result:Zt,text:Rt})}function sr(Te){X=Ii(X,Te)}const ar=()=>{Yt(),ue("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function jr(){Yt(),ue("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Pi=!1;function Yt(){function Te(){Yt()}if(document.readyState==="loading"){Pi||window.addEventListener("DOMContentLoaded",Te,!1),Pi=!0;return}document.querySelectorAll(X.cssSelector).forEach(Bi)}function Uo(Te,Ge){let rt=null;try{rt=Ge(Z)}catch(Rt){if(Ot("Language definition for '{}' could not be registered.".replace("{}",Te)),Ut)Ot(Rt);else throw Rt;rt=De}rt.name||(rt.name=Te),_e[Te]=rt,rt.rawDefinition=Ge.bind(null,Z),rt.aliases&&Fo(rt.aliases,{languageName:Te})}function Ho(Te){delete _e[Te];for(const Ge of Object.keys(Re))Re[Ge]===Te&&delete Re[Ge]}function zi(){return Object.keys(_e)}function Rn(Te){return Te=(Te||"").toLowerCase(),_e[Te]||_e[Re[Te]]}function Fo(Te,{languageName:Ge}){typeof Te=="string"&&(Te=[Te]),Te.forEach(rt=>{Re[rt.toLowerCase()]=Ge})}function fa(Te){const Ge=Rn(Te);return Ge&&!Ge.disableAutodetect}function $o(Te){Te["before:highlightBlock"]&&!Te["before:highlightElement"]&&(Te["before:highlightElement"]=Ge=>{Te["before:highlightBlock"](Object.assign({block:Ge.el},Ge))}),Te["after:highlightBlock"]&&!Te["after:highlightElement"]&&(Te["after:highlightElement"]=Ge=>{Te["after:highlightBlock"](Object.assign({block:Ge.el},Ge))})}function Hc(Te){$o(Te),Ze.push(Te)}function ps(Te){const Ge=Ze.indexOf(Te);Ge!==-1&&Ze.splice(Ge,1)}function ji(Te,Ge){const rt=Te;Ze.forEach(function(Rt){Rt[rt]&&Rt[rt](Ge)})}function mi(Te){return ue("10.7.0","highlightBlock will be removed entirely in v12.0"),ue("10.7.0","Please use highlightElement now."),Bi(Te)}Object.assign(Z,{highlight:Ke,highlightAuto:It,highlightAll:Yt,highlightElement:Bi,highlightBlock:mi,configure:sr,initHighlighting:ar,initHighlightingOnLoad:jr,registerLanguage:Uo,unregisterLanguage:Ho,listLanguages:zi,getLanguage:Rn,registerAliases:Fo,autoDetection:fa,inherit:Ii,addPlugin:Hc,removePlugin:ps}),Z.debugMode=function(){Ut=!1},Z.safeMode=function(){Ut=!0},Z.versionString=Wt,Z.regex={concat:w,lookahead:x,either:b,optional:k,anyNumberOfTimes:S};for(const Te in ce)typeof ce[Te]=="object"&&e(ce[Te]);return Object.assign(Z,ce),Z},fi=ei({});return fi.newInstance=()=>ei({}),gd=fi,fi.HighlightJS=fi,fi.default=fi,gd}var eO=JM();const tO=Xd(eO),zv={},nO="hljs-";function iO(e){const n=tO.newInstance();return e&&u(e),{highlight:r,highlightAuto:a,listLanguages:l,register:u,registerAlias:f,registered:o};function r(h,d,m){const p=m||zv,x=typeof p.prefix=="string"?p.prefix:nO;if(!n.getLanguage(h))throw new Error("Unknown language: `"+h+"` is not registered");n.configure({__emitter:rO,classPrefix:x});const S=n.highlight(d,{ignoreIllegals:!0,language:h});if(S.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:S.errorRaised});const k=S._emitter.root,w=k.data;return w.language=S.language,w.relevance=S.relevance,k}function a(h,d){const p=(d||zv).subset||l();let x=-1,S=0,k;for(;++x<p.length;){const w=p[x];if(!n.getLanguage(w))continue;const _=r(w,h,d);_.data&&_.data.relevance!==void 0&&_.data.relevance>S&&(S=_.data.relevance,k=_)}return k||{type:"root",children:[],data:{language:void 0,relevance:S}}}function l(){return n.listLanguages()}function u(h,d){if(typeof h=="string")n.registerLanguage(h,d);else{let m;for(m in h)Object.hasOwn(h,m)&&n.registerLanguage(m,h[m])}}function f(h,d){if(typeof h=="string")n.registerAliases(typeof d=="string"?d:[...d],{languageName:h});else{let m;for(m in h)if(Object.hasOwn(h,m)){const p=h[m];n.registerAliases(typeof p=="string"?p:[...p],{languageName:m})}}}function o(h){return!!n.getLanguage(h)}}class rO{constructor(n){this.options=n,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(n){if(n==="")return;const r=this.stack[this.stack.length-1],a=r.children[r.children.length-1];a&&a.type==="text"?a.value+=n:r.children.push({type:"text",value:n})}startScope(n){this.openNode(String(n))}endScope(){this.closeNode()}__addSublanguage(n,r){const a=this.stack[this.stack.length-1],l=n.root.children;r?a.children.push({type:"element",tagName:"span",properties:{className:[r]},children:l}):a.children.push(...l)}openNode(n){const r=this,a=n.split(".").map(function(f,o){return o?f+"_".repeat(o):r.options.classPrefix+f}),l=this.stack[this.stack.length-1],u={type:"element",tagName:"span",properties:{className:a},children:[]};l.children.push(u),this.stack.push(u)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const sO={};function jv(e){const n=e||sO,r=n.aliases,a=n.detect||!1,l=n.languages||QM,u=n.plainText,f=n.prefix,o=n.subset;let h="hljs";const d=iO(l);if(r&&d.registerAlias(r),f){const m=f.indexOf("-");h=m===-1?f:f.slice(0,m)}return function(m,p){zc(m,"element",function(x,S,k){if(x.tagName!=="code"||!k||k.type!=="element"||k.tagName!=="pre")return;const w=aO(x);if(w===!1||!w&&!a||w&&u&&u.includes(w))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(h)||x.properties.className.unshift(h);const _=CR(x,{whitespace:"pre"});let b;try{b=w?d.highlight(w,_,{prefix:f}):d.highlightAuto(_,{prefix:f,subset:o})}catch(v){const y=v;if(w&&/Unknown language/.test(y.message)){p.message("Cannot highlight as `"+w+"`, it’s not registered",{ancestors:[k,x],cause:y,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw y}!w&&b.data&&b.data.language&&x.properties.className.push("language-"+b.data.language),b.children.length>0&&(x.children=b.children)})}}function aO(e){const n=e.properties.className;let r=-1;if(!Array.isArray(n))return;let a;for(;++r<n.length;){const l=String(n[r]);if(l==="no-highlight"||l==="nohighlight")return!1;!a&&l.slice(0,5)==="lang-"&&(a=l.slice(5)),!a&&l.slice(0,9)==="language-"&&(a=l.slice(9))}return a}function Zy(e){const n=e.split(`
84
- `),r=[];for(const a of n)a.startsWith("@@")?r.push({kind:"hunk",text:a}):a.startsWith("diff ")||a.startsWith("index ")||a.startsWith("--- ")||a.startsWith("+++ ")?r.push({kind:"meta",text:a}):a.startsWith("+")?r.push({kind:"add",text:a.slice(1)}):a.startsWith("-")?r.push({kind:"remove",text:a.slice(1)}):r.push({kind:"context",text:a.startsWith(" ")?a.slice(1):a});return r}function Xy(e){let n=0,r=0;for(const a of e)a.kind==="add"?n++:a.kind==="remove"&&r++;return{added:n,removed:r}}function Wd(e){var n;return e==null||e===!1||e===!0?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Wd).join(""):typeof e=="object"&&"props"in e?Wd((n=e.props)==null?void 0:n.children):""}function jc({text:e,className:n,label:r="复制"}){const[a,l]=re.useState(!1),u=async f=>{f.stopPropagation();try{await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),1500)}catch{}};return C.jsx("button",{onClick:u,title:a?"已复制":r,"aria-label":r,className:n??"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:a?C.jsx(Mo,{size:13,className:"text-success"}):C.jsx(DS,{size:13})})}function oO(e){const n=e.toLowerCase(),r=a=>{if(!a||!Array.isArray(a.children)||a.type==="element"&&(a.tagName==="code"||a.tagName==="pre"))return;const l=[];for(const u of a.children)if(u.type==="text"&&typeof u.value=="string"){const f=u.value,o=f.toLowerCase();let h=o.indexOf(n);if(h===-1){l.push(u);continue}let d=0;for(;h!==-1;)h>d&&l.push({type:"text",value:f.slice(d,h)}),l.push({type:"element",tagName:"mark",properties:{},children:[{type:"text",value:f.slice(h,h+n.length)}]}),d=h+n.length,h=o.indexOf(n,d);d<f.length&&l.push({type:"text",value:f.slice(d)})}else r(u),l.push(u);a.children=l};return()=>a=>{n&&r(a)}}const Qy=re.memo(function({text:n,highlight:r}){return C.jsx("div",{className:"prose-codex break-words text-[15px] leading-7 text-content-primary",children:C.jsx(s2,{remarkPlugins:[vR],rehypePlugins:r?[[jv,{detect:!0,ignoreMissing:!0}],oO(r)]:[[jv,{detect:!0,ignoreMissing:!0}]],components:{mark({children:a}){return C.jsx("mark",{className:"rounded bg-warning/30 px-0.5 text-content-primary",children:a})},pre({children:a}){return C.jsx(C.Fragment,{children:a})},code({className:a,children:l,...u}){if(/language-|hljs/.test(a??"")){const o=Wd(l);return C.jsxs("div",{className:"group/code relative my-3",children:[C.jsx("pre",{className:"max-w-full overflow-x-auto rounded-lg border border-border bg-surface-raised p-3 font-mono text-[13px] leading-relaxed",children:C.jsx("code",{className:a,...u,children:l})}),C.jsx(jc,{text:o,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/code:opacity-100"})]})}return C.jsx("code",{className:"break-all rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[13px] text-accent",...u,children:l})},a({children:a,...l}){return C.jsx("a",{className:"text-accent underline underline-offset-2",target:"_blank",rel:"noreferrer",...l,children:a})},p({children:a}){return C.jsx("p",{className:"my-2",children:a})},ul({children:a}){return C.jsx("ul",{className:"my-2 list-disc space-y-1 pl-5",children:a})},ol({children:a}){return C.jsx("ol",{className:"my-2 list-decimal space-y-1 pl-5",children:a})}},children:n})})});function Jy({item:e,onOpen:n}){const r=e.fileChange,a=r.diff?Zy(r.diff):[],l=Xy(a),u=r.entries.length>0?r.entries.map(d=>d.path):[],f=u[0]||r.summary||"文件变更",o=u.length>1?` +${u.length-1}`:"",h=!!(r.diff&&n);return C.jsxs("button",{onClick:()=>h&&(n==null?void 0:n(e)),className:`flex w-full items-center gap-2 rounded-xl border border-border bg-surface px-3.5 py-2.5 text-left transition-colors ${h?"cursor-pointer hover:border-border-strong hover:bg-surface-overlay":"cursor-default"}`,children:[C.jsx(na,{size:14,className:"shrink-0 text-content-faint"}),C.jsxs("span",{className:"truncate font-mono text-[13px] text-content-primary",title:u.join(", ")||f,children:[f,o&&C.jsx("span",{className:"text-content-muted",children:o})]}),C.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[l.added>0&&C.jsxs("span",{className:"text-diff-addText",children:["+",l.added]}),l.removed>0&&C.jsxs("span",{className:"text-diff-removeText",children:["−",l.removed]}),h&&C.jsx(Si,{size:13,className:"text-content-faint"})]})]})}function lO(e){const n=/@@\s*-(\d+)(?:,\d+)?\s*\+(\d+)(?:,\d+)?\s*@@/.exec(e);return n?[Number(n[1]),Number(n[2])]:null}function cO({item:e}){const n=e.fileChange,r=n!=null&&n.diff?Zy(n.diff):[],a=Xy(r),l=(n==null?void 0:n.entries.map(o=>o.path).join(", "))||(n==null?void 0:n.summary)||"文件变更";let u=0,f=0;return C.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[C.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-2.5",children:[C.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",title:l,children:l}),C.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[a.added>0&&C.jsxs("span",{className:"text-diff-addText",children:["+",a.added]}),a.removed>0&&C.jsxs("span",{className:"text-diff-removeText",children:["−",a.removed]})]}),(n==null?void 0:n.diff)&&C.jsx(jc,{text:n.diff,label:"复制差异"})]}),C.jsx("div",{className:"min-h-0 flex-1 overflow-auto font-mono text-[13px] leading-[1.6]",children:r.length===0?C.jsx("p",{className:"px-3 py-2 text-content-muted",children:(n==null?void 0:n.summary)||"无差异内容"}):r.map((o,h)=>{if(o.kind==="hunk"){const S=lO(o.text);return S&&(u=S[0],f=S[1]),C.jsxs("div",{className:"flex bg-surface-raised/60 text-accent-dim",children:[C.jsx("span",{className:"w-14 shrink-0 border-r border-border"}),C.jsx("span",{className:"px-3 py-0.5",children:o.text})]},h)}if(o.kind==="meta")return null;const d=o.kind==="add",m=o.kind==="remove",p=d?"":String(u),x=m?"":String(f);return d||(u+=1),m||(f+=1),C.jsxs("div",{className:`flex ${d?"bg-diff-add":m?"bg-diff-remove":""}`,children:[C.jsxs("span",{className:"flex w-14 shrink-0 select-none justify-end gap-1.5 border-r border-border px-1.5 py-0.5 text-[10px] text-content-faint",children:[C.jsx("span",{className:"w-5 text-right",children:p}),C.jsx("span",{className:"w-5 text-right",children:x})]}),C.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${d?"text-diff-addText":m?"text-diff-removeText":"text-content-secondary"}`,children:[C.jsx("span",{className:"mr-2 select-none opacity-60",children:d?"+":m?"−":" "}),o.text||" "]})]},h)})})]})}function uO(e,n=120){const r=e.replace(/\s+/g," ").trim();return r.length>n?r.slice(0,n-1)+"…":r}function hO(e,n){let r={};if(n)try{const u=JSON.parse(n);u&&typeof u=="object"&&(r=u)}catch{}const a=u=>typeof r[u]=="string"?r[u]:void 0;switch(e.split(/ · |__/).pop()??e){case"WebSearch":return{Icon:ls,label:"网络搜索",summary:a("query")};case"WebFetch":return{Icon:hc,label:"获取网页",summary:a("url")};case"Grep":{const u=a("pattern"),f=a("path");return{Icon:ls,label:"搜索代码",summary:f?`${u??""} · ${f}`:u}}case"Glob":return{Icon:ls,label:"查找文件",summary:a("pattern")};case"Read":return{Icon:na,label:"读取文件",summary:a("file_path")??a("path")};case"LS":case"List":return{Icon:Lr,label:"列出目录",summary:a("path")};case"Task":return{Icon:af,label:"子任务",summary:a("description")??a("prompt")};case"TodoWrite":return{Icon:Mo,label:"更新任务列表"};case"NotebookEdit":return{Icon:of,label:"编辑 Notebook",summary:a("notebook_path")};default:return{Icon:sf,label:e}}}function dO({status:e}){const n=e==="completed"?"bg-success":e==="failed"?"bg-danger":e==="running"?"bg-accent animate-pulse-dot":"bg-content-faint";return C.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${n}`})}function e0({item:e}){const n=e.toolCall,r=e.commandExecution,a=(r==null?void 0:r.status)??(n==null?void 0:n.status),l=!!(r!=null&&r.output||n!=null&&n.input||n!=null&&n.output),[u,f]=re.useState(a==="running"||a==="failed"),o=!r&&n?hO(n.name,n.input):null,h=(o==null?void 0:o.Icon)??sf;return C.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-surface",children:[C.jsxs("button",{onClick:()=>l&&f(d=>!d),className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors ${l?"cursor-pointer hover:bg-surface-overlay":"cursor-default"} ${r?"border-b border-border bg-surface-raised":""}`,children:[l?u?C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}):C.jsx("span",{className:"w-3 shrink-0"}),C.jsx(dO,{status:a}),r?C.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",children:`$ ${r.command??"命令"}`}):C.jsxs(C.Fragment,{children:[C.jsx(h,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"shrink-0 text-[13px] font-medium text-content-secondary",children:(o==null?void 0:o.label)??(n==null?void 0:n.name)??"工具调用"}),(o==null?void 0:o.summary)&&C.jsx("span",{className:"truncate font-mono text-[13px] text-content-faint",children:uO(o.summary)})]}),r&&typeof r.exitCode=="number"&&C.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[13px] ${r.exitCode===0?"text-success":"text-danger"}`,children:["exit ",r.exitCode]})]}),u&&l&&C.jsxs("div",{className:r?"":"px-3.5 pb-3 pt-2",children:[(r==null?void 0:r.output)&&C.jsxs("div",{className:"group/out relative",children:[C.jsx("pre",{className:"max-h-72 overflow-auto px-3.5 py-2.5 font-mono text-[13px] leading-relaxed text-content-secondary",children:r.output}),C.jsx(jc,{text:r.output,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/out:opacity-100"})]}),(n==null?void 0:n.input)&&C.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:n.input}),(n==null?void 0:n.output)&&C.jsx("pre",{className:"mt-2 max-h-60 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:n.output})]})]})}function fO({item:e,onRespond:n}){var h;const[r,a]=re.useState(!1),l=e.permission;if(!l)return null;const u=r||((h=e.metadata)==null?void 0:h.permissionPending)===!0,f=l.options.length>0?l.options:[{id:"deny",label:"拒绝",kind:"deny"},{id:"allow_once",label:"允许一次",kind:"allow"}],o=(d,m)=>{u||(a(!0),n(l.requestId,d,m))};return C.jsxs("div",{className:"rounded-xl border border-warning/40 bg-surface p-4",children:[C.jsx("p",{className:"text-sm font-medium text-warning",children:"需要授权"}),l.context&&C.jsx("p",{className:"mt-1.5 text-sm text-content-secondary",children:l.context}),l.toolName&&C.jsx("p",{className:"mt-1.5 font-mono text-[13px] text-content-faint",children:l.toolName}),l.toolInput&&C.jsx("pre",{className:"mt-2 max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:l.toolInput}),C.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:f.map(d=>C.jsx("button",{disabled:u,onClick:()=>o(d.kind==="allow"?"allow":"deny",d.id),className:d.kind==="allow"?"codex-btn-primary text-xs":"codex-btn-outline text-xs border-danger/40 text-danger hover:border-danger hover:bg-danger/10 hover:text-danger",children:d.label},d.id))}),u&&C.jsx("p",{className:"mt-2 text-xs text-content-muted",children:"已发送…"})]})}function pO({item:e}){var n;return(n=e.plan)!=null&&n.length?C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4",children:[C.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"计划"}),C.jsx("ul",{className:"space-y-1.5",children:e.plan.map(r=>C.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[C.jsx("span",{className:"mt-1 shrink-0",children:r.status==="completed"?C.jsx(Mo,{size:12,className:"text-success"}):r.status==="in_progress"?C.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):C.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),C.jsx("div",{className:`min-w-0 flex-1 ${r.status==="completed"?"text-content-muted line-through":"text-content-secondary"}`,children:C.jsx(Qy,{text:r.text})})]},r.id))})]}):null}function mO({item:e,onSubmit:n}){var p,x,S;const r=e.structuredInput,[a,l]=re.useState({});if(!r)return null;const u=((p=e.metadata)==null?void 0:p.inputSubmitting)===!0,f=((x=e.metadata)==null?void 0:x.inputSubmitted)===!0,o=typeof((S=e.metadata)==null?void 0:S.inputError)=="string"?e.metadata.inputError:void 0,h=(k,w,_)=>{l(b=>{const v=b[k]??[];if(v.includes(w))return{...b,[k]:v.filter(T=>T!==w)};if(_===1)return{...b,[k]:[w]};const y=[...v,w];return{...b,[k]:_?y.slice(-_):y}})},d=(k,w)=>{l(_=>({..._,[k]:w?[w]:[]}))},m=r.questions.every(k=>{var w;return(((w=a[k.id])==null?void 0:w.length)??0)>0});return C.jsxs("div",{className:"rounded-xl border border-accent-dim/40 bg-surface p-4",children:[C.jsx("p",{className:"text-sm font-medium text-accent",children:"需要你的输入"}),C.jsx("div",{className:"mt-3 space-y-4",children:r.questions.map(k=>C.jsxs("div",{children:[k.header&&C.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:k.header}),C.jsx("p",{className:"mb-2 text-sm text-content-secondary",children:k.question}),k.options&&k.options.length>0?C.jsx("div",{className:"flex flex-wrap gap-2",children:k.options.map(w=>{const _=(a[k.id]??[]).includes(w.id);return C.jsx("button",{disabled:f||u,onClick:()=>h(k.id,w.id,k.selectionLimit),title:w.description,className:_?"codex-btn-primary text-xs":"codex-btn-outline text-xs",children:w.label},w.id)})}):C.jsx("input",{type:k.isSecret?"password":"text",disabled:f||u,onChange:w=>d(k.id,w.target.value),className:"codex-input text-sm",placeholder:"输入答案…"})]},k.id))}),o&&C.jsx("p",{className:"mt-3 text-xs text-danger",children:o}),C.jsx("div",{className:"mt-3",children:f?C.jsx("span",{className:"text-xs text-content-muted",children:"已提交"}):C.jsx("button",{disabled:!m||u,onClick:()=>n(r.requestId,a),className:"codex-btn-primary text-xs",children:u?"提交中…":"提交"})})]})}function If(){return C.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-2xs text-accent",children:[C.jsx("span",{className:"h-1 w-1 animate-pulse-dot rounded-full bg-accent"}),"正在生成"]})}function t0({item:e}){const[n,r]=re.useState(!!e.isStreaming);return C.jsxs("div",{className:"rounded-xl border border-border bg-surface px-3.5 py-2.5",children:[C.jsxs("button",{onClick:()=>r(a=>!a),className:"flex w-full cursor-pointer items-center gap-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[n?C.jsx(Ir,{size:11,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:11,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:"思考过程"}),e.isStreaming&&C.jsx(If,{})]}),n&&e.text&&C.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words pl-4 text-sm italic leading-relaxed text-content-muted",children:e.text})]})}function Uv({item:e,label:n}){const[r,a]=re.useState(!1),l=e.text!=null&&e.text.trim()!=="";return C.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-2xs text-content-faint",children:[C.jsx("span",{className:"h-px flex-1 bg-border"}),C.jsxs("button",{onClick:()=>l&&a(u=>!u),className:`flex shrink-0 items-center gap-1 rounded-full border border-border bg-surface px-2.5 py-1 ${l?"cursor-pointer transition-colors hover:text-content-secondary":"cursor-default"}`,title:l?r?"收起":"展开":void 0,children:[C.jsx("span",{className:"font-medium",children:n}),e.isStreaming&&C.jsx(If,{}),l&&(r?C.jsx(Ir,{size:10}):C.jsx(Si,{size:10}))]}),C.jsx("span",{className:"h-px flex-1 bg-border"}),r&&l&&C.jsx("p",{className:"basis-full whitespace-pre-wrap break-words pt-1.5 text-xs italic leading-relaxed text-content-muted",children:e.text})]})}function gO(e){const n=Math.max(1,e.receiverThreadIds.length,e.receiverAgents.length),r=(e.tool||"").toLowerCase();return r.includes("spawn")?`启动 ${n} 个子 Agent`:r.includes("wait")?`等待 ${n} 个子 Agent`:r.includes("resume")?`恢复 ${n} 个子 Agent`:r.includes("close")?`关闭 ${n} 个子 Agent`:r.includes("sendinput")||r.includes("send_input")?`更新 ${n} 个子 Agent`:n===1?"子 Agent 活动":`${n} 个子 Agent 活动`}function _O(e){const n=(e||"").toLowerCase().replace(/[\s_-]/g,"");return n==="completed"||n==="done"||n==="success"?"完成":n==="failed"||n==="error"?"失败":n==="stopped"||n==="cancelled"?"已停止":n==="queued"||n==="pending"?"排队中":n==="running"||n==="inprogress"?"运行中":e||"未知"}function n0({item:e,onOpenAgent:n}){const r=e.subagent,[a,l]=re.useState(!0),u=[...new Set(r.receiverThreadIds.length>0?r.receiverThreadIds:r.receiverAgents.map(f=>f.threadId))];return C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-3.5",children:[C.jsxs("button",{onClick:()=>l(f=>!f),className:"flex w-full cursor-pointer items-center gap-2 text-left",children:[C.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-accent/10 text-accent",children:C.jsx(af,{size:13})}),C.jsx("span",{className:"flex-1 truncate text-sm font-medium text-content-primary",children:gO(r)}),e.isStreaming&&C.jsx("span",{className:"h-1.5 w-1.5 animate-pulse-dot rounded-full bg-accent"}),a?C.jsx(Ir,{size:13,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:13,className:"shrink-0 text-content-faint"})]}),r.prompt&&C.jsx("p",{className:`mt-2 text-xs leading-relaxed text-content-muted ${a?"":"line-clamp-1"}`,children:r.prompt}),a&&u.length>0&&C.jsx("div",{className:"mt-2.5 space-y-0.5",children:u.map(f=>{const o=r.receiverAgents.find(x=>x.threadId===f),h=r.agentStates[f],d=_O((h==null?void 0:h.status)??r.status),m=o!=null&&o.nickname&&(o!=null&&o.role)?`${o.nickname} [${o.role}]`:(o==null?void 0:o.nickname)||(o==null?void 0:o.role)||(f.length>14?`Agent ${f.slice(-8)}`:f||"Agent"),p=d==="失败"?"bg-danger":d==="完成"?"bg-success":"bg-accent";return C.jsxs("button",{onClick:()=>n==null?void 0:n({threadId:f,name:m,role:o==null?void 0:o.role,model:o==null?void 0:o.model,prompt:(o==null?void 0:o.prompt)??r.prompt,status:d,message:h==null?void 0:h.message,tool:r.tool}),className:"flex w-full cursor-pointer items-center gap-2 rounded-lg px-1.5 py-1 text-left transition-colors hover:bg-surface-overlay",children:[C.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${p}`}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-content-secondary",children:m}),(o==null?void 0:o.model)&&C.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:o.model}),C.jsx("span",{className:"shrink-0 text-2xs font-medium text-content-muted",children:d}),C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"})]},f)})})]})}function vO({detail:e}){const n=e.status==="失败"?"bg-danger":e.status==="完成"?"bg-success":"bg-accent";return C.jsxs("div",{className:"flex h-full flex-col overflow-y-auto bg-surface",children:[C.jsxs("div",{className:"border-b border-border px-4 py-4",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent/10 text-accent",children:C.jsx(af,{size:15})}),C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("p",{className:"truncate text-sm font-semibold text-content-primary",children:e.name}),C.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",children:e.threadId})]}),C.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-xs text-content-secondary",children:[C.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n}`}),e.status]})]}),C.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.role&&C.jsx("span",{className:"codex-chip",children:e.role}),e.model&&C.jsx("span",{className:"codex-chip",children:e.model}),e.tool&&C.jsx("span",{className:"codex-chip",children:e.tool})]})]}),C.jsxs("div",{className:"space-y-4 px-4 py-4",children:[e.prompt&&C.jsxs("section",{children:[C.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"委派指令"}),C.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.prompt})]}),e.message&&C.jsxs("section",{children:[C.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"状态消息"}),C.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.message})]}),C.jsx("p",{className:"pt-2 text-2xs leading-relaxed text-content-faint",children:"子 Agent 由主 Agent 内部派生,其完整对话记录不经网关透出,因此此处仅展示主 Agent 报告的状态信息。"})]})]})}const bO=new Set(["tool_activity","command_execution","file_change","subagent_action","thinking"]);function yO(e){return!!(e.kind&&bO.has(e.kind)||e.fileChange||e.commandExecution||e.toolCall||e.subagent||e.type==="tool_call")}function oc(e){var n,r,a;return e.role==="user"&&((n=e.metadata)==null?void 0:n.delivery)==="queued"&&((r=e.metadata)==null?void 0:r.queuedSent)!==!0&&((a=e.metadata)==null?void 0:a.queuedDiscarded)!==!0}function xO({items:e,canSteer:n,onSend:r,onSteer:a,onDiscard:l}){return e.length===0?null:C.jsx("div",{className:"mb-2 flex flex-col gap-1.5",children:e.map(u=>C.jsxs("div",{className:"group flex animate-slide-in items-center gap-2 rounded-xl border border-border bg-surface-raised px-3.5 py-2.5 shadow-sm",children:[C.jsx("span",{className:"shrink-0 rounded-full bg-surface-overlay px-2 py-0.5 text-2xs font-medium text-content-muted",children:"已排队"}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-secondary",children:u.text}),C.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[C.jsx("button",{onClick:()=>r(u.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"立即发送",children:"立即发送"}),n&&C.jsx("button",{onClick:()=>a(u.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"引导当前轮",children:"引导"}),C.jsx("button",{onClick:()=>l(u.id),className:"cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:text-danger",title:"丢弃","aria-label":"丢弃排队消息",children:C.jsx(hi,{size:14})})]})]},u.id))})}function Hv(e,n,r){return e.kind==="thinking"?C.jsx(t0,{item:e}):e.kind==="subagent_action"||e.subagent?C.jsx(n0,{item:e,onOpenAgent:r}):e.kind==="file_change"||e.fileChange?C.jsx(Jy,{item:e,onOpen:n}):C.jsx(e0,{item:e})}function SO(e){let n=1/0,r=0;for(const h of e){typeof h.createdAt=="number"&&(n=Math.min(n,h.createdAt));const d=typeof h.updatedAt=="number"?h.updatedAt:h.createdAt;typeof d=="number"&&(r=Math.max(r,d))}if(!Number.isFinite(n)||r<=n)return;const a=r-n;if(a<1e3)return;const l=Math.round(a/1e3);if(l<60)return`${(a/1e3).toFixed(1)}s`;const u=Math.floor(l/60),f=l%60;return u<60?`${u}m ${String(f).padStart(2,"0")}s`:`${Math.floor(u/60)}h ${String(u%60).padStart(2,"0")}m ${String(f).padStart(2,"0")}s`}function EO({items:e,live:n,onOpenDiff:r,onOpenAgent:a}){const[l,u]=re.useState(!1);if(n)return C.jsx("div",{className:"space-y-2",children:e.map(k=>C.jsx("div",{children:Hv(k,r,a)},k.id))});const f=e.filter(k=>k.kind==="file_change"||k.fileChange).length,o=e.filter(k=>k.kind==="command_execution"||k.commandExecution).length,h=e.filter(k=>(k.toolCall||k.type==="tool_call")&&!k.subagent).length,d=e.filter(k=>k.kind==="subagent_action"||k.subagent).length,m=e.filter(k=>k.kind==="thinking").length,p=[];f&&p.push(`编辑 ${f} 个文件`),o&&p.push(`运行 ${o} 条命令`),h&&p.push(`调用 ${h} 个工具`),d&&p.push(`${d} 次子 Agent`),!f&&!o&&!h&&!d&&m&&p.push("思考");const x=p.join(" · ")||`${e.length} 项活动`,S=SO(e);return l?C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-2",children:[C.jsxs("button",{onClick:()=>u(!1),className:"mb-2 flex w-full cursor-pointer items-center gap-1.5 px-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:x}),S&&C.jsxs("span",{className:"text-content-faint",children:["· ",S]})]}),C.jsx("div",{className:"space-y-2",children:e.map(k=>C.jsx("div",{children:Hv(k,r,a)},k.id))})]}):C.jsxs("button",{onClick:()=>u(!0),className:"flex w-full cursor-pointer items-center gap-1.5 rounded-full border border-border bg-surface px-3.5 py-2 text-left text-xs text-content-muted transition-colors hover:border-border-strong hover:text-content-secondary",children:[C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:x}),S&&C.jsxs("span",{className:"text-content-faint",children:["· ",S]}),C.jsx("span",{className:"ml-auto text-content-faint",children:"展开"})]})}const Fv=re.memo(function({item:n,canSteer:r,onPermission:a,onStructuredInput:l,onSendQueued:u,onSteerQueued:f,onDiscardQueued:o,onOpenDiff:h,onOpenAgent:d,onEditMessage:m,highlightQuery:p}){var w;if(n.kind==="user_input_prompt"||n.structuredInput)return C.jsx(mO,{item:n,onSubmit:l});if(n.kind==="subagent_action"||n.subagent)return C.jsx(n0,{item:n,onOpenAgent:d});if(n.kind==="file_change"||n.fileChange)return C.jsx(Jy,{item:n,onOpen:h});if(n.kind==="command_execution"||n.commandExecution||n.type==="tool_call"||n.toolCall)return C.jsx(e0,{item:n});if(n.type==="permission"||n.permission)return C.jsx(fO,{item:n,onRespond:a});if(n.type==="plan"||n.plan)return C.jsx(pO,{item:n});if(n.type==="error"||n.error)return C.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-danger/40 bg-surface px-3.5 py-2.5 text-sm text-danger",children:[C.jsx("span",{className:"mt-1.5 block h-1.5 w-1.5 shrink-0 rounded-full bg-danger"}),C.jsx("span",{children:n.error??"发生错误"})]});if(n.kind==="thinking")return C.jsx(t0,{item:n});if(n.kind==="context_compaction")return C.jsx(Uv,{item:n,label:"上下文压缩"});if(n.kind==="review")return C.jsx(Uv,{item:n,label:"审查"});const x=n.role==="user",S=((w=n.metadata)==null?void 0:w.queuedDiscarded)===!0,k=n.text!=null&&n.text!=="";return C.jsxs("div",{className:x?"group flex flex-col items-end":"group min-w-0",children:[C.jsxs("div",{className:x?`max-w-[85%] break-words rounded-2xl px-4 py-2.5 text-[15px] leading-7 ${S?"bg-surface-raised text-content-secondary line-through opacity-50":"bg-surface-raised text-content-primary"}`:"w-full min-w-0",children:[Array.isArray(n.content)&&n.content.some(_=>_.type==="image")&&C.jsx("div",{className:"mb-1.5 flex flex-wrap gap-2",children:n.content.filter(_=>_.type==="image"&&_.data).map((_,b)=>C.jsx("img",{src:_.data,alt:"附件",className:"max-h-48 rounded-lg border border-border object-contain"},b))}),k&&C.jsx(Qy,{text:n.text,highlight:p}),n.isStreaming&&C.jsx(If,{})]}),S&&C.jsx("span",{className:"mt-1 text-2xs text-content-faint",children:"已丢弃"}),k&&!n.isStreaming&&!S&&C.jsxs("div",{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 ${x?"justify-end":""}`,children:[x&&m&&C.jsx("button",{onClick:()=>m(n.text),title:"编辑并重新发送","aria-label":"编辑并重新发送",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:C.jsx(of,{size:13})}),C.jsx(jc,{text:n.text})]})]})},(e,n)=>e.item===n.item&&e.canSteer===n.canSteer&&e.onPermission===n.onPermission&&e.onStructuredInput===n.onStructuredInput&&e.onSendQueued===n.onSendQueued&&e.onSteerQueued===n.onSteerQueued&&e.onDiscardQueued===n.onDiscardQueued&&e.onOpenDiff===n.onOpenDiff&&e.onOpenAgent===n.onOpenAgent&&e.onEditMessage===n.onEditMessage&&e.highlightQuery===n.highlightQuery);function wO(e){const[n,r]=re.useState(()=>typeof window<"u"&&"matchMedia"in window?window.matchMedia(e).matches:!1);return re.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const a=window.matchMedia(e),l=()=>r(a.matches);return l(),a.addEventListener("change",l),()=>a.removeEventListener("change",l)},[e]),n}function i0(){return wO("(max-width: 767px)")}function CO({disabled:e,running:n,supportsImages:r,commands:a=[],conversationId:l,lastUserText:u,cwd:f,onBrowse:o,seedText:h,controls:d,onSend:m,onCancel:p,onExecuteCommand:x}){const[S,k]=re.useState(""),[w,_]=re.useState([]),[b,v]=re.useState(0),[y,T]=re.useState(!1),[M,N]=re.useState([]),[O,R]=re.useState([]),[L,z]=re.useState(null),H=re.useRef(null),q=re.useRef(null),F=i0();re.useEffect(()=>{if(!l)return;const ee=e1(l);k(ee),N([]),requestAnimationFrame(()=>A())},[l]),re.useEffect(()=>{!h||h.nonce===0||(k(h.text),requestAnimationFrame(()=>{const ee=H.current;ee&&(ee.focus(),ee.setSelectionRange(ee.value.length,ee.value.length),A())}))},[h==null?void 0:h.nonce]);const W=re.useMemo(()=>{const ee=/^\/(\S*)$/.exec(S);if(!ee||a.length===0)return null;const le=ee[1].toLowerCase(),He=a.map(Ee=>{const we=Ee.name.toLowerCase(),ke=Ee.title.toLowerCase();return le?we.startsWith(le)||ke.startsWith(`/${le}`)?{c:Ee,rank:0}:we.includes(le)||ke.includes(le)?{c:Ee,rank:1}:null:{c:Ee,rank:2}}).filter(Ee=>Ee!==null).sort((Ee,we)=>Ee.rank-we.rank).slice(0,8).map(Ee=>Ee.c);return He.length>0?He:null},[S,a]),G=re.useMemo(()=>{if(!o)return null;const ee=/(?:^|\s)@(\S*)$/.exec(S);if(!ee)return null;const le=ee[1],Ce=le.lastIndexOf("/"),He=Ce>=0?le.slice(0,Ce):"",Ee=Ce>=0?le.slice(Ce+1):le;return{token:`@${le}`,query:le,dir:He,filter:Ee}},[S,o]),K=re.useMemo(()=>{if(!G)return null;const ee=(f||".").replace(/\/+$/,"")||"/";return G.dir?`${ee}/${G.dir}`:ee},[G,f]);re.useEffect(()=>{if(!K||!o||K===L)return;let ee=!1;return o(K).then(le=>{ee||(R(le.error?[]:le.entries),z(K))}).catch(()=>{ee||R([])}),()=>{ee=!0}},[K,L,o]);const ne=re.useMemo(()=>{if(!G||L!==K)return null;const ee=G.filter.toLowerCase(),le=O.filter(Ce=>Ce.name.toLowerCase().includes(ee)).sort((Ce,He)=>Ce.isDirectory!==He.isDirectory?Ce.isDirectory?-1:1:Ce.name.localeCompare(He.name)).slice(0,50);return le.length>0?le:null},[G,O,L,K]),Q=W?{kind:"slash",items:W}:ne?{kind:"mention",items:ne}:null,I=()=>{H.current&&(H.current.style.height="auto")},A=()=>{const ee=H.current;ee&&(ee.style.height="auto",ee.style.height=`${Math.min(ee.scrollHeight,200)}px`)},B=ee=>{k(ee),v(0),l&&t1(l,ee),A()},$=ee=>{var le;ee.argsMode==="none"?(x==null||x(ee.id),B(""),I()):(B(`/${ee.name} `),(le=H.current)==null||le.focus())},P=ee=>{var Ee;if(!G)return;const le=(f||".").replace(/\/+$/,""),Ce=le&&ee.path.startsWith(le)?ee.path.slice(le.length).replace(/^\/+/,""):ee.name,He=S.slice(0,S.length-G.token.length);ee.isDirectory?B(`${He}@${Ce}/`):(B(He),N(we=>we.includes(Ce)?we:[...we,Ce])),(Ee=H.current)==null||Ee.focus()},oe=()=>{if(e)return;const ee=S.trim(),le=/^\/(\S+)\s*(.*)$/s.exec(ee);if(le&&x){const Ee=a.find(we=>we.name.toLowerCase()===le[1].toLowerCase());if(Ee){x(Ee.id,le[2]||void 0),B(""),N([]),I();return}}const He=[M.map(Ee=>`@${Ee}`).join(" "),ee].filter(Boolean).join(" ");!He&&w.length===0||(m(He,w),B(""),_([]),N([]),I())},ye=ee=>{if(Q){const le=Q.items.length;if(ee.key==="ArrowDown"){ee.preventDefault(),v(He=>Math.min(He+1,le-1));return}if(ee.key==="ArrowUp"){ee.preventDefault(),v(He=>Math.max(He-1,0));return}const Ce=()=>{const He=Math.min(b,le-1);Q.kind==="slash"?$(Q.items[He]):P(Q.items[He])};if(ee.key==="Tab"){ee.preventDefault(),Ce();return}if(ee.key==="Enter"&&!ee.metaKey&&!ee.ctrlKey&&!ee.shiftKey&&Q.kind==="mention"){ee.preventDefault(),Ce();return}if(ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)){ee.preventDefault(),Ce();return}if(ee.key==="Escape"){ee.preventDefault(),Q.kind==="slash"?B(""):G&&B(S.slice(0,S.length-G.token.length));return}}if(ee.key==="ArrowUp"&&!Q&&S===""&&u){ee.preventDefault(),B(u),requestAnimationFrame(()=>{const le=H.current;le&&le.setSelectionRange(le.value.length,le.value.length)});return}ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)&&(ee.preventDefault(),oe())},pe=ee=>{for(const le of ee){if(!le.type.startsWith("image/"))continue;const Ce=new FileReader;Ce.onload=()=>{const He=String(Ce.result);_(Ee=>[...Ee,{data:He,mimeType:le.type||"image/png",name:le.name||"粘贴图片"}])},Ce.readAsDataURL(le)}},J=ee=>{pe(Array.from(ee.target.files??[])),ee.target.value=""},j=ee=>{if(!r)return;const le=Array.from(ee.clipboardData.items).filter(Ce=>Ce.kind==="file"&&Ce.type.startsWith("image/")).map(Ce=>Ce.getAsFile()).filter(Ce=>Ce!=null);le.length>0&&(ee.preventDefault(),pe(le))},me=ee=>{if(T(!1),!r)return;const le=Array.from(ee.dataTransfer.files).filter(Ce=>Ce.type.startsWith("image/"));le.length>0&&(ee.preventDefault(),pe(le))},ce=ee=>{r&&Array.from(ee.dataTransfer.items).some(le=>le.kind==="file")&&(ee.preventDefault(),T(!0))};return C.jsxs("div",{className:"relative",children:[Q&&C.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 mb-2 max-h-72 w-80 overflow-y-auto p-1",children:Q.kind==="slash"?Q.items.map((ee,le)=>C.jsxs("button",{onMouseEnter:()=>v(le),onClick:()=>$(ee),className:`flex w-full cursor-pointer items-center justify-between rounded-lg px-2.5 py-1.5 text-left transition-colors ${le===b?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[C.jsxs("span",{className:"font-mono text-xs text-accent",children:["/",ee.name]}),C.jsx("span",{className:"ml-2 flex-1 truncate text-xs text-content-muted",children:ee.title}),ee.destructive&&C.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-danger",title:"破坏性操作"})]},ee.id)):Q.items.map((ee,le)=>C.jsxs("button",{onMouseEnter:()=>v(le),onClick:()=>P(ee),className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors ${le===b?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[ee.isDirectory?C.jsx(Lr,{size:13,className:"shrink-0 text-content-faint"}):C.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-xs text-content-secondary",children:ee.name}),ee.isDirectory&&C.jsx("span",{className:"text-content-faint",children:"/"})]},ee.path))}),w.length>0&&C.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:w.map((ee,le)=>C.jsxs("div",{className:"group relative",children:[C.jsx("img",{src:ee.data,alt:ee.name,className:"h-14 w-14 rounded-lg border border-border object-cover"}),C.jsx("button",{onClick:()=>_(Ce=>Ce.filter((He,Ee)=>Ee!==le)),className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-danger text-white","aria-label":"移除图片",children:C.jsx(hi,{size:10})})]},le))}),M.length>0&&C.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:M.map(ee=>C.jsxs("span",{className:"flex items-center gap-1 rounded-lg border border-border bg-surface-overlay py-1 pl-2 pr-1 font-mono text-xs text-content-secondary",children:[C.jsx(na,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"max-w-[200px] truncate",title:ee,children:ee}),C.jsx("button",{onClick:()=>N(le=>le.filter(Ce=>Ce!==ee)),className:"flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-content-faint transition-colors hover:text-danger","aria-label":`移除 ${ee}`,children:C.jsx(hi,{size:11})})]},ee))}),C.jsxs("div",{onDrop:me,onDragOver:ce,onDragLeave:()=>T(!1),className:`codex-card-raised flex flex-col gap-1 px-3 pt-2.5 pb-2 transition-colors focus-within:border-border-strong ${y?"border-border-strong":""}`,children:[r&&C.jsx("input",{ref:q,type:"file",accept:"image/*",multiple:!0,onChange:J,className:"hidden"}),C.jsx("textarea",{ref:H,value:S,rows:1,disabled:e,placeholder:F?a.length>0?"发送指令,或输入 / 调用命令…":"向 agent 发送指令…":a.length>0?"发送指令,/ 调用命令,@ 引用文件 (⌘/Ctrl+Enter 发送)":"向 agent 发送指令,@ 引用文件 (⌘/Ctrl+Enter 发送,Enter 换行)",onChange:ee=>B(ee.target.value),onKeyDown:ye,onPaste:j,className:"min-w-0 resize-none bg-transparent px-0 py-1 text-base leading-6 text-content-primary placeholder-content-muted outline-none md:text-[15px]"}),C.jsxs("div",{className:"flex items-center gap-1",children:[r&&C.jsx("button",{onClick:()=>{var ee;return(ee=q.current)==null?void 0:ee.click()},disabled:e,className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary disabled:opacity-40",title:"附加图片","aria-label":"附加图片",children:C.jsx(Ro,{size:17})}),C.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-0.5",children:d}),n&&p?C.jsx("button",{onClick:p,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface-overlay text-content-secondary transition-colors hover:bg-surface-raised hover:text-content-primary","aria-label":"停止",title:"停止",children:C.jsx(eb,{size:14})}):C.jsx("button",{onClick:oe,disabled:e||!S.trim()&&w.length===0&&M.length===0,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-accent-dim text-white transition-colors hover:bg-accent disabled:cursor-default disabled:bg-surface-overlay disabled:text-content-faint","aria-label":"发送",title:"发送",children:C.jsx(rf,{size:16})})]})]})]})}var _d={exports:{}},$v;function kO(){return $v||($v=1,(function(e,n){(function(r,a){e.exports=a()})(globalThis,(()=>(()=>{var r={4567:function(f,o,h){var d=this&&this.__decorate||function(v,y,T,M){var N,O=arguments.length,R=O<3?y:M===null?M=Object.getOwnPropertyDescriptor(y,T):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(v,y,T,M);else for(var L=v.length-1;L>=0;L--)(N=v[L])&&(R=(O<3?N(R):O>3?N(y,T,R):N(y,T))||R);return O>3&&R&&Object.defineProperty(y,T,R),R},m=this&&this.__param||function(v,y){return function(T,M){y(T,M,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const p=h(9042),x=h(9924),S=h(844),k=h(4725),w=h(2585),_=h(3656);let b=o.AccessibilityManager=class extends S.Disposable{constructor(v,y,T,M){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=M,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
84
+ `),r=[];for(const a of n)a.startsWith("@@")?r.push({kind:"hunk",text:a}):a.startsWith("diff ")||a.startsWith("index ")||a.startsWith("--- ")||a.startsWith("+++ ")?r.push({kind:"meta",text:a}):a.startsWith("+")?r.push({kind:"add",text:a.slice(1)}):a.startsWith("-")?r.push({kind:"remove",text:a.slice(1)}):r.push({kind:"context",text:a.startsWith(" ")?a.slice(1):a});return r}function Xy(e){let n=0,r=0;for(const a of e)a.kind==="add"?n++:a.kind==="remove"&&r++;return{added:n,removed:r}}function Wd(e){var n;return e==null||e===!1||e===!0?"":typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Wd).join(""):typeof e=="object"&&"props"in e?Wd((n=e.props)==null?void 0:n.children):""}function jc({text:e,className:n,label:r="复制"}){const[a,l]=re.useState(!1),u=async f=>{f.stopPropagation();try{await navigator.clipboard.writeText(e),l(!0),setTimeout(()=>l(!1),1500)}catch{}};return C.jsx("button",{onClick:u,title:a?"已复制":r,"aria-label":r,className:n??"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:a?C.jsx(Mo,{size:13,className:"text-success"}):C.jsx(DS,{size:13})})}function oO(e){const n=e.toLowerCase(),r=a=>{if(!a||!Array.isArray(a.children)||a.type==="element"&&(a.tagName==="code"||a.tagName==="pre"))return;const l=[];for(const u of a.children)if(u.type==="text"&&typeof u.value=="string"){const f=u.value,o=f.toLowerCase();let h=o.indexOf(n);if(h===-1){l.push(u);continue}let d=0;for(;h!==-1;)h>d&&l.push({type:"text",value:f.slice(d,h)}),l.push({type:"element",tagName:"mark",properties:{},children:[{type:"text",value:f.slice(h,h+n.length)}]}),d=h+n.length,h=o.indexOf(n,d);d<f.length&&l.push({type:"text",value:f.slice(d)})}else r(u),l.push(u);a.children=l};return()=>a=>{n&&r(a)}}const Qy=re.memo(function({text:n,highlight:r}){return C.jsx("div",{className:"prose-codex break-words text-[15px] leading-7 text-content-primary",children:C.jsx(s2,{remarkPlugins:[vR],rehypePlugins:r?[[jv,{detect:!0,ignoreMissing:!0}],oO(r)]:[[jv,{detect:!0,ignoreMissing:!0}]],components:{mark({children:a}){return C.jsx("mark",{className:"rounded bg-warning/30 px-0.5 text-content-primary",children:a})},pre({children:a}){return C.jsx(C.Fragment,{children:a})},code({className:a,children:l,...u}){if(/language-|hljs/.test(a??"")){const o=Wd(l);return C.jsxs("div",{className:"group/code relative my-3",children:[C.jsx("pre",{className:"max-w-full overflow-x-auto rounded-lg border border-border bg-surface-raised p-3 font-mono text-[13px] leading-relaxed",children:C.jsx("code",{className:a,...u,children:l})}),C.jsx(jc,{text:o,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/code:opacity-100"})]})}return C.jsx("code",{className:"break-all rounded bg-surface-overlay px-1.5 py-0.5 font-mono text-[13px] text-accent",...u,children:l})},a({children:a,...l}){return C.jsx("a",{className:"text-accent underline underline-offset-2",target:"_blank",rel:"noreferrer",...l,children:a})},p({children:a}){return C.jsx("p",{className:"my-2",children:a})},ul({children:a}){return C.jsx("ul",{className:"my-2 list-disc space-y-1 pl-5",children:a})},ol({children:a}){return C.jsx("ol",{className:"my-2 list-decimal space-y-1 pl-5",children:a})}},children:n})})});function Jy({item:e,onOpen:n}){const r=e.fileChange,a=r.diff?Zy(r.diff):[],l=Xy(a),u=r.entries.length>0?r.entries.map(d=>d.path):[],f=u[0]||r.summary||"文件变更",o=u.length>1?` +${u.length-1}`:"",h=!!(r.diff&&n);return C.jsxs("button",{onClick:()=>h&&(n==null?void 0:n(e)),className:`flex w-full items-center gap-2 rounded-xl border border-border bg-surface px-3.5 py-2.5 text-left transition-colors ${h?"cursor-pointer hover:border-border-strong hover:bg-surface-overlay":"cursor-default"}`,children:[C.jsx(na,{size:14,className:"shrink-0 text-content-faint"}),C.jsxs("span",{className:"truncate font-mono text-[13px] text-content-primary",title:u.join(", ")||f,children:[f,o&&C.jsx("span",{className:"text-content-muted",children:o})]}),C.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[l.added>0&&C.jsxs("span",{className:"text-diff-addText",children:["+",l.added]}),l.removed>0&&C.jsxs("span",{className:"text-diff-removeText",children:["−",l.removed]}),h&&C.jsx(Si,{size:13,className:"text-content-faint"})]})]})}function lO(e){const n=/@@\s*-(\d+)(?:,\d+)?\s*\+(\d+)(?:,\d+)?\s*@@/.exec(e);return n?[Number(n[1]),Number(n[2])]:null}function cO({item:e}){const n=e.fileChange,r=n!=null&&n.diff?Zy(n.diff):[],a=Xy(r),l=(n==null?void 0:n.entries.map(o=>o.path).join(", "))||(n==null?void 0:n.summary)||"文件变更";let u=0,f=0;return C.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[C.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-2.5",children:[C.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",title:l,children:l}),C.jsxs("span",{className:"ml-auto flex shrink-0 items-center gap-2 font-mono text-[13px]",children:[a.added>0&&C.jsxs("span",{className:"text-diff-addText",children:["+",a.added]}),a.removed>0&&C.jsxs("span",{className:"text-diff-removeText",children:["−",a.removed]})]}),(n==null?void 0:n.diff)&&C.jsx(jc,{text:n.diff,label:"复制差异"})]}),C.jsx("div",{className:"min-h-0 flex-1 overflow-auto font-mono text-[13px] leading-[1.6]",children:r.length===0?C.jsx("p",{className:"px-3 py-2 text-content-muted",children:(n==null?void 0:n.summary)||"无差异内容"}):r.map((o,h)=>{if(o.kind==="hunk"){const S=lO(o.text);return S&&(u=S[0],f=S[1]),C.jsxs("div",{className:"flex bg-surface-raised/60 text-accent-dim",children:[C.jsx("span",{className:"w-14 shrink-0 border-r border-border"}),C.jsx("span",{className:"px-3 py-0.5",children:o.text})]},h)}if(o.kind==="meta")return null;const d=o.kind==="add",m=o.kind==="remove",p=d?"":String(u),x=m?"":String(f);return d||(u+=1),m||(f+=1),C.jsxs("div",{className:`flex ${d?"bg-diff-add":m?"bg-diff-remove":""}`,children:[C.jsxs("span",{className:"flex w-14 shrink-0 select-none justify-end gap-1.5 border-r border-border px-1.5 py-0.5 text-[10px] text-content-faint",children:[C.jsx("span",{className:"w-5 text-right",children:p}),C.jsx("span",{className:"w-5 text-right",children:x})]}),C.jsxs("span",{className:`flex-1 whitespace-pre px-3 py-0.5 ${d?"text-diff-addText":m?"text-diff-removeText":"text-content-secondary"}`,children:[C.jsx("span",{className:"mr-2 select-none opacity-60",children:d?"+":m?"−":" "}),o.text||" "]})]},h)})})]})}function uO(e,n=120){const r=e.replace(/\s+/g," ").trim();return r.length>n?r.slice(0,n-1)+"…":r}function hO(e,n){let r={};if(n)try{const u=JSON.parse(n);u&&typeof u=="object"&&(r=u)}catch{}const a=u=>typeof r[u]=="string"?r[u]:void 0;switch(e.split(/ · |__/).pop()??e){case"WebSearch":return{Icon:ls,label:"网络搜索",summary:a("query")};case"WebFetch":return{Icon:hc,label:"获取网页",summary:a("url")};case"Grep":{const u=a("pattern"),f=a("path");return{Icon:ls,label:"搜索代码",summary:f?`${u??""} · ${f}`:u}}case"Glob":return{Icon:ls,label:"查找文件",summary:a("pattern")};case"Read":return{Icon:na,label:"读取文件",summary:a("file_path")??a("path")};case"LS":case"List":return{Icon:Lr,label:"列出目录",summary:a("path")};case"Task":return{Icon:af,label:"子任务",summary:a("description")??a("prompt")};case"TodoWrite":return{Icon:Mo,label:"更新任务列表"};case"NotebookEdit":return{Icon:of,label:"编辑 Notebook",summary:a("notebook_path")};default:return{Icon:sf,label:e}}}function dO({status:e}){const n=e==="completed"?"bg-success":e==="failed"?"bg-danger":e==="running"?"bg-accent animate-pulse-dot":"bg-content-faint";return C.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${n}`})}function e0({item:e}){const n=e.toolCall,r=e.commandExecution,a=(r==null?void 0:r.status)??(n==null?void 0:n.status),l=!!(r!=null&&r.output||n!=null&&n.input||n!=null&&n.output),[u,f]=re.useState(a==="running"||a==="failed"),o=!r&&n?hO(n.name,n.input):null,h=(o==null?void 0:o.Icon)??sf;return C.jsxs("div",{className:"overflow-hidden rounded-xl border border-border bg-surface",children:[C.jsxs("button",{onClick:()=>l&&f(d=>!d),className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors ${l?"cursor-pointer hover:bg-surface-overlay":"cursor-default"} ${r?"border-b border-border bg-surface-raised":""}`,children:[l?u?C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}):C.jsx("span",{className:"w-3 shrink-0"}),C.jsx(dO,{status:a}),r?C.jsx("span",{className:"truncate font-mono text-[13px] text-content-secondary",children:`$ ${r.command??"命令"}`}):C.jsxs(C.Fragment,{children:[C.jsx(h,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"shrink-0 text-[13px] font-medium text-content-secondary",children:(o==null?void 0:o.label)??(n==null?void 0:n.name)??"工具调用"}),(o==null?void 0:o.summary)&&C.jsx("span",{className:"truncate font-mono text-[13px] text-content-faint",children:uO(o.summary)})]}),r&&typeof r.exitCode=="number"&&C.jsxs("span",{className:`ml-auto shrink-0 font-mono text-[13px] ${r.exitCode===0?"text-success":"text-danger"}`,children:["exit ",r.exitCode]})]}),u&&l&&C.jsxs("div",{className:r?"":"px-3.5 pb-3 pt-2",children:[(r==null?void 0:r.output)&&C.jsxs("div",{className:"group/out relative",children:[C.jsx("pre",{className:"max-h-72 overflow-auto px-3.5 py-2.5 font-mono text-[13px] leading-relaxed text-content-secondary",children:r.output}),C.jsx(jc,{text:r.output,className:"absolute right-2 top-2 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted opacity-0 transition-opacity hover:text-content-primary group-hover/out:opacity-100"})]}),(n==null?void 0:n.input)&&C.jsx("pre",{className:"max-h-40 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:n.input}),(n==null?void 0:n.output)&&C.jsx("pre",{className:"mt-2 max-h-60 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-secondary",children:n.output})]})]})}function fO({item:e,onRespond:n}){var h;const[r,a]=re.useState(!1),l=e.permission;if(!l)return null;const u=r||((h=e.metadata)==null?void 0:h.permissionPending)===!0,f=l.options.length>0?l.options:[{id:"deny",label:"拒绝",kind:"deny"},{id:"allow_once",label:"允许一次",kind:"allow"}],o=(d,m)=>{u||(a(!0),n(l.requestId,d,m))};return C.jsxs("div",{className:"rounded-xl border border-warning/40 bg-surface p-4",children:[C.jsx("p",{className:"text-sm font-medium text-warning",children:"需要授权"}),l.context&&C.jsx("p",{className:"mt-1.5 text-sm text-content-secondary",children:l.context}),l.toolName&&C.jsx("p",{className:"mt-1.5 font-mono text-[13px] text-content-faint",children:l.toolName}),l.toolInput&&C.jsx("pre",{className:"mt-2 max-h-32 overflow-auto rounded-lg bg-surface-raised px-3 py-2 font-mono text-[13px] text-content-faint",children:l.toolInput}),C.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:f.map(d=>C.jsx("button",{disabled:u,onClick:()=>o(d.kind==="allow"?"allow":"deny",d.id),className:d.kind==="allow"?"codex-btn-primary text-xs":"codex-btn-outline text-xs border-danger/40 text-danger hover:border-danger hover:bg-danger/10 hover:text-danger",children:d.label},d.id))}),u&&C.jsx("p",{className:"mt-2 text-xs text-content-muted",children:"已发送…"})]})}function pO({item:e}){var n;return(n=e.plan)!=null&&n.length?C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-4",children:[C.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"计划"}),C.jsx("ul",{className:"space-y-1.5",children:e.plan.map(r=>C.jsxs("li",{className:"flex items-start gap-2 text-sm leading-6",children:[C.jsx("span",{className:"mt-1 shrink-0",children:r.status==="completed"?C.jsx(Mo,{size:12,className:"text-success"}):r.status==="in_progress"?C.jsx("span",{className:"block h-2.5 w-2.5 animate-pulse-dot rounded-full bg-accent"}):C.jsx("span",{className:"block h-2.5 w-2.5 rounded-full border border-content-faint"})}),C.jsx("div",{className:`min-w-0 flex-1 ${r.status==="completed"?"text-content-muted line-through":"text-content-secondary"}`,children:C.jsx(Qy,{text:r.text})})]},r.id))})]}):null}function mO({item:e,onSubmit:n}){var p,x,S;const r=e.structuredInput,[a,l]=re.useState({});if(!r)return null;const u=((p=e.metadata)==null?void 0:p.inputSubmitting)===!0,f=((x=e.metadata)==null?void 0:x.inputSubmitted)===!0,o=typeof((S=e.metadata)==null?void 0:S.inputError)=="string"?e.metadata.inputError:void 0,h=(k,w,_)=>{l(b=>{const v=b[k]??[];if(v.includes(w))return{...b,[k]:v.filter(T=>T!==w)};if(!_||_<=1)return{...b,[k]:[w]};const y=[...v,w];return{...b,[k]:y.slice(-_)}})},d=(k,w)=>{l(_=>({..._,[k]:w?[w]:[]}))},m=r.questions.every(k=>{var w;return(((w=a[k.id])==null?void 0:w.length)??0)>0});return C.jsxs("div",{className:"rounded-xl border border-accent-dim/40 bg-surface p-4",children:[C.jsx("p",{className:"text-sm font-medium text-accent",children:"需要你的输入"}),C.jsx("div",{className:"mt-3 space-y-4",children:r.questions.map(k=>C.jsxs("div",{children:[k.header&&C.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:k.header}),C.jsx("p",{className:"mb-2 text-sm text-content-secondary",children:k.question}),k.options&&k.options.length>0&&k.selectionLimit&&k.selectionLimit>1&&C.jsxs("p",{className:"mb-2 text-2xs text-content-faint",children:["可多选",k.selectionLimit<k.options.length?`(最多 ${k.selectionLimit} 项)`:""]}),k.options&&k.options.length>0?C.jsx("div",{className:"flex flex-wrap gap-2",children:k.options.map(w=>{const _=(a[k.id]??[]).includes(w.id);return C.jsx("button",{disabled:f||u,onClick:()=>h(k.id,w.id,k.selectionLimit),title:w.description,className:_?"codex-btn-primary text-xs":"codex-btn-outline text-xs",children:w.label},w.id)})}):C.jsx("input",{type:k.isSecret?"password":"text",disabled:f||u,onChange:w=>d(k.id,w.target.value),className:"codex-input text-sm",placeholder:"输入答案…"})]},k.id))}),o&&C.jsx("p",{className:"mt-3 text-xs text-danger",children:o}),C.jsx("div",{className:"mt-3",children:f?C.jsx("span",{className:"text-xs text-content-muted",children:"已提交"}):C.jsx("button",{disabled:!m||u,onClick:()=>n(r.requestId,a),className:"codex-btn-primary text-xs",children:u?"提交中…":"提交"})})]})}function If(){return C.jsxs("span",{className:"ml-2 inline-flex items-center gap-1 text-2xs text-accent",children:[C.jsx("span",{className:"h-1 w-1 animate-pulse-dot rounded-full bg-accent"}),"正在生成"]})}function t0({item:e}){const[n,r]=re.useState(!!e.isStreaming);return C.jsxs("div",{className:"rounded-xl border border-border bg-surface px-3.5 py-2.5",children:[C.jsxs("button",{onClick:()=>r(a=>!a),className:"flex w-full cursor-pointer items-center gap-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[n?C.jsx(Ir,{size:11,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:11,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:"思考过程"}),e.isStreaming&&C.jsx(If,{})]}),n&&e.text&&C.jsx("p",{className:"mt-2 whitespace-pre-wrap break-words pl-4 text-sm italic leading-relaxed text-content-muted",children:e.text})]})}function Uv({item:e,label:n}){const[r,a]=re.useState(!1),l=e.text!=null&&e.text.trim()!=="";return C.jsxs("div",{className:"flex items-center gap-2 py-0.5 text-2xs text-content-faint",children:[C.jsx("span",{className:"h-px flex-1 bg-border"}),C.jsxs("button",{onClick:()=>l&&a(u=>!u),className:`flex shrink-0 items-center gap-1 rounded-full border border-border bg-surface px-2.5 py-1 ${l?"cursor-pointer transition-colors hover:text-content-secondary":"cursor-default"}`,title:l?r?"收起":"展开":void 0,children:[C.jsx("span",{className:"font-medium",children:n}),e.isStreaming&&C.jsx(If,{}),l&&(r?C.jsx(Ir,{size:10}):C.jsx(Si,{size:10}))]}),C.jsx("span",{className:"h-px flex-1 bg-border"}),r&&l&&C.jsx("p",{className:"basis-full whitespace-pre-wrap break-words pt-1.5 text-xs italic leading-relaxed text-content-muted",children:e.text})]})}function gO(e){const n=Math.max(1,e.receiverThreadIds.length,e.receiverAgents.length),r=(e.tool||"").toLowerCase();return r.includes("spawn")?`启动 ${n} 个子 Agent`:r.includes("wait")?`等待 ${n} 个子 Agent`:r.includes("resume")?`恢复 ${n} 个子 Agent`:r.includes("close")?`关闭 ${n} 个子 Agent`:r.includes("sendinput")||r.includes("send_input")?`更新 ${n} 个子 Agent`:n===1?"子 Agent 活动":`${n} 个子 Agent 活动`}function _O(e){const n=(e||"").toLowerCase().replace(/[\s_-]/g,"");return n==="completed"||n==="done"||n==="success"?"完成":n==="failed"||n==="error"?"失败":n==="stopped"||n==="cancelled"?"已停止":n==="queued"||n==="pending"?"排队中":n==="running"||n==="inprogress"?"运行中":e||"未知"}function n0({item:e,onOpenAgent:n}){const r=e.subagent,[a,l]=re.useState(!0),u=[...new Set(r.receiverThreadIds.length>0?r.receiverThreadIds:r.receiverAgents.map(f=>f.threadId))];return C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-3.5",children:[C.jsxs("button",{onClick:()=>l(f=>!f),className:"flex w-full cursor-pointer items-center gap-2 text-left",children:[C.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-accent/10 text-accent",children:C.jsx(af,{size:13})}),C.jsx("span",{className:"flex-1 truncate text-sm font-medium text-content-primary",children:gO(r)}),e.isStreaming&&C.jsx("span",{className:"h-1.5 w-1.5 animate-pulse-dot rounded-full bg-accent"}),a?C.jsx(Ir,{size:13,className:"shrink-0 text-content-faint"}):C.jsx(Si,{size:13,className:"shrink-0 text-content-faint"})]}),r.prompt&&C.jsx("p",{className:`mt-2 text-xs leading-relaxed text-content-muted ${a?"":"line-clamp-1"}`,children:r.prompt}),a&&u.length>0&&C.jsx("div",{className:"mt-2.5 space-y-0.5",children:u.map(f=>{const o=r.receiverAgents.find(x=>x.threadId===f),h=r.agentStates[f],d=_O((h==null?void 0:h.status)??r.status),m=o!=null&&o.nickname&&(o!=null&&o.role)?`${o.nickname} [${o.role}]`:(o==null?void 0:o.nickname)||(o==null?void 0:o.role)||(f.length>14?`Agent ${f.slice(-8)}`:f||"Agent"),p=d==="失败"?"bg-danger":d==="完成"?"bg-success":"bg-accent";return C.jsxs("button",{onClick:()=>n==null?void 0:n({threadId:f,name:m,role:o==null?void 0:o.role,model:o==null?void 0:o.model,prompt:(o==null?void 0:o.prompt)??r.prompt,status:d,message:h==null?void 0:h.message,tool:r.tool}),className:"flex w-full cursor-pointer items-center gap-2 rounded-lg px-1.5 py-1 text-left transition-colors hover:bg-surface-overlay",children:[C.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${p}`}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-content-secondary",children:m}),(o==null?void 0:o.model)&&C.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:o.model}),C.jsx("span",{className:"shrink-0 text-2xs font-medium text-content-muted",children:d}),C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"})]},f)})})]})}function vO({detail:e}){const n=e.status==="失败"?"bg-danger":e.status==="完成"?"bg-success":"bg-accent";return C.jsxs("div",{className:"flex h-full flex-col overflow-y-auto bg-surface",children:[C.jsxs("div",{className:"border-b border-border px-4 py-4",children:[C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-accent/10 text-accent",children:C.jsx(af,{size:15})}),C.jsxs("div",{className:"min-w-0 flex-1",children:[C.jsx("p",{className:"truncate text-sm font-semibold text-content-primary",children:e.name}),C.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",children:e.threadId})]}),C.jsxs("span",{className:"flex shrink-0 items-center gap-1.5 text-xs text-content-secondary",children:[C.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n}`}),e.status]})]}),C.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.role&&C.jsx("span",{className:"codex-chip",children:e.role}),e.model&&C.jsx("span",{className:"codex-chip",children:e.model}),e.tool&&C.jsx("span",{className:"codex-chip",children:e.tool})]})]}),C.jsxs("div",{className:"space-y-4 px-4 py-4",children:[e.prompt&&C.jsxs("section",{children:[C.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"委派指令"}),C.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.prompt})]}),e.message&&C.jsxs("section",{children:[C.jsx("p",{className:"mb-1.5 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"状态消息"}),C.jsx("div",{className:"rounded-xl border border-border bg-surface-raised p-3 text-[13px] leading-relaxed text-content-secondary whitespace-pre-wrap",children:e.message})]}),C.jsx("p",{className:"pt-2 text-2xs leading-relaxed text-content-faint",children:"子 Agent 由主 Agent 内部派生,其完整对话记录不经网关透出,因此此处仅展示主 Agent 报告的状态信息。"})]})]})}const bO=new Set(["tool_activity","command_execution","file_change","subagent_action","thinking"]);function yO(e){return!!(e.kind&&bO.has(e.kind)||e.fileChange||e.commandExecution||e.toolCall||e.subagent||e.type==="tool_call")}function oc(e){var n,r,a;return e.role==="user"&&((n=e.metadata)==null?void 0:n.delivery)==="queued"&&((r=e.metadata)==null?void 0:r.queuedSent)!==!0&&((a=e.metadata)==null?void 0:a.queuedDiscarded)!==!0}function xO({items:e,canSteer:n,onSend:r,onSteer:a,onDiscard:l}){return e.length===0?null:C.jsx("div",{className:"mb-2 flex flex-col gap-1.5",children:e.map(u=>C.jsxs("div",{className:"group flex animate-slide-in items-center gap-2 rounded-xl border border-border bg-surface-raised px-3.5 py-2.5 shadow-sm",children:[C.jsx("span",{className:"shrink-0 rounded-full bg-surface-overlay px-2 py-0.5 text-2xs font-medium text-content-muted",children:"已排队"}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-secondary",children:u.text}),C.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[C.jsx("button",{onClick:()=>r(u.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"立即发送",children:"立即发送"}),n&&C.jsx("button",{onClick:()=>a(u.id),className:"cursor-pointer rounded-md px-2 py-1 text-2xs text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"引导当前轮",children:"引导"}),C.jsx("button",{onClick:()=>l(u.id),className:"cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:text-danger",title:"丢弃","aria-label":"丢弃排队消息",children:C.jsx(hi,{size:14})})]})]},u.id))})}function Hv(e,n,r){return e.kind==="thinking"?C.jsx(t0,{item:e}):e.kind==="subagent_action"||e.subagent?C.jsx(n0,{item:e,onOpenAgent:r}):e.kind==="file_change"||e.fileChange?C.jsx(Jy,{item:e,onOpen:n}):C.jsx(e0,{item:e})}function SO(e){let n=1/0,r=0;for(const h of e){typeof h.createdAt=="number"&&(n=Math.min(n,h.createdAt));const d=typeof h.updatedAt=="number"?h.updatedAt:h.createdAt;typeof d=="number"&&(r=Math.max(r,d))}if(!Number.isFinite(n)||r<=n)return;const a=r-n;if(a<1e3)return;const l=Math.round(a/1e3);if(l<60)return`${(a/1e3).toFixed(1)}s`;const u=Math.floor(l/60),f=l%60;return u<60?`${u}m ${String(f).padStart(2,"0")}s`:`${Math.floor(u/60)}h ${String(u%60).padStart(2,"0")}m ${String(f).padStart(2,"0")}s`}function EO({items:e,live:n,onOpenDiff:r,onOpenAgent:a}){const[l,u]=re.useState(!1);if(n)return C.jsx("div",{className:"space-y-2",children:e.map(k=>C.jsx("div",{children:Hv(k,r,a)},k.id))});const f=e.filter(k=>k.kind==="file_change"||k.fileChange).length,o=e.filter(k=>k.kind==="command_execution"||k.commandExecution).length,h=e.filter(k=>(k.toolCall||k.type==="tool_call")&&!k.subagent).length,d=e.filter(k=>k.kind==="subagent_action"||k.subagent).length,m=e.filter(k=>k.kind==="thinking").length,p=[];f&&p.push(`编辑 ${f} 个文件`),o&&p.push(`运行 ${o} 条命令`),h&&p.push(`调用 ${h} 个工具`),d&&p.push(`${d} 次子 Agent`),!f&&!o&&!h&&!d&&m&&p.push("思考");const x=p.join(" · ")||`${e.length} 项活动`,S=SO(e);return l?C.jsxs("div",{className:"rounded-xl border border-border bg-surface p-2",children:[C.jsxs("button",{onClick:()=>u(!1),className:"mb-2 flex w-full cursor-pointer items-center gap-1.5 px-1.5 text-left text-xs text-content-muted transition-colors hover:text-content-secondary",children:[C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:x}),S&&C.jsxs("span",{className:"text-content-faint",children:["· ",S]})]}),C.jsx("div",{className:"space-y-2",children:e.map(k=>C.jsx("div",{children:Hv(k,r,a)},k.id))})]}):C.jsxs("button",{onClick:()=>u(!0),className:"flex w-full cursor-pointer items-center gap-1.5 rounded-full border border-border bg-surface px-3.5 py-2 text-left text-xs text-content-muted transition-colors hover:border-border-strong hover:text-content-secondary",children:[C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{children:x}),S&&C.jsxs("span",{className:"text-content-faint",children:["· ",S]}),C.jsx("span",{className:"ml-auto text-content-faint",children:"展开"})]})}const Fv=re.memo(function({item:n,canSteer:r,onPermission:a,onStructuredInput:l,onSendQueued:u,onSteerQueued:f,onDiscardQueued:o,onOpenDiff:h,onOpenAgent:d,onEditMessage:m,highlightQuery:p}){var w;if(n.kind==="user_input_prompt"||n.structuredInput)return C.jsx(mO,{item:n,onSubmit:l});if(n.kind==="subagent_action"||n.subagent)return C.jsx(n0,{item:n,onOpenAgent:d});if(n.kind==="file_change"||n.fileChange)return C.jsx(Jy,{item:n,onOpen:h});if(n.kind==="command_execution"||n.commandExecution||n.type==="tool_call"||n.toolCall)return C.jsx(e0,{item:n});if(n.type==="permission"||n.permission)return C.jsx(fO,{item:n,onRespond:a});if(n.type==="plan"||n.plan)return C.jsx(pO,{item:n});if(n.type==="error"||n.error)return C.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-danger/40 bg-surface px-3.5 py-2.5 text-sm text-danger",children:[C.jsx("span",{className:"mt-1.5 block h-1.5 w-1.5 shrink-0 rounded-full bg-danger"}),C.jsx("span",{children:n.error??"发生错误"})]});if(n.kind==="thinking")return C.jsx(t0,{item:n});if(n.kind==="context_compaction")return C.jsx(Uv,{item:n,label:"上下文压缩"});if(n.kind==="review")return C.jsx(Uv,{item:n,label:"审查"});const x=n.role==="user",S=((w=n.metadata)==null?void 0:w.queuedDiscarded)===!0,k=n.text!=null&&n.text!=="";return C.jsxs("div",{className:x?"group flex flex-col items-end":"group min-w-0",children:[C.jsxs("div",{className:x?`max-w-[85%] break-words rounded-2xl px-4 py-2.5 text-[15px] leading-7 ${S?"bg-surface-raised text-content-secondary line-through opacity-50":"bg-surface-raised text-content-primary"}`:"w-full min-w-0",children:[Array.isArray(n.content)&&n.content.some(_=>_.type==="image")&&C.jsx("div",{className:"mb-1.5 flex flex-wrap gap-2",children:n.content.filter(_=>_.type==="image"&&_.data).map((_,b)=>C.jsx("img",{src:_.data,alt:"附件",className:"max-h-48 rounded-lg border border-border object-contain"},b))}),k&&C.jsx(Qy,{text:n.text,highlight:p}),n.isStreaming&&C.jsx(If,{})]}),S&&C.jsx("span",{className:"mt-1 text-2xs text-content-faint",children:"已丢弃"}),k&&!n.isStreaming&&!S&&C.jsxs("div",{className:`mt-1 flex items-center gap-1 opacity-0 transition-opacity group-hover:opacity-100 ${x?"justify-end":""}`,children:[x&&m&&C.jsx("button",{onClick:()=>m(n.text),title:"编辑并重新发送","aria-label":"编辑并重新发送",className:"flex h-7 w-7 cursor-pointer items-center justify-center rounded-md border border-border bg-surface text-content-muted transition-colors hover:text-content-primary",children:C.jsx(of,{size:13})}),C.jsx(jc,{text:n.text})]})]})},(e,n)=>e.item===n.item&&e.canSteer===n.canSteer&&e.onPermission===n.onPermission&&e.onStructuredInput===n.onStructuredInput&&e.onSendQueued===n.onSendQueued&&e.onSteerQueued===n.onSteerQueued&&e.onDiscardQueued===n.onDiscardQueued&&e.onOpenDiff===n.onOpenDiff&&e.onOpenAgent===n.onOpenAgent&&e.onEditMessage===n.onEditMessage&&e.highlightQuery===n.highlightQuery);function wO(e){const[n,r]=re.useState(()=>typeof window<"u"&&"matchMedia"in window?window.matchMedia(e).matches:!1);return re.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const a=window.matchMedia(e),l=()=>r(a.matches);return l(),a.addEventListener("change",l),()=>a.removeEventListener("change",l)},[e]),n}function i0(){return wO("(max-width: 767px)")}function CO({disabled:e,running:n,supportsImages:r,commands:a=[],conversationId:l,lastUserText:u,cwd:f,onBrowse:o,seedText:h,controls:d,onSend:m,onCancel:p,onExecuteCommand:x}){const[S,k]=re.useState(""),[w,_]=re.useState([]),[b,v]=re.useState(0),[y,T]=re.useState(!1),[M,N]=re.useState([]),[O,R]=re.useState([]),[L,z]=re.useState(null),H=re.useRef(null),q=re.useRef(null),F=i0();re.useEffect(()=>{if(!l)return;const ee=e1(l);k(ee),N([]),requestAnimationFrame(()=>A())},[l]),re.useEffect(()=>{!h||h.nonce===0||(k(h.text),requestAnimationFrame(()=>{const ee=H.current;ee&&(ee.focus(),ee.setSelectionRange(ee.value.length,ee.value.length),A())}))},[h==null?void 0:h.nonce]);const W=re.useMemo(()=>{const ee=/^\/(\S*)$/.exec(S);if(!ee||a.length===0)return null;const le=ee[1].toLowerCase(),He=a.map(Ee=>{const we=Ee.name.toLowerCase(),ke=Ee.title.toLowerCase();return le?we.startsWith(le)||ke.startsWith(`/${le}`)?{c:Ee,rank:0}:we.includes(le)||ke.includes(le)?{c:Ee,rank:1}:null:{c:Ee,rank:2}}).filter(Ee=>Ee!==null).sort((Ee,we)=>Ee.rank-we.rank).slice(0,8).map(Ee=>Ee.c);return He.length>0?He:null},[S,a]),G=re.useMemo(()=>{if(!o)return null;const ee=/(?:^|\s)@(\S*)$/.exec(S);if(!ee)return null;const le=ee[1],Ce=le.lastIndexOf("/"),He=Ce>=0?le.slice(0,Ce):"",Ee=Ce>=0?le.slice(Ce+1):le;return{token:`@${le}`,query:le,dir:He,filter:Ee}},[S,o]),K=re.useMemo(()=>{if(!G)return null;const ee=(f||".").replace(/\/+$/,"")||"/";return G.dir?`${ee}/${G.dir}`:ee},[G,f]);re.useEffect(()=>{if(!K||!o||K===L)return;let ee=!1;return o(K).then(le=>{ee||(R(le.error?[]:le.entries),z(K))}).catch(()=>{ee||R([])}),()=>{ee=!0}},[K,L,o]);const ne=re.useMemo(()=>{if(!G||L!==K)return null;const ee=G.filter.toLowerCase(),le=O.filter(Ce=>Ce.name.toLowerCase().includes(ee)).sort((Ce,He)=>Ce.isDirectory!==He.isDirectory?Ce.isDirectory?-1:1:Ce.name.localeCompare(He.name)).slice(0,50);return le.length>0?le:null},[G,O,L,K]),Q=W?{kind:"slash",items:W}:ne?{kind:"mention",items:ne}:null,I=()=>{H.current&&(H.current.style.height="auto")},A=()=>{const ee=H.current;ee&&(ee.style.height="auto",ee.style.height=`${Math.min(ee.scrollHeight,200)}px`)},B=ee=>{k(ee),v(0),l&&t1(l,ee),A()},$=ee=>{var le;ee.argsMode==="none"?(x==null||x(ee.id),B(""),I()):(B(`/${ee.name} `),(le=H.current)==null||le.focus())},P=ee=>{var Ee;if(!G)return;const le=(f||".").replace(/\/+$/,""),Ce=le&&ee.path.startsWith(le)?ee.path.slice(le.length).replace(/^\/+/,""):ee.name,He=S.slice(0,S.length-G.token.length);ee.isDirectory?B(`${He}@${Ce}/`):(B(He),N(we=>we.includes(Ce)?we:[...we,Ce])),(Ee=H.current)==null||Ee.focus()},oe=()=>{if(e)return;const ee=S.trim(),le=/^\/(\S+)\s*(.*)$/s.exec(ee);if(le&&x){const Ee=a.find(we=>we.name.toLowerCase()===le[1].toLowerCase());if(Ee){x(Ee.id,le[2]||void 0),B(""),N([]),I();return}}const He=[M.map(Ee=>`@${Ee}`).join(" "),ee].filter(Boolean).join(" ");!He&&w.length===0||(m(He,w),B(""),_([]),N([]),I())},ye=ee=>{if(Q){const le=Q.items.length;if(ee.key==="ArrowDown"){ee.preventDefault(),v(He=>Math.min(He+1,le-1));return}if(ee.key==="ArrowUp"){ee.preventDefault(),v(He=>Math.max(He-1,0));return}const Ce=()=>{const He=Math.min(b,le-1);Q.kind==="slash"?$(Q.items[He]):P(Q.items[He])};if(ee.key==="Tab"){ee.preventDefault(),Ce();return}if(ee.key==="Enter"&&!ee.metaKey&&!ee.ctrlKey&&!ee.shiftKey&&Q.kind==="mention"){ee.preventDefault(),Ce();return}if(ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)){ee.preventDefault(),Ce();return}if(ee.key==="Escape"){ee.preventDefault(),Q.kind==="slash"?B(""):G&&B(S.slice(0,S.length-G.token.length));return}}if(ee.key==="ArrowUp"&&!Q&&S===""&&u){ee.preventDefault(),B(u),requestAnimationFrame(()=>{const le=H.current;le&&le.setSelectionRange(le.value.length,le.value.length)});return}ee.key==="Enter"&&(ee.metaKey||ee.ctrlKey)&&(ee.preventDefault(),oe())},pe=ee=>{for(const le of ee){if(!le.type.startsWith("image/"))continue;const Ce=new FileReader;Ce.onload=()=>{const He=String(Ce.result);_(Ee=>[...Ee,{data:He,mimeType:le.type||"image/png",name:le.name||"粘贴图片"}])},Ce.readAsDataURL(le)}},J=ee=>{pe(Array.from(ee.target.files??[])),ee.target.value=""},j=ee=>{if(!r)return;const le=Array.from(ee.clipboardData.items).filter(Ce=>Ce.kind==="file"&&Ce.type.startsWith("image/")).map(Ce=>Ce.getAsFile()).filter(Ce=>Ce!=null);le.length>0&&(ee.preventDefault(),pe(le))},me=ee=>{if(T(!1),!r)return;const le=Array.from(ee.dataTransfer.files).filter(Ce=>Ce.type.startsWith("image/"));le.length>0&&(ee.preventDefault(),pe(le))},ce=ee=>{r&&Array.from(ee.dataTransfer.items).some(le=>le.kind==="file")&&(ee.preventDefault(),T(!0))};return C.jsxs("div",{className:"relative",children:[Q&&C.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 mb-2 max-h-72 w-80 overflow-y-auto p-1",children:Q.kind==="slash"?Q.items.map((ee,le)=>C.jsxs("button",{onMouseEnter:()=>v(le),onClick:()=>$(ee),className:`flex w-full cursor-pointer items-center justify-between rounded-lg px-2.5 py-1.5 text-left transition-colors ${le===b?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[C.jsxs("span",{className:"font-mono text-xs text-accent",children:["/",ee.name]}),C.jsx("span",{className:"ml-2 flex-1 truncate text-xs text-content-muted",children:ee.title}),ee.destructive&&C.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-danger",title:"破坏性操作"})]},ee.id)):Q.items.map((ee,le)=>C.jsxs("button",{onMouseEnter:()=>v(le),onClick:()=>P(ee),className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left transition-colors ${le===b?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[ee.isDirectory?C.jsx(Lr,{size:13,className:"shrink-0 text-content-faint"}):C.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-xs text-content-secondary",children:ee.name}),ee.isDirectory&&C.jsx("span",{className:"text-content-faint",children:"/"})]},ee.path))}),w.length>0&&C.jsx("div",{className:"mb-2 flex flex-wrap gap-2",children:w.map((ee,le)=>C.jsxs("div",{className:"group relative",children:[C.jsx("img",{src:ee.data,alt:ee.name,className:"h-14 w-14 rounded-lg border border-border object-cover"}),C.jsx("button",{onClick:()=>_(Ce=>Ce.filter((He,Ee)=>Ee!==le)),className:"absolute -right-1.5 -top-1.5 flex h-4 w-4 cursor-pointer items-center justify-center rounded-full bg-danger text-white","aria-label":"移除图片",children:C.jsx(hi,{size:10})})]},le))}),M.length>0&&C.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:M.map(ee=>C.jsxs("span",{className:"flex items-center gap-1 rounded-lg border border-border bg-surface-overlay py-1 pl-2 pr-1 font-mono text-xs text-content-secondary",children:[C.jsx(na,{size:12,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"max-w-[200px] truncate",title:ee,children:ee}),C.jsx("button",{onClick:()=>N(le=>le.filter(Ce=>Ce!==ee)),className:"flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded text-content-faint transition-colors hover:text-danger","aria-label":`移除 ${ee}`,children:C.jsx(hi,{size:11})})]},ee))}),C.jsxs("div",{onDrop:me,onDragOver:ce,onDragLeave:()=>T(!1),className:`codex-card-raised flex flex-col gap-1 px-3 pt-2.5 pb-2 transition-colors focus-within:border-border-strong ${y?"border-border-strong":""}`,children:[r&&C.jsx("input",{ref:q,type:"file",accept:"image/*",multiple:!0,onChange:J,className:"hidden"}),C.jsx("textarea",{ref:H,value:S,rows:1,disabled:e,placeholder:F?a.length>0?"发送指令,或输入 / 调用命令…":"向 agent 发送指令…":a.length>0?"发送指令,/ 调用命令,@ 引用文件 (⌘/Ctrl+Enter 发送)":"向 agent 发送指令,@ 引用文件 (⌘/Ctrl+Enter 发送,Enter 换行)",onChange:ee=>B(ee.target.value),onKeyDown:ye,onPaste:j,className:"min-w-0 resize-none bg-transparent px-0 py-1 text-base leading-6 text-content-primary placeholder-content-muted outline-none md:text-[15px]"}),C.jsxs("div",{className:"flex items-center gap-1",children:[r&&C.jsx("button",{onClick:()=>{var ee;return(ee=q.current)==null?void 0:ee.click()},disabled:e,className:"flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-full text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary disabled:opacity-40",title:"附加图片","aria-label":"附加图片",children:C.jsx(Ro,{size:17})}),C.jsx("div",{className:"flex min-w-0 flex-1 flex-wrap items-center gap-0.5",children:d}),n&&p?C.jsx("button",{onClick:p,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-surface-overlay text-content-secondary transition-colors hover:bg-surface-raised hover:text-content-primary","aria-label":"停止",title:"停止",children:C.jsx(eb,{size:14})}):C.jsx("button",{onClick:oe,disabled:e||!S.trim()&&w.length===0&&M.length===0,className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-full bg-accent-dim text-white transition-colors hover:bg-accent disabled:cursor-default disabled:bg-surface-overlay disabled:text-content-faint","aria-label":"发送",title:"发送",children:C.jsx(rf,{size:16})})]})]})]})}var _d={exports:{}},$v;function kO(){return $v||($v=1,(function(e,n){(function(r,a){e.exports=a()})(globalThis,(()=>(()=>{var r={4567:function(f,o,h){var d=this&&this.__decorate||function(v,y,T,M){var N,O=arguments.length,R=O<3?y:M===null?M=Object.getOwnPropertyDescriptor(y,T):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(v,y,T,M);else for(var L=v.length-1;L>=0;L--)(N=v[L])&&(R=(O<3?N(R):O>3?N(y,T,R):N(y,T))||R);return O>3&&R&&Object.defineProperty(y,T,R),R},m=this&&this.__param||function(v,y){return function(T,M){y(T,M,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.AccessibilityManager=void 0;const p=h(9042),x=h(9924),S=h(844),k=h(4725),w=h(2585),_=h(3656);let b=o.AccessibilityManager=class extends S.Disposable{constructor(v,y,T,M){super(),this._terminal=v,this._coreBrowserService=T,this._renderService=M,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
85
85
  `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,_.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,S.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let y=0;y<v;y++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
86
86
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=p.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,y){this._liveRegionDebouncer.refresh(v,y,this._terminal.rows)}_renderRows(v,y){const T=this._terminal.buffer,M=T.lines.length.toString();for(let N=v;N<=y;N++){const O=T.lines.get(T.ydisp+N),R=[],L=(O==null?void 0:O.translateToString(!0,void 0,void 0,R))||"",z=(T.ydisp+N+1).toString(),H=this._rowElements[N];H&&(L.length===0?(H.innerText=" ",this._rowColumns.set(H,[0,1])):(H.textContent=L,this._rowColumns.set(H,R)),H.setAttribute("aria-posinset",z),H.setAttribute("aria-setsize",M))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,y){const T=v.target,M=this._rowElements[y===0?1:this._rowElements.length-2];if(T.getAttribute("aria-posinset")===(y===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==M)return;let N,O;if(y===0?(N=T,O=this._rowElements.pop(),this._rowContainer.removeChild(O)):(N=this._rowElements.shift(),O=T,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),O.removeEventListener("focus",this._bottomBoundaryFocusListener),y===0){const R=this._createAccessibilityTreeNode();this._rowElements.unshift(R),this._rowContainer.insertAdjacentElement("afterbegin",R)}else{const R=this._createAccessibilityTreeNode();this._rowElements.push(R),this._rowContainer.appendChild(R)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(y===0?-1:1),this._rowElements[y===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var L;if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let y={node:v.anchorNode,offset:v.anchorOffset},T={node:v.focusNode,offset:v.focusOffset};if((y.node.compareDocumentPosition(T.node)&Node.DOCUMENT_POSITION_PRECEDING||y.node===T.node&&y.offset>T.offset)&&([y,T]=[T,y]),y.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(y={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(y.node))return;const M=this._rowElements.slice(-1)[0];if(T.node.compareDocumentPosition(M)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(T={node:M,offset:((L=M.textContent)==null?void 0:L.length)??0}),!this._rowContainer.contains(T.node))return;const N=({node:z,offset:H})=>{const q=z instanceof Text?z.parentNode:z;let F=parseInt(q==null?void 0:q.getAttribute("aria-posinset"),10)-1;if(isNaN(F))return console.warn("row is invalid. Race condition?"),null;const W=this._rowColumns.get(q);if(!W)return console.warn("columns is null. Race condition?"),null;let G=H<W.length?W[H]:W.slice(-1)[0]+1;return G>=this._terminal.cols&&(++F,G=0),{row:F,column:G}},O=N(y),R=N(T);if(O&&R){if(O.row>R.row||O.row===R.row&&O.column>=R.column)throw new Error("invalid range");this._terminal.select(O.column,O.row,(R.row-O.row)*this._terminal.cols-O.column+R.column)}}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let y=this._rowContainer.children.length;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};o.AccessibilityManager=b=d([m(1,w.IInstantiationService),m(2,k.ICoreBrowserService),m(3,k.IRenderService)],b)},3614:(f,o)=>{function h(x){return x.replace(/\r?\n/g,"\r")}function d(x,S){return S?"\x1B[200~"+x+"\x1B[201~":x}function m(x,S,k,w){x=d(x=h(x),k.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(x,!0),S.value=""}function p(x,S,k){const w=k.getBoundingClientRect(),_=x.clientX-w.left-10,b=x.clientY-w.top-10;S.style.width="20px",S.style.height="20px",S.style.left=`${_}px`,S.style.top=`${b}px`,S.style.zIndex="1000",S.focus()}Object.defineProperty(o,"__esModule",{value:!0}),o.rightClickHandler=o.moveTextAreaUnderMouseCursor=o.paste=o.handlePasteEvent=o.copyHandler=o.bracketTextForPaste=o.prepareTextForTerminal=void 0,o.prepareTextForTerminal=h,o.bracketTextForPaste=d,o.copyHandler=function(x,S){x.clipboardData&&x.clipboardData.setData("text/plain",S.selectionText),x.preventDefault()},o.handlePasteEvent=function(x,S,k,w){x.stopPropagation(),x.clipboardData&&m(x.clipboardData.getData("text/plain"),S,k,w)},o.paste=m,o.moveTextAreaUnderMouseCursor=p,o.rightClickHandler=function(x,S,k,w,_){p(x,S,k),_&&w.rightClickSelect(x),S.value=w.selectionText,S.select()}},7239:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ColorContrastCache=void 0;const d=h(1505);o.ColorContrastCache=class{constructor(){this._color=new d.TwoKeyMap,this._css=new d.TwoKeyMap}setCss(m,p,x){this._css.set(m,p,x)}getCss(m,p){return this._css.get(m,p)}setColor(m,p,x){this._color.set(m,p,x)}getColor(m,p){return this._color.get(m,p)}clear(){this._color.clear(),this._css.clear()}}},3656:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.addDisposableDomListener=void 0,o.addDisposableDomListener=function(h,d,m,p){h.addEventListener(d,m,p);let x=!1;return{dispose:()=>{x||(x=!0,h.removeEventListener(d,m,p))}}}},3551:function(f,o,h){var d=this&&this.__decorate||function(b,v,y,T){var M,N=arguments.length,O=N<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,y):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(b,v,y,T);else for(var R=b.length-1;R>=0;R--)(M=b[R])&&(O=(N<3?M(O):N>3?M(v,y,O):M(v,y))||O);return N>3&&O&&Object.defineProperty(v,y,O),O},m=this&&this.__param||function(b,v){return function(y,T){v(y,T,b)}};Object.defineProperty(o,"__esModule",{value:!0}),o.Linkifier=void 0;const p=h(3656),x=h(8460),S=h(844),k=h(2585),w=h(4725);let _=o.Linkifier=class extends S.Disposable{get currentLink(){return this._currentLink}constructor(b,v,y,T,M){super(),this._element=b,this._mouseService=v,this._renderService=y,this._bufferService=T,this._linkProviderService=M,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,S.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,S.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,p.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,p.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,p.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,p.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(b){this._lastMouseEvent=b;const v=this._positionFromMouseEvent(b,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const y=b.composedPath();for(let T=0;T<y.length;T++){const M=y[T];if(M.classList.contains("xterm"))break;if(M.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(b){if(this._activeLine!==b.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(b,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,b)||(this._clearCurrentLink(),this._askForLink(b,!0))}_askForLink(b,v){var T,M;this._activeProviderReplies&&v||((T=this._activeProviderReplies)==null||T.forEach((N=>{N==null||N.forEach((O=>{O.link.dispose&&O.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=b.y);let y=!1;for(const[N,O]of this._linkProviderService.linkProviders.entries())v?(M=this._activeProviderReplies)!=null&&M.get(N)&&(y=this._checkLinkProviderResult(N,b,y)):O.provideLinks(b.y,(R=>{var z,H;if(this._isMouseOut)return;const L=R==null?void 0:R.map((q=>({link:q})));(z=this._activeProviderReplies)==null||z.set(N,L),y=this._checkLinkProviderResult(N,b,y),((H=this._activeProviderReplies)==null?void 0:H.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(b.y,this._activeProviderReplies)}))}_removeIntersectingLinks(b,v){const y=new Set;for(let T=0;T<v.size;T++){const M=v.get(T);if(M)for(let N=0;N<M.length;N++){const O=M[N],R=O.link.range.start.y<b?0:O.link.range.start.x,L=O.link.range.end.y>b?this._bufferService.cols:O.link.range.end.x;for(let z=R;z<=L;z++){if(y.has(z)){M.splice(N--,1);break}y.add(z)}}}}_checkLinkProviderResult(b,v,y){var N;if(!this._activeProviderReplies)return y;const T=this._activeProviderReplies.get(b);let M=!1;for(let O=0;O<b;O++)this._activeProviderReplies.has(O)&&!this._activeProviderReplies.get(O)||(M=!0);if(!M&&T){const O=T.find((R=>this._linkAtPosition(R.link,v)));O&&(y=!0,this._handleNewLink(O))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!y)for(let O=0;O<this._activeProviderReplies.size;O++){const R=(N=this._activeProviderReplies.get(O))==null?void 0:N.find((L=>this._linkAtPosition(L.link,v)));if(R){y=!0,this._handleNewLink(R);break}}return y}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(b){if(!this._currentLink)return;const v=this._positionFromMouseEvent(b,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(b,this._currentLink.link.text)}_clearCurrentLink(b,v){this._currentLink&&this._lastMouseEvent&&(!b||!v||this._currentLink.link.range.start.y>=b&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,S.disposeArray)(this._linkCacheDisposables))}_handleNewLink(b){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(b.link,v)&&(this._currentLink=b,this._currentLink.state={decorations:{underline:b.link.decorations===void 0||b.link.decorations.underline,pointerCursor:b.link.decorations===void 0||b.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,b.link,this._lastMouseEvent),b.link.decorations={},Object.defineProperties(b.link.decorations,{pointerCursor:{get:()=>{var y,T;return(T=(y=this._currentLink)==null?void 0:y.state)==null?void 0:T.decorations.pointerCursor},set:y=>{var T;(T=this._currentLink)!=null&&T.state&&this._currentLink.state.decorations.pointerCursor!==y&&(this._currentLink.state.decorations.pointerCursor=y,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",y))}},underline:{get:()=>{var y,T;return(T=(y=this._currentLink)==null?void 0:y.state)==null?void 0:T.decorations.underline},set:y=>{var T,M,N;(T=this._currentLink)!=null&&T.state&&((N=(M=this._currentLink)==null?void 0:M.state)==null?void 0:N.decorations.underline)!==y&&(this._currentLink.state.decorations.underline=y,this._currentLink.state.isHovered&&this._fireUnderlineEvent(b.link,y))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((y=>{if(!this._currentLink)return;const T=y.start===0?0:y.start+1+this._bufferService.buffer.ydisp,M=this._bufferService.buffer.ydisp+1+y.end;if(this._currentLink.link.range.start.y>=T&&this._currentLink.link.range.end.y<=M&&(this._clearCurrentLink(T,M),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(b,v,y){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&b.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(y,v.text)}_fireUnderlineEvent(b,v){const y=b.range,T=this._bufferService.buffer.ydisp,M=this._createLinkUnderlineEvent(y.start.x-1,y.start.y-T-1,y.end.x,y.end.y-T-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(M)}_linkLeave(b,v,y){var T;(T=this._currentLink)!=null&&T.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&b.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(y,v.text)}_linkAtPosition(b,v){const y=b.range.start.y*this._bufferService.cols+b.range.start.x,T=b.range.end.y*this._bufferService.cols+b.range.end.x,M=v.y*this._bufferService.cols+v.x;return y<=M&&M<=T}_positionFromMouseEvent(b,v,y){const T=y.getCoords(b,v,this._bufferService.cols,this._bufferService.rows);if(T)return{x:T[0],y:T[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(b,v,y,T,M){return{x1:b,y1:v,x2:y,y2:T,cols:this._bufferService.cols,fg:M}}};o.Linkifier=_=d([m(1,w.IMouseService),m(2,w.IRenderService),m(3,k.IBufferService),m(4,w.ILinkProviderService)],_)},9042:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.tooMuchOutput=o.promptLabel=void 0,o.promptLabel="Terminal input",o.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(f,o,h){var d=this&&this.__decorate||function(w,_,b,v){var y,T=arguments.length,M=T<3?_:v===null?v=Object.getOwnPropertyDescriptor(_,b):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(w,_,b,v);else for(var N=w.length-1;N>=0;N--)(y=w[N])&&(M=(T<3?y(M):T>3?y(_,b,M):y(_,b))||M);return T>3&&M&&Object.defineProperty(_,b,M),M},m=this&&this.__param||function(w,_){return function(b,v){_(b,v,w)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkProvider=void 0;const p=h(511),x=h(2585);let S=o.OscLinkProvider=class{constructor(w,_,b){this._bufferService=w,this._optionsService=_,this._oscLinkService=b}provideLinks(w,_){var L;const b=this._bufferService.buffer.lines.get(w-1);if(!b)return void _(void 0);const v=[],y=this._optionsService.rawOptions.linkHandler,T=new p.CellData,M=b.getTrimmedLength();let N=-1,O=-1,R=!1;for(let z=0;z<M;z++)if(O!==-1||b.hasContent(z)){if(b.loadCell(z,T),T.hasExtendedAttrs()&&T.extended.urlId){if(O===-1){O=z,N=T.extended.urlId;continue}R=T.extended.urlId!==N}else O!==-1&&(R=!0);if(R||O!==-1&&z===M-1){const H=(L=this._oscLinkService.getLinkData(N))==null?void 0:L.uri;if(H){const q={start:{x:O+1,y:w},end:{x:z+(R||z!==M-1?0:1),y:w}};let F=!1;if(!(y!=null&&y.allowNonHttpProtocols))try{const W=new URL(H);["http:","https:"].includes(W.protocol)||(F=!0)}catch{F=!0}F||v.push({text:H,range:q,activate:(W,G)=>y?y.activate(W,G,q):k(0,G),hover:(W,G)=>{var K;return(K=y==null?void 0:y.hover)==null?void 0:K.call(y,W,G,q)},leave:(W,G)=>{var K;return(K=y==null?void 0:y.leave)==null?void 0:K.call(y,W,G,q)}})}R=!1,T.hasExtendedAttrs()&&T.extended.urlId?(O=z,N=T.extended.urlId):(O=-1,N=-1)}}_(v)}};function k(w,_){if(confirm(`Do you want to navigate to ${_}?
87
87
 
@@ -91,4 +91,4 @@ WARNING: This link could potentially be dangerous`)){const b=window.open();if(b)
91
91
  `,p.VT="\v",p.FF="\f",p.CR="\r",p.SO="",p.SI="",p.DLE="",p.DC1="",p.DC2="",p.DC3="",p.DC4="",p.NAK="",p.SYN="",p.ETB="",p.CAN="",p.EM="",p.SUB="",p.ESC="\x1B",p.FS="",p.GS="",p.RS="",p.US="",p.SP=" ",p.DEL=""})(h||(o.C0=h={})),(function(p){p.PAD="€",p.HOP="",p.BPH="‚",p.NBH="ƒ",p.IND="„",p.NEL="…",p.SSA="†",p.ESA="‡",p.HTS="ˆ",p.HTJ="‰",p.VTS="Š",p.PLD="‹",p.PLU="Œ",p.RI="",p.SS2="Ž",p.SS3="",p.DCS="",p.PU1="‘",p.PU2="’",p.STS="“",p.CCH="”",p.MW="•",p.SPA="–",p.EPA="—",p.SOS="˜",p.SGCI="™",p.SCI="š",p.CSI="›",p.ST="œ",p.OSC="",p.PM="ž",p.APC="Ÿ"})(d||(o.C1=d={})),(function(p){p.ST=`${h.ESC}\\`})(m||(o.C1_ESCAPED=m={}))},7399:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.evaluateKeyboardEvent=void 0;const d=h(2584),m={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};o.evaluateKeyboardEvent=function(p,x,S,k){const w={type:0,cancel:!1,key:void 0},_=(p.shiftKey?1:0)|(p.altKey?2:0)|(p.ctrlKey?4:0)|(p.metaKey?8:0);switch(p.keyCode){case 0:p.key==="UIKeyInputUpArrow"?w.key=x?d.C0.ESC+"OA":d.C0.ESC+"[A":p.key==="UIKeyInputLeftArrow"?w.key=x?d.C0.ESC+"OD":d.C0.ESC+"[D":p.key==="UIKeyInputRightArrow"?w.key=x?d.C0.ESC+"OC":d.C0.ESC+"[C":p.key==="UIKeyInputDownArrow"&&(w.key=x?d.C0.ESC+"OB":d.C0.ESC+"[B");break;case 8:w.key=p.ctrlKey?"\b":d.C0.DEL,p.altKey&&(w.key=d.C0.ESC+w.key);break;case 9:if(p.shiftKey){w.key=d.C0.ESC+"[Z";break}w.key=d.C0.HT,w.cancel=!0;break;case 13:w.key=p.altKey?d.C0.ESC+d.C0.CR:d.C0.CR,w.cancel=!0;break;case 27:w.key=d.C0.ESC,p.altKey&&(w.key=d.C0.ESC+d.C0.ESC),w.cancel=!0;break;case 37:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"D",w.key===d.C0.ESC+"[1;3D"&&(w.key=d.C0.ESC+(S?"b":"[1;5D"))):w.key=x?d.C0.ESC+"OD":d.C0.ESC+"[D";break;case 39:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"C",w.key===d.C0.ESC+"[1;3C"&&(w.key=d.C0.ESC+(S?"f":"[1;5C"))):w.key=x?d.C0.ESC+"OC":d.C0.ESC+"[C";break;case 38:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"A",S||w.key!==d.C0.ESC+"[1;3A"||(w.key=d.C0.ESC+"[1;5A")):w.key=x?d.C0.ESC+"OA":d.C0.ESC+"[A";break;case 40:if(p.metaKey)break;_?(w.key=d.C0.ESC+"[1;"+(_+1)+"B",S||w.key!==d.C0.ESC+"[1;3B"||(w.key=d.C0.ESC+"[1;5B")):w.key=x?d.C0.ESC+"OB":d.C0.ESC+"[B";break;case 45:p.shiftKey||p.ctrlKey||(w.key=d.C0.ESC+"[2~");break;case 46:w.key=_?d.C0.ESC+"[3;"+(_+1)+"~":d.C0.ESC+"[3~";break;case 36:w.key=_?d.C0.ESC+"[1;"+(_+1)+"H":x?d.C0.ESC+"OH":d.C0.ESC+"[H";break;case 35:w.key=_?d.C0.ESC+"[1;"+(_+1)+"F":x?d.C0.ESC+"OF":d.C0.ESC+"[F";break;case 33:p.shiftKey?w.type=2:p.ctrlKey?w.key=d.C0.ESC+"[5;"+(_+1)+"~":w.key=d.C0.ESC+"[5~";break;case 34:p.shiftKey?w.type=3:p.ctrlKey?w.key=d.C0.ESC+"[6;"+(_+1)+"~":w.key=d.C0.ESC+"[6~";break;case 112:w.key=_?d.C0.ESC+"[1;"+(_+1)+"P":d.C0.ESC+"OP";break;case 113:w.key=_?d.C0.ESC+"[1;"+(_+1)+"Q":d.C0.ESC+"OQ";break;case 114:w.key=_?d.C0.ESC+"[1;"+(_+1)+"R":d.C0.ESC+"OR";break;case 115:w.key=_?d.C0.ESC+"[1;"+(_+1)+"S":d.C0.ESC+"OS";break;case 116:w.key=_?d.C0.ESC+"[15;"+(_+1)+"~":d.C0.ESC+"[15~";break;case 117:w.key=_?d.C0.ESC+"[17;"+(_+1)+"~":d.C0.ESC+"[17~";break;case 118:w.key=_?d.C0.ESC+"[18;"+(_+1)+"~":d.C0.ESC+"[18~";break;case 119:w.key=_?d.C0.ESC+"[19;"+(_+1)+"~":d.C0.ESC+"[19~";break;case 120:w.key=_?d.C0.ESC+"[20;"+(_+1)+"~":d.C0.ESC+"[20~";break;case 121:w.key=_?d.C0.ESC+"[21;"+(_+1)+"~":d.C0.ESC+"[21~";break;case 122:w.key=_?d.C0.ESC+"[23;"+(_+1)+"~":d.C0.ESC+"[23~";break;case 123:w.key=_?d.C0.ESC+"[24;"+(_+1)+"~":d.C0.ESC+"[24~";break;default:if(!p.ctrlKey||p.shiftKey||p.altKey||p.metaKey)if(S&&!k||!p.altKey||p.metaKey)!S||p.altKey||p.ctrlKey||p.shiftKey||!p.metaKey?p.key&&!p.ctrlKey&&!p.altKey&&!p.metaKey&&p.keyCode>=48&&p.key.length===1?w.key=p.key:p.key&&p.ctrlKey&&(p.key==="_"&&(w.key=d.C0.US),p.key==="@"&&(w.key=d.C0.NUL)):p.keyCode===65&&(w.type=1);else{const b=m[p.keyCode],v=b==null?void 0:b[p.shiftKey?1:0];if(v)w.key=d.C0.ESC+v;else if(p.keyCode>=65&&p.keyCode<=90){const y=p.ctrlKey?p.keyCode-64:p.keyCode+32;let T=String.fromCharCode(y);p.shiftKey&&(T=T.toUpperCase()),w.key=d.C0.ESC+T}else if(p.keyCode===32)w.key=d.C0.ESC+(p.ctrlKey?d.C0.NUL:" ");else if(p.key==="Dead"&&p.code.startsWith("Key")){let y=p.code.slice(3,4);p.shiftKey||(y=y.toLowerCase()),w.key=d.C0.ESC+y,w.cancel=!0}}else p.keyCode>=65&&p.keyCode<=90?w.key=String.fromCharCode(p.keyCode-64):p.keyCode===32?w.key=d.C0.NUL:p.keyCode>=51&&p.keyCode<=55?w.key=String.fromCharCode(p.keyCode-51+27):p.keyCode===56?w.key=d.C0.DEL:p.keyCode===219?w.key=d.C0.ESC:p.keyCode===220?w.key=d.C0.FS:p.keyCode===221&&(w.key=d.C0.GS)}return w}},482:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Utf8ToUtf32=o.StringToUtf32=o.utf32ToString=o.stringFromCodePoint=void 0,o.stringFromCodePoint=function(h){return h>65535?(h-=65536,String.fromCharCode(55296+(h>>10))+String.fromCharCode(h%1024+56320)):String.fromCharCode(h)},o.utf32ToString=function(h,d=0,m=h.length){let p="";for(let x=d;x<m;++x){let S=h[x];S>65535?(S-=65536,p+=String.fromCharCode(55296+(S>>10))+String.fromCharCode(S%1024+56320)):p+=String.fromCharCode(S)}return p},o.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(h,d){const m=h.length;if(!m)return 0;let p=0,x=0;if(this._interim){const S=h.charCodeAt(x++);56320<=S&&S<=57343?d[p++]=1024*(this._interim-55296)+S-56320+65536:(d[p++]=this._interim,d[p++]=S),this._interim=0}for(let S=x;S<m;++S){const k=h.charCodeAt(S);if(55296<=k&&k<=56319){if(++S>=m)return this._interim=k,p;const w=h.charCodeAt(S);56320<=w&&w<=57343?d[p++]=1024*(k-55296)+w-56320+65536:(d[p++]=k,d[p++]=w)}else k!==65279&&(d[p++]=k)}return p}},o.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(h,d){const m=h.length;if(!m)return 0;let p,x,S,k,w=0,_=0,b=0;if(this.interim[0]){let T=!1,M=this.interim[0];M&=(224&M)==192?31:(240&M)==224?15:7;let N,O=0;for(;(N=63&this.interim[++O])&&O<4;)M<<=6,M|=N;const R=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,L=R-O;for(;b<L;){if(b>=m)return 0;if(N=h[b++],(192&N)!=128){b--,T=!0;break}this.interim[O++]=N,M<<=6,M|=63&N}T||(R===2?M<128?b--:d[w++]=M:R===3?M<2048||M>=55296&&M<=57343||M===65279||(d[w++]=M):M<65536||M>1114111||(d[w++]=M)),this.interim.fill(0)}const v=m-4;let y=b;for(;y<m;){for(;!(!(y<v)||128&(p=h[y])||128&(x=h[y+1])||128&(S=h[y+2])||128&(k=h[y+3]));)d[w++]=p,d[w++]=x,d[w++]=S,d[w++]=k,y+=4;if(p=h[y++],p<128)d[w++]=p;else if((224&p)==192){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(_=(31&p)<<6|63&x,_<128){y--;continue}d[w++]=_}else if((240&p)==224){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,w;if(S=h[y++],(192&S)!=128){y--;continue}if(_=(15&p)<<12|(63&x)<<6|63&S,_<2048||_>=55296&&_<=57343||_===65279)continue;d[w++]=_}else if((248&p)==240){if(y>=m)return this.interim[0]=p,w;if(x=h[y++],(192&x)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,w;if(S=h[y++],(192&S)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=x,this.interim[2]=S,w;if(k=h[y++],(192&k)!=128){y--;continue}if(_=(7&p)<<18|(63&x)<<12|(63&S)<<6|63&k,_<65536||_>1114111)continue;d[w++]=_}}return w}}},225:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeV6=void 0;const d=h(1480),m=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],p=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let x;o.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let S=0;S<m.length;++S)x.fill(0,m[S][0],m[S][1]+1)}}wcwidth(S){return S<32?0:S<127?1:S<65536?x[S]:(function(k,w){let _,b=0,v=w.length-1;if(k<w[0][0]||k>w[v][1])return!1;for(;v>=b;)if(_=b+v>>1,k>w[_][1])b=_+1;else{if(!(k<w[_][0]))return!0;v=_-1}return!1})(S,p)?0:S>=131072&&S<=196605||S>=196608&&S<=262141?2:1}charProperties(S,k){let w=this.wcwidth(S),_=w===0&&k!==0;if(_){const b=d.UnicodeService.extractWidth(k);b===0?_=!1:b>w&&(w=b)}return d.UnicodeService.createPropertyValue(0,w,_)}}},5981:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.WriteBuffer=void 0;const d=h(8460),m=h(844);class p extends m.Disposable{constructor(S){super(),this._action=S,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new d.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(S,k){if(k!==void 0&&this._syncCalls>k)return void(this._syncCalls=0);if(this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const _=this._callbacks.shift();_&&_()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(S,k){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(k),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=S.length,this._writeBuffer.push(S),this._callbacks.push(k)}_innerWrite(S=0,k=!0){const w=S||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const _=this._writeBuffer[this._bufferOffset],b=this._action(_,k);if(b){const y=T=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,T))):this._innerWrite(w,T);return void b.catch((T=>(queueMicrotask((()=>{throw T})),Promise.resolve(!1)))).then(y)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=_.length,Date.now()-w>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}o.WriteBuffer=p},5941:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.toRgbString=o.parseColor=void 0;const h=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,d=/^[\da-f]+$/;function m(p,x){const S=p.toString(16),k=S.length<2?"0"+S:S;switch(x){case 4:return S[0];case 8:return k;case 12:return(k+k).slice(0,3);default:return k+k}}o.parseColor=function(p){if(!p)return;let x=p.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const S=h.exec(x);if(S){const k=S[1]?15:S[4]?255:S[7]?4095:65535;return[Math.round(parseInt(S[1]||S[4]||S[7]||S[10],16)/k*255),Math.round(parseInt(S[2]||S[5]||S[8]||S[11],16)/k*255),Math.round(parseInt(S[3]||S[6]||S[9]||S[12],16)/k*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),d.exec(x)&&[3,6,9,12].includes(x.length))){const S=x.length/3,k=[0,0,0];for(let w=0;w<3;++w){const _=parseInt(x.slice(S*w,S*w+S),16);k[w]=S===1?_<<4:S===2?_:S===3?_>>4:_>>8}return k}},o.toRgbString=function(p,x=16){const[S,k,w]=p;return`rgb:${m(S,x)}/${m(k,x)}/${m(w,x)}`}},5770:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.PAYLOAD_LIMIT=void 0,o.PAYLOAD_LIMIT=1e7},6351:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DcsHandler=o.DcsParser=void 0;const d=h(482),m=h(8742),p=h(5770),x=[];o.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(k,w){this._handlers[k]===void 0&&(this._handlers[k]=[]);const _=this._handlers[k];return _.push(w),{dispose:()=>{const b=_.indexOf(w);b!==-1&&_.splice(b,1)}}}clearHandler(k){this._handlers[k]&&delete this._handlers[k]}setHandlerFallback(k){this._handlerFb=k}reset(){if(this._active.length)for(let k=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;k>=0;--k)this._active[k].unhook(!1);this._stack.paused=!1,this._active=x,this._ident=0}hook(k,w){if(this.reset(),this._ident=k,this._active=this._handlers[k]||x,this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(k,w,_){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(k,w,_);else this._handlerFb(this._ident,"PUT",(0,d.utf32ToString)(k,w,_))}unhook(k,w=!0){if(this._active.length){let _=!1,b=this._active.length-1,v=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,_=w,v=this._stack.fallThrough,this._stack.paused=!1),!v&&_===!1){for(;b>=0&&(_=this._active[b].unhook(k),_!==!0);b--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,_;b--}for(;b>=0;b--)if(_=this._active[b].unhook(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,_}else this._handlerFb(this._ident,"UNHOOK",k);this._active=x,this._ident=0}};const S=new m.Params;S.addParam(0),o.DcsHandler=class{constructor(k){this._handler=k,this._data="",this._params=S,this._hitLimit=!1}hook(k){this._params=k.length>1||k.params[0]?k.clone():S,this._data="",this._hitLimit=!1}put(k,w,_){this._hitLimit||(this._data+=(0,d.utf32ToString)(k,w,_),this._data.length>p.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(k){let w=!1;if(this._hitLimit)w=!1;else if(k&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((_=>(this._params=S,this._data="",this._hitLimit=!1,_)));return this._params=S,this._data="",this._hitLimit=!1,w}}},2015:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.EscapeSequenceParser=o.VT500_TRANSITION_TABLE=o.TransitionTable=void 0;const d=h(844),m=h(8742),p=h(6242),x=h(6351);class S{constructor(b){this.table=new Uint8Array(b)}setDefault(b,v){this.table.fill(b<<4|v)}add(b,v,y,T){this.table[v<<8|b]=y<<4|T}addMany(b,v,y,T){for(let M=0;M<b.length;M++)this.table[v<<8|b[M]]=y<<4|T}}o.TransitionTable=S;const k=160;o.VT500_TRANSITION_TABLE=(function(){const _=new S(4095),b=Array.apply(null,Array(256)).map(((O,R)=>R)),v=(O,R)=>b.slice(O,R),y=v(32,127),T=v(0,24);T.push(25),T.push.apply(T,v(28,32));const M=v(0,14);let N;for(N in _.setDefault(1,0),_.addMany(y,0,2,0),M)_.addMany([24,26,153,154],N,3,0),_.addMany(v(128,144),N,3,0),_.addMany(v(144,152),N,3,0),_.add(156,N,0,0),_.add(27,N,11,1),_.add(157,N,4,8),_.addMany([152,158,159],N,0,7),_.add(155,N,11,3),_.add(144,N,11,9);return _.addMany(T,0,3,0),_.addMany(T,1,3,1),_.add(127,1,0,1),_.addMany(T,8,0,8),_.addMany(T,3,3,3),_.add(127,3,0,3),_.addMany(T,4,3,4),_.add(127,4,0,4),_.addMany(T,6,3,6),_.addMany(T,5,3,5),_.add(127,5,0,5),_.addMany(T,2,3,2),_.add(127,2,0,2),_.add(93,1,4,8),_.addMany(y,8,5,8),_.add(127,8,5,8),_.addMany([156,27,24,26,7],8,6,0),_.addMany(v(28,32),8,0,8),_.addMany([88,94,95],1,0,7),_.addMany(y,7,0,7),_.addMany(T,7,0,7),_.add(156,7,0,0),_.add(127,7,0,7),_.add(91,1,11,3),_.addMany(v(64,127),3,7,0),_.addMany(v(48,60),3,8,4),_.addMany([60,61,62,63],3,9,4),_.addMany(v(48,60),4,8,4),_.addMany(v(64,127),4,7,0),_.addMany([60,61,62,63],4,0,6),_.addMany(v(32,64),6,0,6),_.add(127,6,0,6),_.addMany(v(64,127),6,0,0),_.addMany(v(32,48),3,9,5),_.addMany(v(32,48),5,9,5),_.addMany(v(48,64),5,0,6),_.addMany(v(64,127),5,7,0),_.addMany(v(32,48),4,9,5),_.addMany(v(32,48),1,9,2),_.addMany(v(32,48),2,9,2),_.addMany(v(48,127),2,10,0),_.addMany(v(48,80),1,10,0),_.addMany(v(81,88),1,10,0),_.addMany([89,90,92],1,10,0),_.addMany(v(96,127),1,10,0),_.add(80,1,11,9),_.addMany(T,9,0,9),_.add(127,9,0,9),_.addMany(v(28,32),9,0,9),_.addMany(v(32,48),9,9,12),_.addMany(v(48,60),9,8,10),_.addMany([60,61,62,63],9,9,10),_.addMany(T,11,0,11),_.addMany(v(32,128),11,0,11),_.addMany(v(28,32),11,0,11),_.addMany(T,10,0,10),_.add(127,10,0,10),_.addMany(v(28,32),10,0,10),_.addMany(v(48,60),10,8,10),_.addMany([60,61,62,63],10,0,11),_.addMany(v(32,48),10,9,12),_.addMany(T,12,0,12),_.add(127,12,0,12),_.addMany(v(28,32),12,0,12),_.addMany(v(32,48),12,9,12),_.addMany(v(48,64),12,0,11),_.addMany(v(64,127),12,12,13),_.addMany(v(64,127),10,12,13),_.addMany(v(64,127),9,12,13),_.addMany(T,13,13,13),_.addMany(y,13,13,13),_.add(127,13,0,13),_.addMany([27,156,24,26],13,14,0),_.add(k,0,2,0),_.add(k,8,5,8),_.add(k,6,0,6),_.add(k,11,0,11),_.add(k,13,13,13),_})();class w extends d.Disposable{constructor(b=o.VT500_TRANSITION_TABLE){super(),this._transitions=b,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,y,T)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,y)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,d.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new p.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(b,v=[64,126]){let y=0;if(b.prefix){if(b.prefix.length>1)throw new Error("only one byte as prefix supported");if(y=b.prefix.charCodeAt(0),y&&60>y||y>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(b.intermediates){if(b.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let M=0;M<b.intermediates.length;++M){const N=b.intermediates.charCodeAt(M);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");y<<=8,y|=N}}if(b.final.length!==1)throw new Error("final must be a single byte");const T=b.final.charCodeAt(0);if(v[0]>T||T>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return y<<=8,y|=T,y}identToString(b){const v=[];for(;b;)v.push(String.fromCharCode(255&b)),b>>=8;return v.reverse().join("")}setPrintHandler(b){this._printHandler=b}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(b,v){const y=this._identifier(b,[48,126]);this._escHandlers[y]===void 0&&(this._escHandlers[y]=[]);const T=this._escHandlers[y];return T.push(v),{dispose:()=>{const M=T.indexOf(v);M!==-1&&T.splice(M,1)}}}clearEscHandler(b){this._escHandlers[this._identifier(b,[48,126])]&&delete this._escHandlers[this._identifier(b,[48,126])]}setEscHandlerFallback(b){this._escHandlerFb=b}setExecuteHandler(b,v){this._executeHandlers[b.charCodeAt(0)]=v}clearExecuteHandler(b){this._executeHandlers[b.charCodeAt(0)]&&delete this._executeHandlers[b.charCodeAt(0)]}setExecuteHandlerFallback(b){this._executeHandlerFb=b}registerCsiHandler(b,v){const y=this._identifier(b);this._csiHandlers[y]===void 0&&(this._csiHandlers[y]=[]);const T=this._csiHandlers[y];return T.push(v),{dispose:()=>{const M=T.indexOf(v);M!==-1&&T.splice(M,1)}}}clearCsiHandler(b){this._csiHandlers[this._identifier(b)]&&delete this._csiHandlers[this._identifier(b)]}setCsiHandlerFallback(b){this._csiHandlerFb=b}registerDcsHandler(b,v){return this._dcsParser.registerHandler(this._identifier(b),v)}clearDcsHandler(b){this._dcsParser.clearHandler(this._identifier(b))}setDcsHandlerFallback(b){this._dcsParser.setHandlerFallback(b)}registerOscHandler(b,v){return this._oscParser.registerHandler(b,v)}clearOscHandler(b){this._oscParser.clearHandler(b)}setOscHandlerFallback(b){this._oscParser.setHandlerFallback(b)}setErrorHandler(b){this._errorHandler=b}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(b,v,y,T,M){this._parseStack.state=b,this._parseStack.handlers=v,this._parseStack.handlerPos=y,this._parseStack.transition=T,this._parseStack.chunkPos=M}parse(b,v,y){let T,M=0,N=0,O=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,O=this._parseStack.chunkPos+1;else{if(y===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const R=this._parseStack.handlers;let L=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(y===!1&&L>-1){for(;L>=0&&(T=R[L](this._params),T!==!0);L--)if(T instanceof Promise)return this._parseStack.handlerPos=L,T}this._parseStack.handlers=[];break;case 4:if(y===!1&&L>-1){for(;L>=0&&(T=R[L](),T!==!0);L--)if(T instanceof Promise)return this._parseStack.handlerPos=L,T}this._parseStack.handlers=[];break;case 6:if(M=b[this._parseStack.chunkPos],T=this._dcsParser.unhook(M!==24&&M!==26,y),T)return T;M===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(M=b[this._parseStack.chunkPos],T=this._oscParser.end(M!==24&&M!==26,y),T)return T;M===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,O=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let R=O;R<v;++R){switch(M=b[R],N=this._transitions.table[this.currentState<<8|(M<160?M:k)],N>>4){case 2:for(let F=R+1;;++F){if(F>=v||(M=b[F])<32||M>126&&M<k){this._printHandler(b,R,F),R=F-1;break}if(++F>=v||(M=b[F])<32||M>126&&M<k){this._printHandler(b,R,F),R=F-1;break}if(++F>=v||(M=b[F])<32||M>126&&M<k){this._printHandler(b,R,F),R=F-1;break}if(++F>=v||(M=b[F])<32||M>126&&M<k){this._printHandler(b,R,F),R=F-1;break}}break;case 3:this._executeHandlers[M]?this._executeHandlers[M]():this._executeHandlerFb(M),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:R,code:M,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const L=this._csiHandlers[this._collect<<8|M];let z=L?L.length-1:-1;for(;z>=0&&(T=L[z](this._params),T!==!0);z--)if(T instanceof Promise)return this._preserveStack(3,L,z,N,R),T;z<0&&this._csiHandlerFb(this._collect<<8|M,this._params),this.precedingJoinState=0;break;case 8:do switch(M){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(M-48)}while(++R<v&&(M=b[R])>47&&M<60);R--;break;case 9:this._collect<<=8,this._collect|=M;break;case 10:const H=this._escHandlers[this._collect<<8|M];let q=H?H.length-1:-1;for(;q>=0&&(T=H[q](),T!==!0);q--)if(T instanceof Promise)return this._preserveStack(4,H,q,N,R),T;q<0&&this._escHandlerFb(this._collect<<8|M),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|M,this._params);break;case 13:for(let F=R+1;;++F)if(F>=v||(M=b[F])===24||M===26||M===27||M>127&&M<k){this._dcsParser.put(b,R,F),R=F-1;break}break;case 14:if(T=this._dcsParser.unhook(M!==24&&M!==26),T)return this._preserveStack(6,[],0,N,R),T;M===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let F=R+1;;F++)if(F>=v||(M=b[F])<32||M>127&&M<k){this._oscParser.put(b,R,F),R=F-1;break}break;case 6:if(T=this._oscParser.end(M!==24&&M!==26),T)return this._preserveStack(5,[],0,N,R),T;M===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}o.EscapeSequenceParser=w},6242:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OscHandler=o.OscParser=void 0;const d=h(5770),m=h(482),p=[];o.OscParser=class{constructor(){this._state=0,this._active=p,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,S){this._handlers[x]===void 0&&(this._handlers[x]=[]);const k=this._handlers[x];return k.push(S),{dispose:()=>{const w=k.indexOf(S);w!==-1&&k.splice(w,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=p,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||p,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,S,k){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(x,S,k);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(x,S,k))}start(){this.reset(),this._state=1}put(x,S,k){if(this._state!==3){if(this._state===1)for(;S<k;){const w=x[S++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&k-S>0&&this._put(x,S,k)}}end(x,S=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let k=!1,w=this._active.length-1,_=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,k=S,_=this._stack.fallThrough,this._stack.paused=!1),!_&&k===!1){for(;w>=0&&(k=this._active[w].end(x),k!==!0);w--)if(k instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,k;w--}for(;w>=0;w--)if(k=this._active[w].end(!1),k instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,k}else this._handlerFb(this._id,"END",x);this._active=p,this._id=-1,this._state=0}}},o.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,S,k){this._hitLimit||(this._data+=(0,m.utf32ToString)(x,S,k),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let S=!1;if(this._hitLimit)S=!1;else if(x&&(S=this._handler(this._data),S instanceof Promise))return S.then((k=>(this._data="",this._hitLimit=!1,k)));return this._data="",this._hitLimit=!1,S}}},8742:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.Params=void 0;const h=2147483647;class d{static fromArray(p){const x=new d;if(!p.length)return x;for(let S=Array.isArray(p[0])?1:0;S<p.length;++S){const k=p[S];if(Array.isArray(k))for(let w=0;w<k.length;++w)x.addSubParam(k[w]);else x.addParam(k)}return x}constructor(p=32,x=32){if(this.maxLength=p,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(p),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(p),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const p=new d(this.maxLength,this.maxSubParamsLength);return p.params.set(this.params),p.length=this.length,p._subParams.set(this._subParams),p._subParamsLength=this._subParamsLength,p._subParamsIdx.set(this._subParamsIdx),p._rejectDigits=this._rejectDigits,p._rejectSubDigits=this._rejectSubDigits,p._digitIsSub=this._digitIsSub,p}toArray(){const p=[];for(let x=0;x<this.length;++x){p.push(this.params[x]);const S=this._subParamsIdx[x]>>8,k=255&this._subParamsIdx[x];k-S>0&&p.push(Array.prototype.slice.call(this._subParams,S,k))}return p}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(p){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=p>h?h:p}}addSubParam(p){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=p>h?h:p,this._subParamsIdx[this.length-1]++}}hasSubParams(p){return(255&this._subParamsIdx[p])-(this._subParamsIdx[p]>>8)>0}getSubParams(p){const x=this._subParamsIdx[p]>>8,S=255&this._subParamsIdx[p];return S-x>0?this._subParams.subarray(x,S):null}getSubParamsAll(){const p={};for(let x=0;x<this.length;++x){const S=this._subParamsIdx[x]>>8,k=255&this._subParamsIdx[x];k-S>0&&(p[x]=this._subParams.slice(S,k))}return p}addDigit(p){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const S=this._digitIsSub?this._subParams:this.params,k=S[x-1];S[x-1]=~k?Math.min(10*k+p,h):p}}o.Params=d},5741:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.AddonManager=void 0,o.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let h=this._addons.length-1;h>=0;h--)this._addons[h].instance.dispose()}loadAddon(h,d){const m={instance:d,dispose:d.dispose,isDisposed:!1};this._addons.push(m),d.dispose=()=>this._wrappedAddonDispose(m),d.activate(h)}_wrappedAddonDispose(h){if(h.isDisposed)return;let d=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===h){d=m;break}if(d===-1)throw new Error("Could not dispose an addon that has not been loaded");h.isDisposed=!0,h.dispose.apply(h.instance),this._addons.splice(d,1)}}},8771:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferApiView=void 0;const d=h(3785),m=h(511);o.BufferApiView=class{constructor(p,x){this._buffer=p,this.type=x}init(p){return this._buffer=p,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(p){const x=this._buffer.lines.get(p);if(x)return new d.BufferLineApiView(x)}getNullCell(){return new m.CellData}}},3785:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferLineApiView=void 0;const d=h(511);o.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,p){if(!(m<0||m>=this._line.length))return p?(this._line.loadCell(m,p),p):this._line.loadCell(m,new d.CellData)}translateToString(m,p,x){return this._line.translateToString(m,p,x)}}},8285:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.BufferNamespaceApi=void 0;const d=h(8771),m=h(8460),p=h(844);class x extends p.Disposable{constructor(k){super(),this._core=k,this._onBufferChange=this.register(new m.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new d.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new d.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}o.BufferNamespaceApi=x},7975:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.ParserApi=void 0,o.ParserApi=class{constructor(h){this._core=h}registerCsiHandler(h,d){return this._core.registerCsiHandler(h,(m=>d(m.toArray())))}addCsiHandler(h,d){return this.registerCsiHandler(h,d)}registerDcsHandler(h,d){return this._core.registerDcsHandler(h,((m,p)=>d(m,p.toArray())))}addDcsHandler(h,d){return this.registerDcsHandler(h,d)}registerEscHandler(h,d){return this._core.registerEscHandler(h,d)}addEscHandler(h,d){return this.registerEscHandler(h,d)}registerOscHandler(h,d){return this._core.registerOscHandler(h,d)}addOscHandler(h,d){return this.registerOscHandler(h,d)}}},7090:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeApi=void 0,o.UnicodeApi=class{constructor(h){this._core=h}register(h){this._core.unicodeService.register(h)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(h){this._core.unicodeService.activeVersion=h}}},744:function(f,o,h){var d=this&&this.__decorate||function(_,b,v,y){var T,M=arguments.length,N=M<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,v):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,b,v,y);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(N=(M<3?T(N):M>3?T(b,v,N):T(b,v))||N);return M>3&&N&&Object.defineProperty(b,v,N),N},m=this&&this.__param||function(_,b){return function(v,y){b(v,y,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.BufferService=o.MINIMUM_ROWS=o.MINIMUM_COLS=void 0;const p=h(8460),x=h(844),S=h(5295),k=h(2585);o.MINIMUM_COLS=2,o.MINIMUM_ROWS=1;let w=o.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(_){super(),this.isUserScrolling=!1,this._onResize=this.register(new p.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new p.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(_.rawOptions.cols||0,o.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,o.MINIMUM_ROWS),this.buffers=this.register(new S.BufferSet(_,this))}resize(_,b){this.cols=_,this.rows=b,this.buffers.resize(_,b),this._onResize.fire({cols:_,rows:b})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(_,b=!1){const v=this.buffer;let y;y=this._cachedBlankLine,y&&y.length===this.cols&&y.getFg(0)===_.fg&&y.getBg(0)===_.bg||(y=v.getBlankLine(_,b),this._cachedBlankLine=y),y.isWrapped=b;const T=v.ybase+v.scrollTop,M=v.ybase+v.scrollBottom;if(v.scrollTop===0){const N=v.lines.isFull;M===v.lines.length-1?N?v.lines.recycle().copyFrom(y):v.lines.push(y.clone()):v.lines.splice(M+1,0,y.clone()),N?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const N=M-T+1;v.lines.shiftElements(T+1,N-1,-1),v.lines.set(M,y.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(_,b,v){const y=this.buffer;if(_<0){if(y.ydisp===0)return;this.isUserScrolling=!0}else _+y.ydisp>=y.ybase&&(this.isUserScrolling=!1);const T=y.ydisp;y.ydisp=Math.max(Math.min(y.ydisp+_,y.ybase),0),T!==y.ydisp&&(b||this._onScroll.fire(y.ydisp))}};o.BufferService=w=d([m(0,k.IOptionsService)],w)},7994:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.CharsetService=void 0,o.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(h){this.glevel=h,this.charset=this._charsets[h]}setgCharset(h,d){this._charsets[h]=d,this.glevel===h&&(this.charset=d)}}},1753:function(f,o,h){var d=this&&this.__decorate||function(y,T,M,N){var O,R=arguments.length,L=R<3?T:N===null?N=Object.getOwnPropertyDescriptor(T,M):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(y,T,M,N);else for(var z=y.length-1;z>=0;z--)(O=y[z])&&(L=(R<3?O(L):R>3?O(T,M,L):O(T,M))||L);return R>3&&L&&Object.defineProperty(T,M,L),L},m=this&&this.__param||function(y,T){return function(M,N){T(M,N,y)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreMouseService=void 0;const p=h(2585),x=h(8460),S=h(844),k={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:y=>y.button!==4&&y.action===1&&(y.ctrl=!1,y.alt=!1,y.shift=!1,!0)},VT200:{events:19,restrict:y=>y.action!==32},DRAG:{events:23,restrict:y=>y.action!==32||y.button!==3},ANY:{events:31,restrict:y=>!0}};function w(y,T){let M=(y.ctrl?16:0)|(y.shift?4:0)|(y.alt?8:0);return y.button===4?(M|=64,M|=y.action):(M|=3&y.button,4&y.button&&(M|=64),8&y.button&&(M|=128),y.action===32?M|=32:y.action!==0||T||(M|=3)),M}const _=String.fromCharCode,b={DEFAULT:y=>{const T=[w(y,!1)+32,y.col+32,y.row+32];return T[0]>255||T[1]>255||T[2]>255?"":`\x1B[M${_(T[0])}${_(T[1])}${_(T[2])}`},SGR:y=>{const T=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${w(y,!0)};${y.col};${y.row}${T}`},SGR_PIXELS:y=>{const T=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${w(y,!0)};${y.x};${y.y}${T}`}};let v=o.CoreMouseService=class extends S.Disposable{constructor(y,T){super(),this._bufferService=y,this._coreService=T,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const M of Object.keys(k))this.addProtocol(M,k[M]);for(const M of Object.keys(b))this.addEncoding(M,b[M]);this.reset()}addProtocol(y,T){this._protocols[y]=T}addEncoding(y,T){this._encodings[y]=T}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(y){if(!this._protocols[y])throw new Error(`unknown protocol "${y}"`);this._activeProtocol=y,this._onProtocolChange.fire(this._protocols[y].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(y){if(!this._encodings[y])throw new Error(`unknown encoding "${y}"`);this._activeEncoding=y}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(y){if(y.col<0||y.col>=this._bufferService.cols||y.row<0||y.row>=this._bufferService.rows||y.button===4&&y.action===32||y.button===3&&y.action!==32||y.button!==4&&(y.action===2||y.action===3)||(y.col++,y.row++,y.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,y,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(y))return!1;const T=this._encodings[this._activeEncoding](y);return T&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(T):this._coreService.triggerDataEvent(T,!0)),this._lastEvent=y,!0}explainEvents(y){return{down:!!(1&y),up:!!(2&y),drag:!!(4&y),move:!!(8&y),wheel:!!(16&y)}}_equalEvents(y,T,M){if(M){if(y.x!==T.x||y.y!==T.y)return!1}else if(y.col!==T.col||y.row!==T.row)return!1;return y.button===T.button&&y.action===T.action&&y.ctrl===T.ctrl&&y.alt===T.alt&&y.shift===T.shift}};o.CoreMouseService=v=d([m(0,p.IBufferService),m(1,p.ICoreService)],v)},6975:function(f,o,h){var d=this&&this.__decorate||function(v,y,T,M){var N,O=arguments.length,R=O<3?y:M===null?M=Object.getOwnPropertyDescriptor(y,T):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(v,y,T,M);else for(var L=v.length-1;L>=0;L--)(N=v[L])&&(R=(O<3?N(R):O>3?N(y,T,R):N(y,T))||R);return O>3&&R&&Object.defineProperty(y,T,R),R},m=this&&this.__param||function(v,y){return function(T,M){y(T,M,v)}};Object.defineProperty(o,"__esModule",{value:!0}),o.CoreService=void 0;const p=h(1439),x=h(8460),S=h(844),k=h(2585),w=Object.freeze({insertMode:!1}),_=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let b=o.CoreService=class extends S.Disposable{constructor(v,y,T){super(),this._bufferService=v,this._logService=y,this._optionsService=T,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,p.clone)(w),this.decPrivateModes=(0,p.clone)(_)}reset(){this.modes=(0,p.clone)(w),this.decPrivateModes=(0,p.clone)(_)}triggerDataEvent(v,y=!1){if(this._optionsService.rawOptions.disableStdin)return;const T=this._bufferService.buffer;y&&this._optionsService.rawOptions.scrollOnUserInput&&T.ybase!==T.ydisp&&this._onRequestScrollToBottom.fire(),y&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((M=>M.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((y=>y.charCodeAt(0))))),this._onBinary.fire(v))}};o.CoreService=b=d([m(0,k.IBufferService),m(1,k.ILogService),m(2,k.IOptionsService)],b)},9074:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.DecorationService=void 0;const d=h(8055),m=h(8460),p=h(844),x=h(6106);let S=0,k=0;class w extends p.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((v=>v==null?void 0:v.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,p.toDisposable)((()=>this.reset())))}registerDecoration(v){if(v.marker.isDisposed)return;const y=new _(v);if(y){const T=y.marker.onDispose((()=>y.dispose()));y.onDispose((()=>{y&&(this._decorations.delete(y)&&this._onDecorationRemoved.fire(y),T.dispose())})),this._decorations.insert(y),this._onDecorationRegistered.fire(y)}return y}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,y,T){let M=0,N=0;for(const O of this._decorations.getKeyIterator(y))M=O.options.x??0,N=M+(O.options.width??1),v>=M&&v<N&&(!T||(O.options.layer??"bottom")===T)&&(yield O)}forEachDecorationAtCell(v,y,T,M){this._decorations.forEachByKey(y,(N=>{S=N.options.x??0,k=S+(N.options.width??1),v>=S&&v<k&&(!T||(N.options.layer??"bottom")===T)&&M(N)}))}}o.DecorationService=w;class _ extends p.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=d.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=d.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=v.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.InstantiationService=o.ServiceCollection=void 0;const d=h(2585),m=h(8343);class p{constructor(...S){this._entries=new Map;for(const[k,w]of S)this.set(k,w)}set(S,k){const w=this._entries.get(S);return this._entries.set(S,k),w}forEach(S){for(const[k,w]of this._entries.entries())S(k,w)}has(S){return this._entries.has(S)}get(S){return this._entries.get(S)}}o.ServiceCollection=p,o.InstantiationService=class{constructor(){this._services=new p,this._services.set(d.IInstantiationService,this)}setService(x,S){this._services.set(x,S)}getService(x){return this._services.get(x)}createInstance(x,...S){const k=(0,m.getServiceDependencies)(x).sort(((b,v)=>b.index-v.index)),w=[];for(const b of k){const v=this._services.get(b.id);if(!v)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${b.id}.`);w.push(v)}const _=k.length>0?k[0].index:S.length;if(S.length!==_)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${_+1} conflicts with ${S.length} static arguments`);return new x(...S,...w)}}},7866:function(f,o,h){var d=this&&this.__decorate||function(_,b,v,y){var T,M=arguments.length,N=M<3?b:y===null?y=Object.getOwnPropertyDescriptor(b,v):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,b,v,y);else for(var O=_.length-1;O>=0;O--)(T=_[O])&&(N=(M<3?T(N):M>3?T(b,v,N):T(b,v))||N);return M>3&&N&&Object.defineProperty(b,v,N),N},m=this&&this.__param||function(_,b){return function(v,y){b(v,y,_)}};Object.defineProperty(o,"__esModule",{value:!0}),o.traceCall=o.setTraceLogger=o.LogService=void 0;const p=h(844),x=h(2585),S={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let k,w=o.LogService=class extends p.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),k=this}_updateLogLevel(){this._logLevel=S[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){for(let b=0;b<_.length;b++)typeof _[b]=="function"&&(_[b]=_[b]())}_log(_,b,v){this._evalLazyOptionalParams(v),_.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+b,...v)}trace(_,...b){var v;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.trace.bind(this._optionsService.options.logger))??console.log,_,b)}debug(_,...b){var v;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.debug.bind(this._optionsService.options.logger))??console.log,_,b)}info(_,...b){var v;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.info.bind(this._optionsService.options.logger))??console.info,_,b)}warn(_,...b){var v;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.warn.bind(this._optionsService.options.logger))??console.warn,_,b)}error(_,...b){var v;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,_,b)}};o.LogService=w=d([m(0,x.IOptionsService)],w),o.setTraceLogger=function(_){k=_},o.traceCall=function(_,b,v){if(typeof v.value!="function")throw new Error("not supported");const y=v.value;v.value=function(...T){if(k.logLevel!==x.LogLevelEnum.TRACE)return y.apply(this,T);k.trace(`GlyphRenderer#${y.name}(${T.map((N=>JSON.stringify(N))).join(", ")})`);const M=y.apply(this,T);return k.trace(`GlyphRenderer#${y.name} return`,M),M}}},7302:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.OptionsService=o.DEFAULT_OPTIONS=void 0;const d=h(8460),m=h(844),p=h(6114);o.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:p.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class S extends m.Disposable{constructor(w){super(),this._onOptionChange=this.register(new d.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...o.DEFAULT_OPTIONS};for(const b in w)if(b in _)try{const v=w[b];_[b]=this._sanitizeAndValidateOption(b,v)}catch(v){console.error(v)}this.rawOptions=_,this.options={..._},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(w,_){return this.onOptionChange((b=>{b===w&&_(this.rawOptions[w])}))}onMultipleOptionChange(w,_){return this.onOptionChange((b=>{w.indexOf(b)!==-1&&_()}))}_setupOptions(){const w=b=>{if(!(b in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${b}"`);return this.rawOptions[b]},_=(b,v)=>{if(!(b in o.DEFAULT_OPTIONS))throw new Error(`No option with key "${b}"`);v=this._sanitizeAndValidateOption(b,v),this.rawOptions[b]!==v&&(this.rawOptions[b]=v,this._onOptionChange.fire(b))};for(const b in this.rawOptions){const v={get:w.bind(this,b),set:_.bind(this,b)};Object.defineProperty(this.options,b,v)}}_sanitizeAndValidateOption(w,_){switch(w){case"cursorStyle":if(_||(_=o.DEFAULT_OPTIONS[w]),!(function(b){return b==="block"||b==="underline"||b==="bar"})(_))throw new Error(`"${_}" is not a valid value for ${w}`);break;case"wordSeparator":_||(_=o.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=x.includes(_)?_:o.DEFAULT_OPTIONS[w];break;case"cursorWidth":_=Math.floor(_);case"lineHeight":case"tabStopWidth":if(_<1)throw new Error(`${w} cannot be less than 1, value: ${_}`);break;case"minimumContrastRatio":_=Math.max(1,Math.min(21,Math.round(10*_)/10));break;case"scrollback":if((_=Math.min(_,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${_}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(_<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${_}`);break;case"rows":case"cols":if(!_&&_!==0)throw new Error(`${w} must be numeric, value: ${_}`);break;case"windowsPty":_=_??{}}return _}}o.OptionsService=S},2660:function(f,o,h){var d=this&&this.__decorate||function(S,k,w,_){var b,v=arguments.length,y=v<3?k:_===null?_=Object.getOwnPropertyDescriptor(k,w):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(S,k,w,_);else for(var T=S.length-1;T>=0;T--)(b=S[T])&&(y=(v<3?b(y):v>3?b(k,w,y):b(k,w))||y);return v>3&&y&&Object.defineProperty(k,w,y),y},m=this&&this.__param||function(S,k){return function(w,_){k(w,_,S)}};Object.defineProperty(o,"__esModule",{value:!0}),o.OscLinkService=void 0;const p=h(2585);let x=o.OscLinkService=class{constructor(S){this._bufferService=S,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(S){const k=this._bufferService.buffer;if(S.id===void 0){const T=k.addMarker(k.ybase+k.y),M={data:S,id:this._nextId++,lines:[T]};return T.onDispose((()=>this._removeMarkerFromLink(M,T))),this._dataByLinkId.set(M.id,M),M.id}const w=S,_=this._getEntryIdKey(w),b=this._entriesWithId.get(_);if(b)return this.addLineToLink(b.id,k.ybase+k.y),b.id;const v=k.addMarker(k.ybase+k.y),y={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(y,v))),this._entriesWithId.set(y.key,y),this._dataByLinkId.set(y.id,y),y.id}addLineToLink(S,k){const w=this._dataByLinkId.get(S);if(w&&w.lines.every((_=>_.line!==k))){const _=this._bufferService.buffer.addMarker(k);w.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(w,_)))}}getLinkData(S){var k;return(k=this._dataByLinkId.get(S))==null?void 0:k.data}_getEntryIdKey(S){return`${S.id};;${S.uri}`}_removeMarkerFromLink(S,k){const w=S.lines.indexOf(k);w!==-1&&(S.lines.splice(w,1),S.lines.length===0&&(S.data.id!==void 0&&this._entriesWithId.delete(S.key),this._dataByLinkId.delete(S.id)))}};o.OscLinkService=x=d([m(0,p.IBufferService)],x)},8343:(f,o)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.createDecorator=o.getServiceDependencies=o.serviceRegistry=void 0;const h="di$target",d="di$dependencies";o.serviceRegistry=new Map,o.getServiceDependencies=function(m){return m[d]||[]},o.createDecorator=function(m){if(o.serviceRegistry.has(m))return o.serviceRegistry.get(m);const p=function(x,S,k){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,_,b){_[h]===_?_[d].push({id:w,index:b}):(_[d]=[{id:w,index:b}],_[h]=_)})(p,x,k)};return p.toString=()=>m,o.serviceRegistry.set(m,p),p}},2585:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.IDecorationService=o.IUnicodeService=o.IOscLinkService=o.IOptionsService=o.ILogService=o.LogLevelEnum=o.IInstantiationService=o.ICharsetService=o.ICoreService=o.ICoreMouseService=o.IBufferService=void 0;const d=h(8343);var m;o.IBufferService=(0,d.createDecorator)("BufferService"),o.ICoreMouseService=(0,d.createDecorator)("CoreMouseService"),o.ICoreService=(0,d.createDecorator)("CoreService"),o.ICharsetService=(0,d.createDecorator)("CharsetService"),o.IInstantiationService=(0,d.createDecorator)("InstantiationService"),(function(p){p[p.TRACE=0]="TRACE",p[p.DEBUG=1]="DEBUG",p[p.INFO=2]="INFO",p[p.WARN=3]="WARN",p[p.ERROR=4]="ERROR",p[p.OFF=5]="OFF"})(m||(o.LogLevelEnum=m={})),o.ILogService=(0,d.createDecorator)("LogService"),o.IOptionsService=(0,d.createDecorator)("OptionsService"),o.IOscLinkService=(0,d.createDecorator)("OscLinkService"),o.IUnicodeService=(0,d.createDecorator)("UnicodeService"),o.IDecorationService=(0,d.createDecorator)("DecorationService")},1480:(f,o,h)=>{Object.defineProperty(o,"__esModule",{value:!0}),o.UnicodeService=void 0;const d=h(8460),m=h(225);class p{static extractShouldJoin(S){return(1&S)!=0}static extractWidth(S){return S>>1&3}static extractCharKind(S){return S>>3}static createPropertyValue(S,k,w=!1){return(16777215&S)<<3|(3&k)<<1|(w?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new d.EventEmitter,this.onChange=this._onChange.event;const S=new m.UnicodeV6;this.register(S),this._active=S.version,this._activeProvider=S}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(S){if(!this._providers[S])throw new Error(`unknown Unicode version "${S}"`);this._active=S,this._activeProvider=this._providers[S],this._onChange.fire(S)}register(S){this._providers[S.version]=S}wcwidth(S){return this._activeProvider.wcwidth(S)}getStringCellWidth(S){let k=0,w=0;const _=S.length;for(let b=0;b<_;++b){let v=S.charCodeAt(b);if(55296<=v&&v<=56319){if(++b>=_)return k+this.wcwidth(v);const M=S.charCodeAt(b);56320<=M&&M<=57343?v=1024*(v-55296)+M-56320+65536:k+=this.wcwidth(M)}const y=this.charProperties(v,w);let T=p.extractWidth(y);p.extractShouldJoin(y)&&(T-=p.extractWidth(w)),k+=T,w=y}return k}charProperties(S,k){return this._activeProvider.charProperties(S,k)}}o.UnicodeService=p}},a={};function l(f){var o=a[f];if(o!==void 0)return o.exports;var h=a[f]={exports:{}};return r[f].call(h.exports,h,h.exports,l),h.exports}var u={};return(()=>{var f=u;Object.defineProperty(f,"__esModule",{value:!0}),f.Terminal=void 0;const o=l(9042),h=l(3236),d=l(844),m=l(5741),p=l(8285),x=l(7975),S=l(7090),k=["cols","rows"];class w extends d.Disposable{constructor(b){super(),this._core=this.register(new h.Terminal(b)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const v=T=>this._core.options[T],y=(T,M)=>{this._checkReadonlyOptions(T),this._core.options[T]=M};for(const T in this._core.options){const M={get:v.bind(this,T),set:y.bind(this,T)};Object.defineProperty(this._publicOptions,T,M)}}_checkReadonlyOptions(b){if(k.includes(b))throw new Error(`Option "${b}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new S.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new p.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const b=this._core.coreService.decPrivateModes;let v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:b.applicationCursorKeys,applicationKeypadMode:b.applicationKeypad,bracketedPasteMode:b.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:b.origin,reverseWraparoundMode:b.reverseWraparound,sendFocusMode:b.sendFocus,wraparoundMode:b.wraparound}}get options(){return this._publicOptions}set options(b){for(const v in b)this._publicOptions[v]=b[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(b,v=!0){this._core.input(b,v)}resize(b,v){this._verifyIntegers(b,v),this._core.resize(b,v)}open(b){this._core.open(b)}attachCustomKeyEventHandler(b){this._core.attachCustomKeyEventHandler(b)}attachCustomWheelEventHandler(b){this._core.attachCustomWheelEventHandler(b)}registerLinkProvider(b){return this._core.registerLinkProvider(b)}registerCharacterJoiner(b){return this._checkProposedApi(),this._core.registerCharacterJoiner(b)}deregisterCharacterJoiner(b){this._checkProposedApi(),this._core.deregisterCharacterJoiner(b)}registerMarker(b=0){return this._verifyIntegers(b),this._core.registerMarker(b)}registerDecoration(b){return this._checkProposedApi(),this._verifyPositiveIntegers(b.x??0,b.width??0,b.height??0),this._core.registerDecoration(b)}hasSelection(){return this._core.hasSelection()}select(b,v,y){this._verifyIntegers(b,v,y),this._core.select(b,v,y)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(b,v){this._verifyIntegers(b,v),this._core.selectLines(b,v)}dispose(){super.dispose()}scrollLines(b){this._verifyIntegers(b),this._core.scrollLines(b)}scrollPages(b){this._verifyIntegers(b),this._core.scrollPages(b)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(b){this._verifyIntegers(b),this._core.scrollToLine(b)}clear(){this._core.clear()}write(b,v){this._core.write(b,v)}writeln(b,v){this._core.write(b),this._core.write(`\r
92
92
  `,v)}paste(b){this._core.paste(b)}refresh(b,v){this._verifyIntegers(b,v),this._core.refresh(b,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(b){this._addonManager.loadAddon(this,b)}static get strings(){return o}_verifyIntegers(...b){for(const v of b)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...b){for(const v of b)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}f.Terminal=w})(),u})()))})(_d)),_d.exports}var TO=kO(),vd={exports:{}},qv;function AO(){return qv||(qv=1,(function(e,n){(function(r,a){e.exports=a()})(self,(()=>(()=>{var r={};return(()=>{var a=r;Object.defineProperty(a,"__esModule",{value:!0}),a.FitAddon=void 0,a.FitAddon=class{activate(l){this._terminal=l}dispose(){}fit(){const l=this.proposeDimensions();if(!l||!this._terminal||isNaN(l.cols)||isNaN(l.rows))return;const u=this._terminal._core;this._terminal.rows===l.rows&&this._terminal.cols===l.cols||(u._renderService.clear(),this._terminal.resize(l.cols,l.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;const l=this._terminal._core,u=l._renderService.dimensions;if(u.css.cell.width===0||u.css.cell.height===0)return;const f=this._terminal.options.scrollback===0?0:l.viewport.scrollBarWidth,o=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(o.getPropertyValue("height")),d=Math.max(0,parseInt(o.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),p=h-(parseInt(m.getPropertyValue("padding-top"))+parseInt(m.getPropertyValue("padding-bottom"))),x=d-(parseInt(m.getPropertyValue("padding-right"))+parseInt(m.getPropertyValue("padding-left")))-f;return{cols:Math.max(2,Math.floor(x/u.css.cell.width)),rows:Math.max(1,Math.floor(p/u.css.cell.height))}}}})(),r})()))})(vd)),vd.exports}var NO=AO();function os(e,n){const r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return r?`rgb(${r})`:n}function RO(e,n,r){const a=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return a?`rgb(${a} / ${n})`:r}function Kv(){return{background:os("--c-canvas","#0b0d0f"),foreground:os("--c-content-primary","#e6e8eb"),cursor:os("--c-accent","#2dd4bf"),selectionBackground:RO("--c-accent",.22,"rgba(45,212,191,0.25)"),black:os("--c-content-faint","#4e535a"),brightBlack:os("--c-content-muted","#70767e"),white:os("--c-content-secondary","#9ea5ad"),brightWhite:os("--c-content-primary","#e9ebee")}}function MO(e,n){const r=re.useRef(null),a=re.useRef(null),l=re.useRef(null);return re.useEffect(()=>{if(!r.current||!e)return;const u=new TO.Terminal({fontFamily:"JetBrains Mono, ui-monospace, monospace",fontSize:13,cursorBlink:!0,theme:Kv(),scrollback:5e3}),f=new NO.FitAddon;u.loadAddon(f),u.open(r.current),f.fit(),a.current=u,l.current=f;const o=e.terminalBuffer(n);o&&u.write(o);const h=u.onData(S=>e.sendInput(n,S)),d=u.onResize(({cols:S,rows:k})=>e.sendResize(n,S,k)),m=e.onEvent(S=>{if(S.type==="terminal.reset"&&S.terminalId===n){u.reset();return}S.type==="terminal.output"&&S.terminalId===n&&u.write(S.data)}),p=new ResizeObserver(()=>{try{f.fit(),e.sendResize(n,u.cols,u.rows)}catch{}});p.observe(r.current);const x=new MutationObserver(()=>{u.options.theme=Kv()});return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),e.sendResize(n,u.cols,u.rows),()=>{h.dispose(),d.dispose(),m(),p.disconnect(),x.disconnect(),u.dispose(),a.current=null,l.current=null}},[e,n]),{containerRef:r}}function Gv(e,n){return e==="default"?"默认":n||e.slice(0,8)}const s0=e=>`linkshell:web:lastTerminal:${e}`;function OO(e){if(!e)return null;try{return localStorage.getItem(s0(e))}catch{return null}}function DO(e,n){if(e)try{localStorage.setItem(s0(e),n)}catch{}}function LO(e,n){if(e.length===0)return null;if(n&&e.includes(n))return n;const r=e.filter(a=>a!=="default");return r.length>0?r[r.length-1]:e[0]}function IO({bridge:e,terminalId:n}){const{containerRef:r}=MO(e,n);return C.jsx("div",{ref:r,className:"xterm-host min-h-0 flex-1 bg-canvas p-2"})}function BO({bridge:e,onNewTerminal:n}){const r=e==null?void 0:e.sessionId,[a,l]=re.useState([]),[u,f]=re.useState("default"),o=re.useRef(!1),h=re.useRef(!1),d=re.useCallback((x,S)=>{l(k=>k.some(w=>w.id===x)?k:[...k,{id:x,label:Gv(x,S)}])},[]);re.useEffect(()=>{if(!e)return;o.current=!1,h.current=!1;const x=OO(r);return e.requestTerminalList(),e.onEvent(k=>{if(k.type==="terminal.output"){d(k.terminalId);return}if(k.type==="terminal.list"){const w=k.envelope,_=w.payload;if(w.type==="terminal.spawned"){const b=_==null?void 0:_.terminalId;b&&(d(b,_==null?void 0:_.projectName),f(b));return}if(w.type==="terminal.list"){const y=(Array.isArray(_==null?void 0:_.terminals)?_.terminals:[]).filter(T=>typeof T.terminalId=="string"&&T.status!=="exited").map(T=>({id:T.terminalId,label:Gv(T.terminalId,T.projectName)}));if(l(y),!o.current){o.current=!0;const T=y.map(N=>N.id),M=LO(T,x);M?f(M):h.current||(h.current=!0,n==null||n())}}}})},[e,d,n]),re.useEffect(()=>{o.current&&u&&DO(r,u)},[r,u]);const m=()=>n==null?void 0:n(),p=x=>{e==null||e.killTerminal(x),l(S=>{var w;const k=S.filter(_=>_.id!==x);return x===u&&f(((w=k[k.length-1])==null?void 0:w.id)??"default"),k})};return C.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[C.jsxs("div",{className:"flex items-center gap-0.5 border-b border-border bg-surface-raised px-1.5 py-1",children:[C.jsx(Ed,{size:13,className:"mx-1 shrink-0 text-content-faint"}),C.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto",children:a.map(x=>C.jsxs("div",{className:`group flex shrink-0 items-center gap-1 rounded-md px-2 py-1 text-2xs transition-colors ${x.id===u?"bg-surface-overlay text-content-primary":"text-content-muted hover:bg-surface-overlay/60"}`,children:[C.jsx("button",{onClick:()=>f(x.id),className:"cursor-pointer font-mono",children:x.label}),a.length>1&&C.jsx("button",{onClick:()=>p(x.id),className:"cursor-pointer rounded text-content-faint opacity-0 transition hover:text-danger group-hover:opacity-100","aria-label":"关闭终端",children:C.jsx(hi,{size:11})})]},x.id))}),C.jsx("button",{onClick:m,className:"ml-1 shrink-0 cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"新建终端","aria-label":"新建终端",children:C.jsx(Ro,{size:14})})]}),C.jsx(IO,{bridge:e,terminalId:u},u)]})}function a0(e){if(!e||e==="—")return"(未知目录)";const n=e.replace(/\/+$/,"").split("/");return n[n.length-1]||e}function Vv(e,n){return e.status==="waiting_permission"?0:e.status==="running"?1:e.status==="error"?2:e.id===n?3:4}function PO(e){return(n,r)=>{const a=Vv(n,e)-Vv(r,e);return a!==0?a:r.lastActivityAt-n.lastActivityAt}}function zO(e){return e.status==="waiting_permission"||e.status==="running"||e.status==="error"}function jO(e){const n=new Map;for(const a of e){const l=a.cwd||"—";let u=n.get(l);u||(u={cwd:l,label:a0(l),providers:new Map},n.set(l,u));const f=u.providers.get(a.provider)??[];f.push(a),u.providers.set(a.provider,f)}for(const a of n.values())for(const l of a.providers.values())l.sort((u,f)=>f.lastActivityAt-u.lastActivityAt);const r=a=>{let l=0;for(const u of a.providers.values())for(const f of u)l=Math.max(l,f.lastActivityAt);return l};return[...n.values()].sort((a,l)=>r(l)-r(a))}function UO(e){return[...e.providers.entries()].map(([n,r])=>({provider:n,conversations:r})).sort((n,r)=>Yd(n.provider).localeCompare(Yd(r.provider)))}function Yd(e){return e==="claude"?"Claude":e==="codex"?"Codex":e}function bd(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};case"idle":default:return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"}}}function Wv({deviceLabel:e,conversations:n,capabilities:r,activeConversationId:a,externalAgentStatus:l,externalAgentTitle:u,externalAgentProvider:f,store:o,onSelect:h,onNewConversation:d,onOpenExternalTerminal:m}){const x=((r==null?void 0:r.providers)??[]).filter(B=>B.enabled),[S,k]=re.useState(!1),w=re.useMemo(()=>n.filter(B=>B.archived).length,[n]),_=re.useCallback(B=>!(B.archived&&!S||B.model==="<synthetic>"),[S]),b=re.useMemo(()=>n.filter(_),[n,_]),v=re.useMemo(()=>b.filter(zO).sort(PO(a)),[b,a]),y=l==="running"||l==="waiting_permission"||l==="error",T=y||v.length>0,M=re.useMemo(()=>jO(b),[b]),[N,O]=re.useState(new Set),R=B=>O($=>{const P=new Set($);return P.has(B)?P.delete(B):P.add(B),P}),[L,z]=re.useState(null),[H,q]=re.useState(null),[F,W]=re.useState(null),[G,K]=re.useState(""),ne=re.useRef(!1),Q=()=>{z(null),q(null)},I=B=>{Q(),W(B.id),K(B.title&&B.title.trim()||"")},A=B=>{o.renameConversation(B.id,G),W(null)};return C.jsxs("div",{className:"flex h-full flex-col",children:[C.jsxs("div",{className:"flex items-center gap-2.5 border-b border-border px-3 py-3",children:[C.jsx(TS,{size:14,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-[13px] font-semibold text-content-secondary",children:e})]}),C.jsxs("div",{className:"space-y-2 border-b border-border px-3 py-3",children:[C.jsx("p",{className:"text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"新建对话"}),x.length===0?C.jsx("span",{className:"text-2xs text-content-faint",children:"等待能力…"}):C.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(B=>C.jsxs("button",{onClick:()=>d(B.id),className:"codex-btn-outline text-2xs","aria-label":`新建 ${B.label} 对话`,children:[C.jsx(ea,{provider:B.id,size:13})," ",B.label]},B.id))})]}),T&&C.jsxs("div",{className:"border-b border-border px-3 py-3",children:[C.jsx("p",{className:"mb-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:"活跃会话"}),C.jsxs("div",{className:"space-y-1",children:[y&&l&&C.jsxs("button",{onClick:m,className:"flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay",title:"打开终端面板",children:[C.jsx(ea,{provider:f??"custom",size:14}),C.jsxs("span",{className:"min-w-0 flex-1",children:[C.jsxs("span",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:u??"外部终端"}),(()=>{const B=bd(l);return C.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${B.className}`,children:[B.pulsing&&C.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),B.text]})})()]}),C.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:e})]})]},"active:external-terminal"),v.map(B=>{const $=B.title&&B.title.trim()||B.lastMessagePreview&&B.lastMessagePreview.trim().slice(0,40)||`对话 ${B.id.slice(-6)}`,P=bd(B.status);return C.jsxs("button",{onClick:()=>h(B.id),className:`flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-2 text-left transition-colors duration-150 hover:bg-surface-overlay ${B.id===a?"tree-row-active":""}`,title:B.cwd,children:[C.jsx(ea,{provider:B.provider,size:14}),C.jsxs("span",{className:"min-w-0 flex-1",children:[C.jsxs("span",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"truncate text-[13px] font-medium text-content-primary",children:$}),C.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${P.className}`,children:[P.pulsing&&C.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),P.text]})]}),C.jsx("span",{className:"mt-0.5 block truncate font-mono text-2xs text-content-muted",children:a0(B.cwd)})]})]},`active:${B.id}`)})]})]}),C.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 py-3",children:M.length===0?C.jsx("p",{className:"px-3 py-2 text-2xs text-content-faint",children:S||w===0?"还没有对话":"没有未归档的对话"}):M.map(B=>{const $=`folder:${B.cwd}`,P=N.has($);return C.jsxs("div",{className:"py-1",children:[C.jsxs("button",{onClick:()=>R($),className:"tree-row",title:B.cwd,children:[P?C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}):C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}),C.jsx(Lr,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate text-2xs font-semibold uppercase tracking-wider text-content-faint",children:B.label})]}),!P&&UO(B).map(({provider:oe,conversations:ye})=>{const pe=`prov:${B.cwd}:${oe}`,J=N.has(pe);return C.jsxs("div",{className:"pl-3",children:[C.jsxs("div",{className:"flex items-center gap-1",children:[C.jsxs("button",{onClick:()=>R(pe),className:"tree-row flex-1",children:[J?C.jsx(Si,{size:12,className:"shrink-0 text-content-faint"}):C.jsx(Ir,{size:12,className:"shrink-0 text-content-faint"}),C.jsx(ea,{provider:oe,size:13}),C.jsx("span",{className:"text-[13px] font-medium text-content-secondary",children:Yd(oe)}),C.jsxs("span",{className:"text-2xs text-content-faint",children:["(",ye.length,")"]})]}),C.jsx("button",{onClick:()=>d(oe,B.cwd==="—"?void 0:B.cwd),className:"cursor-pointer rounded-lg p-1.5 text-content-faint transition-colors hover:bg-surface-overlay hover:text-accent",title:"在此目录新建对话","aria-label":"新建对话",children:C.jsx(Ro,{size:13})})]}),!J&&ye.map(j=>{const me=j.title&&j.title.trim()||j.lastMessagePreview&&j.lastMessagePreview.trim().slice(0,40)||`对话 ${j.id.slice(-6)}`,ce=F===j.id,ee=L===j.id,le=bd(j.status);return C.jsxs("div",{className:"group relative",children:[ce?C.jsx("input",{autoFocus:!0,value:G,onChange:Ce=>K(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"?(Ce.preventDefault(),Ce.currentTarget.blur()):Ce.key==="Escape"&&(ne.current=!0,Ce.currentTarget.blur())},onBlur:()=>{if(ne.current){ne.current=!1,W(null);return}A(j)},placeholder:"对话名称",className:"block w-full rounded-lg border border-accent bg-surface py-2 pl-7 pr-3 text-[13px] text-content-primary outline-none"}):C.jsxs("button",{onClick:()=>h(j.id),className:`block w-full cursor-pointer rounded-lg py-2 pl-7 pr-9 text-left transition-colors duration-150 hover:bg-surface-overlay ${j.id===a?"tree-row-active":""}`,children:[C.jsxs("p",{className:"flex items-center gap-2",children:[C.jsx("span",{className:"truncate text-[13px] text-content-primary",children:me}),C.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${le.className}`,children:[le.pulsing&&C.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse-dot"}),le.text]}),j.archived&&C.jsx("span",{className:"shrink-0 rounded bg-surface-overlay px-1 text-2xs text-content-faint",children:"已归档"})]}),j.lastMessagePreview&&j.lastMessagePreview.trim()!==me&&C.jsx("p",{className:"mt-0.5 truncate text-2xs text-content-muted",children:j.lastMessagePreview})]}),!ce&&C.jsx("button",{onClick:Ce=>{Ce.stopPropagation(),q(null),z(ee?null:j.id)},className:`absolute right-1.5 top-1.5 cursor-pointer rounded-md p-1 text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-primary ${ee?"opacity-100":"opacity-0 group-hover:opacity-100"}`,title:"更多操作","aria-label":"更多操作",children:C.jsx(IS,{size:14})}),ee&&C.jsxs(C.Fragment,{children:[C.jsx("button",{className:"fixed inset-0 z-10 cursor-default",onClick:Q,"aria-label":"关闭菜单"}),C.jsxs("div",{className:"absolute right-1.5 top-9 z-20 w-36 overflow-hidden rounded-lg border border-border bg-surface py-1 shadow-xl",children:[C.jsxs("button",{onClick:()=>I(j),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[C.jsx(of,{size:13})," 改名"]}),C.jsxs("button",{onClick:()=>{o.setConversationArchived(j.id,!j.archived),Q()},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-content-secondary transition-colors hover:bg-surface-overlay",children:[C.jsx(m_,{size:13})," ",j.archived?"取消归档":"归档"]}),C.jsxs("button",{onClick:()=>{H===j.id?(o.deleteConversation(j.id),Q()):q(j.id)},className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1.5 text-left text-2xs text-danger transition-colors hover:bg-danger/10",children:[C.jsx(LS,{size:13})," ",H===j.id?"确认删除?":"删除"]})]})]})]},j.id)})]},oe)})]},B.cwd)})}),w>0&&C.jsxs("button",{onClick:()=>k(B=>!B),className:"flex items-center gap-2 border-t border-border px-3 py-2.5 text-left text-2xs text-content-faint transition-colors hover:bg-surface-overlay hover:text-content-secondary",children:[C.jsx(m_,{size:13,className:"shrink-0"}),S?"隐藏已归档":`显示已归档 (${w})`]})]})}const HO={none:"无",minimal:"极简",low:"低",medium:"中",high:"高",xhigh:"极高"},FO={read_only:"只读",workspace_write:"工作区写",full_access:"完全访问"};function yd({icon:e,value:n,options:r,render:a,onChange:l,title:u}){const[f,o]=re.useState(!1),h=re.useRef(null);if(re.useEffect(()=>{if(!f)return;const m=p=>{h.current&&!h.current.contains(p.target)&&o(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[f]),r.length===0)return null;const d=n??r[0];return C.jsxs("div",{ref:h,className:"relative",children:[C.jsxs("button",{type:"button",onClick:()=>o(m=>!m),title:u,className:"flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium text-content-secondary transition-colors hover:bg-surface-overlay hover:text-content-primary",children:[e,C.jsx("span",{className:"max-w-[7rem] truncate",children:a(d)}),C.jsx(Ir,{size:11,className:"text-content-faint"})]}),f&&C.jsx("div",{className:"codex-card-raised absolute bottom-full left-0 z-20 mb-1.5 min-w-[8rem] overflow-hidden p-1 animate-fade-in",children:r.map(m=>C.jsxs("button",{type:"button",onClick:()=>{l(m),o(!1)},className:`flex w-full cursor-pointer items-center justify-between gap-3 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors hover:bg-surface-overlay ${m===d?"text-content-primary":"text-content-secondary"}`,children:[C.jsx("span",{className:"truncate",children:a(m)}),m===d&&C.jsx(Mo,{size:13,className:"shrink-0 text-accent"})]},m))})]})}function $O({conversation:e,capability:n,onChange:r}){var d;const l=((n==null?void 0:n.models)??[]).filter(m=>m.id!=="default"),u=(n==null?void 0:n.reasoningEfforts)??[],f=(n==null?void 0:n.permissionModes)??[],o=(n==null?void 0:n.supportsPlan)??!1,h=e.collaborationMode==="plan";return C.jsxs(C.Fragment,{children:[l.length>0&&C.jsx(yd,{title:"模型",value:e.model??(n==null?void 0:n.defaultModel)??((d=l[0])==null?void 0:d.id),options:l.map(m=>m.id),render:m=>{var p;return((p=l.find(x=>x.id===m))==null?void 0:p.label)??m},onChange:m=>r({model:m})}),C.jsx(yd,{title:"推理强度",value:e.reasoningEffort,options:u,render:m=>HO[m]??m,onChange:m=>r({reasoningEffort:m})}),C.jsx(yd,{title:"权限",value:e.permissionMode,options:f,render:m=>FO[m]??m,onChange:m=>r({permissionMode:m})}),o&&C.jsxs("button",{type:"button",onClick:()=>r({collaborationMode:h?"default":"plan"}),className:`inline-flex cursor-pointer items-center gap-1 rounded-full px-2 py-1 text-2xs font-medium transition-colors ${h?"bg-accent-dim text-white":"text-content-secondary hover:bg-surface-overlay hover:text-content-primary"}`,title:"计划模式",children:[h&&C.jsx(Mo,{size:11}),"计划"]})]})}function qO({store:e,initialPath:n,onClose:r}){const[a,l]=re.useState(n||"."),[u,f]=re.useState([]),[o,h]=re.useState(!1),[d,m]=re.useState(null),[p,x]=re.useState(null),S=re.useCallback(async _=>{h(!0),m(null),x(null);try{const b=await e.browse(_,!0);b.error?m(b.error):(l(b.path),f([...b.entries].sort((v,y)=>v.isDirectory!==y.isDirectory?v.isDirectory?-1:1:v.name.localeCompare(y.name))))}catch(b){m(b.message||"浏览失败")}finally{h(!1)}},[e]);re.useEffect(()=>{S(n||".")},[S,n]);const k=async _=>{h(!0),m(null);try{const b=await e.readFile(_.path);b.error?m(b.error):x({path:b.path,content:b.content,truncated:b.truncated})}catch(b){m(b.message||"读取失败")}finally{h(!1)}},w=a.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return C.jsxs("div",{className:"flex h-full flex-col bg-surface",children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[C.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-2xs text-content-secondary",children:[C.jsx(Lr,{size:13,className:"text-content-faint"})," 文件"]}),C.jsx("button",{onClick:r,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭文件面板",children:C.jsx(hi,{size:15})})]}),C.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-2 py-1.5",children:[C.jsx("button",{onClick:()=>S(w),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:C.jsx(rf,{size:14})}),C.jsx("input",{value:a,onChange:_=>l(_.target.value),onKeyDown:_=>_.key==="Enter"&&S(a),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),C.jsx("button",{onClick:()=>S(a),disabled:o,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:C.jsx(kc,{size:14})})]}),d&&C.jsx("p",{className:"px-3 py-1.5 text-2xs text-danger",children:d}),C.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[o&&C.jsx("p",{className:"px-3 py-2 text-2xs text-content-muted",children:"加载中…"}),!o&&p?C.jsxs("div",{children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[C.jsx("span",{className:"truncate font-mono text-2xs text-content-secondary",children:p.path}),C.jsx("button",{onClick:()=>x(null),className:"codex-btn-ghost text-2xs",children:"返回"})]}),C.jsxs("pre",{className:"whitespace-pre-wrap px-3 py-2 font-mono text-2xs leading-relaxed text-content-secondary",children:[p.content,p.truncated&&C.jsx("span",{className:"text-warning",children:`
93
93
  …(已截断)`})]})]}):!o&&u.map(_=>C.jsxs("button",{onClick:()=>_.isDirectory?S(_.path):k(_),className:"flex w-full cursor-pointer items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-surface-overlay",children:[_.isDirectory?C.jsx(Lr,{size:13,className:"shrink-0 text-content-faint"}):C.jsx(na,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:_.name}),!_.isDirectory&&_.size!=null&&C.jsxs("span",{className:"ml-auto font-mono text-2xs text-content-faint",children:[_.size,"B"]})]},_.path))]})]})}function KO({store:e,initialPath:n,providerLabel:r,onCancel:a,onConfirm:l}){const[u,f]=re.useState(n||"."),[o,h]=re.useState([]),[d,m]=re.useState(!1),[p,x]=re.useState(null),S=re.useCallback(async w=>{m(!0),x(null);try{const _=await e.browse(w,!1);_.error?x(_.error):(f(_.path),h(_.entries.filter(b=>b.isDirectory).sort((b,v)=>b.name.localeCompare(v.name))))}catch(_){x(_.message||"无法读取目录")}finally{m(!1)}},[e]);re.useEffect(()=>{S(n||".")},[S,n]);const k=u.replace(/\/+$/,"").split("/").slice(0,-1).join("/")||"/";return C.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:a,children:C.jsxs("div",{className:"codex-card flex max-h-[80vh] w-full max-w-lg flex-col overflow-hidden",onClick:w=>w.stopPropagation(),children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[C.jsxs("h3",{className:"text-sm font-semibold",children:["选择工作目录 · ",r]}),C.jsx("button",{onClick:a,className:"codex-btn-ghost px-2 py-1.5","aria-label":"取消",children:C.jsx(hi,{size:15})})]}),C.jsxs("div",{className:"flex items-center gap-1 border-b border-border px-3 py-2",children:[C.jsx("button",{onClick:()=>S(k),disabled:d,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"上级目录","aria-label":"上级目录",children:C.jsx(rf,{size:14})}),C.jsx("input",{value:u,onChange:w=>f(w.target.value),onKeyDown:w=>w.key==="Enter"&&S(u),className:"flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none"}),C.jsx("button",{onClick:()=>S(u),disabled:d,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent",title:"刷新","aria-label":"刷新",children:C.jsx(kc,{size:14})})]}),p&&C.jsx("p",{className:"px-4 py-2 text-2xs text-danger",children:p}),C.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:d?C.jsx("p",{className:"px-4 py-3 text-2xs text-content-muted",children:"加载中…"}):o.length===0?C.jsx("p",{className:"px-4 py-3 text-2xs text-content-faint",children:"(无子目录)"}):o.map(w=>C.jsxs("button",{onClick:()=>S(w.path),className:"flex w-full cursor-pointer items-center gap-2 px-4 py-1.5 text-left transition-colors hover:bg-surface-overlay",children:[C.jsx(Lr,{size:13,className:"shrink-0 text-content-faint"}),C.jsx("span",{className:"truncate font-mono text-2xs text-content-primary",children:w.name})]},w.path))}),C.jsxs("div",{className:"flex items-center justify-between gap-3 border-t border-border px-4 py-3",children:[C.jsxs("span",{className:"truncate font-mono text-2xs text-content-muted",title:u,children:["将在此创建:",u]}),C.jsx("button",{onClick:()=>l(u),disabled:d,className:"codex-btn-primary text-2xs",children:"在此新建"})]})]})})}const o0=[{cssProp:"color",label:"文本颜色"},{cssProp:"background-color",label:"背景"},{cssProp:"font-size",label:"字号"},{cssProp:"font-weight",label:"字重"},{cssProp:"padding",label:"内边距"},{cssProp:"border-radius",label:"圆角"}];function GO(e){var a;const n=(a=e.ownerDocument.defaultView)==null?void 0:a.getComputedStyle(e),r={};for(const{cssProp:l}of o0)r[l]=(n==null?void 0:n.getPropertyValue(l).trim())??"";return r}function VO(e){const n=/^\s*(\d{1,5})(.*)$/.exec(e);if(!n)return null;const r=n[1];if(Number(r)<1||Number(r)>65535)return null;let a=n[2]||"/";return a.startsWith("/")||(a=`/${a}`),{port:r,path:a}}function WO(e){if(e.id)return`#${CSS.escape(e.id)}`;const n=[];let r=e,a=0;for(;r&&r.nodeType===1&&a<4;){let l=r.tagName.toLowerCase();const u=(r.getAttribute("class")||"").trim().split(/\s+/).filter(Boolean).slice(0,2).map(o=>`.${CSS.escape(o)}`).join("");l+=u;const f=r.parentElement;if(f){const o=[...f.children].filter(h=>h.tagName===r.tagName);o.length>1&&(l+=`:nth-of-type(${o.indexOf(r)+1})`)}if(n.unshift(l),r.id){n[0]=`#${CSS.escape(r.id)}`;break}r=f,a+=1}return n.join(" > ")}function YO({gatewayUrl:e,sessionId:n,initialAuthToken:r,defaultPort:a,isMobile:l,onClose:u,onAnnotate:f}){const[o,h]=re.useState(a||"3000"),[d,m]=re.useState(null),[p,x]=re.useState(r??null),[S,k]=re.useState(!1),[w,_]=re.useState("desktop"),[b,v]=re.useState(0),[y,T]=re.useState(!1),[M,N]=re.useState(null),[O,R]=re.useState(null),[L,z]=re.useState(null),[H,q]=re.useState(""),[F,W]=re.useState(!1),[G,K]=re.useState({}),[ne,Q]=re.useState({}),I=re.useRef(null),A=re.useRef(null),B=re.useMemo(()=>ab(),[]);re.useEffect(()=>{let Ee=!1;return k(!1),nf().then(we=>{Ee||x((we==null?void 0:we.accessToken)??null)}).finally(()=>{Ee||k(!0)}),()=>{Ee=!0}},[r]);const $=re.useMemo(()=>{if(!d||r&&!S)return null;const Ee=`${e.replace(/\/+$/,"")}/tunnel/${encodeURIComponent(n)}/${d.port}${d.path}`,we=[];if(B&&we.push(`token=${encodeURIComponent(B)}`),p&&we.push(`auth_token=${encodeURIComponent(p)}`),we.length===0)return Ee;const ke=d.path.includes("?")?"&":"?";return`${Ee}${ke}${we.join("&")}`},[d,e,n,B,p,S]),P=()=>{const Ee=VO(o);Ee&&(m(Ee),v(we=>we+1))},oe=()=>v(Ee=>Ee+1),ye=()=>{var Ee;if(d)try{const we=(Ee=I.current)==null?void 0:Ee.contentWindow;if(!we)return;const ke=`/tunnel/${encodeURIComponent(n)}/${d.port}`;let Tt=we.location.pathname;Tt.startsWith(ke)&&(Tt=Tt.slice(ke.length)||"/");const Fe=new URLSearchParams(we.location.search);Fe.delete("token"),Fe.delete("auth_token");const At=Fe.toString();h(`${d.port}${Tt}${At?`?${At}`:""}`)}catch{}},pe=(Ee,we)=>{const ke=I.current,Tt=ke==null?void 0:ke.contentDocument;if(!ke||!Tt)return null;const Fe=ke.getBoundingClientRect();return Tt.elementFromPoint(Ee-Fe.left,we-Fe.top)},J=Ee=>{const we=Ee.getBoundingClientRect();return{top:we.top,left:we.left,width:we.width,height:we.height}},j=Ee=>{try{const we=pe(Ee.clientX,Ee.clientY);R(we?J(we):null)}catch{R(null),N("此页面跨域,无法读取元素(生产环境同源可用)"),T(!1)}},me=Ee=>{Ee.preventDefault();try{const we=pe(Ee.clientX,Ee.clientY);if(!we||!("style"in we))return;const ke=we;z({el:ke,selector:WO(ke),text:(ke.textContent||"").replace(/\s+/g," ").trim().slice(0,120),rect:J(ke)}),K(GO(ke)),Q({}),q("")}catch{N("此页面跨域,无法读取元素(生产环境同源可用)"),T(!1)}},ce=(Ee,we)=>{if(L){try{L.el.style.setProperty(Ee,we)}catch{}Q(ke=>({...ke,[Ee]:we}))}},ee=()=>Object.entries(ne).filter(([Ee,we])=>we!==(G[Ee]??"")).map(([Ee,we])=>({cssProp:Ee,from:G[Ee]??"",to:we})),le=()=>{if(!L)return;const Ee=ee(),we=["关于预览页面中的这个元素:",`- 选择器: \`${L.selector}\``,L.text?`- 文本: "${L.text}"`:"",`- 路径: localhost:${o}`,H.trim()?`- 批注: ${H.trim()}`:""];if(Ee.length>0){we.push("- 请把以下样式改动应用到源码:");for(const ke of Ee)we.push(` - ${ke.cssProp}: ${ke.from||"(默认)"} → ${ke.to}`)}f==null||f(we.filter(Boolean).join(`
94
- `)),z(null),q(""),K({}),Q({}),W(!1),R(null),T(!1)},Ce=()=>{z(null),q(""),K({}),Q({}),W(!1)},He=()=>{N(null),Ce(),R(null),T(Ee=>!Ee)};return C.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[C.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1.5",children:[l&&C.jsx("button",{onClick:u,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭预览",children:C.jsx(hi,{size:15})}),C.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 rounded-lg border border-border bg-surface-raised px-2 py-1",children:[C.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:"localhost:"}),C.jsx("input",{value:o,onChange:Ee=>h(Ee.target.value),onKeyDown:Ee=>Ee.key==="Enter"&&P(),placeholder:"3000",spellCheck:!1,className:"min-w-0 flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none","aria-label":"端口与路径"}),C.jsx("button",{onClick:P,className:"shrink-0 cursor-pointer rounded bg-accent-dim px-2 py-0.5 text-2xs font-medium text-white transition-colors hover:bg-accent",children:"前往"})]}),C.jsx("button",{onClick:He,disabled:!d,className:`shrink-0 cursor-pointer rounded-md p-1.5 transition-colors disabled:opacity-40 ${y?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-accent"}`,title:"标注元素","aria-label":"标注元素",children:C.jsx(zS,{size:14})}),C.jsxs("div",{className:"flex shrink-0 items-center rounded-lg border border-border bg-surface-raised p-0.5",children:[C.jsx("button",{onClick:()=>_("desktop"),className:`cursor-pointer rounded p-1 transition-colors ${w==="desktop"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"桌面视口","aria-label":"桌面视口",children:C.jsx(tb,{size:13})}),C.jsx("button",{onClick:()=>_("mobile"),className:`cursor-pointer rounded p-1 transition-colors ${w==="mobile"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"移动视口","aria-label":"移动视口",children:C.jsx(PS,{size:13})})]}),C.jsx("button",{onClick:oe,disabled:!d,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"刷新","aria-label":"刷新",children:C.jsx(kc,{size:14})}),C.jsx("button",{onClick:()=>$&&window.open($,"_blank","noopener,noreferrer"),disabled:!$,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"在新窗口打开","aria-label":"在新窗口打开",children:C.jsx(BS,{size:14})})]}),M&&C.jsx("p",{className:"border-b border-border bg-warning/10 px-3 py-1.5 text-2xs text-warning",children:M}),y&&!L&&C.jsx("p",{className:"border-b border-border bg-accent/10 px-3 py-1.5 text-2xs text-accent",children:"标注模式:移动鼠标高亮元素,点击选择并添加批注。"}),C.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-surface-raised",children:$?C.jsx("div",{className:w==="mobile"?"mx-auto h-full w-[390px] max-w-full border-x border-border":"h-full w-full",children:C.jsxs("div",{className:"relative h-full w-full",children:[C.jsx("iframe",{ref:I,src:$,title:"端口预览",onLoad:ye,className:"h-full w-full bg-white"},`${$}-${b}`),y&&C.jsx("div",{className:"absolute inset-0 cursor-crosshair",onMouseMove:j,onMouseLeave:()=>R(null),onClick:me,children:O&&!L&&C.jsx("div",{className:"pointer-events-none absolute border-2 border-accent bg-accent/10",style:{top:O.top,left:O.left,width:O.width,height:O.height}})}),L&&(()=>{var Ot,wt;const ke=((Ot=A.current)==null?void 0:Ot.clientHeight)??600,Tt=L.rect.top+L.rect.height+8,Fe=L.rect.top-8,At=F?340:140,pn=Tt+At>ke&&Fe-At>0?Math.max(4,Fe-At):Tt,Nt=Math.max(4,Math.min(L.rect.left,(((wt=A.current)==null?void 0:wt.clientWidth)??800)-280-4));return C.jsxs("div",{className:"absolute z-20 flex flex-col gap-2 rounded-xl border border-accent-dim/40 bg-surface-raised px-3 py-2.5 shadow-2xl animate-fade-in",style:{top:pn,left:Nt,width:280,maxHeight:ke-pn-8},children:[C.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",title:L.selector,children:L.selector}),L.text&&C.jsxs("p",{className:"-mt-1 truncate text-2xs text-content-muted",children:['"',L.text,'"']}),C.jsx("input",{value:H,onChange:ue=>q(ue.target.value),onKeyDown:ue=>ue.key==="Enter"&&le(),autoFocus:!0,placeholder:"添加批注…",className:"w-full rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-content-primary placeholder-content-muted outline-none focus:border-accent-dim"}),C.jsxs("button",{onClick:()=>W(ue=>!ue),className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-2xs transition-colors ${F?"text-accent":"text-content-muted hover:text-content-secondary"}`,children:[C.jsx("svg",{width:10,height:10,viewBox:"0 0 10 10",className:`shrink-0 transition-transform ${F?"rotate-180":""}`,children:C.jsx("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),"调整样式"]}),F&&C.jsx("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1.5 animate-fade-in",children:o0.map(({cssProp:ue,label:xe})=>{const Ie=ne[ue]??G[ue]??"",$e=ue in ne&&ne[ue]!==(G[ue]??"");return C.jsxs("label",{className:"flex flex-col gap-0.5",children:[C.jsx("span",{className:`text-2xs ${$e?"text-accent":"text-content-faint"}`,children:xe}),C.jsx("input",{value:Ie,onChange:Je=>ce(ue,Je.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-2xs text-content-primary outline-none focus:border-accent-dim"})]},ue)})}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("button",{onClick:Ce,className:"codex-btn-ghost flex-1 text-2xs",children:"取消"}),C.jsx("button",{onClick:le,className:"codex-btn-primary flex-1 text-2xs",children:"发送给 Agent"})]})]})})()]})}):C.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[C.jsx(hc,{size:34,className:"text-content-faint"}),C.jsx("p",{className:"text-sm leading-6 text-content-muted",children:d&&!S?"正在准备预览认证...":"输入主机上服务的端口号,预览远程本地服务"})]})})]})}const l0="linkshell_theme",wc=new Set;let Uc=ZO();function ZO(){try{const e=localStorage.getItem(l0);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function XO(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function QO(e=Uc){return e==="system"?XO()?"dark":"light":e}function Zd(){typeof document>"u"||document.documentElement.setAttribute("data-theme",QO())}function Yv(){return Uc}function Bf(e){Uc=e;try{localStorage.setItem(l0,e)}catch{}Zd();for(const n of wc)n()}function JO(e){return wc.add(e),()=>wc.delete(e)}function eD(){var e;if(Zd(),typeof window<"u"&&window.matchMedia){const n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{if(Uc==="system"){Zd();for(const a of wc)a()}};(e=n.addEventListener)==null||e.call(n,"change",r)}}const xd=["light","dark","system"],Zv={light:"浅色",dark:"深色",system:"跟随系统"};function tD(){const e=re.useSyncExternalStore(JO,Yv,Yv),n=()=>Bf(xd[(xd.indexOf(e)+1)%xd.length]),r=e==="light"?RS:e==="dark"?MS:tb;return C.jsx("button",{onClick:n,className:"codex-btn-ghost px-2 py-1.5",title:`主题:${Zv[e]}(点击切换)`,"aria-label":`主题:${Zv[e]}`,children:C.jsx(r,{size:15})})}function nD(){try{const e=new URLSearchParams(window.location.search),n=e.get("embed")==="1",r=e.get("theme");return{embed:n,sessionId:e.get("session"),gateway:e.get("gateway"),token:e.get("token"),theme:r==="dark"||r==="light"?r:null}}catch{return{embed:!1,sessionId:null,gateway:null,token:null,theme:null}}}function iD(e){return!e.embed||!e.sessionId||!e.token||!e.gateway?null:(rb(e.gateway),uf(e.token),e.theme&&Bf(e.theme),Cd([{id:e.sessionId,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),{name:"console",sessionId:e.sessionId})}function rD(){try{const e=window.ReactNativeWebView;e==null||e.postMessage(JSON.stringify({type:"requestClose"}))}catch{}}const sD="linkshell_embed";function c0(){try{return new URLSearchParams(window.location.search).get("embed")==="1"?!0:localStorage.getItem(sD)==="1"}catch{return!1}}function aD(e,n){if(!e)return 0;const r=e.toLowerCase(),a=n.toLowerCase();let l=0,u=0,f=-1;for(let o=0;o<r.length;o++){const h=r[o],d=a.indexOf(h,l);if(d===-1)return null;f>=0?u+=d-f-1:u+=d,f=d,l=d+1}return u}function oD({open:e,onClose:n,actions:r,placeholder:a="搜索命令、对话…"}){const[l,u]=re.useState(""),[f,o]=re.useState(0),h=re.useRef(null);re.useEffect(()=>{e&&(u(""),o(0),requestAnimationFrame(()=>{var k;return(k=h.current)==null?void 0:k.focus()}))},[e]);const d=re.useMemo(()=>r.map(w=>({a:w,score:aD(l,`${w.label} ${w.hint??""} ${w.keywords??""}`)})).filter(w=>w.score!==null).sort((w,_)=>w.score-_.score).map(w=>w.a),[r,l]);if(re.useEffect(()=>{o(k=>Math.min(k,Math.max(0,d.length-1)))},[d.length]),!e)return null;const m=k=>{const w=d[k];w&&(n(),w.run())},p=k=>{k.key==="ArrowDown"?(k.preventDefault(),o(w=>Math.min(w+1,d.length-1))):k.key==="ArrowUp"?(k.preventDefault(),o(w=>Math.max(w-1,0))):k.key==="Enter"?(k.preventDefault(),m(f)):k.key==="Escape"&&(k.preventDefault(),n())};let x=-1;const S=new Map;for(const k of d){const w=k.group??"",_=S.get(w)??[];_.push(k),S.set(w,_)}return C.jsx("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-canvas/60 px-4 pt-[12vh] backdrop-blur-sm animate-fade-in",onClick:n,children:C.jsxs("div",{className:"codex-card-raised w-full max-w-xl overflow-hidden",onClick:k=>k.stopPropagation(),children:[C.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-3",children:[C.jsx(ls,{size:16,className:"shrink-0 text-content-faint"}),C.jsx("input",{ref:h,value:l,onChange:k=>u(k.target.value),onKeyDown:p,placeholder:a,className:"min-w-0 flex-1 bg-transparent text-[15px] text-content-primary placeholder-content-muted outline-none"}),C.jsx("kbd",{className:"shrink-0 rounded border border-border px-1.5 py-0.5 font-mono text-2xs text-content-faint",children:"esc"})]}),C.jsx("div",{className:"max-h-[50vh] overflow-y-auto p-1.5",children:d.length===0?C.jsx("p",{className:"px-3 py-6 text-center text-sm text-content-muted",children:"没有匹配项"}):[...S.entries()].map(([k,w])=>C.jsxs("div",{className:"mb-1",children:[k&&C.jsx("p",{className:"px-2.5 pb-1 pt-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:k}),w.map(_=>{x+=1;const b=x;return C.jsxs("button",{onMouseEnter:()=>o(b),onClick:()=>m(b),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${b===f?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[_.icon&&C.jsx("span",{className:"shrink-0 text-content-muted",children:_.icon}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-primary",children:_.label}),_.hint&&C.jsx("span",{className:"shrink-0 text-2xs text-content-faint",children:_.hint})]},_.id)})]},k||"_"))})]})})}function lD(e){return e==="connected"?{text:"已连接",color:"text-success"}:e==="connecting"||e==="reconnecting"||e==="claiming"?{text:"连接中",color:"text-warning"}:e==="host_disconnected"?{text:"主机离线",color:"text-warning"}:e.startsWith("error")?{text:"错误",color:"text-danger"}:{text:"未连接",color:"text-content-muted"}}function Xv(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"idle":return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};default:return null}}function uc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cD(e){if(!e)return null;const n=e.inputTokens!=null||e.cacheReadTokens!=null?(e.inputTokens??0)+(e.cacheReadTokens??0):null,r=[];let a="";if(n!=null&&e.contextWindow&&e.contextWindow>0){const l=Math.min(100,Math.round(n/e.contextWindow*100));r.push(`${l}%`),a=`上下文 ${uc(n)} / ${uc(e.contextWindow)} tokens`}else{const l=e.totalTokens??n??e.outputTokens??null;l!=null&&(r.push(uc(l)),a=`${l.toLocaleString()} tokens`)}return typeof e.totalCostUsd=="number"&&e.totalCostUsd>0&&(r.push(`$${e.totalCostUsd.toFixed(e.totalCostUsd<1?3:2)}`),a=a?`${a} · $${e.totalCostUsd.toFixed(4)}`:`$${e.totalCostUsd.toFixed(4)}`),r.length===0?null:{text:r.join(" · "),title:a}}function uD(e){const n=Math.max(0,Math.floor(e)),r=Math.floor(n/3600),a=Math.floor(n%3600/60),l=n%60;return r>0?`${r}h ${String(a).padStart(2,"0")}m ${String(l).padStart(2,"0")}s`:a>0?`${a}m ${String(l).padStart(2,"0")}s`:`${l}s`}function hD(e){const[n,r]=re.useState(0),a=re.useRef(null);return re.useEffect(()=>{if(!e){a.current=null,r(0);return}a.current=Date.now(),r(0);const l=setInterval(()=>{a.current!=null&&r(Math.floor((Date.now()-a.current)/1e3))},1e3);return()=>clearInterval(l)},[e]),n}function dD(e,n,r){const[a,l]=re.useState(()=>({render:e,className:e?n:""})),u=re.useRef(e);re.useEffect(()=>{e&&!u.current?l({render:!0,className:n}):!e&&u.current&&l({render:!0,className:r}),u.current=e},[e,n,r]);const f=re.useCallback(()=>{u.current||l({render:!1,className:""})},[]);return{render:a.render,className:a.className,onAnimationEnd:f}}function fD(e,n){var l,u,f,o,h,d,m,p;const r=n.toLowerCase();return[e.text,(l=e.commandExecution)==null?void 0:l.command,(u=e.commandExecution)==null?void 0:u.output,(f=e.toolCall)==null?void 0:f.name,(o=e.toolCall)==null?void 0:o.input,(h=e.toolCall)==null?void 0:h.output,(d=e.fileChange)==null?void 0:d.summary,...((p=(m=e.fileChange)==null?void 0:m.entries)==null?void 0:p.map(x=>x.path))??[],e.error].some(x=>typeof x=="string"&&x.toLowerCase().includes(r))}function pD({sessionId:e,session:n,onBack:r}){var Ut,$t,De;const a=re.useMemo(()=>ib(),[]),l=re.useMemo(()=>c0(),[]),{store:u,snapshot:f}=Ww(a,e),o=i0(),[h,d]=re.useState("none"),[m,p]=re.useState(!1),[x,S]=re.useState(!1),[k,w]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_terminal_h"));return X>=120&&X<=600?X:320}),_=re.useRef(!1),b=re.useRef(k);b.current=k;const v=re.useRef(m);v.current=m;const y=re.useCallback(()=>{v.current?S(!0):p(!0)},[]),T=re.useCallback(()=>{S(!1),p(!0)},[]),[M,N]=re.useState(!1),[O,R]=re.useState(null),[L,z]=re.useState(null),[H,q]=re.useState(!1),[F,W]=re.useState(null),[G,K]=re.useState({text:"",nonce:0}),[ne,Q]=re.useState(!1),[I,A]=re.useState(""),[B,$]=re.useState(!1),P=re.useRef(null),[oe,ye]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_sidebar_w"));return X>=180&&X<=520?X:256}),[pe,J]=re.useState(()=>localStorage.getItem("linkshell_sidebar_collapsed")==="1"),[j,me]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_rightpanel_w"));return X>=320&&X<=1100?X:560}),ce=re.useRef(!1),ee=re.useRef(!1),le=re.useRef(null),Ce=()=>{J(X=>(localStorage.setItem("linkshell_sidebar_collapsed",X?"0":"1"),!X))},He=X=>{X.preventDefault(),ce.current=!0;const de=Ke=>{if(!ce.current)return;const gt=Math.min(520,Math.max(180,Ke.clientX));ye(gt)},Be=()=>{ce.current=!1,localStorage.setItem("linkshell_sidebar_w",String(Ee.current)),window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",Be)};window.addEventListener("pointermove",de),window.addEventListener("pointerup",Be)},Ee=re.useRef(oe);Ee.current=oe;const we=re.useRef(j);we.current=j;const ke=X=>{X.preventDefault(),ee.current=!0;const de=Ke=>{if(!ee.current)return;const gt=Math.min(1100,Math.max(320,window.innerWidth-Ke.clientX));me(gt)},Be=()=>{ee.current=!1,localStorage.setItem("linkshell_rightpanel_w",String(we.current)),window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",Be)};window.addEventListener("pointermove",de),window.addEventListener("pointerup",Be)},Tt=X=>{X.preventDefault(),_.current=!0;const de=X.clientY,Be=b.current,Ke=Nn=>{if(!_.current)return;const It=Math.min(600,Math.max(120,Be+(de-Nn.clientY)));w(It)},gt=()=>{_.current=!1,localStorage.setItem("linkshell_terminal_h",String(b.current)),window.removeEventListener("pointermove",Ke),window.removeEventListener("pointerup",gt)};window.addEventListener("pointermove",Ke),window.addEventListener("pointerup",gt)},Fe=f.activeConversationId,At=Fe?f.timelines.get(Fe)??[]:[],Me=f.conversations.find(X=>X.id===Fe),pn=((Ut=f.capabilities)==null?void 0:Ut.providers)??[],Nt=Me?pn.find(X=>X.id===Me.provider):void 0,Ot=(Me==null?void 0:Me.status)==="running",wt=Fe?f.history.get(Fe):void 0,ue=re.useMemo(()=>{for(let X=At.length-1;X>=0;X--){const de=At[X];if(de.role==="user"&&de.text)return de.text}},[At]),xe=X=>{K(de=>({text:X,nonce:de.nonce+1}))},Ie=re.useMemo(()=>{if((Me==null?void 0:Me.collaborationMode)!=="plan"||Ot||(Me==null?void 0:Me.status)==="waiting_permission")return!1;const X=[...At].reverse().find(de=>!oc(de));return X!=null&&X.role!=="user"},[Me==null?void 0:Me.collaborationMode,Me==null?void 0:Me.status,Ot,At]),$e=()=>{Fe&&u.sendPrompt({conversationId:Fe,text:"请按上面的计划开始执行。",collaborationMode:"default",model:Me==null?void 0:Me.model,reasoningEffort:Me==null?void 0:Me.reasoningEffort,permissionMode:Me==null?void 0:Me.permissionMode})};re.useEffect(()=>{const X=de=>{const Be=de.metaKey||de.ctrlKey;Be&&de.shiftKey&&de.key.toLowerCase()==="p"?(de.preventDefault(),$(Ke=>!Ke)):Be&&!de.shiftKey&&de.key.toLowerCase()==="k"?(de.preventDefault(),$(Ke=>!Ke)):Be&&!de.shiftKey&&de.key.toLowerCase()==="j"?(de.preventDefault(),y()):Be&&!de.shiftKey&&de.key.toLowerCase()==="f"?(de.preventDefault(),Q(!0),requestAnimationFrame(()=>{var Ke;return(Ke=P.current)==null?void 0:Ke.focus()})):de.key==="Escape"&&Q(!1)};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[]),re.useEffect(()=>{Q(!1),A("")},[Fe]);const Je=re.useRef(0),Gt=re.useRef(!0),ht=()=>{const X=le.current;X&&(Gt.current=X.scrollHeight-X.scrollTop-X.clientHeight<80,X.scrollTop<60&&Fe&&(wt!=null&&wt.hasMore)&&!wt.loading&&(Je.current=X.scrollHeight,u.loadOlderHistory(Fe)))};re.useLayoutEffect(()=>{const X=le.current;X&&(Je.current>0?(X.scrollTop=X.scrollHeight-Je.current,Je.current=0):Gt.current&&(X.scrollTop=X.scrollHeight))},[At.length,Fe]);const Qt=(X,de)=>{de?En(X,de):W(X)},En=(X,de)=>{const Be=pn.find(gt=>gt.id===X),Ke=u.openConversation({provider:X,cwd:de,model:Be==null?void 0:Be.defaultModel});u.setActiveConversation(Ke),W(null)},vn=(X,de)=>{Fe&&u.sendPrompt({conversationId:Fe,text:X,images:de.map(Be=>({data:Be.data,mimeType:Be.mimeType})),model:Me==null?void 0:Me.model,reasoningEffort:Me==null?void 0:Me.reasoningEffort,permissionMode:Me==null?void 0:Me.permissionMode,collaborationMode:Me==null?void 0:Me.collaborationMode})},Wt=lD(f.status),rn=f.externalAgentStatus==="running"||f.externalAgentStatus==="waiting_permission"||f.externalAgentStatus==="error",sn=Xv(rn?f.externalAgentStatus??void 0:Me==null?void 0:Me.status),Ii=rn?f.externalAgentTitle??"外部终端":Me==null?void 0:Me.provider,rr=rn?f.externalAgentStatus==="running":(Me==null?void 0:Me.status)==="running",zr=hD(rr),ei=rn?null:cD(Me==null?void 0:Me.usage),fi=`CLI 设备 · ${e.slice(0,8)}`,Z=Me==null?void 0:Me.cwd,_e=re.useCallback(()=>{u.client.spawnTerminal(Z||".")},[u,Z]),Re=pn.filter(X=>X.enabled),Ze=re.useMemo(()=>{const X=[];for(const de of Re)X.push({id:`new-${de.id}`,label:`新建 ${de.label} 对话`,group:"新建",keywords:`new conversation ${de.id}`,icon:C.jsx(Ro,{size:15}),run:()=>Qt(de.id)});for(const de of f.conversations.filter(Be=>!Be.archived)){const Be=de.title&&de.title.trim()||de.lastMessagePreview&&de.lastMessagePreview.trim().slice(0,40)||`对话 ${de.id.slice(-6)}`;X.push({id:`conv-${de.id}`,label:Be,group:"对话",hint:de.cwd?de.cwd.split("/").slice(-1)[0]:void 0,keywords:`${de.provider} ${de.cwd??""}`,icon:C.jsx(ea,{provider:de.provider,size:15}),run:()=>u.setActiveConversation(de.id)})}return Fe&&Ot&&X.push({id:"cancel",label:"停止当前回合",group:"操作",keywords:"cancel stop interrupt",icon:C.jsx(eb,{size:15}),run:()=>u.cancel(Fe)}),Fe&&X.push({id:"search",label:"在对话中搜索",group:"操作",hint:"⌘F",keywords:"search find filter",icon:C.jsx(ls,{size:15}),run:()=>{Q(!0),requestAnimationFrame(()=>{var de;return(de=P.current)==null?void 0:de.focus()})}}),X.push({id:"panel-terminal",label:"切换终端",group:"操作",hint:"⌘J",keywords:"terminal shell",icon:C.jsx(Ed,{size:15}),run:y},{id:"panel-files",label:"打开文件浏览器",group:"操作",keywords:"files browse",icon:C.jsx(Lr,{size:15}),run:()=>d(de=>de==="files"?"none":"files")},{id:"panel-preview",label:"打开端口预览",group:"操作",keywords:"preview port browser localhost tunnel",icon:C.jsx(hc,{size:15}),run:()=>d(de=>de==="preview"?"none":"preview")}),X},[Re,f.conversations,Fe,Ot]);return C.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[C.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-2",style:{paddingTop:"max(0.5rem, env(safe-area-inset-top))"},children:[C.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o&&C.jsx("button",{onClick:()=>N(!0),className:"codex-btn-ghost shrink-0 px-2 py-1.5","aria-label":"打开会话列表",children:C.jsx(AS,{size:17})}),C.jsx("button",{onClick:r,className:"codex-btn-ghost shrink-0 text-2xs","aria-label":"返回会话列表",children:"← 会话"}),C.jsxs("span",{className:`flex shrink-0 items-center gap-1 text-2xs ${Wt.color}`,children:[C.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),!o&&Wt.text]}),sn&&C.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${sn.className}`,title:rn?"外部终端状态":"当前对话状态",children:[sn.pulsing&&C.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current animate-pulse-dot"}),Ii&&C.jsx("span",{className:"min-w-0 truncate",children:Ii}),C.jsxs("span",{className:"shrink-0",children:[Ii?"· ":"",sn.text]}),rr&&C.jsx("span",{className:"shrink-0 font-mono tabular-nums opacity-70",children:uD(zr)})]}),ei&&C.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:ei.title,children:ei.text}),(($t=f.usage)==null?void 0:$t.totals)&&C.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:"全机用量",children:[C.jsx(g_,{size:12}),uc(f.usage.totals.totalTokens)]}),f.lastError&&C.jsx("button",{onClick:()=>u.dismissError(),className:"min-w-0 truncate rounded-full border border-danger/30 bg-danger/10 px-2 py-0.5 text-2xs text-danger",title:`${f.lastError.message}(点击关闭)`,children:f.lastError.code})]}),C.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[C.jsx("button",{onClick:()=>{Fe&&(Q(!0),requestAnimationFrame(()=>{var X;return(X=P.current)==null?void 0:X.focus()}))},disabled:!Fe,className:"codex-btn-ghost px-2 py-1.5 disabled:opacity-40",title:"在对话中搜索 (⌘/Ctrl+F)","aria-label":"在对话中搜索",children:C.jsx(ls,{size:16})}),!l&&C.jsx(tD,{}),C.jsx("button",{onClick:()=>d(X=>X==="preview"?"none":"preview"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="preview"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"端口预览","aria-label":"端口预览",children:C.jsx(hc,{size:16})}),C.jsx("button",{onClick:()=>d(X=>X==="files"?"none":"files"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="files"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"文件","aria-label":"文件",children:C.jsx(Lr,{size:16})}),C.jsx("button",{onClick:y,className:`cursor-pointer rounded-md p-1.5 transition-colors ${m?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"终端 (⌘J)","aria-label":"终端",children:C.jsx(Ed,{size:16})}),C.jsx("button",{onClick:()=>{u.requestUsage(),q(!0)},className:`cursor-pointer rounded-md p-1.5 transition-colors ${H?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"用量统计","aria-label":"用量统计",children:C.jsx(g_,{size:16})})]})]}),C.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[f.status==="host_disconnected"&&C.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-canvas/80 backdrop-blur-sm",children:C.jsxs("div",{className:"codex-card-raised mx-4 flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center animate-fade-in",children:[C.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-warning/15 text-warning",children:C.jsx(OS,{size:24})}),C.jsx("h2",{className:"text-base font-semibold text-content-primary",children:"主机已离线"}),C.jsxs("p",{className:"text-sm leading-relaxed text-content-muted",children:["与该会话的主机连接已断开。请确认主机上的"," ",C.jsx("code",{className:"font-mono text-accent",children:"linkshell"})," 仍在运行。正在自动尝试重新连接…"]}),C.jsx("button",{onClick:r,className:"codex-btn-outline mt-1 text-2xs",children:"返回会话列表"})]})}),o?M&&C.jsxs("div",{className:"absolute inset-0 z-30 flex animate-fade-in",children:[C.jsxs("aside",{className:"flex w-[82%] max-w-xs flex-col border-r border-border bg-surface shadow-2xl animate-drawer-in",children:[C.jsx("div",{className:"flex items-center border-b border-border px-3 py-2",children:C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"})}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(Wv,{deviceLabel:fi,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:Fe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:X=>{u.setActiveConversation(X),N(!1)},onNewConversation:(X,de)=>{N(!1),Qt(X,de)},onOpenExternalTerminal:()=>{var de;const X=f.externalAgentConversationId||((de=f.conversations.find(Be=>Be.status==="running"||Be.status==="waiting_permission"))==null?void 0:de.id);X?(u.setActiveConversation(X),N(!1)):(N(!1),T())}})})]}),C.jsx("button",{className:"flex-1 bg-canvas/60 backdrop-blur-sm",onClick:()=>N(!1),"aria-label":"关闭"})]}):pe?C.jsx("div",{className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-surface py-2",children:C.jsx("button",{onClick:Ce,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"展开侧边栏","aria-label":"展开侧边栏",children:C.jsx(Si,{size:16})})}):C.jsxs("aside",{className:"relative flex shrink-0 flex-col border-r border-border bg-surface",style:{width:oe},children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[C.jsx("span",{className:"pl-1 text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),C.jsx("button",{onClick:Ce,className:"cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"收起侧边栏","aria-label":"收起侧边栏",children:C.jsx(NS,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(Wv,{deviceLabel:fi,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:Fe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:X=>u.setActiveConversation(X),onNewConversation:Qt,onOpenExternalTerminal:()=>{var de;const X=f.externalAgentConversationId||((de=f.conversations.find(Be=>Be.status==="running"||Be.status==="waiting_permission"))==null?void 0:de.id);X?u.setActiveConversation(X):T()}})}),C.jsx("div",{onPointerDown:He,className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"})]}),C.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:!Fe||!Me?C.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[C.jsx(lf,{size:44,className:"opacity-40"}),C.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:o?"点击左上角菜单选择对话,或新建一个开始":"从左侧选择一个对话,或新建一个开始"})]}):C.jsxs(C.Fragment,{children:[ne&&C.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[C.jsx(ls,{size:15,className:"shrink-0 text-content-faint"}),C.jsx("input",{ref:P,value:I,onChange:X=>A(X.target.value),onKeyDown:X=>X.key==="Escape"&&(Q(!1),A("")),placeholder:"在此对话中搜索…",className:"min-w-0 flex-1 bg-transparent text-sm text-content-primary placeholder-content-muted outline-none"}),C.jsx("button",{onClick:()=>{Q(!1),A("")},className:"codex-btn-ghost px-2 py-1","aria-label":"关闭搜索",children:C.jsx(hi,{size:14})})]}),C.jsx("div",{ref:le,onScroll:ht,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-8",children:C.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-6",children:[(wt==null?void 0:wt.loading)&&C.jsx("p",{className:"text-center text-2xs text-content-muted",children:"加载更早的消息…"}),ne&&I.trim()?(()=>{const X=I.trim(),de=At.filter(Be=>!oc(Be)&&fD(Be,X));return de.length===0?C.jsxs("p",{className:"py-12 text-center text-sm text-content-muted",children:["没有匹配「",X,"」的消息"]}):C.jsxs(C.Fragment,{children:[C.jsxs("p",{className:"text-center text-2xs text-content-faint",children:[de.length," 条匹配"]}),de.map(Be=>C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(Fv,{item:Be,canSteer:!1,onPermission:(Ke,gt,Nn)=>u.respondPermission(Fe,Ke,gt,Nn),onStructuredInput:(Ke,gt)=>u.respondStructuredInput(Fe,Ke,gt),onOpenDiff:Ke=>{R(Ke),d("none")},onOpenAgent:Ke=>{z(Ke),R(null),d("none")},onEditMessage:xe,highlightQuery:X})},Be.id))]})})():(()=>{const X=[];let de=[];const Be=()=>{de.length&&(X.push({k:"group",key:`grp-${de[0].id}`,items:de}),de=[])};for(const gt of At)oc(gt)||(yO(gt)?de.push(gt):(Be(),X.push({k:"item",item:gt})));Be();let Ke=-1;return X.forEach((gt,Nn)=>{gt.k==="group"&&(Ke=Nn)}),X.map((gt,Nn)=>gt.k==="item"?C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(Fv,{item:gt.item,canSteer:Me.provider==="codex"&&Ot,onPermission:(It,pi,Bi)=>u.respondPermission(Fe,It,pi,Bi),onStructuredInput:(It,pi)=>u.respondStructuredInput(Fe,It,pi),onSendQueued:It=>u.sendQueuedFollowUp(Fe,It,"new_turn"),onSteerQueued:It=>u.sendQueuedFollowUp(Fe,It,"steer"),onDiscardQueued:It=>u.discardQueuedFollowUp(Fe,It),onOpenDiff:It=>{R(It),d("none")},onOpenAgent:It=>{z(It),R(null),d("none")},onEditMessage:xe})},gt.item.id):C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(EO,{items:gt.items,live:Ot&&Nn===Ke,onOpenDiff:It=>{R(It),d("none")},onOpenAgent:It=>{z(It),R(null),d("none")}})},gt.key))})(),At.length===0&&(Me!=null&&Me.lastMessagePreview||wt!=null&&wt.loading?C.jsxs("div",{className:"flex flex-col items-center gap-2 py-16 text-content-muted",children:[C.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"}),C.jsx("p",{className:"text-sm",children:"加载对话记录…"})]}):C.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"发送第一条指令…"}))]})}),C.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-3xl px-4 pb-4",children:[Ie&&C.jsxs("div",{className:"mb-2 flex items-center gap-3 rounded-xl border border-accent-dim/40 bg-surface px-3.5 py-2.5 animate-slide-in",children:[C.jsx("span",{className:"min-w-0 flex-1 text-sm text-content-secondary",children:"计划已就绪。执行它,或在下方继续补充。"}),C.jsx("button",{onClick:$e,className:"codex-btn-primary shrink-0 text-xs",children:"执行计划"})]}),C.jsx(xO,{items:At.filter(oc),canSteer:Me.provider==="codex"&&Ot,onSend:X=>u.sendQueuedFollowUp(Fe,X,"new_turn"),onSteer:X=>u.sendQueuedFollowUp(Fe,X,"steer"),onDiscard:X=>u.discardQueuedFollowUp(Fe,X)}),C.jsx(CO,{disabled:f.status!=="connected",running:Ot,supportsImages:Nt==null?void 0:Nt.supportsImages,commands:Nt==null?void 0:Nt.commands,conversationId:Fe,lastUserText:ue,cwd:Me.cwd,onBrowse:X=>u.browse(X,!0),seedText:G,controls:C.jsx($O,{conversation:Me,capability:Nt,onChange:X=>u.updateConversationSettings(Fe,X)}),onSend:vn,onCancel:()=>u.cancel(Fe),onExecuteCommand:(X,de)=>u.executeCommand(Fe,X,de)})]}),(m||x)&&C.jsxs("div",{className:`relative shrink-0 overflow-hidden border-t border-border bg-surface ${x?"animate-panel-out-down":"animate-panel-in-up"}`,style:{height:k},onAnimationEnd:()=>{x&&(S(!1),p(!1))},children:[C.jsx("div",{onPointerDown:Tt,className:"absolute left-0 right-0 top-0 z-10 h-1 cursor-row-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整终端高度"}),C.jsx(BO,{bridge:u.client,onNewTerminal:_e})]})]})}),(()=>{let X=null;L?X=C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"子 Agent"}),C.jsx("button",{onClick:()=>z(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭",children:C.jsx(hi,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(vO,{detail:L})})]}):O?X=C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"文件差异"}),C.jsx("button",{onClick:()=>R(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭差异",children:C.jsx(hi,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(cO,{item:O})})]}):h==="files"?X=C.jsx(qO,{store:u,initialPath:(Me==null?void 0:Me.cwd)||".",onClose:()=>d("none")}):h==="preview"&&(X=C.jsx(YO,{gatewayUrl:a.httpUrl,sessionId:e,initialAuthToken:(n==null?void 0:n.accessToken)??null,isMobile:o,onClose:()=>d("none"),onAnnotate:Nn=>{K(It=>({text:Nn,nonce:It.nonce+1})),o&&d("none")}}));const de=re.useRef(null);X!==null&&(de.current=X);const Be=X!==null,Ke=dD(Be,"animate-panel-in-right","animate-panel-out-right");if(!Ke.render&&!Be)return null;const gt=Be?X:de.current;return o?C.jsx("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${Ke.className||"animate-fade-in"}`,onAnimationEnd:Ke.onAnimationEnd,children:gt}):C.jsxs("aside",{className:`relative flex shrink-0 flex-col border-l border-border ${Ke.className}`,style:{width:j},onAnimationEnd:Ke.onAnimationEnd,children:[C.jsx("div",{onPointerDown:ke,className:"absolute left-0 top-0 z-10 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"}),gt]})})()]}),F&&C.jsx(KO,{store:u,initialPath:(Me==null?void 0:Me.cwd)||".",providerLabel:((De=pn.find(X=>X.id===F))==null?void 0:De.label)??F,onCancel:()=>W(null),onConfirm:X=>En(F,X)}),f.notices.length>0&&C.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex w-80 flex-col gap-2",children:f.notices.map(X=>C.jsxs("button",{onClick:()=>u.dismissNotice(X.id),className:`codex-card-raised pointer-events-auto animate-fade-in cursor-pointer px-3 py-2 text-left ${X.kind==="warning"?"border-warning/40":""}`,children:[C.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-content-primary",children:[C.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${X.kind==="warning"?"bg-warning":"bg-accent"}`}),X.title]}),X.detail&&C.jsx("p",{className:"mt-0.5 pl-3 text-2xs text-content-muted",children:X.detail})]},X.id))}),C.jsx(oD,{open:B,onClose:()=>$(!1),actions:Ze}),H&&C.jsx(o1,{report:f.usage,onClose:()=>q(!1)})]})}eD();function mD(){const[e,n]=re.useState(null),[r,a]=re.useState(!1),[l,u]=re.useState(!1),f=re.useMemo(()=>iD(nD()),[]),o=re.useMemo(()=>c0(),[]),[h,d]=re.useState(()=>f??ZS()),m=p=>{d(p),v_(p)};return re.useEffect(()=>{const p=Cc();p&&n(p),a(!0),p&&nf().then(x=>{x&&n(x)})},[]),re.useEffect(()=>{if(!o)return;const p=window;return p.__linkshellSetTheme=x=>{(x==="dark"||x==="light")&&Bf(x)},()=>{delete p.__linkshellSetTheme}},[o]),re.useEffect(()=>yS(()=>{n(null),u(!1),d(p=>p.name==="list"?p:{name:"list"}),v_({name:"list"})}),[]),r?l?C.jsx(jS,{onLogin:p=>{n(p),u(!1)},onCancel:()=>u(!1)}):h.name==="console"?C.jsx(pD,{sessionId:h.sessionId,session:e,onBack:o?rD:()=>m({name:"list"})}):C.jsx(u1,{session:e,onLogin:()=>u(!0),onLogout:()=>{n(null),m({name:"list"})},onOpenSession:p=>m({name:"console",sessionId:p})}):null}bS.createRoot(document.getElementById("root")).render(C.jsx(mD,{}));
94
+ `)),z(null),q(""),K({}),Q({}),W(!1),R(null),T(!1)},Ce=()=>{z(null),q(""),K({}),Q({}),W(!1)},He=()=>{N(null),Ce(),R(null),T(Ee=>!Ee)};return C.jsxs("div",{className:"flex h-full flex-col bg-canvas",children:[C.jsxs("div",{className:"flex items-center gap-1.5 border-b border-border bg-surface px-2 py-1.5",children:[l&&C.jsx("button",{onClick:u,className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭预览",children:C.jsx(hi,{size:15})}),C.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1 rounded-lg border border-border bg-surface-raised px-2 py-1",children:[C.jsx("span",{className:"shrink-0 font-mono text-2xs text-content-faint",children:"localhost:"}),C.jsx("input",{value:o,onChange:Ee=>h(Ee.target.value),onKeyDown:Ee=>Ee.key==="Enter"&&P(),placeholder:"3000",spellCheck:!1,className:"min-w-0 flex-1 bg-transparent font-mono text-2xs text-content-primary outline-none","aria-label":"端口与路径"}),C.jsx("button",{onClick:P,className:"shrink-0 cursor-pointer rounded bg-accent-dim px-2 py-0.5 text-2xs font-medium text-white transition-colors hover:bg-accent",children:"前往"})]}),C.jsx("button",{onClick:He,disabled:!d,className:`shrink-0 cursor-pointer rounded-md p-1.5 transition-colors disabled:opacity-40 ${y?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-accent"}`,title:"标注元素","aria-label":"标注元素",children:C.jsx(zS,{size:14})}),C.jsxs("div",{className:"flex shrink-0 items-center rounded-lg border border-border bg-surface-raised p-0.5",children:[C.jsx("button",{onClick:()=>_("desktop"),className:`cursor-pointer rounded p-1 transition-colors ${w==="desktop"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"桌面视口","aria-label":"桌面视口",children:C.jsx(tb,{size:13})}),C.jsx("button",{onClick:()=>_("mobile"),className:`cursor-pointer rounded p-1 transition-colors ${w==="mobile"?"bg-surface-overlay text-content-primary":"text-content-muted hover:text-content-primary"}`,title:"移动视口","aria-label":"移动视口",children:C.jsx(PS,{size:13})})]}),C.jsx("button",{onClick:oe,disabled:!d,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"刷新","aria-label":"刷新",children:C.jsx(kc,{size:14})}),C.jsx("button",{onClick:()=>$&&window.open($,"_blank","noopener,noreferrer"),disabled:!$,className:"shrink-0 cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-accent disabled:opacity-40",title:"在新窗口打开","aria-label":"在新窗口打开",children:C.jsx(BS,{size:14})})]}),M&&C.jsx("p",{className:"border-b border-border bg-warning/10 px-3 py-1.5 text-2xs text-warning",children:M}),y&&!L&&C.jsx("p",{className:"border-b border-border bg-accent/10 px-3 py-1.5 text-2xs text-accent",children:"标注模式:移动鼠标高亮元素,点击选择并添加批注。"}),C.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-surface-raised",children:$?C.jsx("div",{className:w==="mobile"?"mx-auto h-full w-[390px] max-w-full border-x border-border":"h-full w-full",children:C.jsxs("div",{className:"relative h-full w-full",children:[C.jsx("iframe",{ref:I,src:$,title:"端口预览",onLoad:ye,className:"h-full w-full bg-white"},`${$}-${b}`),y&&C.jsx("div",{className:"absolute inset-0 cursor-crosshair",onMouseMove:j,onMouseLeave:()=>R(null),onClick:me,children:O&&!L&&C.jsx("div",{className:"pointer-events-none absolute border-2 border-accent bg-accent/10",style:{top:O.top,left:O.left,width:O.width,height:O.height}})}),L&&(()=>{var Ot,wt;const ke=((Ot=A.current)==null?void 0:Ot.clientHeight)??600,Tt=L.rect.top+L.rect.height+8,Fe=L.rect.top-8,At=F?340:140,pn=Tt+At>ke&&Fe-At>0?Math.max(4,Fe-At):Tt,Nt=Math.max(4,Math.min(L.rect.left,(((wt=A.current)==null?void 0:wt.clientWidth)??800)-280-4));return C.jsxs("div",{className:"absolute z-20 flex flex-col gap-2 rounded-xl border border-accent-dim/40 bg-surface-raised px-3 py-2.5 shadow-2xl animate-fade-in",style:{top:pn,left:Nt,width:280,maxHeight:ke-pn-8},children:[C.jsx("p",{className:"truncate font-mono text-2xs text-content-faint",title:L.selector,children:L.selector}),L.text&&C.jsxs("p",{className:"-mt-1 truncate text-2xs text-content-muted",children:['"',L.text,'"']}),C.jsx("input",{value:H,onChange:ue=>q(ue.target.value),onKeyDown:ue=>ue.key==="Enter"&&le(),autoFocus:!0,placeholder:"添加批注…",className:"w-full rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs text-content-primary placeholder-content-muted outline-none focus:border-accent-dim"}),C.jsxs("button",{onClick:()=>W(ue=>!ue),className:`flex cursor-pointer items-center gap-1 self-start rounded-md px-1.5 py-0.5 text-2xs transition-colors ${F?"text-accent":"text-content-muted hover:text-content-secondary"}`,children:[C.jsx("svg",{width:10,height:10,viewBox:"0 0 10 10",className:`shrink-0 transition-transform ${F?"rotate-180":""}`,children:C.jsx("path",{d:"M2 3.5 L5 6.5 L8 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})}),"调整样式"]}),F&&C.jsx("div",{className:"grid grid-cols-2 gap-x-2 gap-y-1.5 animate-fade-in",children:o0.map(({cssProp:ue,label:xe})=>{const Ie=ne[ue]??G[ue]??"",$e=ue in ne&&ne[ue]!==(G[ue]??"");return C.jsxs("label",{className:"flex flex-col gap-0.5",children:[C.jsx("span",{className:`text-2xs ${$e?"text-accent":"text-content-faint"}`,children:xe}),C.jsx("input",{value:Ie,onChange:Je=>ce(ue,Je.target.value),spellCheck:!1,className:"w-full rounded-md border border-border bg-surface px-2 py-1 font-mono text-2xs text-content-primary outline-none focus:border-accent-dim"})]},ue)})}),C.jsxs("div",{className:"flex items-center gap-2",children:[C.jsx("button",{onClick:Ce,className:"codex-btn-ghost flex-1 text-2xs",children:"取消"}),C.jsx("button",{onClick:le,className:"codex-btn-primary flex-1 text-2xs",children:"发送给 Agent"})]})]})})()]})}):C.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[C.jsx(hc,{size:34,className:"text-content-faint"}),C.jsx("p",{className:"text-sm leading-6 text-content-muted",children:d&&!S?"正在准备预览认证...":"输入主机上服务的端口号,预览远程本地服务"})]})})]})}const l0="linkshell_theme",wc=new Set;let Uc=ZO();function ZO(){try{const e=localStorage.getItem(l0);if(e==="light"||e==="dark"||e==="system")return e}catch{}return"dark"}function XO(){return typeof window<"u"&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)").matches:!0}function QO(e=Uc){return e==="system"?XO()?"dark":"light":e}function Zd(){typeof document>"u"||document.documentElement.setAttribute("data-theme",QO())}function Yv(){return Uc}function Bf(e){Uc=e;try{localStorage.setItem(l0,e)}catch{}Zd();for(const n of wc)n()}function JO(e){return wc.add(e),()=>wc.delete(e)}function eD(){var e;if(Zd(),typeof window<"u"&&window.matchMedia){const n=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>{if(Uc==="system"){Zd();for(const a of wc)a()}};(e=n.addEventListener)==null||e.call(n,"change",r)}}const xd=["light","dark","system"],Zv={light:"浅色",dark:"深色",system:"跟随系统"};function tD(){const e=re.useSyncExternalStore(JO,Yv,Yv),n=()=>Bf(xd[(xd.indexOf(e)+1)%xd.length]),r=e==="light"?RS:e==="dark"?MS:tb;return C.jsx("button",{onClick:n,className:"codex-btn-ghost px-2 py-1.5",title:`主题:${Zv[e]}(点击切换)`,"aria-label":`主题:${Zv[e]}`,children:C.jsx(r,{size:15})})}function nD(){try{const e=new URLSearchParams(window.location.search),n=e.get("embed")==="1",r=e.get("theme");return{embed:n,sessionId:e.get("session"),gateway:e.get("gateway"),token:e.get("token"),theme:r==="dark"||r==="light"?r:null}}catch{return{embed:!1,sessionId:null,gateway:null,token:null,theme:null}}}function iD(e){return!e.embed||!e.sessionId||!e.token||!e.gateway?null:(rb(e.gateway),uf(e.token),e.theme&&Bf(e.theme),Cd([{id:e.sessionId,state:"active",hasHost:!0,clientCount:1,provider:null,machineId:null,hostname:null,platform:null,projectName:null,cwd:null,lastActivity:Date.now()}]),{name:"console",sessionId:e.sessionId})}function rD(){try{const e=window.ReactNativeWebView;e==null||e.postMessage(JSON.stringify({type:"requestClose"}))}catch{}}const sD="linkshell_embed";function c0(){try{return new URLSearchParams(window.location.search).get("embed")==="1"?!0:localStorage.getItem(sD)==="1"}catch{return!1}}function aD(e,n){if(!e)return 0;const r=e.toLowerCase(),a=n.toLowerCase();let l=0,u=0,f=-1;for(let o=0;o<r.length;o++){const h=r[o],d=a.indexOf(h,l);if(d===-1)return null;f>=0?u+=d-f-1:u+=d,f=d,l=d+1}return u}function oD({open:e,onClose:n,actions:r,placeholder:a="搜索命令、对话…"}){const[l,u]=re.useState(""),[f,o]=re.useState(0),h=re.useRef(null);re.useEffect(()=>{e&&(u(""),o(0),requestAnimationFrame(()=>{var k;return(k=h.current)==null?void 0:k.focus()}))},[e]);const d=re.useMemo(()=>r.map(w=>({a:w,score:aD(l,`${w.label} ${w.hint??""} ${w.keywords??""}`)})).filter(w=>w.score!==null).sort((w,_)=>w.score-_.score).map(w=>w.a),[r,l]);if(re.useEffect(()=>{o(k=>Math.min(k,Math.max(0,d.length-1)))},[d.length]),!e)return null;const m=k=>{const w=d[k];w&&(n(),w.run())},p=k=>{k.key==="ArrowDown"?(k.preventDefault(),o(w=>Math.min(w+1,d.length-1))):k.key==="ArrowUp"?(k.preventDefault(),o(w=>Math.max(w-1,0))):k.key==="Enter"?(k.preventDefault(),m(f)):k.key==="Escape"&&(k.preventDefault(),n())};let x=-1;const S=new Map;for(const k of d){const w=k.group??"",_=S.get(w)??[];_.push(k),S.set(w,_)}return C.jsx("div",{className:"fixed inset-0 z-[60] flex items-start justify-center bg-canvas/60 px-4 pt-[12vh] backdrop-blur-sm animate-fade-in",onClick:n,children:C.jsxs("div",{className:"codex-card-raised w-full max-w-xl overflow-hidden",onClick:k=>k.stopPropagation(),children:[C.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3.5 py-3",children:[C.jsx(ls,{size:16,className:"shrink-0 text-content-faint"}),C.jsx("input",{ref:h,value:l,onChange:k=>u(k.target.value),onKeyDown:p,placeholder:a,className:"min-w-0 flex-1 bg-transparent text-[15px] text-content-primary placeholder-content-muted outline-none"}),C.jsx("kbd",{className:"shrink-0 rounded border border-border px-1.5 py-0.5 font-mono text-2xs text-content-faint",children:"esc"})]}),C.jsx("div",{className:"max-h-[50vh] overflow-y-auto p-1.5",children:d.length===0?C.jsx("p",{className:"px-3 py-6 text-center text-sm text-content-muted",children:"没有匹配项"}):[...S.entries()].map(([k,w])=>C.jsxs("div",{className:"mb-1",children:[k&&C.jsx("p",{className:"px-2.5 pb-1 pt-2 text-2xs font-semibold uppercase tracking-wider text-content-faint",children:k}),w.map(_=>{x+=1;const b=x;return C.jsxs("button",{onMouseEnter:()=>o(b),onClick:()=>m(b),className:`flex w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 py-2 text-left transition-colors ${b===f?"bg-surface-overlay":"hover:bg-surface-overlay"}`,children:[_.icon&&C.jsx("span",{className:"shrink-0 text-content-muted",children:_.icon}),C.jsx("span",{className:"min-w-0 flex-1 truncate text-sm text-content-primary",children:_.label}),_.hint&&C.jsx("span",{className:"shrink-0 text-2xs text-content-faint",children:_.hint})]},_.id)})]},k||"_"))})]})})}function lD(e){return e==="connected"?{text:"已连接",color:"text-success"}:e==="connecting"||e==="reconnecting"||e==="claiming"?{text:"连接中",color:"text-warning"}:e==="host_disconnected"?{text:"主机离线",color:"text-warning"}:e.startsWith("error")?{text:"错误",color:"text-danger"}:{text:"未连接",color:"text-content-muted"}}function Xv(e){switch(e){case"running":return{text:"运行中",className:"border-success/30 bg-success/10 text-success",pulsing:!0};case"waiting_permission":return{text:"等待授权",className:"border-warning/40 bg-warning/10 text-warning",pulsing:!0};case"error":return{text:"异常",className:"border-danger/30 bg-danger/10 text-danger"};case"idle":return{text:"空闲",className:"border-border bg-surface-overlay text-content-muted"};case"unavailable":return{text:"不可用",className:"border-border bg-surface-overlay text-content-faint"};default:return null}}function uc(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cD(e){if(!e)return null;const n=e.inputTokens!=null||e.cacheReadTokens!=null?(e.inputTokens??0)+(e.cacheReadTokens??0):null,r=[];let a="";if(n!=null&&e.contextWindow&&e.contextWindow>0){const l=Math.min(100,Math.round(n/e.contextWindow*100));r.push(`${l}%`),a=`上下文 ${uc(n)} / ${uc(e.contextWindow)} tokens`}else{const l=e.totalTokens??n??e.outputTokens??null;l!=null&&(r.push(uc(l)),a=`${l.toLocaleString()} tokens`)}return typeof e.totalCostUsd=="number"&&e.totalCostUsd>0&&(r.push(`$${e.totalCostUsd.toFixed(e.totalCostUsd<1?3:2)}`),a=a?`${a} · $${e.totalCostUsd.toFixed(4)}`:`$${e.totalCostUsd.toFixed(4)}`),r.length===0?null:{text:r.join(" · "),title:a}}function uD(e){const n=Math.max(0,Math.floor(e)),r=Math.floor(n/3600),a=Math.floor(n%3600/60),l=n%60;return r>0?`${r}h ${String(a).padStart(2,"0")}m ${String(l).padStart(2,"0")}s`:a>0?`${a}m ${String(l).padStart(2,"0")}s`:`${l}s`}function hD(e){const[n,r]=re.useState(0),a=re.useRef(null);return re.useEffect(()=>{if(!e){a.current=null,r(0);return}a.current=Date.now(),r(0);const l=setInterval(()=>{a.current!=null&&r(Math.floor((Date.now()-a.current)/1e3))},1e3);return()=>clearInterval(l)},[e]),n}function dD(e,n,r){const[a,l]=re.useState(()=>({render:e,className:e?n:""})),u=re.useRef(e);re.useEffect(()=>{e&&!u.current?l({render:!0,className:n}):!e&&u.current&&l({render:!0,className:r}),u.current=e},[e,n,r]);const f=re.useCallback(()=>{u.current||l({render:!1,className:""})},[]);return{render:a.render,className:a.className,onAnimationEnd:f}}function fD(e,n){var l,u,f,o,h,d,m,p;const r=n.toLowerCase();return[e.text,(l=e.commandExecution)==null?void 0:l.command,(u=e.commandExecution)==null?void 0:u.output,(f=e.toolCall)==null?void 0:f.name,(o=e.toolCall)==null?void 0:o.input,(h=e.toolCall)==null?void 0:h.output,(d=e.fileChange)==null?void 0:d.summary,...((p=(m=e.fileChange)==null?void 0:m.entries)==null?void 0:p.map(x=>x.path))??[],e.error].some(x=>typeof x=="string"&&x.toLowerCase().includes(r))}function pD({sessionId:e,session:n,onBack:r}){var Ut,$t,De;const a=re.useMemo(()=>ib(),[]),l=re.useMemo(()=>c0(),[]),{store:u,snapshot:f}=Ww(a,e),o=i0(),[h,d]=re.useState("none"),[m,p]=re.useState(!1),[x,S]=re.useState(!1),[k,w]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_terminal_h"));return X>=120&&X<=600?X:320}),_=re.useRef(!1),b=re.useRef(k);b.current=k;const v=re.useRef(m);v.current=m;const y=re.useCallback(()=>{v.current?S(!0):p(!0)},[]),T=re.useCallback(()=>{S(!1),p(!0)},[]),[M,N]=re.useState(!1),[O,R]=re.useState(null),[L,z]=re.useState(null),[H,q]=re.useState(!1),[F,W]=re.useState(null),[G,K]=re.useState({text:"",nonce:0}),[ne,Q]=re.useState(!1),[I,A]=re.useState(""),[B,$]=re.useState(!1),P=re.useRef(null),[oe,ye]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_sidebar_w"));return X>=180&&X<=520?X:256}),[pe,J]=re.useState(()=>localStorage.getItem("linkshell_sidebar_collapsed")==="1"),[j,me]=re.useState(()=>{const X=Number(localStorage.getItem("linkshell_rightpanel_w"));return X>=320&&X<=1100?X:560}),ce=re.useRef(!1),ee=re.useRef(!1),le=re.useRef(null),Ce=()=>{J(X=>(localStorage.setItem("linkshell_sidebar_collapsed",X?"0":"1"),!X))},He=X=>{X.preventDefault(),ce.current=!0;const de=Ke=>{if(!ce.current)return;const gt=Math.min(520,Math.max(180,Ke.clientX));ye(gt)},Be=()=>{ce.current=!1,localStorage.setItem("linkshell_sidebar_w",String(Ee.current)),window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",Be)};window.addEventListener("pointermove",de),window.addEventListener("pointerup",Be)},Ee=re.useRef(oe);Ee.current=oe;const we=re.useRef(j);we.current=j;const ke=X=>{X.preventDefault(),ee.current=!0;const de=Ke=>{if(!ee.current)return;const gt=Math.min(1100,Math.max(320,window.innerWidth-Ke.clientX));me(gt)},Be=()=>{ee.current=!1,localStorage.setItem("linkshell_rightpanel_w",String(we.current)),window.removeEventListener("pointermove",de),window.removeEventListener("pointerup",Be)};window.addEventListener("pointermove",de),window.addEventListener("pointerup",Be)},Tt=X=>{X.preventDefault(),_.current=!0;const de=X.clientY,Be=b.current,Ke=Nn=>{if(!_.current)return;const It=Math.min(600,Math.max(120,Be+(de-Nn.clientY)));w(It)},gt=()=>{_.current=!1,localStorage.setItem("linkshell_terminal_h",String(b.current)),window.removeEventListener("pointermove",Ke),window.removeEventListener("pointerup",gt)};window.addEventListener("pointermove",Ke),window.addEventListener("pointerup",gt)},Fe=f.activeConversationId,At=Fe?f.timelines.get(Fe)??[]:[],Me=f.conversations.find(X=>X.id===Fe),pn=((Ut=f.capabilities)==null?void 0:Ut.providers)??[],Nt=Me?pn.find(X=>X.id===Me.provider):void 0,Ot=(Me==null?void 0:Me.status)==="running",wt=Fe?f.history.get(Fe):void 0,ue=re.useMemo(()=>{for(let X=At.length-1;X>=0;X--){const de=At[X];if(de.role==="user"&&de.text)return de.text}},[At]),xe=X=>{K(de=>({text:X,nonce:de.nonce+1}))},Ie=re.useMemo(()=>{if((Me==null?void 0:Me.collaborationMode)!=="plan"||Ot||(Me==null?void 0:Me.status)==="waiting_permission")return!1;const X=[...At].reverse().find(de=>!oc(de));return X!=null&&X.role!=="user"},[Me==null?void 0:Me.collaborationMode,Me==null?void 0:Me.status,Ot,At]),$e=()=>{Fe&&u.sendPrompt({conversationId:Fe,text:"请按上面的计划开始执行。",collaborationMode:"default",model:Me==null?void 0:Me.model,reasoningEffort:Me==null?void 0:Me.reasoningEffort,permissionMode:Me==null?void 0:Me.permissionMode})};re.useEffect(()=>{const X=de=>{const Be=de.metaKey||de.ctrlKey;Be&&de.shiftKey&&de.key.toLowerCase()==="p"?(de.preventDefault(),$(Ke=>!Ke)):Be&&!de.shiftKey&&de.key.toLowerCase()==="k"?(de.preventDefault(),$(Ke=>!Ke)):Be&&!de.shiftKey&&de.key.toLowerCase()==="j"?(de.preventDefault(),y()):Be&&!de.shiftKey&&de.key.toLowerCase()==="f"?(de.preventDefault(),Q(!0),requestAnimationFrame(()=>{var Ke;return(Ke=P.current)==null?void 0:Ke.focus()})):de.key==="Escape"&&Q(!1)};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[]),re.useEffect(()=>{Q(!1),A("")},[Fe]);const Je=re.useRef(0),Gt=re.useRef(!0),ht=()=>{const X=le.current;X&&(Gt.current=X.scrollHeight-X.scrollTop-X.clientHeight<80,X.scrollTop<60&&Fe&&(wt!=null&&wt.hasMore)&&!wt.loading&&(Je.current=X.scrollHeight,u.loadOlderHistory(Fe)))};re.useLayoutEffect(()=>{const X=le.current;X&&(Je.current>0?(X.scrollTop=X.scrollHeight-Je.current,Je.current=0):Gt.current&&(X.scrollTop=X.scrollHeight))},[At.length,Fe]);const Qt=(X,de)=>{de?En(X,de):W(X)},En=(X,de)=>{const Be=pn.find(gt=>gt.id===X),Ke=u.openConversation({provider:X,cwd:de,model:Be==null?void 0:Be.defaultModel});u.setActiveConversation(Ke),W(null)},vn=(X,de)=>{Fe&&u.sendPrompt({conversationId:Fe,text:X,images:de.map(Be=>({data:Be.data,mimeType:Be.mimeType})),model:Me==null?void 0:Me.model,reasoningEffort:Me==null?void 0:Me.reasoningEffort,permissionMode:Me==null?void 0:Me.permissionMode,collaborationMode:Me==null?void 0:Me.collaborationMode})},Wt=lD(f.status),rn=f.externalAgentStatus==="running"||f.externalAgentStatus==="waiting_permission"||f.externalAgentStatus==="error",sn=Xv(rn?f.externalAgentStatus??void 0:Me==null?void 0:Me.status),Ii=rn?f.externalAgentTitle??"外部终端":Me==null?void 0:Me.provider,rr=rn?f.externalAgentStatus==="running":(Me==null?void 0:Me.status)==="running",zr=hD(rr),ei=rn?null:cD(Me==null?void 0:Me.usage),fi=`CLI 设备 · ${e.slice(0,8)}`,Z=Me==null?void 0:Me.cwd,_e=re.useCallback(()=>{u.client.spawnTerminal(Z||".")},[u,Z]),Re=pn.filter(X=>X.enabled),Ze=re.useMemo(()=>{const X=[];for(const de of Re)X.push({id:`new-${de.id}`,label:`新建 ${de.label} 对话`,group:"新建",keywords:`new conversation ${de.id}`,icon:C.jsx(Ro,{size:15}),run:()=>Qt(de.id)});for(const de of f.conversations.filter(Be=>!Be.archived)){const Be=de.title&&de.title.trim()||de.lastMessagePreview&&de.lastMessagePreview.trim().slice(0,40)||`对话 ${de.id.slice(-6)}`;X.push({id:`conv-${de.id}`,label:Be,group:"对话",hint:de.cwd?de.cwd.split("/").slice(-1)[0]:void 0,keywords:`${de.provider} ${de.cwd??""}`,icon:C.jsx(ea,{provider:de.provider,size:15}),run:()=>u.setActiveConversation(de.id)})}return Fe&&Ot&&X.push({id:"cancel",label:"停止当前回合",group:"操作",keywords:"cancel stop interrupt",icon:C.jsx(eb,{size:15}),run:()=>u.cancel(Fe)}),Fe&&X.push({id:"search",label:"在对话中搜索",group:"操作",hint:"⌘F",keywords:"search find filter",icon:C.jsx(ls,{size:15}),run:()=>{Q(!0),requestAnimationFrame(()=>{var de;return(de=P.current)==null?void 0:de.focus()})}}),X.push({id:"panel-terminal",label:"切换终端",group:"操作",hint:"⌘J",keywords:"terminal shell",icon:C.jsx(Ed,{size:15}),run:y},{id:"panel-files",label:"打开文件浏览器",group:"操作",keywords:"files browse",icon:C.jsx(Lr,{size:15}),run:()=>d(de=>de==="files"?"none":"files")},{id:"panel-preview",label:"打开端口预览",group:"操作",keywords:"preview port browser localhost tunnel",icon:C.jsx(hc,{size:15}),run:()=>d(de=>de==="preview"?"none":"preview")}),X},[Re,f.conversations,Fe,Ot]);return C.jsxs("div",{className:"flex h-[100dvh] flex-col overflow-hidden",children:[C.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-2",style:{paddingTop:"max(0.5rem, env(safe-area-inset-top))"},children:[C.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[o&&C.jsx("button",{onClick:()=>N(!0),className:"codex-btn-ghost shrink-0 px-2 py-1.5","aria-label":"打开会话列表",children:C.jsx(AS,{size:17})}),C.jsx("button",{onClick:r,className:"codex-btn-ghost shrink-0 text-2xs","aria-label":"返回会话列表",children:"← 会话"}),C.jsxs("span",{className:`flex shrink-0 items-center gap-1 text-2xs ${Wt.color}`,children:[C.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current"}),!o&&Wt.text]}),sn&&C.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1 rounded-full border px-2 py-0.5 text-2xs font-medium ${sn.className}`,title:rn?"外部终端状态":"当前对话状态",children:[sn.pulsing&&C.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current animate-pulse-dot"}),Ii&&C.jsx("span",{className:"min-w-0 truncate",children:Ii}),C.jsxs("span",{className:"shrink-0",children:[Ii?"· ":"",sn.text]}),rr&&C.jsx("span",{className:"shrink-0 font-mono tabular-nums opacity-70",children:uD(zr)})]}),ei&&!o&&C.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:ei.title,children:ei.text}),(($t=f.usage)==null?void 0:$t.totals)&&!o&&C.jsxs("span",{className:"inline-flex shrink-0 items-center gap-0.5 rounded-full border border-border bg-surface-overlay px-2 py-0.5 font-mono text-2xs tabular-nums text-content-muted",title:"全机用量",children:[C.jsx(g_,{size:12}),uc(f.usage.totals.totalTokens)]}),f.lastError&&C.jsx("button",{onClick:()=>u.dismissError(),className:"min-w-0 truncate rounded-full border border-danger/30 bg-danger/10 px-2 py-0.5 text-2xs text-danger",title:`${f.lastError.message}(点击关闭)`,children:f.lastError.code})]}),C.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[C.jsx("button",{onClick:()=>{Fe&&(Q(!0),requestAnimationFrame(()=>{var X;return(X=P.current)==null?void 0:X.focus()}))},disabled:!Fe,className:"codex-btn-ghost px-2 py-1.5 disabled:opacity-40",title:"在对话中搜索 (⌘/Ctrl+F)","aria-label":"在对话中搜索",children:C.jsx(ls,{size:16})}),!l&&C.jsx(tD,{}),!o&&C.jsx("button",{onClick:()=>d(X=>X==="preview"?"none":"preview"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="preview"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"端口预览","aria-label":"端口预览",children:C.jsx(hc,{size:16})}),C.jsx("button",{onClick:()=>d(X=>X==="files"?"none":"files"),className:`cursor-pointer rounded-md p-1.5 transition-colors ${h==="files"?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"文件","aria-label":"文件",children:C.jsx(Lr,{size:16})}),C.jsx("button",{onClick:y,className:`cursor-pointer rounded-md p-1.5 transition-colors ${m?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"终端 (⌘J)","aria-label":"终端",children:C.jsx(Ed,{size:16})}),C.jsx("button",{onClick:()=>{u.requestUsage(),q(!0)},className:`cursor-pointer rounded-md p-1.5 transition-colors ${H?"bg-accent-dim text-white":"text-content-muted hover:bg-surface-overlay hover:text-content-primary"}`,title:"用量统计","aria-label":"用量统计",children:C.jsx(g_,{size:16})})]})]}),C.jsxs("div",{className:"relative flex min-h-0 flex-1",children:[f.status==="host_disconnected"&&C.jsx("div",{className:"absolute inset-0 z-40 flex items-center justify-center bg-canvas/80 backdrop-blur-sm",children:C.jsxs("div",{className:"codex-card-raised mx-4 flex max-w-sm flex-col items-center gap-3 px-6 py-8 text-center animate-fade-in",children:[C.jsx("span",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-warning/15 text-warning",children:C.jsx(OS,{size:24})}),C.jsx("h2",{className:"text-base font-semibold text-content-primary",children:"主机已离线"}),C.jsxs("p",{className:"text-sm leading-relaxed text-content-muted",children:["与该会话的主机连接已断开。请确认主机上的"," ",C.jsx("code",{className:"font-mono text-accent",children:"linkshell"})," 仍在运行。正在自动尝试重新连接…"]}),C.jsx("button",{onClick:r,className:"codex-btn-outline mt-1 text-2xs",children:"返回会话列表"})]})}),o?M&&C.jsxs("div",{className:"absolute inset-0 z-30 flex animate-fade-in",children:[C.jsxs("aside",{className:"flex w-[82%] max-w-xs flex-col border-r border-border bg-surface shadow-2xl animate-drawer-in",children:[C.jsx("div",{className:"flex items-center border-b border-border px-3 py-2",children:C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"})}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(Wv,{deviceLabel:fi,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:Fe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:X=>{u.setActiveConversation(X),N(!1)},onNewConversation:(X,de)=>{N(!1),Qt(X,de)},onOpenExternalTerminal:()=>{var de;const X=f.externalAgentConversationId||((de=f.conversations.find(Be=>Be.status==="running"||Be.status==="waiting_permission"))==null?void 0:de.id);X?(u.setActiveConversation(X),N(!1)):(N(!1),T())}})})]}),C.jsx("button",{className:"flex-1 bg-canvas/60 backdrop-blur-sm",onClick:()=>N(!1),"aria-label":"关闭"})]}):pe?C.jsx("div",{className:"flex w-9 shrink-0 flex-col items-center border-r border-border bg-surface py-2",children:C.jsx("button",{onClick:Ce,className:"cursor-pointer rounded-md p-1.5 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"展开侧边栏","aria-label":"展开侧边栏",children:C.jsx(Si,{size:16})})}):C.jsxs("aside",{className:"relative flex shrink-0 flex-col border-r border-border bg-surface",style:{width:oe},children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-2 py-1",children:[C.jsx("span",{className:"pl-1 text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"会话"}),C.jsx("button",{onClick:Ce,className:"cursor-pointer rounded-md p-1 text-content-muted transition-colors hover:bg-surface-overlay hover:text-content-primary",title:"收起侧边栏","aria-label":"收起侧边栏",children:C.jsx(NS,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(Wv,{deviceLabel:fi,conversations:f.conversations,capabilities:f.capabilities,activeConversationId:Fe,externalAgentStatus:f.externalAgentStatus,externalAgentTitle:f.externalAgentTitle,externalAgentProvider:f.externalAgentProvider,store:u,onSelect:X=>u.setActiveConversation(X),onNewConversation:Qt,onOpenExternalTerminal:()=>{var de;const X=f.externalAgentConversationId||((de=f.conversations.find(Be=>Be.status==="running"||Be.status==="waiting_permission"))==null?void 0:de.id);X?u.setActiveConversation(X):T()}})}),C.jsx("div",{onPointerDown:He,className:"absolute right-0 top-0 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"})]}),C.jsx("main",{className:"flex min-w-0 flex-1 flex-col",children:!Fe||!Me?C.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[C.jsx(lf,{size:44,className:"opacity-40"}),C.jsx("p",{className:"text-[15px] leading-7 text-content-muted",children:o?"点击左上角菜单选择对话,或新建一个开始":"从左侧选择一个对话,或新建一个开始"})]}):C.jsxs(C.Fragment,{children:[ne&&C.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-surface px-4 py-2",children:[C.jsx(ls,{size:15,className:"shrink-0 text-content-faint"}),C.jsx("input",{ref:P,value:I,onChange:X=>A(X.target.value),onKeyDown:X=>X.key==="Escape"&&(Q(!1),A("")),placeholder:"在此对话中搜索…",className:"min-w-0 flex-1 bg-transparent text-sm text-content-primary placeholder-content-muted outline-none"}),C.jsx("button",{onClick:()=>{Q(!1),A("")},className:"codex-btn-ghost px-2 py-1","aria-label":"关闭搜索",children:C.jsx(hi,{size:14})})]}),C.jsx("div",{ref:le,onScroll:ht,className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-8",children:C.jsxs("div",{className:"mx-auto flex w-full min-w-0 max-w-3xl flex-col gap-6",children:[(wt==null?void 0:wt.loading)&&C.jsx("p",{className:"text-center text-2xs text-content-muted",children:"加载更早的消息…"}),ne&&I.trim()?(()=>{const X=I.trim(),de=At.filter(Be=>!oc(Be)&&fD(Be,X));return de.length===0?C.jsxs("p",{className:"py-12 text-center text-sm text-content-muted",children:["没有匹配「",X,"」的消息"]}):C.jsxs(C.Fragment,{children:[C.jsxs("p",{className:"text-center text-2xs text-content-faint",children:[de.length," 条匹配"]}),de.map(Be=>C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(Fv,{item:Be,canSteer:!1,onPermission:(Ke,gt,Nn)=>u.respondPermission(Fe,Ke,gt,Nn),onStructuredInput:(Ke,gt)=>u.respondStructuredInput(Fe,Ke,gt),onOpenDiff:Ke=>{R(Ke),d("none")},onOpenAgent:Ke=>{z(Ke),R(null),d("none")},onEditMessage:xe,highlightQuery:X})},Be.id))]})})():(()=>{const X=[];let de=[];const Be=()=>{de.length&&(X.push({k:"group",key:`grp-${de[0].id}`,items:de}),de=[])};for(const gt of At)oc(gt)||(yO(gt)?de.push(gt):(Be(),X.push({k:"item",item:gt})));Be();let Ke=-1;return X.forEach((gt,Nn)=>{gt.k==="group"&&(Ke=Nn)}),X.map((gt,Nn)=>gt.k==="item"?C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(Fv,{item:gt.item,canSteer:Me.provider==="codex"&&Ot,onPermission:(It,pi,Bi)=>u.respondPermission(Fe,It,pi,Bi),onStructuredInput:(It,pi)=>u.respondStructuredInput(Fe,It,pi),onSendQueued:It=>u.sendQueuedFollowUp(Fe,It,"new_turn"),onSteerQueued:It=>u.sendQueuedFollowUp(Fe,It,"steer"),onDiscardQueued:It=>u.discardQueuedFollowUp(Fe,It),onOpenDiff:It=>{R(It),d("none")},onOpenAgent:It=>{z(It),R(null),d("none")},onEditMessage:xe})},gt.item.id):C.jsx("div",{className:"min-w-0 animate-fade-in",children:C.jsx(EO,{items:gt.items,live:Ot&&Nn===Ke,onOpenDiff:It=>{R(It),d("none")},onOpenAgent:It=>{z(It),R(null),d("none")}})},gt.key))})(),At.length===0&&(Me!=null&&Me.lastMessagePreview||wt!=null&&wt.loading?C.jsxs("div",{className:"flex flex-col items-center gap-2 py-16 text-content-muted",children:[C.jsx("span",{className:"h-5 w-5 animate-spin rounded-full border-2 border-content-faint border-t-accent"}),C.jsx("p",{className:"text-sm",children:"加载对话记录…"})]}):C.jsx("p",{className:"py-12 text-center text-sm text-content-muted",children:"发送第一条指令…"}))]})}),C.jsxs("div",{className:"mx-auto w-full min-w-0 max-w-3xl px-4 pb-4",children:[Ie&&C.jsxs("div",{className:"mb-2 flex items-center gap-3 rounded-xl border border-accent-dim/40 bg-surface px-3.5 py-2.5 animate-slide-in",children:[C.jsx("span",{className:"min-w-0 flex-1 text-sm text-content-secondary",children:"计划已就绪。执行它,或在下方继续补充。"}),C.jsx("button",{onClick:$e,className:"codex-btn-primary shrink-0 text-xs",children:"执行计划"})]}),C.jsx(xO,{items:At.filter(oc),canSteer:Me.provider==="codex"&&Ot,onSend:X=>u.sendQueuedFollowUp(Fe,X,"new_turn"),onSteer:X=>u.sendQueuedFollowUp(Fe,X,"steer"),onDiscard:X=>u.discardQueuedFollowUp(Fe,X)}),C.jsx(CO,{disabled:f.status!=="connected",running:Ot,supportsImages:Nt==null?void 0:Nt.supportsImages,commands:Nt==null?void 0:Nt.commands,conversationId:Fe,lastUserText:ue,cwd:Me.cwd,onBrowse:X=>u.browse(X,!0),seedText:G,controls:C.jsx($O,{conversation:Me,capability:Nt,onChange:X=>u.updateConversationSettings(Fe,X)}),onSend:vn,onCancel:()=>u.cancel(Fe),onExecuteCommand:(X,de)=>u.executeCommand(Fe,X,de)})]}),(m||x)&&C.jsxs("div",{className:`relative shrink-0 overflow-hidden border-t border-border bg-surface ${x?"animate-panel-out-down":"animate-panel-in-up"}`,style:{height:k},onAnimationEnd:()=>{x&&(S(!1),p(!1))},children:[C.jsx("div",{onPointerDown:Tt,className:"absolute left-0 right-0 top-0 z-10 h-1 cursor-row-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整终端高度"}),C.jsx(BO,{bridge:u.client,onNewTerminal:_e})]})]})}),(()=>{let X=null;L?X=C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"子 Agent"}),C.jsx("button",{onClick:()=>z(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭",children:C.jsx(hi,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(vO,{detail:L})})]}):O?X=C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-1.5",children:[C.jsx("span",{className:"text-2xs font-semibold uppercase tracking-wide text-content-muted",children:"文件差异"}),C.jsx("button",{onClick:()=>R(null),className:"codex-btn-ghost px-2 py-1.5","aria-label":"关闭差异",children:C.jsx(hi,{size:15})})]}),C.jsx("div",{className:"min-h-0 flex-1",children:C.jsx(cO,{item:O})})]}):h==="files"?X=C.jsx(qO,{store:u,initialPath:(Me==null?void 0:Me.cwd)||".",onClose:()=>d("none")}):h==="preview"&&(X=C.jsx(YO,{gatewayUrl:a.httpUrl,sessionId:e,initialAuthToken:(n==null?void 0:n.accessToken)??null,isMobile:o,onClose:()=>d("none"),onAnnotate:Nn=>{K(It=>({text:Nn,nonce:It.nonce+1})),o&&d("none")}}));const de=re.useRef(null);X!==null&&(de.current=X);const Be=X!==null,Ke=dD(Be,"animate-panel-in-right","animate-panel-out-right");if(!Ke.render&&!Be)return null;const gt=Be?X:de.current;return o?C.jsx("aside",{className:`absolute inset-0 z-30 flex flex-col bg-canvas ${Ke.className||"animate-fade-in"}`,onAnimationEnd:Ke.onAnimationEnd,children:gt}):C.jsxs("aside",{className:`relative flex shrink-0 flex-col border-l border-border ${Ke.className}`,style:{width:j},onAnimationEnd:Ke.onAnimationEnd,children:[C.jsx("div",{onPointerDown:ke,className:"absolute left-0 top-0 z-10 h-full w-1 cursor-col-resize bg-transparent transition-colors hover:bg-accent-dim/50",title:"拖动调整宽度"}),gt]})})()]}),F&&C.jsx(KO,{store:u,initialPath:(Me==null?void 0:Me.cwd)||".",providerLabel:((De=pn.find(X=>X.id===F))==null?void 0:De.label)??F,onCancel:()=>W(null),onConfirm:X=>En(F,X)}),f.notices.length>0&&C.jsx("div",{className:"pointer-events-none fixed bottom-4 right-4 z-50 flex w-80 flex-col gap-2",children:f.notices.map(X=>C.jsxs("button",{onClick:()=>u.dismissNotice(X.id),className:`codex-card-raised pointer-events-auto animate-fade-in cursor-pointer px-3 py-2 text-left ${X.kind==="warning"?"border-warning/40":""}`,children:[C.jsxs("p",{className:"flex items-center gap-1.5 text-xs font-medium text-content-primary",children:[C.jsx("span",{className:`h-1.5 w-1.5 shrink-0 rounded-full ${X.kind==="warning"?"bg-warning":"bg-accent"}`}),X.title]}),X.detail&&C.jsx("p",{className:"mt-0.5 pl-3 text-2xs text-content-muted",children:X.detail})]},X.id))}),C.jsx(oD,{open:B,onClose:()=>$(!1),actions:Ze}),H&&C.jsx(o1,{report:f.usage,onClose:()=>q(!1)})]})}eD();function mD(){const[e,n]=re.useState(null),[r,a]=re.useState(!1),[l,u]=re.useState(!1),f=re.useMemo(()=>iD(nD()),[]),o=re.useMemo(()=>c0(),[]),[h,d]=re.useState(()=>f??ZS()),m=p=>{d(p),v_(p)};return re.useEffect(()=>{const p=Cc();p&&n(p),a(!0),p&&nf().then(x=>{x&&n(x)})},[]),re.useEffect(()=>{if(!o)return;const p=window;return p.__linkshellSetTheme=x=>{(x==="dark"||x==="light")&&Bf(x)},()=>{delete p.__linkshellSetTheme}},[o]),re.useEffect(()=>yS(()=>{n(null),u(!1),d(p=>p.name==="list"?p:{name:"list"}),v_({name:"list"})}),[]),r?l?C.jsx(jS,{onLogin:p=>{n(p),u(!1)},onCancel:()=>u(!1)}):h.name==="console"?C.jsx(pD,{sessionId:h.sessionId,session:e,onBack:o?rD:()=>m({name:"list"})}):C.jsx(u1,{session:e,onLogin:()=>u(!0),onLogout:()=>{n(null),m({name:"list"})},onOpenSession:p=>m({name:"console",sessionId:p})}):null}bS.createRoot(document.getElementById("root")).render(C.jsx(mD,{}));