@jamiexiongr/panda-hub 0.1.31 → 0.1.32

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.
@@ -1,53 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/session-file-markdown-preview-ChAPAUwv.js","assets/index-2xq-OQM2.js","assets/index-DBWUmekP.css","assets/xml-COG-BRHv.js"])))=>i.map(i=>d[i]);
2
- var pe=e=>{throw TypeError(e)};var te=(e,s,t)=>s.has(e)||pe("Cannot "+t);var f=(e,s,t)=>(te(e,s,"read from private field"),t?t.call(e):s.get(e)),R=(e,s,t)=>s.has(e)?pe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(e):s.set(e,t),x=(e,s,t,n)=>(te(e,s,"write to private field"),n?n.call(e,t):s.set(e,t),t),I=(e,s,t)=>(te(e,s,"access private method"),t);import{S as Ae,n as re,s as Pe,a as je,Q as Ne,b as xe,c as De,d as $e,r as l,e as Fe,f as Be,g as ze,h as He,i as ge,k as Qe,l as We,m as A,q as Se,o as ke,p as Ke,j as r,_ as qe}from"./index-2xq-OQM2.js";import{H as P,c as Ue,j as Ye,a as Ge,m as Ve,t as Xe,x as Ze}from"./xml-COG-BRHv.js";function _e(e,s){const t=new Set(s);return e.filter(n=>!t.has(n))}function Je(e,s,t){const n=e.slice(0);return n[s]=t,n}var $,O,F,B,C,j,K,q,U,Y,N,ae,oe,ce,le,ue,Ee,es=(Ee=class extends Ae{constructor(s,t,n){super();R(this,N);R(this,$);R(this,O);R(this,F);R(this,B);R(this,C);R(this,j);R(this,K);R(this,q);R(this,U);R(this,Y,[]);x(this,$,s),x(this,B,n),x(this,F,[]),x(this,C,[]),x(this,O,[]),this.setQueries(t)}onSubscribe(){this.listeners.size===1&&f(this,C).forEach(s=>{s.subscribe(t=>{I(this,N,le).call(this,s,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,f(this,C).forEach(s=>{s.destroy()})}setQueries(s,t){x(this,F,s),x(this,B,t),re.batch(()=>{const n=f(this,C),i=I(this,N,ce).call(this,f(this,F));i.forEach(m=>m.observer.setOptions(m.defaultedQueryOptions));const c=i.map(m=>m.observer),a=c.map(m=>m.getCurrentResult()),d=n.length!==c.length,p=c.some((m,E)=>m!==n[E]),_=d||p,S=_?!0:a.some((m,E)=>{const u=f(this,O)[E];return!u||!Pe(m,u)});!_&&!S||(_&&(x(this,Y,i),x(this,C,c)),x(this,O,a),this.hasListeners()&&(_&&(_e(n,c).forEach(m=>{m.destroy()}),_e(c,n).forEach(m=>{m.subscribe(E=>{I(this,N,le).call(this,m,E)})})),I(this,N,ue).call(this)))})}getCurrentResult(){return f(this,O)}getQueries(){return f(this,C).map(s=>s.getCurrentQuery())}getObservers(){return f(this,C)}getOptimisticResult(s,t){const n=I(this,N,ce).call(this,s),i=n.map(a=>a.observer.getOptimisticResult(a.defaultedQueryOptions)),c=n.map(a=>a.defaultedQueryOptions.queryHash);return[i,a=>I(this,N,oe).call(this,a??i,t,c),()=>I(this,N,ae).call(this,i,n)]}},$=new WeakMap,O=new WeakMap,F=new WeakMap,B=new WeakMap,C=new WeakMap,j=new WeakMap,K=new WeakMap,q=new WeakMap,U=new WeakMap,Y=new WeakMap,N=new WeakSet,ae=function(s,t){return t.map((n,i)=>{const c=s[i];return n.defaultedQueryOptions.notifyOnChangeProps?c:n.observer.trackResult(c,a=>{t.forEach(d=>{d.observer.trackProp(a)})})})},oe=function(s,t,n){if(t){const i=f(this,U),c=n!==void 0&&i!==void 0&&(i.length!==n.length||n.some((a,d)=>a!==i[d]));return(!f(this,j)||f(this,O)!==f(this,q)||c||t!==f(this,K))&&(x(this,K,t),x(this,q,f(this,O)),n!==void 0&&x(this,U,n),x(this,j,je(f(this,j),t(s)))),f(this,j)}return s},ce=function(s){const t=new Map;f(this,C).forEach(i=>{const c=i.options.queryHash;if(!c)return;const a=t.get(c);a?a.push(i):t.set(c,[i])});const n=[];return s.forEach(i=>{var p;const c=f(this,$).defaultQueryOptions(i),d=((p=t.get(c.queryHash))==null?void 0:p.shift())??new Ne(f(this,$),c);n.push({defaultedQueryOptions:c,observer:d})}),n},le=function(s,t){const n=f(this,C).indexOf(s);n!==-1&&(x(this,O,Je(f(this,O),n,t)),I(this,N,ue).call(this))},ue=function(){var s;if(this.hasListeners()){const t=f(this,j),n=I(this,N,ae).call(this,f(this,O),f(this,Y)),i=I(this,N,oe).call(this,n,(s=f(this,B))==null?void 0:s.combine);t!==i&&re.batch(()=>{this.listeners.forEach(c=>{c(f(this,O))})})}},Ee);function ss({queries:e,...s},t){const n=xe(),i=De(),c=$e(),a=l.useMemo(()=>e.map(h=>{const y=n.defaultQueryOptions(h);return y._optimisticResults=i?"isRestoring":"optimistic",y}),[e,n,i]);a.forEach(h=>{Fe(h);const y=n.getQueryCache().get(h.queryHash);Be(h,c,y)}),ze(c);const[d]=l.useState(()=>new es(n,a,s)),[p,_,S]=d.getOptimisticResult(a,s.combine),m=!i&&s.subscribed!==!1;l.useSyncExternalStore(l.useCallback(h=>m?d.subscribe(re.batchCalls(h)):He,[d,m]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),l.useEffect(()=>{d.setQueries(a,s)},[a,s,d]);const u=p.some((h,y)=>ge(a[y],h))?p.flatMap((h,y)=>{const b=a[y];if(b&&ge(b,h)){const M=new Ne(n,b);return Qe(b,M,c)}return[]}):[];if(u.length>0)throw Promise.all(u);const g=p.find((h,y)=>{const b=a[y];return b&&We({result:h,errorResetBoundary:c,throwOnError:b.throwOnError,query:n.getQueryCache().get(b.queryHash),suspense:b.suspense})});if(g!=null&&g.error)throw g.error;return _(S())}/**
3
- * @license lucide-react v0.577.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const ts=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],ns=A("check",ts);/**
8
- * @license lucide-react v0.577.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const is=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rs=A("chevron-down",is);/**
13
- * @license lucide-react v0.577.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const as=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],os=A("chevron-left",as);/**
18
- * @license lucide-react v0.577.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const cs=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],ls=A("file-braces-corner",cs);/**
23
- * @license lucide-react v0.577.0 - ISC
24
- *
25
- * This source code is licensed under the ISC license.
26
- * See the LICENSE file in the root directory of this source tree.
27
- */const us=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],ds=A("file-code-corner",us);/**
28
- * @license lucide-react v0.577.0 - ISC
29
- *
30
- * This source code is licensed under the ISC license.
31
- * See the LICENSE file in the root directory of this source tree.
32
- */const hs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],ms=A("file-image",hs);/**
33
- * @license lucide-react v0.577.0 - ISC
34
- *
35
- * This source code is licensed under the ISC license.
36
- * See the LICENSE file in the root directory of this source tree.
37
- */const fs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ps=A("file-text",fs);/**
38
- * @license lucide-react v0.577.0 - ISC
39
- *
40
- * This source code is licensed under the ISC license.
41
- * See the LICENSE file in the root directory of this source tree.
42
- */const gs=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],_s=A("file",gs);/**
43
- * @license lucide-react v0.577.0 - ISC
44
- *
45
- * This source code is licensed under the ISC license.
46
- * See the LICENSE file in the root directory of this source tree.
47
- */const bs=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],vs=A("folder",bs);/**
48
- * @license lucide-react v0.577.0 - ISC
49
- *
50
- * This source code is licensed under the ISC license.
51
- * See the LICENSE file in the root directory of this source tree.
52
- */const ys=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Oe=A("x",ys);function ws(e){const s=e.regex,t={},n={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[t]}]};Object.assign(t,{className:"variable",variants:[{begin:s.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},n]});const i={className:"subst",begin:/\$\(/,end:/\)/,contains:[e.BACKSLASH_ESCAPE]},c=e.inherit(e.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),a={begin:/<<-?\s*(?=\w+)/,starts:{contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},d={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t,i]};i.contains.push(d);const p={match:/\\"/},_={className:"string",begin:/'/,end:/'/},S={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},e.NUMBER_MODE,t]},E=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],u=e.SHEBANG({binary:`(${E.join("|")})`,relevance:10}),g={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[e.inherit(e.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},h=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},M=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],G=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],T=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],z=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:h,literal:y,built_in:[...M,...G,"set","shopt",...T,...z]},contains:[u,e.SHEBANG(),g,m,c,a,b,d,p,_,S,t]}}var D="[0-9](_*[0-9])*",J=`\\.(${D})`,ee="[0-9a-fA-F](_*[0-9a-fA-F])*",be={className:"number",variants:[{begin:`(\\b(${D})((${J})|\\.)?|(${J}))[eE][+-]?(${D})[fFdD]?\\b`},{begin:`\\b(${D})((${J})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${J})[fFdD]?\\b`},{begin:`\\b(${D})[fFdD]\\b`},{begin:`\\b0[xX]((${ee})\\.?|(${ee})?\\.(${ee}))[pP][+-]?(${D})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${ee})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function Re(e,s,t){return t===-1?"":e.replace(s,n=>Re(e,s,t-1))}function Es(e){const s=e.regex,t="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",n=t+Re("(?:<"+t+"~~~(?:\\s*,\\s*"+t+"~~~)*>)?",/~~~/g,2),p={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},_={className:"meta",begin:"@"+t,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},S={className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[e.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:p,illegal:/<\/|#/,contains:[e.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[e.BACKSLASH_ESCAPE]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,t],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[s.concat(/(?!else)/,t),/\s+/,t,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,t],className:{1:"keyword",3:"title.class"},contains:[S,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+n+"\\s+)",e.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:p,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:p,relevance:0,contains:[_,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,be,e.C_BLOCK_COMMENT_MODE]},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},be,_]}}function Ns(e){const s="true false yes no null",t="[\\w#;/?:@&=+$,.~*'()[\\]]+",n={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},i={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},c={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},a={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,i]},d=e.inherit(a,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),E={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"},u={end:",",endsWithParent:!0,excludeEnd:!0,keywords:s,relevance:0},g={begin:/\{/,end:/\}/,contains:[u],illegal:"\\n",relevance:0},h={begin:"\\[",end:"\\]",contains:[u],illegal:"\\n",relevance:0},y=[n,{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+!"+t},{className:"type",begin:"!<"+t+">"},{className:"type",begin:"!"+t},{className:"type",begin:"!!"+t},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:s,keywords:{literal:s}},E,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},g,h,c,a],b=[...y];return b.pop(),b.push(d),u.contains=b,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:y}}const xs=async e=>(await ke({agentId:e.agentId??void 0,sessionId:e.agentId?void 0:e.sessionId})).client.getSessionFilePreviewTree(e.sessionId,{path:e.path??null}),Ss=async e=>(await ke({agentId:e.agentId??void 0,sessionId:e.agentId?void 0:e.sessionId})).client.getSessionFilePreviewContent(e.sessionId,{path:e.path}),ks=e=>{var s;return["session-file-preview","tree",e.sessionId,((s=e.path)==null?void 0:s.trim())??""]},Os=e=>["session-file-preview","content",e.sessionId,e.path.trim()],Rs=e=>Se({queryKey:ks(e),enabled:e.enabled??!0,queryFn:()=>xs(e),staleTime:3e4,refetchOnMount:!1,refetchOnWindowFocus:!1,retry:1}),Cs=e=>Se({queryKey:Os(e),enabled:e.enabled??!0,queryFn:()=>Ss(e),staleTime:3e4,refetchOnMount:!1,refetchOnWindowFocus:!1,retry:1});P.registerLanguage("bash",ws);P.registerLanguage("css",Ue);P.registerLanguage("java",Es);P.registerLanguage("javascript",Ye);P.registerLanguage("json",Ge);P.registerLanguage("markdown",Ve);P.registerLanguage("typescript",Xe);P.registerLanguage("xml",Ze);P.registerLanguage("yaml",Ns);const Ms=l.lazy(async()=>({default:(await qe(()=>import("./session-file-markdown-preview-ChAPAUwv.js"),__vite__mapDeps([0,1,2,3]))).SessionFileMarkdownPreview})),ne=e=>e.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),Ce=e=>{const s=e.toLowerCase();return s.endsWith(".ts")||s.endsWith(".tsx")||s.endsWith(".mts")||s.endsWith(".cts")?"typescript":s.endsWith(".js")||s.endsWith(".jsx")||s.endsWith(".mjs")||s.endsWith(".cjs")?"javascript":s.endsWith(".json")?"json":s.endsWith(".css")||s.endsWith(".scss")||s.endsWith(".less")?"css":s.endsWith(".html")||s.endsWith(".svg")||s.endsWith(".xml")?"xml":s.endsWith(".md")||s.endsWith(".markdown")?"markdown":s.endsWith(".yml")||s.endsWith(".yaml")?"yaml":s.endsWith(".sh")?"bash":s.endsWith(".java")?"java":null},Ts=(e,s,t=!1)=>{if(t||!e.trim())return ne(e);const n=Ce(s);if(!n)return ne(e);try{return P.highlight(e,{language:n,ignoreIllegals:!0}).value}catch{return ne(e)}},Is=(e,s)=>{const t=[{key:"root",label:e,currentPath:null}];if(!s)return t;const n=s.split("/").filter(Boolean);let i=null;for(const c of n)i=i?`${i}/${c}`:c,t.push({key:i,label:c,currentPath:i});return t},ve=e=>{const s=e.split("/").filter(Boolean);return s.length<=1?null:s.slice(0,-1).join("/")},Ls=e=>e.kind==="directory"?vs:e.file_kind==="image"?ms:e.extension===".json"?ls:e.file_kind==="code"?ds:e.file_kind==="markdown"||e.file_kind==="text"?ps:_s,As=l.memo(function({level:s,isOpen:t,onToggle:n,buttonRef:i}){return r.jsx("div",{className:`session-file-preview-nav__level ${t?"is-open":""}`,children:r.jsxs("button",{ref:i,type:"button",className:"session-file-preview-nav__trigger",onClick:n,"aria-expanded":t,children:[r.jsx("span",{className:"session-file-preview-nav__trigger-label",children:s.label}),r.jsx(rs,{"aria-hidden":"true"})]})})}),ye=(e,s)=>{s.removeQueries({predicate:t=>{const n=t.queryKey;return Array.isArray(n)&&n[0]==="session-file-preview"&&n[2]===e}})},Ps=e=>Math.max(1,Math.min(4,e)),ie=e=>{if(e.length<2)return 0;const s=e.item(0),t=e.item(1);if(!s||!t)return 0;const n=t.clientX-s.clientX,i=t.clientY-s.clientY;return Math.hypot(n,i)},js=l.memo(function({src:s,alt:t,onOpen:n}){return r.jsx("button",{type:"button",className:"session-file-preview-viewer__image",onClick:n,"aria-label":"全屏查看图片",children:r.jsx("img",{src:s,alt:t})})}),Ds=l.memo(function({src:s,alt:t,onClose:n}){const[i,c]=l.useState(1),[a,d]=l.useState({x:0,y:0}),p=l.useRef(null),_=l.useRef(null);l.useEffect(()=>{const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=u}},[]),l.useEffect(()=>{const u=g=>{g.key==="Escape"&&n()};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u)}},[n]),l.useEffect(()=>{i===1&&(a.x!==0||a.y!==0)&&d({x:0,y:0})},[a.x,a.y,i]);const S=u=>{if(u.touches.length>=2){p.current={distance:ie(u.touches),scale:i},_.current=null;return}if(u.touches.length===1&&i>1){const g=u.touches[0];_.current={startX:g.clientX,startY:g.clientY,originX:a.x,originY:a.y}}},m=u=>{if(u.touches.length>=2){const g=p.current;if(!g){p.current={distance:ie(u.touches),scale:i};return}const h=ie(u.touches);if(h<=0||g.distance<=0)return;u.preventDefault(),c(Ps(h/g.distance*g.scale));return}if(u.touches.length===1&&_.current&&i>1){const g=u.touches[0];u.preventDefault(),d({x:_.current.originX+(g.clientX-_.current.startX),y:_.current.originY+(g.clientY-_.current.startY)})}},E=()=>{p.current&&i<=1&&c(1),i<=1&&d({x:0,y:0}),p.current=null,_.current=null};return r.jsxs("div",{className:"session-file-preview-lightbox",role:"dialog","aria-modal":"true","aria-label":"图片全屏预览",onClick:n,children:[r.jsx("button",{type:"button",className:"session-file-preview-lightbox__close",onClick:n,"aria-label":"关闭图片预览",children:r.jsx(Oe,{})}),r.jsx("div",{className:"session-file-preview-lightbox__stage",onClick:u=>{u.stopPropagation()},onTouchStart:S,onTouchMove:m,onTouchEnd:E,onTouchCancel:E,children:r.jsx("img",{src:s,alt:t,className:"session-file-preview-lightbox__image",style:{transform:`translate(${a.x}px, ${a.y}px) scale(${i})`}})})]})}),we=l.memo(function({content:s,path:t,plainText:n=!1}){const i=l.useMemo(()=>Ts(s,t,n),[s,t,n]),c=l.useMemo(()=>i.split(`
53
- `),[i]);return r.jsx("div",{className:"session-file-preview-viewer__code-shell",children:r.jsx("div",{className:"session-file-preview-viewer__code-scroll",children:r.jsx("div",{className:"session-file-preview-viewer__code",role:"presentation",children:c.map((a,d)=>r.jsxs("div",{className:"session-file-preview-viewer__code-line",children:[r.jsx("span",{className:"session-file-preview-viewer__line-number","aria-hidden":"true",children:d+1}),r.jsx("span",{className:"session-file-preview-viewer__line-content",dangerouslySetInnerHTML:{__html:a||" "}})]},`${t}-line-${d+1}`))})})})}),$s=(e,s,t,n)=>{const i=Ce(t.path);if(t.content_text!==null&&(t.file_kind==="markdown"||i==="markdown")){const a=t.content_text;return a===null?r.jsx("div",{className:"session-file-preview-viewer__empty",children:"暂时没有可显示的内容。"}):r.jsx(l.Suspense,{fallback:r.jsx("div",{className:"session-file-preview-viewer__empty",children:"正在载入 Markdown…"}),children:r.jsx(Ms,{agentId:e,sessionId:s,filePath:t.path,content:a})})}if(t.content_text!==null&&(t.file_kind==="code"||i!==null&&i!=="markdown"))return r.jsx(we,{content:t.content_text,path:t.path});if(t.file_kind==="text"&&t.content_text!==null)return r.jsx(we,{content:t.content_text,path:t.path,plainText:!0});if(t.file_kind==="image"&&t.content_base64){const a=`data:${t.mime_type??"application/octet-stream"};base64,${t.content_base64}`;return r.jsx(js,{src:a,alt:t.name,onOpen:()=>{n({src:a,alt:t.name})}})}return t.file_kind==="image"?r.jsx("div",{className:"session-file-preview-viewer__empty",children:"这张图片体积过大,当前预览页没有继续加载内容。"}):r.jsx("div",{className:"session-file-preview-viewer__empty",children:"当前文件暂不支持预览。"})},Fs=({agentId:e,sessionId:s,projectName:t,projectPath:n,isActive:i,onBack:c})=>{var fe;const a=xe(),d=l.useRef(null),p=l.useRef(null),_=l.useRef({}),S=l.useRef(s),[m,E]=l.useState(null),[u,g]=l.useState([]),[h,y]=l.useState(null),[b,M]=l.useState(null),[G,T]=l.useState(null),[z,H]=l.useState(null),Q=l.useMemo(()=>Is(t,m),[m,t]),Me=ss({queries:Q.map(o=>Rs({agentId:e,sessionId:s,enabled:i,path:o.currentPath}))}),V=Ke(Cs({agentId:e,sessionId:s,enabled:i&&!!h,path:h??""})),de=V.data,X=Q.findIndex(o=>o.key===b),he=X>=0?Q[X]:null,L=X>=0?Me[X]:null,me=((fe=L==null?void 0:L.data)==null?void 0:fe.nodes)??[],Te=o=>{g(v=>v.some(w=>w.path===o.path)?v:[...v,o]),y(o.path)},Ie=o=>{g(v=>{const w=v.filter(k=>k.path!==o);return y(k=>{if(k!==o)return k;const Z=v.findIndex(se=>se.path===o),W=w[Z]??w[Math.max(0,Z-1)]??null;return(W==null?void 0:W.path)??null}),w})};l.useEffect(()=>{const o=S.current;o!==s&&(ye(o,a),S.current=s),E(null),g([]),y(null),M(null),T(null),H(null)},[a,s,n]),l.useEffect(()=>()=>{ye(S.current,a)},[a]),l.useEffect(()=>{i||(M(null),T(null),H(null))},[i]),l.useEffect(()=>{H(null)},[h]),l.useEffect(()=>{h&&(E(ve(h)),M(null),T(null))},[h]),l.useEffect(()=>{if(!i||!m)return;const o=p.current;if(!o)return;const v=window.requestAnimationFrame(()=>{o.scrollTo({left:o.scrollWidth,behavior:"smooth"})});return()=>{window.cancelAnimationFrame(v)}},[m,i]),l.useEffect(()=>{if(!i)return;const o=v=>{const w=d.current;!w||w.contains(v.target)||(M(null),T(null))};return document.addEventListener("pointerdown",o),()=>{document.removeEventListener("pointerdown",o)}},[i]),l.useEffect(()=>{if(!b){T(null);return}const o=d.current,v=_.current[b];if(!o||!v){T(null);return}const w=()=>{const Z=o.getBoundingClientRect(),W=v.getBoundingClientRect(),se=Math.max(0,W.left-Z.left);T({left:`${se}px`})};w();const k=p.current;return k==null||k.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w),()=>{k==null||k.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[b,Q]);const Le=()=>!he||!G?null:r.jsx("div",{className:"session-file-preview-nav__menu",role:"menu",style:G,children:L!=null&&L.isPending?r.jsx("div",{className:"session-file-preview-nav__status",children:"正在载入…"}):L!=null&&L.isError?r.jsx("div",{className:"session-file-preview-nav__status is-error",children:L.error.message}):me.length>0?me.map(o=>{const v=Ls(o),w=o.kind==="directory"&&o.path===he.currentPath,k=o.kind==="file"&&o.path===h;return r.jsxs("button",{type:"button",className:`session-file-preview-nav__option ${w||k?"is-selected":""}`,onClick:()=>{o.kind==="directory"?(E(o.path),M(o.path)):(E(ve(o.path)),Te({path:o.path,name:o.name}),M(null),T(null))},role:"menuitem",children:[r.jsx("span",{className:"session-file-preview-nav__option-icon","aria-hidden":"true",children:r.jsx(v,{})}),r.jsx("span",{className:"session-file-preview-nav__option-label",children:o.name}),w||k?r.jsx("span",{className:"session-file-preview-nav__option-check","aria-hidden":"true",children:r.jsx(ns,{})}):null]},o.path)}):r.jsx("div",{className:"session-file-preview-nav__status",children:"这一层没有可选内容。"})});return r.jsxs("section",{className:"session-file-preview","aria-label":"项目文件预览",children:[r.jsxs("header",{className:"session-file-preview__topbar",children:[r.jsx("button",{type:"button",className:"session-file-preview__back",onClick:c,"aria-label":"返回会话页",children:r.jsx(os,{strokeWidth:1.8})}),r.jsxs("div",{ref:d,className:"session-file-preview-nav-shell",children:[r.jsx("div",{ref:p,className:"session-file-preview-nav",children:Q.map(o=>r.jsx(As,{level:o,isOpen:b===o.key,onToggle:()=>{M(v=>{const w=v===o.key?null:o.key;return w===null&&T(null),w})},buttonRef:v=>{_.current[o.key]=v}},o.key))}),Le()]})]}),r.jsxs("div",{className:"session-file-preview__viewer",children:[r.jsx("div",{className:"session-file-preview__tabs",role:"tablist","aria-label":"已打开文件",children:u.length>0?u.map(o=>r.jsxs("div",{className:`session-file-preview__tab ${o.path===h?"is-active":""}`,children:[r.jsx("button",{type:"button",role:"tab","aria-selected":o.path===h,className:"session-file-preview__tab-button",onClick:()=>{y(o.path)},children:r.jsx("span",{className:"session-file-preview__tab-label",children:o.name})}),r.jsx("button",{type:"button",className:"session-file-preview__tab-close",onClick:v=>{v.stopPropagation(),Ie(o.path)},"aria-label":`关闭 ${o.name}`,children:r.jsx(Oe,{})})]},o.path)):r.jsx("div",{className:"session-file-preview__tabs-empty",children:"未打开文件"})}),r.jsx("div",{className:"session-file-preview__viewer-scroll",children:h?V.isPending?r.jsx("div",{className:"session-file-preview-viewer__empty",children:"正在载入文件内容…"}):V.isError?r.jsx("div",{className:"session-file-preview-viewer__empty is-error",children:V.error.message}):de?r.jsx("div",{className:"session-file-preview__viewer-content",children:$s(e,s,de,H)}):r.jsx("div",{className:"session-file-preview-viewer__empty",children:"暂时没有可显示的内容。"}):r.jsxs("div",{className:"session-file-preview-viewer__empty",children:[r.jsx("div",{className:"session-file-preview-viewer__empty-title",children:"选择一个文件开始预览"}),r.jsxs("div",{className:"session-file-preview-viewer__empty-meta",children:["当前项目根目录:",n]})]})})]}),z?r.jsx(Ds,{src:z.src,alt:z.alt,onClose:()=>{H(null)}}):null]})},Qs=Object.freeze(Object.defineProperty({__proto__:null,SessionFilePreviewPage:Fs},Symbol.toStringTag,{value:"Module"}));export{Cs as g,Qs as s};