@myskyline_ai/ccdebug 0.2.16 → 0.2.17

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.
@@ -35,8 +35,8 @@
35
35
  `+a.map(Ry).join(`
36
36
  `):" "+Ry(a[0]):"as no adapter specified";throw new dt("There is no suitable adapter to dispatch the request "+i,"ERR_NOT_SUPPORT")}return o}const L2={getAdapter:LV,adapters:Uh};function Pp(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new er(null,e)}function zy(e){return Pp(e),e.headers=Wn.from(e.headers),e.data=Sp.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),L2.getAdapter(e.adapter||vi.adapter,e)(e).then(function(l){return Pp(e),l.data=Sp.call(e,e.transformResponse,l),l.headers=Wn.from(l.headers),l},function(l){return S2(l)||(Pp(e),l&&l.response&&(l.response.data=Sp.call(e,e.transformResponse,l.response),l.response.headers=Wn.from(l.response.headers))),Promise.reject(l)})}const E2="1.13.2",gc={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{gc[e]=function(l){return typeof l===e||"a"+(t<1?"n ":" ")+e}});const Dy={};gc.transitional=function(t,n,l){function o(r,a){return"[Axios v"+E2+"] Transitional option '"+r+"'"+a+(l?". "+l:"")}return(r,a,i)=>{if(t===!1)throw new dt(o(a," has been removed"+(n?" in "+n:"")),dt.ERR_DEPRECATED);return n&&!Dy[a]&&(Dy[a]=!0,console.warn(o(a," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(r,a,i):!0}};gc.spelling=function(t){return(n,l)=>(console.warn(`${l} is likely a misspelling of ${t}`),!0)};function EV(e,t,n){if(typeof e!="object")throw new dt("options must be an object",dt.ERR_BAD_OPTION_VALUE);const l=Object.keys(e);let o=l.length;for(;o-- >0;){const r=l[o],a=t[r];if(a){const i=e[r],s=i===void 0||a(i,r,e);if(s!==!0)throw new dt("option "+r+" must be "+s,dt.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new dt("Unknown option "+r,dt.ERR_BAD_OPTION)}}const Hs={assertOptions:EV,validators:gc},Ol=Hs.validators;let na=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ty,response:new Ty}}async request(t,n){try{return await this._request(t,n)}catch(l){if(l instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const r=o.stack?o.stack.replace(/^.+\n/,""):"";try{l.stack?r&&!String(l.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(l.stack+=`
37
37
  `+r):l.stack=r}catch{}}throw l}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ia(this.defaults,n);const{transitional:l,paramsSerializer:o,headers:r}=n;l!==void 0&&Hs.assertOptions(l,{silentJSONParsing:Ol.transitional(Ol.boolean),forcedJSONParsing:Ol.transitional(Ol.boolean),clarifyTimeoutError:Ol.transitional(Ol.boolean)},!1),o!=null&&(Se.isFunction(o)?n.paramsSerializer={serialize:o}:Hs.assertOptions(o,{encode:Ol.function,serialize:Ol.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Hs.assertOptions(n,{baseUrl:Ol.spelling("baseURL"),withXsrfToken:Ol.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let a=r&&Se.merge(r.common,r[n.method]);r&&Se.forEach(["delete","get","head","post","put","patch","common"],m=>{delete r[m]}),n.headers=Wn.concat(a,r);const i=[];let s=!0;this.interceptors.request.forEach(function(y){typeof y.runWhen=="function"&&y.runWhen(n)===!1||(s=s&&y.synchronous,i.unshift(y.fulfilled,y.rejected))});const c=[];this.interceptors.response.forEach(function(y){c.push(y.fulfilled,y.rejected)});let u,f=0,v;if(!s){const m=[zy.bind(this),void 0];for(m.unshift(...i),m.push(...c),v=m.length,u=Promise.resolve(n);f<v;)u=u.then(m[f++],m[f++]);return u}v=i.length;let h=n;for(;f<v;){const m=i[f++],y=i[f++];try{h=m(h)}catch(g){y.call(this,g);break}}try{u=zy.call(this,h)}catch(m){return Promise.reject(m)}for(f=0,v=c.length;f<v;)u=u.then(c[f++],c[f++]);return u}getUri(t){t=ia(this.defaults,t);const n=O2(t.baseURL,t.url,t.allowAbsoluteUrls);return k2(n,t.params,t.paramsSerializer)}};Se.forEach(["delete","get","head","options"],function(t){na.prototype[t]=function(n,l){return this.request(ia(l||{},{method:t,url:n,data:(l||{}).data}))}});Se.forEach(["post","put","patch"],function(t){function n(l){return function(r,a,i){return this.request(ia(i||{},{method:t,headers:l?{"Content-Type":"multipart/form-data"}:{},url:r,data:a}))}}na.prototype[t]=n(),na.prototype[t+"Form"]=n(!0)});let IV=class I2{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(r){n=r});const l=this;this.promise.then(o=>{if(!l._listeners)return;let r=l._listeners.length;for(;r-- >0;)l._listeners[r](o);l._listeners=null}),this.promise.then=o=>{let r;const a=new Promise(i=>{l.subscribe(i),r=i}).then(o);return a.cancel=function(){l.unsubscribe(r)},a},t(function(r,a,i){l.reason||(l.reason=new er(r,a,i),n(l.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=l=>{t.abort(l)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new I2(function(o){t=o}),cancel:t}}};function BV(e){return function(n){return e.apply(null,n)}}function AV(e){return Se.isObject(e)&&e.isAxiosError===!0}const $v={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries($v).forEach(([e,t])=>{$v[t]=e});function B2(e){const t=new na(e),n=u2(na.prototype.request,t);return Se.extend(n,na.prototype,t,{allOwnKeys:!0}),Se.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return B2(ia(e,o))},n}const wt=B2(vi);wt.Axios=na;wt.CanceledError=er;wt.CancelToken=IV;wt.isCancel=S2;wt.VERSION=E2;wt.toFormData=mc;wt.AxiosError=dt;wt.Cancel=wt.CanceledError;wt.all=function(t){return Promise.all(t)};wt.spread=BV;wt.isAxiosError=AV;wt.mergeConfig=ia;wt.AxiosHeaders=Wn;wt.formToJSON=e=>$2(Se.isHTMLForm(e)?new FormData(e):e);wt.getAdapter=L2.getAdapter;wt.HttpStatusCode=$v;wt.default=wt;const{Axios:ND,AxiosError:RD,CanceledError:zD,isCancel:DD,CancelToken:jD,VERSION:FD,all:HD,Cancel:WD,isAxiosError:KD,spread:qD,toFormData:UD,AxiosHeaders:YD,HttpStatusCode:ZD,formToJSON:GD,getAdapter:XD,mergeConfig:JD}=wt,Nl=Object.create(null);Nl.open="0";Nl.close="1";Nl.ping="2";Nl.pong="3";Nl.message="4";Nl.upgrade="5";Nl.noop="6";const Ws=Object.create(null);Object.keys(Nl).forEach(e=>{Ws[Nl[e]]=e});const Sv={type:"error",data:"parser error"},A2=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",x2=typeof ArrayBuffer=="function",V2=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Yh=({type:e,data:t},n,l)=>A2&&t instanceof Blob?n?l(t):jy(t,l):x2&&(t instanceof ArrayBuffer||V2(t))?n?l(t):jy(new Blob([t]),l):l(Nl[e]+(t||"")),jy=(e,t)=>{const n=new FileReader;return n.onload=function(){const l=n.result.split(",")[1];t("b"+(l||""))},n.readAsDataURL(e)};function Fy(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Op;function xV(e,t){if(A2&&e.data instanceof Blob)return e.data.arrayBuffer().then(Fy).then(t);if(x2&&(e.data instanceof ArrayBuffer||V2(e.data)))return t(Fy(e.data));Yh(e,!1,n=>{Op||(Op=new TextEncoder),t(Op.encode(n))})}const Hy="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yr=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<Hy.length;e++)yr[Hy.charCodeAt(e)]=e;const VV=e=>{let t=e.length*.75,n=e.length,l,o=0,r,a,i,s;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const c=new ArrayBuffer(t),u=new Uint8Array(c);for(l=0;l<n;l+=4)r=yr[e.charCodeAt(l)],a=yr[e.charCodeAt(l+1)],i=yr[e.charCodeAt(l+2)],s=yr[e.charCodeAt(l+3)],u[o++]=r<<2|a>>4,u[o++]=(a&15)<<4|i>>2,u[o++]=(i&3)<<6|s&63;return c},MV=typeof ArrayBuffer=="function",Zh=(e,t)=>{if(typeof e!="string")return{type:"message",data:M2(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:NV(e.substring(1),t)}:Ws[n]?e.length>1?{type:Ws[n],data:e.substring(1)}:{type:Ws[n]}:Sv},NV=(e,t)=>{if(MV){const n=VV(e);return M2(n,t)}else return{base64:!0,data:e}},M2=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},N2="",RV=(e,t)=>{const n=e.length,l=new Array(n);let o=0;e.forEach((r,a)=>{Yh(r,!1,i=>{l[a]=i,++o===n&&t(l.join(N2))})})},zV=(e,t)=>{const n=e.split(N2),l=[];for(let o=0;o<n.length;o++){const r=Zh(n[o],t);if(l.push(r),r.type==="error")break}return l};function DV(){return new TransformStream({transform(e,t){xV(e,n=>{const l=n.length;let o;if(l<126)o=new Uint8Array(1),new DataView(o.buffer).setUint8(0,l);else if(l<65536){o=new Uint8Array(3);const r=new DataView(o.buffer);r.setUint8(0,126),r.setUint16(1,l)}else{o=new Uint8Array(9);const r=new DataView(o.buffer);r.setUint8(0,127),r.setBigUint64(1,BigInt(l))}e.data&&typeof e.data!="string"&&(o[0]|=128),t.enqueue(o),t.enqueue(n)})}})}let _p;function Ri(e){return e.reduce((t,n)=>t+n.length,0)}function zi(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let l=0;for(let o=0;o<t;o++)n[o]=e[0][l++],l===e[0].length&&(e.shift(),l=0);return e.length&&l<e[0].length&&(e[0]=e[0].slice(l)),n}function jV(e,t){_p||(_p=new TextDecoder);const n=[];let l=0,o=-1,r=!1;return new TransformStream({transform(a,i){for(n.push(a);;){if(l===0){if(Ri(n)<1)break;const s=zi(n,1);r=(s[0]&128)===128,o=s[0]&127,o<126?l=3:o===126?l=1:l=2}else if(l===1){if(Ri(n)<2)break;const s=zi(n,2);o=new DataView(s.buffer,s.byteOffset,s.length).getUint16(0),l=3}else if(l===2){if(Ri(n)<8)break;const s=zi(n,8),c=new DataView(s.buffer,s.byteOffset,s.length),u=c.getUint32(0);if(u>Math.pow(2,21)-1){i.enqueue(Sv);break}o=u*Math.pow(2,32)+c.getUint32(4),l=3}else{if(Ri(n)<o)break;const s=zi(n,o);i.enqueue(Zh(r?s:_p.decode(s),t)),l=0}if(o===0||o>e){i.enqueue(Sv);break}}}})}const R2=4;function Xt(e){if(e)return FV(e)}function FV(e){for(var t in Xt.prototype)e[t]=Xt.prototype[t];return e}Xt.prototype.on=Xt.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};Xt.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};Xt.prototype.off=Xt.prototype.removeListener=Xt.prototype.removeAllListeners=Xt.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var l,o=0;o<n.length;o++)if(l=n[o],l===t||l.fn===t){n.splice(o,1);break}return n.length===0&&delete this._callbacks["$"+e],this};Xt.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],l=1;l<arguments.length;l++)t[l-1]=arguments[l];if(n){n=n.slice(0);for(var l=0,o=n.length;l<o;++l)n[l].apply(this,t)}return this};Xt.prototype.emitReserved=Xt.prototype.emit;Xt.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};Xt.prototype.hasListeners=function(e){return!!this.listeners(e).length};const yc=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qn=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),HV="arraybuffer";function z2(e,...t){return t.reduce((n,l)=>(e.hasOwnProperty(l)&&(n[l]=e[l]),n),{})}const WV=Qn.setTimeout,KV=Qn.clearTimeout;function bc(e,t){t.useNativeTimers?(e.setTimeoutFn=WV.bind(Qn),e.clearTimeoutFn=KV.bind(Qn)):(e.setTimeoutFn=Qn.setTimeout.bind(Qn),e.clearTimeoutFn=Qn.clearTimeout.bind(Qn))}const qV=1.33;function UV(e){return typeof e=="string"?YV(e):Math.ceil((e.byteLength||e.size)*qV)}function YV(e){let t=0,n=0;for(let l=0,o=e.length;l<o;l++)t=e.charCodeAt(l),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(l++,n+=4);return n}function D2(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function ZV(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function GV(e){let t={},n=e.split("&");for(let l=0,o=n.length;l<o;l++){let r=n[l].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}class XV extends Error{constructor(t,n,l){super(t),this.description=n,this.context=l,this.type="TransportError"}}class Gh extends Xt{constructor(t){super(),this.writable=!1,bc(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,l){return super.emitReserved("error",new XV(t,n,l)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=Zh(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=ZV(t);return n.length?"?"+n:""}}class JV extends Gh{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let l=0;this._polling&&(l++,this.once("pollComplete",function(){--l||n()})),this.writable||(l++,this.once("drain",function(){--l||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=l=>{if(this.readyState==="opening"&&l.type==="open"&&this.onOpen(),l.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(l)};zV(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,RV(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=D2()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let j2=!1;try{j2=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const QV=j2;function eM(){}class tM extends JV{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let l=location.port;l||(l=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||l!==t.port}}doWrite(t,n){const l=this.request({method:"POST",data:t});l.on("success",n),l.on("error",(o,r)=>{this.onError("xhr post error",o,r)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,l)=>{this.onError("xhr poll error",n,l)}),this.pollXhr=t}}class xl extends Xt{constructor(t,n,l){super(),this.createRequest=t,bc(this,l),this._opts=l,this._method=l.method||"GET",this._uri=n,this._data=l.data!==void 0?l.data:null,this._create()}_create(){var t;const n=z2(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const l=this._xhr=this.createRequest(n);try{l.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){l.setDisableHeaderCheck&&l.setDisableHeaderCheck(!0);for(let o in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(o)&&l.setRequestHeader(o,this._opts.extraHeaders[o])}}catch{}if(this._method==="POST")try{l.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{l.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(l),"withCredentials"in l&&(l.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(l.timeout=this._opts.requestTimeout),l.onreadystatechange=()=>{var o;l.readyState===3&&((o=this._opts.cookieJar)===null||o===void 0||o.parseCookies(l.getResponseHeader("set-cookie"))),l.readyState===4&&(l.status===200||l.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof l.status=="number"?l.status:0)},0))},l.send(this._data)}catch(o){this.setTimeoutFn(()=>{this._onError(o)},0);return}typeof document<"u"&&(this._index=xl.requestsCount++,xl.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=eM,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete xl.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}xl.requestsCount=0;xl.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",Wy);else if(typeof addEventListener=="function"){const e="onpagehide"in Qn?"pagehide":"unload";addEventListener(e,Wy,!1)}}function Wy(){for(let e in xl.requests)xl.requests.hasOwnProperty(e)&&xl.requests[e].abort()}const nM=function(){const e=F2({xdomain:!1});return e&&e.responseType!==null}();class lM extends tM{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=nM&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new xl(F2,this.uri(),t)}}function F2(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||QV))return new XMLHttpRequest}catch{}if(!t)try{return new Qn[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const H2=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class oM extends Gh{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,l=H2?{}:z2(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(l.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,l)}catch(o){return this.emitReserved("error",o)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const l=t[n],o=n===t.length-1;Yh(l,this.supportsBinary,r=>{try{this.doWrite(l,r)}catch{}o&&yc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=D2()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Tp=Qn.WebSocket||Qn.MozWebSocket;class aM extends oM{createSocket(t,n,l){return H2?new Tp(t,n,l):n?new Tp(t,n):new Tp(t)}doWrite(t,n){this.ws.send(n)}}class rM extends Gh{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=jV(Number.MAX_SAFE_INTEGER,this.socket.binaryType),l=t.readable.pipeThrough(n).getReader(),o=DV();o.readable.pipeTo(t.writable),this._writer=o.writable.getWriter();const r=()=>{l.read().then(({done:i,value:s})=>{i||(this.onPacket(s),r())}).catch(i=>{})};r();const a={type:"open"};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const l=t[n],o=n===t.length-1;this._writer.write(l).then(()=>{o&&yc(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const iM={websocket:aM,webtransport:rM,polling:lM},sM=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,uM=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function Pv(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),l=e.indexOf("]");n!=-1&&l!=-1&&(e=e.substring(0,n)+e.substring(n,l).replace(/:/g,";")+e.substring(l,e.length));let o=sM.exec(e||""),r={},a=14;for(;a--;)r[uM[a]]=o[a]||"";return n!=-1&&l!=-1&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=cM(r,r.path),r.queryKey=dM(r,r.query),r}function cM(e,t){const n=/\/{2,9}/g,l=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&l.splice(0,1),t.slice(-1)=="/"&&l.splice(l.length-1,1),l}function dM(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(l,o,r){o&&(n[o]=r)}),n}const Ov=typeof addEventListener=="function"&&typeof removeEventListener=="function",Ks=[];Ov&&addEventListener("offline",()=>{Ks.forEach(e=>e())},!1);class _o extends Xt{constructor(t,n){if(super(),this.binaryType=HV,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const l=Pv(t);n.hostname=l.host,n.secure=l.protocol==="https"||l.protocol==="wss",n.port=l.port,l.query&&(n.query=l.query)}else n.host&&(n.hostname=Pv(n.host).host);bc(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(l=>{const o=l.prototype.name;this.transports.push(o),this._transportsByName[o]=l}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=GV(this.opts.query)),Ov&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},Ks.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=R2,n.transport=t,this.id&&(n.sid=this.id);const l=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](l)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&_o.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",_o.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let l=0;l<this.writeBuffer.length;l++){const o=this.writeBuffer[l].data;if(o&&(n+=UV(o)),l>0&&n>this._maxPayload)return this.writeBuffer.slice(0,l);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,yc(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,l){return this._sendPacket("message",t,n,l),this}send(t,n,l){return this._sendPacket("message",t,n,l),this}_sendPacket(t,n,l,o){if(typeof n=="function"&&(o=n,n=void 0),typeof l=="function"&&(o=l,l=null),this.readyState==="closing"||this.readyState==="closed")return;l=l||{},l.compress=l.compress!==!1;const r={type:t,data:n,options:l};this.emitReserved("packetCreate",r),this.writeBuffer.push(r),o&&this.once("flush",o),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},l=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?l():t()}):this.upgrading?l():t()),this}_onError(t){if(_o.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),Ov&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const l=Ks.indexOf(this._offlineEventListener);l!==-1&&Ks.splice(l,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}_o.protocol=R2;class fM extends _o{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),l=!1;_o.priorWebsocketSuccess=!1;const o=()=>{l||(n.send([{type:"ping",data:"probe"}]),n.once("packet",f=>{if(!l)if(f.type==="pong"&&f.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;_o.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{l||this.readyState!=="closed"&&(u(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const v=new Error("probe error");v.transport=n.name,this.emitReserved("upgradeError",v)}}))};function r(){l||(l=!0,u(),n.close(),n=null)}const a=f=>{const v=new Error("probe error: "+f);v.transport=n.name,r(),this.emitReserved("upgradeError",v)};function i(){a("transport closed")}function s(){a("socket closed")}function c(f){n&&f.name!==n.name&&r()}const u=()=>{n.removeListener("open",o),n.removeListener("error",a),n.removeListener("close",i),this.off("close",s),this.off("upgrading",c)};n.once("open",o),n.once("error",a),n.once("close",i),this.once("close",s),this.once("upgrading",c),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{l||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let l=0;l<t.length;l++)~this.transports.indexOf(t[l])&&n.push(t[l]);return n}}let pM=class extends fM{constructor(t,n={}){const l=typeof t=="object"?t:n;(!l.transports||l.transports&&typeof l.transports[0]=="string")&&(l.transports=(l.transports||["polling","websocket","webtransport"]).map(o=>iM[o]).filter(o=>!!o)),super(t,l)}};function vM(e,t="",n){let l=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),l=Pv(e)),l.port||(/^(http|ws)$/.test(l.protocol)?l.port="80":/^(http|ws)s$/.test(l.protocol)&&(l.port="443")),l.path=l.path||"/";const r=l.host.indexOf(":")!==-1?"["+l.host+"]":l.host;return l.id=l.protocol+"://"+r+":"+l.port+t,l.href=l.protocol+"://"+r+(n&&n.port===l.port?"":":"+l.port),l}const hM=typeof ArrayBuffer=="function",mM=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,W2=Object.prototype.toString,gM=typeof Blob=="function"||typeof Blob<"u"&&W2.call(Blob)==="[object BlobConstructor]",yM=typeof File=="function"||typeof File<"u"&&W2.call(File)==="[object FileConstructor]";function Xh(e){return hM&&(e instanceof ArrayBuffer||mM(e))||gM&&e instanceof Blob||yM&&e instanceof File}function qs(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,l=e.length;n<l;n++)if(qs(e[n]))return!0;return!1}if(Xh(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return qs(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&qs(e[n]))return!0;return!1}function bM(e){const t=[],n=e.data,l=e;return l.data=_v(n,t),l.attachments=t.length,{packet:l,buffers:t}}function _v(e,t){if(!e)return e;if(Xh(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let l=0;l<e.length;l++)n[l]=_v(e[l],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const l in e)Object.prototype.hasOwnProperty.call(e,l)&&(n[l]=_v(e[l],t));return n}return e}function CM(e,t){return e.data=Tv(e.data,t),delete e.attachments,e}function Tv(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Tv(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Tv(e[n],t));return e}const kM=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],wM=5;var gt;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(gt||(gt={}));class $M{constructor(t){this.replacer=t}encode(t){return(t.type===gt.EVENT||t.type===gt.ACK)&&qs(t)?this.encodeAsBinary({type:t.type===gt.EVENT?gt.BINARY_EVENT:gt.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===gt.BINARY_EVENT||t.type===gt.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=bM(t),l=this.encodeAsString(n.packet),o=n.buffers;return o.unshift(l),o}}function Ky(e){return Object.prototype.toString.call(e)==="[object Object]"}class Jh extends Xt{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const l=n.type===gt.BINARY_EVENT;l||n.type===gt.BINARY_ACK?(n.type=l?gt.EVENT:gt.ACK,this.reconstructor=new SM(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(Xh(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const l={type:Number(t.charAt(0))};if(gt[l.type]===void 0)throw new Error("unknown packet type "+l.type);if(l.type===gt.BINARY_EVENT||l.type===gt.BINARY_ACK){const r=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const a=t.substring(r,n);if(a!=Number(a)||t.charAt(n)!=="-")throw new Error("Illegal attachments");l.attachments=Number(a)}if(t.charAt(n+1)==="/"){const r=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););l.nsp=t.substring(r,n)}else l.nsp="/";const o=t.charAt(n+1);if(o!==""&&Number(o)==o){const r=n+1;for(;++n;){const a=t.charAt(n);if(a==null||Number(a)!=a){--n;break}if(n===t.length)break}l.id=Number(t.substring(r,n+1))}if(t.charAt(++n)){const r=this.tryParse(t.substr(n));if(Jh.isPayloadValid(l.type,r))l.data=r;else throw new Error("invalid payload")}return l}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case gt.CONNECT:return Ky(n);case gt.DISCONNECT:return n===void 0;case gt.CONNECT_ERROR:return typeof n=="string"||Ky(n);case gt.EVENT:case gt.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&kM.indexOf(n[0])===-1);case gt.ACK:case gt.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class SM{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=CM(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const PM=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Jh,Encoder:$M,get PacketType(){return gt},protocol:wM},Symbol.toStringTag,{value:"Module"}));function rl(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const OM=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class K2 extends Xt{constructor(t,n,l){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,l&&l.auth&&(this.auth=l.auth),this._opts=Object.assign({},l),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[rl(t,"open",this.onopen.bind(this)),rl(t,"packet",this.onpacket.bind(this)),rl(t,"error",this.onerror.bind(this)),rl(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var l,o,r;if(OM.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const a={type:gt.EVENT,data:n};if(a.options={},a.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const u=this.ids++,f=n.pop();this._registerAckCallback(u,f),a.id=u}const i=(o=(l=this.io.engine)===null||l===void 0?void 0:l.transport)===null||o===void 0?void 0:o.writable,s=this.connected&&!(!((r=this.io.engine)===null||r===void 0)&&r._hasPingExpired());return this.flags.volatile&&!i||(s?(this.notifyOutgoingListeners(a),this.packet(a)):this.sendBuffer.push(a)),this.flags={},this}_registerAckCallback(t,n){var l;const o=(l=this.flags.timeout)!==null&&l!==void 0?l:this._opts.ackTimeout;if(o===void 0){this.acks[t]=n;return}const r=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let i=0;i<this.sendBuffer.length;i++)this.sendBuffer[i].id===t&&this.sendBuffer.splice(i,1);n.call(this,new Error("operation has timed out"))},o),a=(...i)=>{this.io.clearTimeoutFn(r),n.apply(this,i)};a.withError=!0,this.acks[t]=a}emitWithAck(t,...n){return new Promise((l,o)=>{const r=(a,i)=>a?o(a):l(i);r.withError=!0,n.push(r),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const l={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((o,...r)=>l!==this._queue[0]?void 0:(o!==null?l.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(o)):(this._queue.shift(),n&&n(null,...r)),l.pending=!1,this._drainQueue())),this._queue.push(l),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:gt.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(l=>String(l.id)===t)){const l=this.acks[t];delete this.acks[t],l.withError&&l.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case gt.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case gt.EVENT:case gt.BINARY_EVENT:this.onevent(t);break;case gt.ACK:case gt.BINARY_ACK:this.onack(t);break;case gt.DISCONNECT:this.ondisconnect();break;case gt.CONNECT_ERROR:this.destroy();const l=new Error(t.data.message);l.data=t.data.data,this.emitReserved("connect_error",l);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const l of n)l.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let l=!1;return function(...o){l||(l=!0,n.packet({type:gt.ACK,id:t,data:o}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:gt.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let l=0;l<n.length;l++)if(t===n[l])return n.splice(l,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let l=0;l<n.length;l++)if(t===n[l])return n.splice(l,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const l of n)l.apply(this,t.data)}}}function tr(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}tr.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};tr.prototype.reset=function(){this.attempts=0};tr.prototype.setMin=function(e){this.ms=e};tr.prototype.setMax=function(e){this.max=e};tr.prototype.setJitter=function(e){this.jitter=e};class Lv extends Xt{constructor(t,n){var l;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,bc(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((l=n.randomizationFactor)!==null&&l!==void 0?l:.5),this.backoff=new tr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const o=n.parser||PM;this.encoder=new o.Encoder,this.decoder=new o.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new pM(this.uri,this.opts);const n=this.engine,l=this;this._readyState="opening",this.skipReconnect=!1;const o=rl(n,"open",function(){l.onopen(),t&&t()}),r=i=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",i),t?t(i):this.maybeReconnectOnOpen()},a=rl(n,"error",r);if(this._timeout!==!1){const i=this._timeout,s=this.setTimeoutFn(()=>{o(),r(new Error("timeout")),n.close()},i);this.opts.autoUnref&&s.unref(),this.subs.push(()=>{this.clearTimeoutFn(s)})}return this.subs.push(o),this.subs.push(a),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(rl(t,"ping",this.onping.bind(this)),rl(t,"data",this.ondata.bind(this)),rl(t,"error",this.onerror.bind(this)),rl(t,"close",this.onclose.bind(this)),rl(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){yc(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let l=this.nsps[t];return l?this._autoConnect&&!l.active&&l.connect():(l=new K2(this,t,n),this.nsps[t]=l),l}_destroy(t){const n=Object.keys(this.nsps);for(const l of n)if(this.nsps[l].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let l=0;l<n.length;l++)this.engine.write(n[l],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var l;this.cleanup(),(l=this.engine)===null||l===void 0||l.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const l=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(o=>{o?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",o)):t.onreconnect()}))},n);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const fr={};function Us(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=vM(e,t.path||"/socket.io"),l=n.source,o=n.id,r=n.path,a=fr[o]&&r in fr[o].nsps,i=t.forceNew||t["force new connection"]||t.multiplex===!1||a;let s;return i?s=new Lv(l,t):(fr[o]||(fr[o]=new Lv(l,t)),s=fr[o]),n.query&&!t.query&&(t.query=n.queryKey),s.socket(n.path,t)}Object.assign(Us,{Manager:Lv,Socket:K2,io:Us,connect:Us});const _M=typeof window<"u",TM=_M&&(new URLSearchParams(window.location.search).get("debug")==="1"||window.localStorage.getItem("CCDEBUG_DEBUG")==="1"),Kl=(...e)=>{TM&&console.log(...e)},hi=V4("timeline",()=>{const e=I(null),t=I([]),n=I(null),l=I([]),o=I(null),r=I(null),a=I(!1),i=I(null),s=I(null),c=I([]),u=I(null),f=I(!1),v=I(""),h=I([]),m=I(!1),y=I(new Set),g=I(new Set),b=p(()=>o.value?o.value:null),k=p(()=>r.value?r.value:null),w=p(()=>{var ne;return((ne=s.value)==null?void 0:ne.connected)||!1}),$=async(ne=!1)=>{var ue;a.value=!0,i.value=null;try{const he=await wt.get("/api/project/info");he.data.success&&he.data.data&&(e.value=he.data.data);const me=new URLSearchParams(window.location.search),q=me.get("sessionid"),K=me.get("file"),z=me.get("step"),J=me.get("project");if(J&&!ne){const E=decodeURIComponent(J);if(Kl("检测到URL项目路径参数:",E),((ue=e.value)==null?void 0:ue.projectDir)!==E)try{await j(E);return}catch(G){console.warn("切换到指定项目失败:",G)}}if(K){await U();const E=c.value.find(G=>G.id===K);if(E)await M(E);else{let G=null;for(const ce of c.value){const re=`/api/files?mainLogId=${encodeURIComponent(ce.id)}`;try{const W=await wt.get(re);if(W.data.success&&W.data.data){const ge=W.data.data.files;if(ge.some(Ee=>Ee.id===K)){G=ce,t.value=ge;break}}}catch(W){console.error(`获取主日志 ${ce.id} 的文件列表失败:`,W)}}if(G)u.value=G,await S(K);else{const ce=await wt.get("/api/files");ce.data.success&&ce.data.data&&(t.value=ce.data.data.files),await S(K)}}if(o.value&&z){const G=o.value.steps.find(ce=>ce.id===z);G&&(r.value=G,setTimeout(()=>{ee(z),L(z)},300))}}else if(q){const E=`/api/files?sessionId=${encodeURIComponent(q)}`,G=await wt.get(E);if(G.data.success&&G.data.data){const{files:ce}=G.data.data;t.value=ce,ce.length===1&&(Kl(`找到唯一匹配sessionId ${q} 的文件,自动加载: ${ce[0].id}`),await S(ce[0].id))}}else await U(),c.value.length>0&&await M(c.value[0]);R()}catch(he){console.error("初始化失败:",he),i.value="初始化失败,请检查服务器连接"}finally{a.value=!1}},S=async ne=>{if(!(n.value===ne&&o.value!==null)){a.value=!0,i.value=null,o.value=null,r.value=null,l.value=[];try{const ue=await wt.get(`/api/conversations/${ne}`);if(ue.data.success&&ue.data.data)l.value=[ue.data.data],n.value=ne,o.value=ue.data.data,ue.data.data.steps&&ue.data.data.steps.length>0?r.value=ue.data.data.steps[0]:r.value=null;else throw n.value=ne,new Error(ue.data.error||"加载文件失败")}catch(ue){console.error("加载文件失败:",ue),i.value="加载文件失败,请重试",o.value=null,r.value=null,l.value=[]}finally{a.value=!1}}},P=ne=>{o.value=ne,ne.steps.length>0?r.value=ne.steps[0]:r.value=null},O=ne=>{r.value=ne,ne&&L(ne.id)},L=ne=>{setTimeout(()=>{const ue=document.querySelector(`[data-step-id="${ne}"]`);ue&&ue.scrollIntoView({behavior:"smooth",block:"center"})},100)},R=()=>{s.value&&s.value.disconnect();const ue=`http://localhost:${window.location.port||"3003"}`;s.value=Us(ue,{transports:["websocket","polling"]}),s.value.on("connect",()=>{Kl("WebSocket连接成功")}),s.value.on("disconnect",()=>{Kl("WebSocket连接断开")}),s.value.on("file:updated",async he=>{if(Kl("文件更新:",he),he.data.files&&(t.value=he.data.files),n.value&&he.data.fileId===n.value)if(he.data.conversations)if(l.value=he.data.conversations,o.value){const me=he.data.conversations.find(q=>{var K;return q.id===((K=o.value)==null?void 0:K.id)});if(me){if(o.value=me,r.value){const q=typeof r.value=="string"?r.value:r.value.id,K=me.steps.find(z=>z.id===q);K?r.value=K:r.value=me.steps[me.steps.length-1]||null}}else he.data.conversations.length>0?P(he.data.conversations[0]):(o.value=null,r.value=null)}else he.data.conversations.length>0&&P(he.data.conversations[0]);else await S(n.value)}),s.value.on("project:changed",he=>{Kl("项目变更:",he),$(!0)})},F=async()=>{try{const ue=new URLSearchParams(window.location.search).get("sessionid"),he=ue?`/api/files?sessionId=${encodeURIComponent(ue)}`:"/api/files",me=await wt.get(he);me.data.success&&me.data.data&&(t.value=me.data.data.files)}catch(ne){console.error("刷新文件列表失败:",ne),i.value="刷新文件列表失败"}},x=()=>{i.value=null},Z=()=>{s.value&&(s.value.disconnect(),s.value=null)},U=async()=>{f.value=!0,i.value=null;try{const ne=await wt.get("/api/main-logs");if(ne.data.success&&ne.data.data)c.value=ne.data.data.mainLogs,Kl(`获取到 ${c.value.length} 个主日志`);else throw new Error(ne.data.error||"获取主日志列表失败")}catch(ne){console.error("获取主日志列表失败:",ne),i.value="获取主日志列表失败,请重试"}finally{f.value=!1}},M=async ne=>{u.value=ne,a.value=!0,i.value=null;try{const ue=`/api/files?mainLogId=${encodeURIComponent(ne.id)}`,he=await wt.get(ue);if(he.data.success&&he.data.data)t.value=he.data.data.files,Kl(`选中主日志 ${ne.id},共 ${t.value.length} 个文件`);else throw new Error(he.data.error||"获取文件列表失败")}catch(ue){console.error("选择主日志失败:",ue),i.value="选择主日志失败,请重试"}finally{a.value=!1}},Y=async()=>{try{const ne=await wt.get("/api/projects");if(ne.data.success&&ne.data.data)return Kl(`获取到 ${ne.data.data.projects.length} 个可用项目`),ne.data.data.projects;throw new Error(ne.data.error||"获取项目列表失败")}catch(ne){throw console.error("获取项目列表失败:",ne),i.value="获取项目列表失败,请重试",ne}},j=async ne=>{a.value=!0,i.value=null;try{const ue=await wt.post("/api/project/switch",{projectPath:ne});if(ue.data.success&&ue.data.data)console.log(`项目已切换到: ${ue.data.data.projectDir}`),console.log(`日志目录: ${ue.data.data.logDir}`),n.value=null,o.value=null,r.value=null,l.value=[],t.value=[],c.value=[],u.value=null,await $(!0);else throw new Error(ue.data.error||"切换项目失败")}catch(ue){throw console.error("切换项目失败:",ue),i.value="切换项目失败,请重试",ue}finally{a.value=!1}},A=async ne=>{if(!ne.trim())return[];m.value=!0,v.value=ne;const ue=[];try{const he=[];if(u.value)he.push({fileId:u.value.id,fileName:u.value.name,isSubAgent:!1}),u.value.agentLogs&&u.value.agentLogs.length>0&&u.value.agentLogs.forEach(me=>{he.push({fileId:me.id,fileName:me.agentName||me.name,isSubAgent:!0})});else if(n.value){const me=t.value.find(q=>q.id===n.value);me&&he.push({fileId:me.id,fileName:me.name,isSubAgent:!1})}for(const me of he){const q=await N(me.fileId,me.fileName,me.isSubAgent,ne);q.resultCount>0&&ue.push(q)}return h.value=ue,ue}catch(he){throw console.error("搜索失败:",he),he}finally{m.value=!1}},N=async(ne,ue,he,me)=>{const q={fileId:ne,fileName:ue,isSubAgent:he,resultCount:0,results:[]};try{const K=await wt.get(`/api/conversations/${ne}`);if(!K.data.success||!K.data.data)return q;const z=K.data.data,J=me.toLowerCase().split(/\s+/).filter(E=>E.length>0);return z.steps.forEach((E,G)=>{const ce=D(E,J,ne,ue);q.results.push(...ce)}),q.resultCount=q.results.length,q}catch(K){return console.error(`搜索文件 ${ne} 失败:`,K),q}},D=(ne,ue,he,me)=>{const q=[];if(ne.content){const K=ne.content.toLowerCase();if(ue.every(z=>K.includes(z))){const z=V(ne.content,ue[0]);q.push({stepId:ne.id,stepType:ne.type,stepIndex:ne.originalIndex||0,timestamp:ne.timestamp,matchedContent:z,matchedField:"content",fileId:he,fileName:me,tool_use_id:ne.tool_use_id})}}return q},V=(ne,ue)=>{const he=ne.toLowerCase(),me=ue.toLowerCase(),q=he.indexOf(me);if(q===-1)return ne.substring(0,100)+(ne.length>100?"...":"");const K=Math.max(0,q-50),z=Math.min(ne.length,q+ue.length+50);let J=ne.substring(K,z);return K>0&&(J="..."+J),z<ne.length&&(J=J+"..."),J},H=ne=>{y.value.has(ne)?y.value.delete(ne):y.value.add(ne)},te=ne=>y.value.has(ne),ee=ne=>{y.value.has(ne)||y.value.add(ne)};return{currentProject:e,availableFiles:t,currentFileId:n,conversations:l,currentConversation:o,selectedStep:r,loading:a,error:i,mainLogs:c,selectedMainLog:u,mainLogsLoading:f,searchKeyword:v,searchResults:h,searchLoading:m,expandedSteps:y,durationNodes:g,currentConversationData:b,currentStepData:k,isConnected:w,initialize:$,loadFile:S,selectConversation:P,selectStep:O,scrollToStep:L,refreshFiles:F,clearError:x,disconnect:Z,fetchMainLogs:U,selectMainLog:M,fetchAvailableProjects:Y,switchProject:j,performSearch:A,toggleExpanded:H,isExpanded:te,ensureStepExpanded:ee,addDurationNode:ne=>{g.value.add(ne)},removeDurationNode:ne=>{g.value.delete(ne)},clearDurationNodes:()=>{g.value.clear()},isDurationNode:ne=>g.value.has(ne)}}),LM=Q({name:"IconShareAlt",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:t}){const n=ie("icon"),l=p(()=>[n,`${n}-share-alt`,{[`${n}-spin`]:e.spin}]),o=p(()=>{const a={};return e.size&&(a.fontSize=Be(e.size)?`${e.size}px`:e.size),e.rotate&&(a.transform=`rotate(${e.rotate}deg)`),a});return{cls:l,innerStyle:o,onClick:a=>{t("click",a)}}}}),EM=["stroke-width","stroke-linecap","stroke-linejoin"];function IM(e,t,n,l,o,r){return C(),T("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:_(e.cls),style:Ie(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:t[0]||(t[0]=(...a)=>e.onClick&&e.onClick(...a))},t[1]||(t[1]=[B("path",{d:"M32.442 21.552a4.5 4.5 0 1 1 .065 4.025m-.065-4.025-16.884-8.104m16.884 8.104A4.483 4.483 0 0 0 32 23.5c0 .75.183 1.455.507 2.077m-16.95-12.13a4.5 4.5 0 1 1-8.113-3.895 4.5 4.5 0 0 1 8.114 3.896Zm-.064 20.977A4.5 4.5 0 1 0 11.5 41c3.334-.001 5.503-3.68 3.993-6.578Zm0 0 17.014-8.847"},null,-1)]),14,EM)}var Lp=be(LM,[["render",IM]]);const BM=Object.assign(Lp,{install:(e,t)=>{var n;const l=(n=t==null?void 0:t.iconPrefix)!=null?n:"";e.component(l+Lp.name,Lp)}}),AM=Q({name:"IconBug",props:{size:{type:[Number,String]},strokeWidth:{type:Number,default:4},strokeLinecap:{type:String,default:"butt",validator:e=>["butt","round","square"].includes(e)},strokeLinejoin:{type:String,default:"miter",validator:e=>["arcs","bevel","miter","miter-clip","round"].includes(e)},rotate:Number,spin:Boolean},emits:{click:e=>!0},setup(e,{emit:t}){const n=ie("icon"),l=p(()=>[n,`${n}-bug`,{[`${n}-spin`]:e.spin}]),o=p(()=>{const a={};return e.size&&(a.fontSize=Be(e.size)?`${e.size}px`:e.size),e.rotate&&(a.transform=`rotate(${e.rotate}deg)`),a});return{cls:l,innerStyle:o,onClick:a=>{t("click",a)}}}}),xM=["stroke-width","stroke-linecap","stroke-linejoin"];function VM(e,t,n,l,o,r){return C(),T("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor",class:_(e.cls),style:Ie(e.innerStyle),"stroke-width":e.strokeWidth,"stroke-linecap":e.strokeLinecap,"stroke-linejoin":e.strokeLinejoin,onClick:t[0]||(t[0]=(...a)=>e.onClick&&e.onClick(...a))},t[1]||(t[1]=[B("path",{d:"M24 42c-6.075 0-11-4.925-11-11V18h22v13c0 6.075-4.925 11-11 11Zm0 0V23m11 4h8M5 27h8M7 14a4 4 0 0 0 4 4h26a4 4 0 0 0 4-4m0 28v-.5a6.5 6.5 0 0 0-6.5-6.5M7 42v-.5a6.5 6.5 0 0 1 6.5-6.5M17 14a7 7 0 1 1 14 0"},null,-1)]),14,xM)}var Ep=be(AM,[["render",VM]]);const MM=Object.assign(Ep,{install:(e,t)=>{var n;const l=(n=t==null?void 0:t.iconPrefix)!=null?n:"";e.component(l+Ep.name,Ep)}}),NM={class:"main-log-dialog"},RM={class:"file-name-cell"},zM={class:"file-id"},DM={class:"preview-text"},jM=Q({__name:"MainLogSelectDialog",props:{visible:{type:Boolean,default:!1},mainLogs:{default:()=>[]},loading:{type:Boolean,default:!1}},emits:["update:visible","select"],setup(e,{emit:t}){const n=e,l=t,o=p({get:()=>n.visible,set:m=>l("update:visible",m)}),r=I(null),a=I([]),i=[{title:"文件名",dataIndex:"name",slotName:"fileName",width:240,ellipsis:!0},{title:"开始时间",dataIndex:"startTime",slotName:"startTime",width:200},{title:"结束时间",dataIndex:"endTime",slotName:"endTime",width:200},{title:"输入消息",dataIndex:"inputPreview",slotName:"inputPreview",ellipsis:!0},{title:"子Agent数",dataIndex:"agentCount",slotName:"agentCount",width:120,align:"center"}],s={type:"radio"};Ae(a,m=>{if(m.length>0){const y=n.mainLogs.find(g=>g.id===m[0]);y&&(r.value=y)}});const c=m=>{if(!m)return"";const y=new Date(m),g=y.getFullYear(),b=String(y.getMonth()+1).padStart(2,"0"),k=String(y.getDate()).padStart(2,"0"),w=String(y.getHours()).padStart(2,"0"),$=String(y.getMinutes()).padStart(2,"0"),S=String(y.getSeconds()).padStart(2,"0");return`${g}/${b}/${k} ${w}:${$}:${S}`},u=m=>{a.value=[m.id],r.value=m},f=()=>{r.value&&(l("select",r.value),o.value=!1,h())},v=()=>{o.value=!1,h()},h=()=>{r.value=null,a.value=[]};return Ae(o,m=>{m||h()}),(m,y)=>{const g=oe("a-tooltip"),b=oe("a-tag"),k=oe("a-table"),w=oe("a-modal");return C(),ve(w,{visible:o.value,"onUpdate:visible":y[1]||(y[1]=$=>o.value=$),title:"选择会话日志",width:"1020px","mask-closable":!1,onOk:f,onCancel:v},{default:pe(()=>[B("div",NM,[d(k,{columns:i,data:n.mainLogs,loading:n.loading,pagination:!1,scroll:{y:400},"row-key":"id","row-selection":s,"selected-keys":a.value,"onUpdate:selectedKeys":y[0]||(y[0]=$=>a.value=$),onRowClick:u},{fileName:pe(({record:$})=>[B("div",RM,[B("span",zM,we($.id),1)])]),startTime:pe(({record:$})=>[B("span",null,we(c($.startTime)),1)]),endTime:pe(({record:$})=>[B("span",null,we(c($.endTime)),1)]),inputPreview:pe(({record:$})=>[d(g,{content:$.inputFull,position:"top"},{default:pe(()=>[B("span",DM,we($.inputPreview),1)]),_:2},1032,["content"])]),agentCount:pe(({record:$})=>[d(b,{color:"blue"},{default:pe(()=>[De(we($.agentLogs.length),1)]),_:2},1024)]),_:1},8,["data","loading","selected-keys"])])]),_:1},8,["visible"])}}}),Vo=(e,t)=>{const n=e.__vccOpts||e;for(const[l,o]of t)n[l]=o;return n},FM=Vo(jM,[["__scopeId","data-v-533a9e6f"]]),HM={class:"project-select-dialog"},WM={class:"search-container"},KM={class:"project-name-cell"},qM={class:"project-name"},UM={class:"path-text"},YM=Q({__name:"ProjectSelectDialog",props:{visible:{type:Boolean,default:!1},projects:{default:()=>[]},currentProject:{},loading:{type:Boolean,default:!1}},emits:["update:visible","select"],setup(e,{emit:t}){const n=e,l=t,o=I(""),r=p(()=>{if(!o.value.trim())return n.projects;const b=o.value.toLowerCase();return n.projects.filter(k=>k.name.toLowerCase().includes(b)||k.path.toLowerCase().includes(b))}),a=p({get:()=>n.visible,set:b=>l("update:visible",b)}),i=I(null),s=I([]),c=[{title:"项目名称",dataIndex:"name",slotName:"projectName",width:300},{title:"项目路径",dataIndex:"path",slotName:"projectPath"}],u={type:"radio"};Ae(s,b=>{if(b.length>0){const k=r.value.find(w=>w.path===b[0]);k&&(i.value=k)}});const f=b=>{o.value=b},v=()=>{o.value=""},h=b=>{s.value=[b.path],i.value=b},m=()=>{i.value&&(l("select",i.value.path),a.value=!1,g())},y=()=>{a.value=!1,g()},g=()=>{i.value=null,s.value=[]};return Ae(a,b=>{if(b&&n.currentProject){const k=r.value.find(w=>w.path===n.currentProject);k&&(s.value=[k.path],i.value=k)}else b||(g(),o.value="")}),(b,k)=>{const w=oe("a-input-search"),$=oe("a-alert"),S=oe("a-tag"),P=oe("a-table"),O=oe("a-modal");return C(),ve(O,{visible:a.value,"onUpdate:visible":k[2]||(k[2]=L=>a.value=L),title:"选择项目",width:"1200px","mask-closable":!1,onOk:m,onCancel:y},{default:pe(()=>[B("div",HM,[B("div",WM,[d(w,{modelValue:o.value,"onUpdate:modelValue":k[0]||(k[0]=L=>o.value=L),placeholder:"请输入项目名称进行搜索","allow-clear":"",onClear:v,onSearch:f,style:{"margin-bottom":"16px"}},null,8,["modelValue"])]),!n.loading&&r.value.length===0?(C(),ve($,{key:0,type:"warning",style:{"margin-bottom":"16px"}},{default:pe(()=>[De(we(o.value?"未找到匹配的项目":"未找到可用项目")+"。请确认用户主目录下存在 ",1),k[3]||(k[3]=B("code",null,"~/.claude/projects",-1)),k[4]||(k[4]=De(" 目录。 ",-1))]),_:1})):ae("",!0),d(P,{columns:c,data:r.value,loading:n.loading,pagination:!1,scroll:{y:500},"row-key":"path","row-selection":u,"selected-keys":s.value,"onUpdate:selectedKeys":k[1]||(k[1]=L=>s.value=L),onRowClick:h},{projectName:pe(({record:L})=>[B("div",KM,[B("span",qM,we(L.name),1),L.isDefault?(C(),ve(S,{key:0,color:"blue",size:"small",style:{"margin-left":"8px"}},{default:pe(()=>[...k[5]||(k[5]=[De(" 当前项目 ",-1)])]),_:1})):ae("",!0)])]),projectPath:pe(({record:L})=>[B("span",UM,we(L.path),1)]),_:1},8,["data","loading","selected-keys"])])]),_:1},8,["visible"])}}}),ZM=Vo(YM,[["__scopeId","data-v-a8fb4722"]]),qy=e=>({user_message:"#1890ff",assistant_thinking:"#faad14",assistant_message:"#52c41a",tool_call:"#722ed1",tool_result:"#13c2c2",agent_child:"#eb2f96",agent_end:"#eb2f96",sub_agent:"#eb2f96"})[e]||"#d9d9d9",GM=e=>({user_message:"#e6f7ff",assistant_thinking:"#fff7e6",assistant_message:"#f6ffed",tool_call:"#f9f0ff",tool_result:"#e6fffb",agent_child:"#fff0f6",agent_end:"#fff0f6",sub_agent:"#fff0f6"})[e]||"#f5f5f5",XM={class:"file-selector"},JM={class:"info-item"},QM={class:"value"},eN={class:"info-item"},tN={class:"value"},nN={class:"file-selector-content"},lN={class:"file-option"},oN={class:"file-name"},aN={class:"step-count"},rN={key:0,class:"no-files"},iN={key:0},sN={class:"detail-item"},uN={class:"value"},cN={class:"detail-item"},dN={class:"value"},fN={class:"detail-item"},pN={class:"value"},vN={class:"step-type-filter"},hN={class:"filter-actions"},mN={class:"steps-chart"},gN=["title","onClick"],yN={class:"step-index"},bN={key:0,class:"filter-stats"},CN={key:1,class:"file-hint"},kN=Q({__name:"ProjectPanel",setup(e){const t=(()=>{try{return new URLSearchParams(window.location.search).get("debug")==="1"||window.localStorage.getItem("CCDEBUG_DEBUG")==="1"}catch{return!1}})(),n=(...ee)=>{t&&console.log(...ee)},l=hi(),o=p(()=>l.currentProject),r=p(()=>l.availableFiles),a=p(()=>l.currentFileId),i=p(()=>l.conversations),s=p(()=>l.currentConversation),c=p(()=>l.selectedStep),u=p(()=>l.loading);p(()=>l.isConnected);const f=p(()=>l.mainLogs),v=p(()=>l.mainLogsLoading),h=I(null),m=I(null),y=I(!1),g=I(!1),b=I([]),k=I(!1),w=[{value:"user_message",label:"用户消息",color:"#1890ff"},{value:"assistant_thinking",label:"助手思考",color:"#faad14"},{value:"assistant_message",label:"助手消息",color:"#52c41a"},{value:"tool_call",label:"工具调用",color:"#722ed1"},{value:"sub_agent",label:"子代理",color:"#eb2f96"}],$=I(["user_message","assistant_thinking","assistant_message","tool_call","sub_agent"]),S=I([]),P=p(()=>{var X;if(!((X=s.value)!=null&&X.steps))return[];const ee=new Set;return s.value.steps.forEach(le=>{le.type==="tool_call"&&le.tool_name&&ee.add(le.tool_name)}),Array.from(ee).sort()});Ae([()=>w,P],([ee,X])=>{if(ee.length>0&&S.value.length===0){const le=ee.map(de=>de.value),fe=X.map(de=>`tool:${de}`);S.value=[...le,...fe]}},{immediate:!0});const O=p(()=>w.map(ee=>ee.value==="tool_call"?{key:ee.value,title:ee.label,children:P.value.map(X=>({key:`tool:${X}`,title:X}))}:{key:ee.value,title:ee.label})),L=p(()=>{var ee;return(ee=s.value)!=null&&ee.steps?s.value.steps.filter(X=>{const le=X.type==="agent_child"||X.type==="agent_end"?"sub_agent":X.type;if(le==="tool_call"){const fe=S.value.filter(de=>de.startsWith("tool:")).map(de=>de.substring(5));return fe.length>0?(n("过滤工具调用:",{stepToolName:X.tool_name,selectedTools:fe,match:fe.includes(X.tool_name||"")}),fe.includes(X.tool_name||"")):S.value.includes("tool_call")}return S.value.includes(le)}):[]}),R=()=>{const ee=w.map(le=>le.value),X=P.value.map(le=>`tool:${le}`);S.value=[...ee,...X]},F=()=>{S.value=[]};Ae(S,ee=>{$.value=ee.filter(X=>!X.startsWith("tool:"))},{immediate:!0}),Ae(a,ee=>{n("🔍 调试测试: currentFileId变化",{newFileId:ee,oldSelectedFileId:h.value}),h.value=ee},{immediate:!0});const x=ee=>{n("🔍 调试测试: 文件切换",{fileId:ee,currentFileId:a.value}),h.value=ee,ee!==a.value&&l.loadFile(ee)},Z=ee=>{l.selectStep(ee),U(ee.id)},U=ee=>{setTimeout(()=>{const X=document.querySelector(`[data-step-id="${ee}"]`);X&&X.scrollIntoView({behavior:"smooth",block:"center"})},100)},M=ee=>new Date(ee).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Y=ee=>new Date(ee).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),j=()=>{var fe;if(!h.value)return"";let ee=r.value.find(de=>de.id===h.value);if(!ee)for(const de of f.value){const ne=(fe=de.agentLogs)==null?void 0:fe.find(ue=>ue.id===h.value);if(ne){ee=ne;break}}if(ee)return A(ee);const X=h.value,le=X.lastIndexOf(".");return le>-1?X.substring(0,le):X},A=ee=>{if(ee.agentName)return ee.agentName;const X=ee.name,le=X.lastIndexOf(".");return le>-1?X.substring(0,le):X},N=ee=>{const X=i.value.find(le=>le.id===ee.id);return X!=null&&X.steps?X.steps.filter(le=>le.type!=="tool_result").length:ee.stepCount!==void 0?ee.stepCount:0},D=async()=>{await l.fetchMainLogs(),y.value=!0},V=async ee=>{n("📋 选择主日志:",ee),await l.selectMainLog(ee)},H=async()=>{k.value=!0;try{b.value=await l.fetchAvailableProjects()}catch(ee){console.error("获取项目列表失败:",ee)}finally{k.value=!1}g.value=!0},te=async ee=>{n("📁 选择项目:",ee);try{await l.switchProject(ee),g.value=!1}catch(X){console.error("切换项目失败:",X)}};return Ae(i,()=>{ft(()=>{const ee=h.value;ee&&(h.value=null,ft(()=>{h.value=ee}))})},{deep:!0}),lt(()=>{const X=new URLSearchParams(window.location.search).get("sessionid");X&&(m.value=X)}),(ee,X)=>{var fe,de;const le=oe("a-alert");return C(),T("div",XM,[d(it(hr),{title:"项目信息",bordered:!1,size:"small",class:"file-card"},{extra:pe(()=>[d(it(qt),{type:"primary",size:"small",onClick:H,loading:k.value},{default:pe(()=>[...X[4]||(X[4]=[De(" 选择项目 ",-1)])]),_:1},8,["loading"])]),default:pe(()=>{var ne,ue;return[B("div",JM,[X[5]||(X[5]=B("span",{class:"label"},"项目路径:",-1)),B("span",QM,we(((ne=o.value)==null?void 0:ne.path)||"未知"),1)]),B("div",eN,[X[6]||(X[6]=B("span",{class:"label"},"日志目录:",-1)),B("span",tN,we(((ue=o.value)==null?void 0:ue.logDir)||"未知"),1)])]}),_:1}),d(it(hr),{title:"日志文件",bordered:!1,size:"small",class:"file-card"},{extra:pe(()=>[d(it(qt),{type:"primary",size:"small",onClick:D,loading:v.value},{default:pe(()=>[...X[7]||(X[7]=[De(" 选择会话 ",-1)])]),_:1},8,["loading"])]),default:pe(()=>[B("div",nN,[d(it(za),{modelValue:h.value,"onUpdate:modelValue":X[0]||(X[0]=ne=>h.value=ne),placeholder:"请选择日志文件",loading:u.value,disabled:r.value.length===0,onChange:x,class:"file-select","popup-container":".file-selector","popup-props":{class:"custom-select-popup"}},{default:pe(()=>[(C(!0),T(Me,null,Ct(r.value,ne=>(C(),ve(it(Po),{key:ne.id,value:ne.id,label:A(ne)},{default:pe(()=>[B("div",lN,[B("div",oN,[De(we(A(ne)),1),B("span",aN,"("+we(N(ne))+"步)",1)])])]),_:2},1032,["value","label"]))),128))]),_:1},8,["modelValue","loading","disabled"]),r.value.length===0&&!u.value?(C(),T("div",rN,[d(it(Rl),{description:"未找到日志文件"})])):ae("",!0)])]),_:1}),d(FM,{visible:y.value,"onUpdate:visible":X[1]||(X[1]=ne=>y.value=ne),"main-logs":f.value,loading:v.value,onSelect:V},null,8,["visible","main-logs","loading"]),d(ZM,{visible:g.value,"onUpdate:visible":X[2]||(X[2]=ne=>g.value=ne),projects:b.value,"current-project":(fe=o.value)==null?void 0:fe.path,loading:k.value,onSelect:te},null,8,["visible","projects","current-project","loading"]),h.value?(C(),T("div",iN,[d(it(hr),{title:"日志信息",bordered:!1,size:"small",class:"file-card"},{default:pe(()=>{var ne,ue;return[B("div",sN,[X[8]||(X[8]=B("span",{class:"label"},"文件名:",-1)),B("span",uN,we(j()),1)]),B("div",cN,[X[9]||(X[9]=B("span",{class:"label"},"开始时间:",-1)),B("span",dN,we((ne=s.value)!=null&&ne.timestamp?Y(s.value.timestamp):"-"),1)]),B("div",fN,[X[10]||(X[10]=B("span",{class:"label"},"步骤数量:",-1)),B("span",pN,we((ue=s.value)!=null&&ue.steps?s.value.steps.filter(he=>he.type!=="tool_result").length:0),1)])]}),_:1}),(de=s.value)!=null&&de.steps&&s.value.steps.length>0?(C(),ve(it(hr),{key:0,title:"步骤概览",bordered:!1,class:"file-card",size:"small"},{extra:pe(()=>[d(it(Ju),{trigger:"click",position:"bottom"},{content:pe(()=>[B("div",vN,[X[13]||(X[13]=B("div",{class:"filter-header"},"选择要显示的节点类型",-1)),d(it(ku),{"checked-keys":S.value,"onUpdate:checkedKeys":X[3]||(X[3]=ne=>S.value=ne),data:O.value,checkable:!0,"default-expand-all":!0,"show-line":!1,size:"mini","block-node":!0},{icon:pe(({node:ne})=>{var ue;return[B("div",{class:"tree-node-color",style:Ie({backgroundColor:ne.key.startsWith("tool:")?"#722ed1":(ue=w.find(he=>he.value===ne.key))==null?void 0:ue.color})},null,4)]}),_:1},8,["checked-keys","data"]),B("div",hN,[d(it(qt),{size:"mini",onClick:R},{default:pe(()=>[...X[11]||(X[11]=[De(" 全选 ",-1)])]),_:1}),d(it(qt),{size:"mini",onClick:F},{default:pe(()=>[...X[12]||(X[12]=[De(" 清空 ",-1)])]),_:1})])])]),default:pe(()=>[d(it(qt),{type:"text",size:"small"},{icon:pe(()=>[d(it(MC))]),default:pe(()=>[De(" 过滤 ("+we(L.value.length)+") ",1)]),_:1})]),_:1})]),default:pe(()=>[B("div",mN,[(C(!0),T(Me,null,Ct(L.value,(ne,ue)=>{var he;return C(),T("div",{key:ne.id,class:_(["step-bar",{selected:((he=c.value)==null?void 0:he.id)===ne.id}]),style:Ie({backgroundColor:it(GM)(ne.type),borderColor:it(qy)(ne.type),color:it(qy)(ne.type)}),title:`${ne.type} - ${M(ne.timestamp)}`,onClick:me=>Z(ne)},[B("span",yN,we(ne.originalIndex),1)],14,gN)}),128))]),s.value?(C(),T("div",bN," 显示 "+we(L.value.length)+" / "+we(s.value.steps.filter(ne=>ne.type!=="tool_result").length)+" 个步骤 ",1)):ae("",!0)]),_:1})):ae("",!0)])):(C(),T("div",CN,[d(le,null,{default:pe(()=>[...X[14]||(X[14]=[De("选择一个日志文件以查看对话时间线和详细信息",-1)])]),_:1})]))])}}}),wN=Vo(kN,[["__scopeId","data-v-40398113"]]),$N={key:0,class:"loading"},SN={key:1,class:"timeline-content"},PN={key:0,class:"empty-state"},ON={key:1,class:"timeline-wrapper"},_N={class:"timeline-title"},TN={class:"timeline-main"},LN=["onClick"],EN={key:0,class:"timeline-time"},IN={key:0,class:"timeline-elapsed"},BN={class:"timeline-connector"},AN=["title","onContextmenu"],xN={class:"step-number"},VN={key:0,class:"timeline-line"},MN=["data-from-id","data-to-id"],NN={class:"duration-label"},RN=["data-step-id"],zN=["onClick"],DN={class:"header-left"},jN={class:"tag-duration-group"},FN={class:"step-type-tag"},HN={class:"summary-text"},WN={key:0,class:"tool-name-highlight"},KN={key:1,class:"subagent-type-highlight"},qN={key:2,class:"tool-specific-info"},UN={key:3,class:"subagent-prompt"},YN={class:"tag-duration-group"},ZN=["title"],GN={key:0,class:"header-info"},XN={key:0,class:"tool-name-header"},JN={key:1,class:"subagent-name-header"},QN=["onClick"],eR={key:0,class:"user-query-content"},tR=["innerHTML"],nR={key:1,class:"agent-thinking-content"},lR=["innerHTML"],oR={key:2,class:"agent-message-content"},aR=["innerHTML"],rR={key:3,class:"tool-use-content"},iR={key:0,class:"tool-details-expanded"},sR={class:"tool-header"},uR={class:"tool-name"},cR={class:"tool-parameters"},dR=["innerHTML"],fR={key:0,class:"tool-result-container"},pR={class:"tool-result-card"},vR={class:"result-content"},hR=["innerHTML"],mR={key:4,class:"sub-agent-content"},gR={key:0,class:"sub-agent-details-expanded"},yR={class:"sub-agent-header"},bR=["onClick","title"],CR={key:1,class:"sub-agent-type-text"},kR={class:"sub-agent-parameters"},wR=["innerHTML"],$R={key:0,class:"tool-result-container"},SR={class:"tool-result-card"},PR={class:"result-content"},OR=["innerHTML"],_R={key:5,class:"default-content"},TR=["innerHTML"],LR=Q({components:{ATooltip:qn},__name:"Timeline",setup(e,{expose:t}){const n=(()=>{var E;if(typeof window<"u")try{return new URL(window.location.href).searchParams.get("debug")==="1"||((E=window.localStorage)==null?void 0:E.getItem("CCDEBUG_DEBUG"))==="1"}catch{return!1}return!1})(),l=(...E)=>{n&&console.log(...E)},o=(...E)=>{n&&console.warn(...E)},r=hi(),a=p(()=>r.loading);p(()=>r.conversations);const i=p(()=>r.currentConversation),s=p(()=>r.selectedStep),c=p(()=>r.searchKeyword),u=I(!1),f=I({x:0,y:0}),v=I(null),h=p(()=>{var re;if(!((re=i.value)!=null&&re.steps))return[];const E=i.value.steps;l("🔍 processedSteps - 原始步骤数量:",E.length);const G=new Map;E.forEach(W=>{(W.type==="tool_call"||W.type==="agent_child")&&(l("🔧 找到工具/子代理步骤:",{id:W.id,tool_use_id:W.tool_use_id,tool_name:W.tool_name,type:W.type}),W.tool_use_id?G.set(W.tool_use_id,{...W}):(o("⚠️ 工具/子代理步骤缺少tool_use_id,使用步骤id作为fallback:",W.id),G.set(W.id,{...W})))}),l("🗺️ toolUseMap大小:",G.size),E.forEach(W=>{if(W.type==="tool_result"){l("📊 找到tool_result步骤:",{id:W.id,tool_use_id:W.tool_use_id});let ge=null;if(W.tool_use_id&&(ge=G.get(W.tool_use_id)),!ge){const Ee=E.indexOf(W);for(let _e=Ee-1;_e>=0;_e--){const Ve=E[_e];if(Ve.type==="tool_call"){const Ke=Ve.tool_use_id||Ve.id;if(ge=G.get(Ke),ge){l("🔗 通过位置关系关联tool_result到tool_call:",{toolResultId:W.id,toolCallId:Ve.id});break}}}}ge?(ge.toolResult=W,l("✅ 成功关联tool_result到tool_call")):o("⚠️ 无法找到对应的tool_call步骤")}});const ce=[];return E.forEach(W=>{if(W.type==="tool_call"||W.type==="agent_child"){const ge=W.tool_use_id||W.id,Ee=G.get(ge);Ee?(ce.push(Ee),l("📝 添加工具/子代理步骤:",{id:Ee.id,type:Ee.type,hasToolResult:!!Ee.toolResult})):(ce.push(W),l("📝 添加原始工具/子代理步骤:",{id:W.id,type:W.type}))}else W.type==="tool_result"?l("🚫 跳过tool_result步骤,应作为工具/子代理的子节点:",W.id):ce.push(W)}),l("📋 最终处理后的步骤数量:",ce.length),ce}),m=E=>{r.selectConversation(E)},y=E=>{r.selectStep(E)},g=E=>{k(E)&&(r.toggleExpanded(E.id),te(),r.selectStep(E))},b=E=>{if(E.type==="user_message"||E.type==="assistant_thought"||E.type==="assistant_message")return!1;if(E.type==="tool_call"||E.type==="agent_child")return!0;const G=R(E);return G?Math.ceil(G.length/50)*20+40>150:!1},k=E=>E.type==="tool_call"||E.type==="agent_child",w=(E,G)=>E?E.length<=G?E:E.substring(0,G)+"...":"",$=E=>E&&(E.prompt||E.query||E.input||E.message)||"",S=E=>{var Ee,_e;const G=Ve=>{if(!Array.isArray(Ve))return"任务总数:0; completed:0; in_progress:0; pending:0";const Ke=Ve.length,rt=Ve.filter(Te=>Te.status==="completed").length,$e=Ve.filter(Te=>Te.status==="in_progress").length,Ce=Ve.filter(Te=>Te.status==="pending").length;return`任务总数:${Ke}; pending:${Ce}; in_progress:${$e}; completed:${rt}`};let ce=[],re=[];E.toolResult&&E.toolResult.rawLogEntry.toolUseResult?(ce=E.toolResult.rawLogEntry.toolUseResult.oldTodos,re=E.toolResult.rawLogEntry.toolUseResult.newTodos):(ce=((Ee=E.parameters)==null?void 0:Ee.old_todos)||[],re=((_e=E.parameters)==null?void 0:_e.todos)||[]);const W=G(ce),ge=G(re);return`调用前(${W}) -> 调用后(${ge})`},P=E=>{var re;const G=E.parameters||{};switch(((re=E.tool_name)==null?void 0:re.toLowerCase())||""){case"edit":return G.filePath||G.file_path||"";case"glob":return G.pattern||"";case"grep":const W=G.path||"",ge=G.pattern||"";return`${W} | ${ge}`;case"read":return G.file_path||"";case"skill":return G.skill||"";case"todowrite":return S(E);case"write":return G.file_path||"";case"bash":return G.command||"";default:const Ee=Object.keys(G)[0];return Ee?String(G[Ee]):""}},O=E=>{if(E.type==="agent_child"){const G=E.subagent_type||"未知",ce=$(E.parameters);return`${G} | ${ce}`}if(E.type==="tool_call"){const G=E.tool_name||"未知工具",ce=P(E);return`${G} | ${ce}`}return""},L=E=>{if(E.type==="agent_child")return $(E.parameters)||"无参数信息";if(E.type==="tool_call"){const G=E.parameters||{};return JSON.stringify(G,null,2)}return""},R=E=>{if(E.type==="tool_call"){let G=JSON.stringify(E.parameters||{},null,2);if(E.toolResult){const ce=z(E,!0);G+=`
38
- `+ce}return G}else if(E.type==="tool_result")return z(E,!0);return E.content||""},F=E=>{if(!E.toolResult||!E.timestamp||!E.toolResult.timestamp)return null;try{const G=new Date(E.timestamp).getTime(),ce=new Date(E.toolResult.timestamp).getTime();if(isNaN(G)||isNaN(ce))return null;const re=ce-G;let W="",ge="";if(re<1e3)W=`耗时:${re}毫秒`,ge="duration-fast";else if(re<6e4){const Ee=Math.floor(re/1e3),_e=re%1e3;_e>0?W=`耗时:${Ee}.${Math.floor(_e/100)}秒`:W=`耗时:${Ee}秒`,re<3e3?ge="duration-fast":re<3e4?ge="duration-medium":ge="duration-slow"}else{const Ee=Math.floor(re/6e4),_e=Math.floor(re%6e4/1e3);_e>0?W=`耗时:${Ee}分${_e}秒`:W=`耗时:${Ee}分钟`,re<12e4?ge="duration-slow":ge="duration-very-slow"}return{text:W,class:ge}}catch(G){return console.warn("计算耗时失败:",G),null}},x=E=>{if(!c.value||!E)return E;const G=c.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),ce=new RegExp(`(${G})`,"gi");return E.replace(ce,'<mark class="search-highlight-keyword">$1</mark>')},Z=E=>{if(!E)return"";const G=c.value;let ce=E;return G&&(ce=x(E)),ce.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(re){let W="json-number";return/^"/.test(re)?/:$/.test(re)?W="json-key":W="json-string":/true|false/.test(re)?W="json-boolean":/null/.test(re)&&(W="json-null"),'<span class="'+W+'">'+re+"</span>"}).replace(/([{}[\],])/g,'<span class="json-bracket">$1</span>')},U=(E,G)=>{c.value;const ce=r.isExpanded(E.id);let re=G;return re||(E.type==="tool_result"||E.type==="tool_call"&&E.toolResult?re=z(E,ce):re=E.content||""),ce?x(re):b(E)?x(A(re,150)):x(re)},M=(E,G)=>{let ce=G;return ce||(ce=E.content||""),Z(ce)},Y=(E,G=!1)=>{const ce=z(E,!0);return Z(ce)},j=(E,G)=>{if(typeof window<"u"){const re=document.querySelector(`[data-step-id="${E.id}"] .card-content`);if(re){const W=re.scrollHeight,ge=re.clientHeight;return W>ge}}const ce=G||E.content||"";if(!b(E)){const W=Math.floor(15.5)*50;return ce.length>W}if(r.isExpanded(E.id)){const W=Math.floor(15.5)*50;return ce.length>W}else{const W=Math.floor(5.5)*50;return ce.length>W}},A=(E,G)=>{if(!E)return"";const re=Math.floor((G-40)/20)*50;if(E.length<=re)return E;const W=E.substring(0,re),ge=W.lastIndexOf(`
38
+ `+ce}return G}else if(E.type==="tool_result")return z(E,!0);return E.content||""},F=E=>{if(!E.toolResult||!E.timestamp||!E.toolResult.timestamp)return null;try{const G=new Date(E.timestamp).getTime(),ce=new Date(E.toolResult.timestamp).getTime();if(isNaN(G)||isNaN(ce))return null;const re=ce-G;let W="",ge="";if(re<1e3)W=`耗时:${re}毫秒`,ge="duration-fast";else if(re<6e4){const Ee=Math.floor(re/1e3),_e=re%1e3;_e>0?W=`耗时:${Ee}.${Math.floor(_e/100)}秒`:W=`耗时:${Ee}秒`,re<3e3?ge="duration-fast":re<3e4?ge="duration-medium":ge="duration-slow"}else{const Ee=Math.floor(re/6e4),_e=Math.floor(re%6e4/1e3);_e>0?W=`耗时:${Ee}分${_e}秒`:W=`耗时:${Ee}分钟`,re<12e4?ge="duration-slow":ge="duration-very-slow"}return{text:W,class:ge}}catch(G){return console.warn("计算耗时失败:",G),null}},x=E=>{if(!c.value||!E)return E;const G=typeof E=="string"?E:JSON.stringify(E,null,2),ce=c.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),re=new RegExp(`(${ce})`,"gi");return G.replace(re,'<mark class="search-highlight-keyword">$1</mark>')},Z=E=>{if(!E)return"";const G=c.value;let ce=E;return G&&(ce=x(E)),ce.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(re){let W="json-number";return/^"/.test(re)?/:$/.test(re)?W="json-key":W="json-string":/true|false/.test(re)?W="json-boolean":/null/.test(re)&&(W="json-null"),'<span class="'+W+'">'+re+"</span>"}).replace(/([{}[\],])/g,'<span class="json-bracket">$1</span>')},U=(E,G)=>{c.value;const ce=r.isExpanded(E.id);let re=G;return re||(E.type==="tool_result"||E.type==="tool_call"&&E.toolResult?re=z(E,ce):re=E.content||""),ce?x(re):b(E)?x(A(re,150)):x(re)},M=(E,G)=>{let ce=G;return ce||(ce=E.content||""),Z(ce)},Y=(E,G=!1)=>{const ce=z(E,!0);return Z(ce)},j=(E,G)=>{if(typeof window<"u"){const re=document.querySelector(`[data-step-id="${E.id}"] .card-content`);if(re){const W=re.scrollHeight,ge=re.clientHeight;return W>ge}}const ce=G||E.content||"";if(!b(E)){const W=Math.floor(15.5)*50;return ce.length>W}if(r.isExpanded(E.id)){const W=Math.floor(15.5)*50;return ce.length>W}else{const W=Math.floor(5.5)*50;return ce.length>W}},A=(E,G)=>{if(!E)return"";const re=Math.floor((G-40)/20)*50;if(E.length<=re)return E;const W=E.substring(0,re),ge=W.lastIndexOf(`
39
39
  `);return ge>re*.8?W.substring(0,ge)+`
40
- ...`:W+"..."},N=E=>{var G;if(!((G=i.value)!=null&&G.steps)||i.value.steps.length===0)return null;try{const ce=i.value.steps[0];if(!ce.timestamp||!E.timestamp)return null;const re=new Date(ce.timestamp).getTime(),W=new Date(E.timestamp).getTime();if(isNaN(re)||isNaN(W))return null;const ge=W-re;return D(ge)}catch(ce){return console.warn("计算耗时失败:",ce),null}},D=E=>{if(E<1e3)return`${E}ms`;if(E<6e4)return`${(E/1e3).toFixed(1)}s`;{const G=Math.floor(E/6e4),ce=Math.floor(E%6e4/1e3);return ce>0?`${G}m${ce}s`:`${G}m`}},V=(E,G)=>{if(!G||!E.timestamp||!G.timestamp)return"";try{const ce=new Date(E.timestamp).getTime(),re=new Date(G.timestamp).getTime();if(isNaN(ce)||isNaN(re))return"";const W=re-ce;return D(W)}catch(ce){return console.warn("计算节点间耗时失败:",ce),""}},H=E=>{if(!h.value)return null;for(let G=E+1;G<h.value.length;G++){const ce=h.value[G];if(r.isDurationNode(ce.id))return ce}return null},te=()=>{typeof window>"u"||requestAnimationFrame(()=>{document.querySelectorAll(".duration-connector").forEach(G=>{const ce=G,re=ce.dataset.fromId,W=ce.dataset.toId;if(re&&W){const ge=document.querySelector(`[data-step-id="${re}"]`),Ee=document.querySelector(`[data-step-id="${W}"]`);if(ge&&Ee){const _e=ge.closest(".timeline-item"),Ve=Ee.closest(".timeline-item");if(_e&&Ve){const Ke=_e.querySelector(".timeline-dot"),rt=Ve.querySelector(".timeline-dot");if(Ke&&rt){const $e=Ke.getBoundingClientRect(),Te=rt.getBoundingClientRect().top-$e.top-28;Te>0&&(ce.style.height=`${Te}px`)}}}}})})};Ae([h,()=>r.durationNodes,()=>r.expandedSteps],()=>{te()},{deep:!0});const ee=(E,G)=>{E.preventDefault(),u.value=!0,f.value={x:E.clientX,y:E.clientY},v.value=G},X=()=>{u.value=!1,v.value=null},le=()=>{v.value&&r.addDurationNode(v.value.id),X()},fe=()=>{v.value&&r.removeDurationNode(v.value.id),X()},de=()=>{r.clearDurationNodes(),X()},ne=E=>{if(!E)return"";const G=new Date(E);return isNaN(G.getTime())?"":G.toLocaleTimeString({hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})},ue=E=>({user_message:"User_Query",assistant_thinking:"Agent_Thinking",assistant_message:"Agent_Message",tool_call:"Tool_Use",tool_result:"Tool_Result",agent_child:"Sub_Agent",agent_end:"Sub_Agent",sub_agent:"Sub_Agent"})[E]||E,he=E=>{const G=ue(E.type),ce=ne(E.timestamp);return`${G} - ${ce}`},me=E=>({user_message:"#1890ff",assistant_thinking:"#faad14",assistant_message:"#52c41a",tool_call:"#722ed1",tool_result:"#13c2c2",agent_child:"#eb2f96",agent_end:"#eb2f96",sub_agent:"#eb2f96"})[E]||"#d9d9d9",q=E=>({user_message:"用户查询 - 用户向AI助手提出的问题或请求",assistant_thinking:"AI思考 - AI助手的内部思考过程",assistant_message:"AI回复 - AI助手对用户的回应",tool_call:"工具调用 - AI助手调用外部工具或函数",tool_result:"工具结果 - 外部工具返回的执行结果",agent_child:"子代理 - 启动的子代理进程",agent_end:"对话结束 - 当前对话会话结束",sub_agent:"子代理 - 启动的子代理进程"})[E]||E,K=(E,G=500)=>E?E.length<=G?E:E.substring(0,G)+"...":"",z=(E,G=!1)=>{var ce;if(l("🔍 getToolResultContent called:",{stepId:E.id,stepType:E.type,isExpanded:G,hasToolResult:!!E.toolResult,hasContent:!!E.content,contentLength:((ce=E.content)==null?void 0:ce.length)||0,rawLogEntry:E.rawLogEntry?Object.keys(E.rawLogEntry):[]}),(E.type==="tool_call"||E.type==="agent_child")&&E.toolResult){l("🎯 使用关联的toolResult内容");let re=null;E.toolResult&&(E.toolResult.content?re=E.toolResult.content:E.toolResult.rawLogEntry&&E.toolResult.rawLogEntry.toolUseResult&&(re=E.toolResult.rawLogEntry.toolUseResult));try{return re}catch(W){return o("toolUseResult JSON序列化失败:",W),""}return l("⚠️ 未找到toolUseResult,返回空内容"),""}return l("⚠️ 无法提取Tool Result内容,使用兜底显示"),"No result content available"};lt(()=>{te()});const J=async E=>{var G,ce;if(!(!E.subagent_type||E.subagent_type==="未知"))try{const re=r.selectedMainLog;if(!re||!re.agentLogs){console.warn("未找到当前主日志或其子代理日志列表");return}let W=re.agentLogs.find(ge=>ge.agentName===E.subagent_type);if(!W&&((ce=(G=E.rawLogEntry)==null?void 0:G.toolUseResult)!=null&&ce.agentId)){const ge=E.rawLogEntry.toolUseResult.agentId;W=re.agentLogs.find(Ee=>Ee.agentId===ge)}W&&r.loadFile(W.id)}catch(re){console.error("加载子代理日志失败:",re)}};return t({formatTime:ne,getNodeTypeLabel:ue,getNodeTooltip:he,getNodeColor:me,getStepTypeDescription:q,truncateContent:K,getToolResultContent:z,selectConversation:m,selectStep:y,isCollapsible:k,shouldShowExpandButton:b,getContentForMeasurement:R,getDisplayContent:U,isContentTruncated:j,truncateContentByHeight:A,truncateText:w,extractPromptParam:$,getToolSpecificInfo:P,getSummaryText:O,getSummaryTooltip:L,handleSubAgentClick:J}),(E,G)=>{const ce=oe("a-spin"),re=oe("a-empty");return C(),T("div",{class:"timeline-container",onClick:X},[a.value?(C(),T("div",$N,[d(ce,{size:32}),G[1]||(G[1]=B("p",null,"加载中...",-1))])):(C(),T("div",SN,[!i.value||!i.value.steps||i.value.steps.length===0?(C(),T("div",PN,[d(re,{description:""},{image:pe(()=>[d(it(YC),{size:48})]),default:pe(()=>[G[2]||(G[2]=B("div",{class:"empty-message"},[B("p",{class:"empty-title"},"无对话数据"),B("p",{class:"empty-description"},"未从当前会话日志中提取到对话数据,请选择其他会话。"),B("p",{class:"empty-hint"},"此文件可能是会话摘要或尚未记录任何交互")],-1))]),_:1})])):i.value?(C(),T("div",ON,[B("h2",_N,we(i.value.title),1),B("div",TN,[(C(!0),T(Me,null,Ct(h.value,(W,ge)=>{var Ee,_e;return C(),T("div",{key:W.id,class:_(["timeline-item",[`step-${W.type.toLowerCase().replace("_","-")}`,{selected:((Ee=s.value)==null?void 0:Ee.id)===W.id,"has-tool-result":W.toolResult,expanded:it(r).isExpanded(W.id)}]]),onClick:Ve=>y(W)},[ne(W.timestamp)?(C(),T("div",EN,[De(we(ne(W.timestamp))+" ",1),N(W)?(C(),T("div",IN,we(N(W)),1)):ae("",!0)])):ae("",!0),B("div",BN,[B("div",{class:_(["timeline-dot",{"duration-node":it(r).isDurationNode(W.id)}]),style:Ie({backgroundColor:me(W.type)}),title:`${ue(W.type)} - ${ne(W.timestamp)}`,onContextmenu:Zt(Ve=>ee(Ve,W),["prevent"])},[B("span",xN,we(W.originalIndex),1)],46,AN),ge<h.value.length-1?(C(),T("div",VN)):ae("",!0),it(r).isDurationNode(W.id)&&H(ge)?(C(),T("div",{key:1,class:"duration-connector","data-from-id":W.id,"data-to-id":(_e=H(ge))==null?void 0:_e.id},[B("div",NN,we(V(W,H(ge))),1)],8,MN)):ae("",!0)]),B("div",{class:"timeline-content-card","data-step-id":W.id},[B("div",{class:"card-header",onClick:Zt(Ve=>g(W),["stop"])},[B("div",DN,[!it(r).isExpanded(W.id)&&k(W)?(C(),T(Me,{key:0},[B("div",jN,[B("span",FN,we(ue(W.type)),1)]),d(it(qn),{content:L(W),position:"tl","background-color":"#3491FA",theme:"light"},{default:pe(()=>[B("span",HN,[W.type==="tool_call"?(C(),T("span",WN,we(W.tool_name||"未知工具"),1)):W.type==="agent_child"?(C(),T("span",KN,we(W.subagent_type||"未知"),1)):ae("",!0),G[3]||(G[3]=B("span",{class:"separator"}," | ",-1)),W.type==="tool_call"?(C(),T("span",qN,we(P(W)),1)):W.type==="agent_child"?(C(),T("span",UN,we(w($(W.parameters),80)),1)):ae("",!0)])]),_:2},1032,["content"]),F(W)?(C(),T("span",{key:0,class:_(["duration-tag",F(W).class])},we(F(W).text),3)):ae("",!0)],64)):(C(),T(Me,{key:1},[B("div",YN,[!k(W)||it(r).isExpanded(W.id)?(C(),T("span",{key:0,class:"step-type-tag",title:q(W.type)},we(ue(W.type)),9,ZN)):ae("",!0)]),it(r).isExpanded(W.id)&&k(W)?(C(),T("span",GN,[W.type==="tool_call"?(C(),T("span",XN,we(W.tool_name||"未知工具"),1)):W.type==="agent_child"?(C(),T("span",JN,we(W.subagent_type||"未知"),1)):ae("",!0)])):ae("",!0),F(W)?(C(),T("span",{key:1,class:_(["duration-tag",F(W).class])},we(F(W).text),3)):ae("",!0)],64))]),b(W)?(C(),T("div",{key:0,class:_(["expand-icon",{expanded:it(r).isExpanded(W.id)}]),onClick:Zt(Ve=>it(r).toggleExpanded(W.id),["stop"])},we(it(r).isExpanded(W.id)?"▼":"▶"),11,QN)):ae("",!0)],8,zN),!k(W)||it(r).isExpanded(W.id)?(C(),T("div",{key:0,class:_(["card-content",{"content-collapsed":!it(r).isExpanded(W.id)&&b(W),"content-expanded":it(r).isExpanded(W.id)}])},[W.type==="user_message"?(C(),T("div",eR,[B("div",{class:"content-text",innerHTML:U(W)},null,8,tR)])):W.type==="assistant_thinking"?(C(),T("div",nR,[G[4]||(G[4]=B("div",{class:"thinking-indicator"},[B("span",null,"思考中...")],-1)),B("div",{class:"content-text",innerHTML:U(W)},null,8,lR)])):W.type==="assistant_message"?(C(),T("div",oR,[B("div",{class:"content-text",innerHTML:U(W)},null,8,aR)])):W.type==="tool_call"?(C(),T("div",rR,[it(r).isExpanded(W.id)?(C(),T("div",iR,[B("div",sR,[B("span",uR,"工具名称:"+we(W.tool_name||"工具调用"),1),G[5]||(G[5]=B("br",null,null,-1)),G[6]||(G[6]=B("span",{class:"tool-name"},"工具参数:",-1))]),B("div",cR,[B("pre",{innerHTML:M(W,JSON.stringify(W.parameters||{},null,2))},null,8,dR)]),W.toolResult?(C(),T("div",fR,[G[8]||(G[8]=B("div",{class:"connection-line"},null,-1)),B("div",pR,[G[7]||(G[7]=B("div",{class:"result-header"},[B("span",{class:"result-type-tag"},"Tool Result")],-1)),B("div",vR,[B("pre",{innerHTML:Y(W,!0)},null,8,hR)])])])):ae("",!0)])):ae("",!0)])):W.type==="agent_child"?(C(),T("div",mR,[it(r).isExpanded(W.id)?(C(),T("div",gR,[B("div",yR,[G[9]||(G[9]=B("span",{class:"sub-agent-type"},"子代理类型:",-1)),W.subagent_type&&W.subagent_type!=="未知"?(C(),T("a",{key:0,class:"sub-agent-link",onClick:Zt(Ve=>J(W),["stop"]),title:`点击跳转到 ${W.subagent_type} 的日志文件`},we(W.subagent_type),9,bR)):(C(),T("span",CR,we(W.subagent_type||"未知"),1)),G[10]||(G[10]=B("br",null,null,-1)),G[11]||(G[11]=B("span",{class:"sub-agent-name"},"调用参数:",-1))]),B("div",kR,[B("pre",{innerHTML:M(W,JSON.stringify(W.parameters||{},null,2))},null,8,wR)]),W.toolResult?(C(),T("div",$R,[G[13]||(G[13]=B("div",{class:"connection-line"},null,-1)),B("div",SR,[G[12]||(G[12]=B("div",{class:"result-header"},[B("span",{class:"result-type-tag"},"Sub Agent Result")],-1)),B("div",PR,[B("pre",{innerHTML:Y(W,!0)},null,8,OR)])])])):ae("",!0)])):ae("",!0)])):(C(),T("div",_R,[B("div",{class:"content-text",innerHTML:U(W)},null,8,TR)]))],2)):ae("",!0)],8,RN)],10,LN)}),128))])])):ae("",!0)])),u.value?(C(),T("div",{key:2,class:"context-menu",style:Ie({left:f.value.x+"px",top:f.value.y+"px"}),onClick:G[0]||(G[0]=Zt(()=>{},["stop"]))},[v.value&&!it(r).isDurationNode(v.value.id)?(C(),T("div",{key:0,class:"context-menu-item",onClick:le}," 设置为耗时统计节点 ")):ae("",!0),v.value&&it(r).isDurationNode(v.value.id)?(C(),T("div",{key:1,class:"context-menu-item",onClick:fe}," 取消耗时节点设置 ")):ae("",!0),B("div",{class:"context-menu-item",onClick:de}," 清除所有耗时节点设置 ")],4)):ae("",!0)])}}}),ER=Vo(LR,[["__scopeId","data-v-dbcd604e"]]),IR={class:"step-detail"},BR={key:0,class:"step-detail-content"},AR={class:"step-info-header"},xR={class:"detail-item"},VR={class:"value"},MR={class:"detail-item"},NR={class:"value"},RR={class:"detail-item"},zR={class:"value"},DR={key:0,class:"detail-item"},jR={class:"value"},FR={key:0,class:"metadata-section"},HR={class:"metadata-grid"},WR={class:"metadata-key"},KR={class:"metadata-value"},qR={class:"content-container"},UR={class:"content-display"},YR={key:0},ZR={class:"log-section"},GR=["innerHTML"],XR={key:0,class:"log-section"},JR=["innerHTML"],QR={key:1},ez=["innerHTML"],tz=Q({__name:"StepDetail",setup(e){const t=hi(),n=p(()=>t.selectedStep),l=p(()=>t.currentFileId),o=c=>c?c.type==="assistant_message"||c.type==="tool_call":!1,r=()=>{if(!n.value||!l.value)return;const c=`/debug.html?fileId=${l.value}&stepId=${n.value.id}&stepType=${n.value.type}`;window.open(c,"_blank")},a=c=>{if(!c)return"";const u=t.searchKeyword;let v=JSON.stringify(c,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(h){let m="json-number";return/^"/.test(h)?/:$/.test(h)?m="json-key":m="json-string":/true|false/.test(h)?m="json-boolean":/null/.test(h)&&(m="json-null"),'<span class="'+m+'">'+h+"</span>"});if(u){const h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=new RegExp(`(${h})`,"gi");v=v.replace(m,'<mark class="search-highlight-keyword">$1</mark>')}return v},i=c=>new Date(c).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),s=c=>typeof c=="object"?JSON.stringify(c,null,2):String(c);return(c,u)=>{const f=oe("a-button"),v=oe("a-card");return C(),T("div",IR,[n.value?(C(),T("div",BR,[d(v,{bordered:!1,class:"step-info-card"},{title:pe(()=>[B("div",AR,[u[1]||(u[1]=B("span",null,"步骤信息",-1)),o(n.value)?(C(),ve(f,{key:0,type:"primary",size:"small",onClick:r,class:"debug-button"},{icon:pe(()=>[d(it(MM))]),default:pe(()=>[u[0]||(u[0]=De(" 调试 ",-1))]),_:1})):ae("",!0)])]),default:pe(()=>[B("div",xR,[u[2]||(u[2]=B("span",{class:"label"},"步骤ID:",-1)),B("span",VR,we(n.value.id),1)]),B("div",MR,[u[3]||(u[3]=B("span",{class:"label"},"类型:",-1)),B("span",NR,we(n.value.type),1)]),B("div",RR,[u[4]||(u[4]=B("span",{class:"label"},"时间:",-1)),B("span",zR,we(i(n.value.timestamp)),1)]),n.value.tool_name?(C(),T("div",DR,[u[5]||(u[5]=B("span",{class:"label"},"工具名称:",-1)),B("span",jR,we(n.value.tool_name),1)])):ae("",!0)]),_:1}),n.value.metadata&&Object.keys(n.value.metadata).length>0?(C(),T("div",FR,[u[6]||(u[6]=B("h4",null,"元数据",-1)),B("div",HR,[(C(!0),T(Me,null,Ct(Object.entries(n.value.metadata),([h,m])=>(C(),T("div",{key:h,class:"metadata-item"},[B("span",WR,we(h)+":",1),B("span",KR,we(s(m)),1)]))),128))])])):ae("",!0),d(v,{title:"完整日志",bordered:!1,class:"log-card"},{default:pe(()=>[B("div",qR,[B("div",UR,[n.value.type==="tool_call"?(C(),T("div",YR,[B("div",ZR,[u[7]||(u[7]=B("h5",{class:"log-section-title"},"Tool_Use 日志",-1)),B("pre",{class:"json-content",innerHTML:a(n.value.rawLogEntry||{})},null,8,GR)]),n.value.toolResult?(C(),T("div",XR,[u[8]||(u[8]=B("h5",{class:"log-section-title"},"Tool_Result 日志",-1)),B("pre",{class:"json-content",innerHTML:a(n.value.toolResult.rawLogEntry||{})},null,8,JR)])):ae("",!0)])):(C(),T("div",QR,[B("pre",{class:"json-content",innerHTML:a(n.value.rawLogEntry||{})},null,8,ez)]))])])]),_:1})])):ae("",!0)])}}}),nz=Vo(tz,[["__scopeId","data-v-a56f8487"]]),lz={class:"search-panel"},oz={class:"search-header"},az={key:0,class:"search-summary"},rz={class:"search-content"},iz={key:0,class:"loading-container"},sz={key:1,class:"empty-state"},uz={key:2,class:"results-container"},cz={class:"file-results"},dz=["onClick"],fz={class:"result-header"},pz={class:"step-index"},vz={class:"step-time"},hz={class:"result-content"},mz=["innerHTML"],gz={class:"matched-field"},yz={key:3,class:"initial-state"},bz=Q({__name:"SearchPanel",setup(e){const t=hi(),n=I(""),l=I(!1),o=I([]),r=I([]),a=p(()=>o.value.reduce((y,g)=>y+g.resultCount,0)),i=async y=>{if(!y.trim()){Oo.warning("请输入搜索关键字");return}l.value=!0,r.value=[];try{o.value=await t.performSearch(y.trim()),o.value.length>0&&(r.value=[o.value[0].fileId])}catch(g){console.error("搜索失败:",g),Oo.error("搜索失败,请重试")}finally{l.value=!1}},s=()=>{n.value="",o.value=[],r.value=[],t.searchKeyword=""},c=async y=>{try{y.fileId!==t.currentFileId&&await t.loadFile(y.fileId),setTimeout(()=>{var b,k;let g=(b=t.currentConversation)==null?void 0:b.steps.find(w=>w.id===y.stepId);if(g&&(g.type==="tool_result"||g.type==="agent_child_result")){const w=(k=t.currentConversation)==null?void 0:k.steps.find($=>($.type==="tool_call"||$.type==="agent_child")&&$.tool_use_id?$.tool_use_id===g.tool_use_id:!1);w?g=w:console.warn(`无法找到对应的父节点,${g.type} id:`,g.id)}g&&(t.selectStep(g),t.ensureStepExpanded(g.id),setTimeout(()=>{const w=document.querySelector('.detail-tabs [data-key="detail"]');w&&w.click()},100))},200)}catch(g){console.error("跳转失败:",g),Oo.error("跳转失败,请重试")}},u=y=>{if(!n.value)return y;const g=n.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`(${g})`,"gi");return y.replace(b,'<mark class="search-highlight">$1</mark>')},f=(y,g)=>{var k;return y==="tool_result"&&g&&g.tool_use_id&&((k=t.currentConversation)!=null&&k.steps.find($=>$.type==="agent_child"&&$.tool_use_id===g.tool_use_id))&&(y="agent_child_result"),{user_message:"#1890ff",assistant_thinking:"#faad14",assistant_message:"#52c41a",tool_call:"#722ed1",tool_result:"#722ed1",agent_child:"#eb2f96",agent_child_result:"cyan",agent_end:"cyan",sub_agent:"cyan"}[y]||"gray"},v=(y,g)=>{var w;return y==="tool_result"&&g&&g.tool_use_id&&((w=t.currentConversation)!=null&&w.steps.find(S=>S.type==="agent_child"&&S.tool_use_id===g.tool_use_id))&&(y="agent_child_result"),{user_message:"User_Query",assistant_thinking:"Agent_Thinking",assistant_message:"Agent_Message",tool_call:"Tool_Use",tool_result:"Tool_Result",agent_child:"Sub_Agent",agent_child_result:"Sub_Agent_Result",agent_end:"Sub_Agent",sub_agent:"Sub_Agent"}[y]||y},h=y=>new Date(y).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});let m=null;return Ae(n,y=>{m&&clearTimeout(m),y.trim()?m=setTimeout(()=>{i(y)},300):s()}),(y,g)=>{const b=oe("a-input-search"),k=oe("a-spin"),w=oe("a-empty"),$=oe("a-tag"),S=oe("a-collapse-item"),P=oe("a-collapse");return C(),T("div",lz,[B("div",oz,[d(b,{modelValue:n.value,"onUpdate:modelValue":g[0]||(g[0]=O=>n.value=O),placeholder:"请输入搜索关键字",loading:l.value,onSearch:i,onClear:s,class:"search-input"},null,8,["modelValue","loading"]),o.value.length>0?(C(),T("div",az," 找到 "+we(a.value)+" 个结果,分布在 "+we(o.value.length)+" 个文件中 ",1)):ae("",!0)]),B("div",rz,[l.value?(C(),T("div",iz,[d(k,{size:"large"}),g[2]||(g[2]=B("p",null,"正在搜索中...",-1))])):!l.value&&n.value&&o.value.length===0?(C(),T("div",sz,[d(w,{description:"未找到匹配的结果"})])):o.value.length>0?(C(),T("div",uz,[d(P,{"active-key":r.value,"onUpdate:activeKey":g[1]||(g[1]=O=>r.value=O),bordered:!1,class:"search-collapse"},{default:pe(()=>[(C(!0),T(Me,null,Ct(o.value,O=>(C(),ve(S,{key:O.fileId,header:`${O.fileName} (${O.resultCount}个结果)`,class:"file-result-item"},{default:pe(()=>[B("div",cz,[(C(!0),T(Me,null,Ct(O.results,(L,R)=>(C(),T("div",{key:L.stepId,class:"result-item",onClick:F=>c(L)},[B("div",fz,[d($,{color:f(L.stepType,L),size:"small",class:"step-type-tag"},{default:pe(()=>[De(we(v(L.stepType,L)),1)]),_:2},1032,["color"]),B("span",pz,"#"+we(L.stepIndex),1),B("span",vz,we(h(L.timestamp)),1)]),B("div",hz,[B("div",{class:"matched-text",innerHTML:u(L.matchedContent)},null,8,mz),B("div",gz,"匹配字段: "+we(L.matchedField),1)])],8,dz))),128))])]),_:2},1032,["header"]))),128))]),_:1},8,["active-key"])])):(C(),T("div",yz,[d(w,{description:"请输入关键字开始搜索"})]))])])}}}),Cz=Vo(bz,[["__scopeId","data-v-ffbd5663"]]),kz={class:"detail-panel"},wz={class:"detail-content"},$z=Q({__name:"DetailPanel",setup(e){return(t,n)=>{const l=oe("a-tab-pane"),o=oe("a-tabs");return C(),T("div",kz,[B("div",wz,[d(o,{"default-active-key":"search",class:"detail-tabs"},{default:pe(()=>[d(l,{key:"search",title:"全局搜索"},{default:pe(()=>[d(Cz)]),_:1}),d(l,{key:"detail",title:"步骤详情"},{default:pe(()=>[d(nz)]),_:1})]),_:1})])])}}}),Sz={class:"main-layout"},Pz={class:"header-content"},Oz={class:"header-actions"},_z={class:"content-wrapper"},Tz={class:"timeline-section"},Lz=Q({__name:"MainLayout",setup(e){const t=hi(),n=I(!1),l=I(500),o=I(360),r=I(!1),a=I(!1),i=I(0),s=I(0),c=async()=>{var g;try{const b=new URL(window.location.href);if(b.searchParams.delete("project"),b.searchParams.delete("file"),b.searchParams.delete("step"),b.searchParams.delete("sessionid"),t.currentFileId){b.searchParams.set("file",t.currentFileId),t.selectedStep&&b.searchParams.set("step",t.selectedStep.id);let w=null;(g=t.currentProject)!=null&&g.projectDir?w=t.currentProject.projectDir:w=new URL(window.location.href).searchParams.get("project"),w&&b.searchParams.set("project",w)}const k=b.toString();if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(k);else{const w=document.createElement("textarea");w.value=k,w.style.position="fixed",w.style.left="-999999px",w.style.top="-999999px",document.body.appendChild(w),w.focus(),w.select();try{document.execCommand("copy")}finally{document.body.removeChild(w)}}Oo.success("分享链接已复制到剪贴板")}catch(b){console.error("复制链接失败:",b),Oo.error("复制链接失败,请重试")}},u=g=>{r.value=!0,i.value=g.clientX,s.value=l.value,document.addEventListener("mousemove",v),document.addEventListener("mouseup",m),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},f=g=>{a.value=!0,i.value=g.clientX,s.value=o.value,document.addEventListener("mousemove",h),document.addEventListener("mouseup",y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},v=g=>{if(!r.value)return;const b=i.value-g.clientX,k=s.value+b,w=300,$=window.innerWidth*.6;l.value=Math.max(w,Math.min($,k))},h=g=>{if(!a.value)return;const b=g.clientX-i.value,k=s.value+b,w=200,$=window.innerWidth*.5;o.value=Math.max(w,Math.min($,k))},m=()=>{r.value=!1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect=""},y=()=>{a.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};return lt(()=>{t.initialize()}),Jt(()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",y)}),(g,b)=>{const k=oe("a-button"),w=oe("a-layout-header"),$=oe("a-layout-sider"),S=oe("a-layout-content"),P=oe("a-layout");return C(),T("div",Sz,[d(P,{class:"layout"},{default:pe(()=>[d(w,{class:"header"},{default:pe(()=>[B("div",Pz,[b[1]||(b[1]=B("h1",{class:"title"},"Claude Code Debug",-1)),B("div",Oz,[d(k,{type:"outline",size:"small",disabled:!it(t).currentFileId,onClick:c,title:"复制分享链接"},{icon:pe(()=>[d(it(BM))]),default:pe(()=>[b[0]||(b[0]=De(" 复制链接 ",-1))]),_:1},8,["disabled"])])])]),_:1}),d(P,{class:"body"},{default:pe(()=>[d($,{width:o.value,collapsed:!1,collapsible:!1,class:"sidebar"},{default:pe(()=>[d(wN)]),_:1},8,["width"]),B("div",{class:"resize-handle resize-handle-left",onMousedown:f},null,32),d(S,{class:"main-content"},{default:pe(()=>[B("div",_z,[B("div",Tz,[d(ER)]),n.value?ae("",!0):(C(),T("div",{key:0,class:"resize-handle",onMousedown:u},null,32)),n.value?ae("",!0):(C(),T("div",{key:1,class:"detail-section",style:Ie({width:l.value+"px"})},[d($z)],4))])]),_:1})]),_:1})]),_:1})])}}}),Ez=Vo(Lz,[["__scopeId","data-v-9f52bc01"]]),Iz={class:"debug-page"},Bz={class:"header"},Az={class:"params-info"},xz={class:"param-item"},Vz={class:"value"},Mz={class:"param-item"},Nz={class:"value"},Rz={class:"param-item"},zz={class:"value"},Dz={class:"param-item"},jz={class:"value"},Fz={class:"content"},Hz={key:0,class:"loading"},Wz={key:1,class:"error"},Kz={key:2,class:"llm-log-container"},qz={class:"main-layout"},Uz={class:"left-panel"},Yz={class:"section"},Zz={class:"user-messages"},Gz={class:"user-messages-header"},Xz={class:"messages-container"},Jz={class:"message-header"},Qz=["onUpdate:modelValue"],eD=["onClick"],tD={key:0,class:"content-list"},nD={class:"content-header"},lD={class:"content-type"},oD=["onClick"],aD=["onUpdate:modelValue"],rD=["value","onInput"],iD=["onUpdate:modelValue"],sD=["onClick"],uD={key:1,class:"single-content"},cD=["onUpdate:modelValue"],dD=["onClick"],fD={class:"right-panel"},pD={class:"section"},vD={class:"response-tabs"},hD={class:"tab-headers"},mD=["onClick"],gD=["onClick"],yD={class:"tab-content"},bD={key:0,class:"response-content"},CD=["innerHTML"],kD={class:"actions"},wD=["disabled"],$D=["disabled"],SD={key:3,class:"no-data"},PD=Q({__name:"DebugPage",setup(e){const t=ox(),n=(()=>{try{return new URLSearchParams(window.location.search).get("debug")==="1"||window.localStorage.getItem("CCDEBUG_DEBUG")==="1"}catch{return!1}})(),l=(...M)=>{n&&console.warn(...M)},o=I(null),r=I(""),a=I(""),i=I(""),s=I(""),c=I(!1),u=I(""),f=I(!1),v=I(!1),h=I([]),m=I({});p(()=>m.value?{...m.value,body:{...m.value.body,messages:h.value}}:{});const y=I([]),g=I(0);function b(){return{fileId:t.query.fileId,stepId:t.query.stepId,stepType:t.query.stepType}}function k(M){return M?JSON.stringify(M,null,2).replace(/(".*?")\s*:/g,'<span class="json-key">$1</span>:').replace(/:\s*(".*?")/g,': <span class="json-string">$1</span>').replace(/:\s*(true|false)/g,': <span class="json-boolean">$1</span>').replace(/:\s*(null)/g,': <span class="json-null">$1</span>').replace(/:\s*(\d+\.?\d*)/g,': <span class="json-number">$1</span>'):""}function w(M){var j,A;if(!M)return;const Y=((A=(j=M.request)==null?void 0:j.body)==null?void 0:A.messages)||[];h.value=Y.map(N=>({role:N.role||"user",content:(typeof N.content=="string",N.content)})),m.value=JSON.parse(JSON.stringify(M.request||{})),y.value=[{title:"原始响应",data:M.response||{}}],g.value=0}function $(){h.value.push({role:"user",content:""})}function S(M){h.value.splice(M,1)}function P(M){const Y=h.value[M];Array.isArray(Y.content)||(Y.content=[{type:"text",text:Y.content||""}]),Y.content.push({type:"text",text:""})}function O(M,Y){const j=h.value[M];Array.isArray(j.content)&&(j.content.splice(Y,1),j.content.length===1&&(j.content=j.content[0].text))}function L(M){const Y=h.value[M];Array.isArray(Y.content)||(Y.content=[{type:"text",text:Y.content||""}])}function R(){if(!o.value){alert("暂无日志数据");return}const M=window.open("","_blank","width=1200,height=800,scrollbars=yes,resizable=yes");if(M){const Y=JSON.stringify(o.value.request,null,2),N=["<!DOCTYPE html>","<html>","<head>"," <title>完整LLM请求日志</title>"," <style>"," body { ",' font-family: "Monaco", "Menlo", "Consolas", "Courier New", monospace; '," margin: 20px; "," background: #f8f9fa; "," line-height: 1.5;"," }"," .container {"," max-width: 100%;"," background: white;"," border-radius: 8px;"," box-shadow: 0 2px 10px rgba(0,0,0,0.1);"," overflow: hidden;"," }"," .header {"," background: #2c3e50;"," color: white;"," padding: 15px 20px;"," margin: 0;"," font-size: 18px;"," font-weight: 500;"," }"," pre { "," background: #ffffff; "," padding: 20px; "," margin: 0;"," overflow: auto; "," white-space: pre-wrap; "," word-break: break-all;"," font-size: 13px;"," line-height: 1.6;"," }"," "," /* JSON语法高亮样式 */"," .json-key {"," color: #0066cc;"," font-weight: 600;"," }"," .json-string {"," color: #22863a;"," }"," .json-number {"," color: #005cc5;"," }"," .json-boolean {"," color: #d73a49;"," font-weight: 600;"," }"," .json-null {"," color: #6f42c1;"," font-weight: 600;"," }"," "," /* 复制按钮 */"," .copy-btn {"," position: fixed;"," top: 20px;"," right: 20px;"," background: #28a745;"," color: white;"," border: none;"," padding: 10px 15px;"," border-radius: 5px;"," cursor: pointer;"," font-size: 14px;"," z-index: 1000;"," }"," .copy-btn:hover {"," background: #218838;"," }"," .copy-btn:active {"," background: #1e7e34;"," }"," </style>","</head>","<body>",' <button class="copy-btn" onclick="copyToClipboard()">复制JSON</button>',' <div class="container">',' <h1 class="header">完整LLM请求日志</h1>',' <pre id="json-content">'+(D=>D.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,V=>{let H="json-number";return/^"/.test(V)?/:$/.test(V)?H="json-key":H="json-string":/true|false/.test(V)?H="json-boolean":/null/.test(V)&&(H="json-null"),'<span class="'+H+'">'+V+"</span>"}))(Y)+"</pre>"," </div>"," "," <script>"," function copyToClipboard() {"," const jsonText = "+JSON.stringify(Y)+";"," navigator.clipboard.writeText(jsonText).then(() => {",' const btn = document.querySelector(".copy-btn");'," const originalText = btn.textContent;",' btn.textContent = "已复制!";',' btn.style.background = "#17a2b8";'," setTimeout(() => {"," btn.textContent = originalText;",' btn.style.background = "#28a745";'," }, 2000);"," }).catch(err => {",' console.error("复制失败:", err);',' alert("复制失败,请手动选择文本复制");'," });"," }"," <\/script>","</body>","</html>"].join(`
40
+ ...`:W+"..."},N=E=>{var G;if(!((G=i.value)!=null&&G.steps)||i.value.steps.length===0)return null;try{const ce=i.value.steps[0];if(!ce.timestamp||!E.timestamp)return null;const re=new Date(ce.timestamp).getTime(),W=new Date(E.timestamp).getTime();if(isNaN(re)||isNaN(W))return null;const ge=W-re;return D(ge)}catch(ce){return console.warn("计算耗时失败:",ce),null}},D=E=>{if(E<1e3)return`${E}ms`;if(E<6e4)return`${(E/1e3).toFixed(1)}s`;{const G=Math.floor(E/6e4),ce=Math.floor(E%6e4/1e3);return ce>0?`${G}m${ce}s`:`${G}m`}},V=(E,G)=>{if(!G||!E.timestamp||!G.timestamp)return"";try{const ce=new Date(E.timestamp).getTime(),re=new Date(G.timestamp).getTime();if(isNaN(ce)||isNaN(re))return"";const W=re-ce;return D(W)}catch(ce){return console.warn("计算节点间耗时失败:",ce),""}},H=E=>{if(!h.value)return null;for(let G=E+1;G<h.value.length;G++){const ce=h.value[G];if(r.isDurationNode(ce.id))return ce}return null},te=()=>{typeof window>"u"||requestAnimationFrame(()=>{document.querySelectorAll(".duration-connector").forEach(G=>{const ce=G,re=ce.dataset.fromId,W=ce.dataset.toId;if(re&&W){const ge=document.querySelector(`[data-step-id="${re}"]`),Ee=document.querySelector(`[data-step-id="${W}"]`);if(ge&&Ee){const _e=ge.closest(".timeline-item"),Ve=Ee.closest(".timeline-item");if(_e&&Ve){const Ke=_e.querySelector(".timeline-dot"),rt=Ve.querySelector(".timeline-dot");if(Ke&&rt){const $e=Ke.getBoundingClientRect(),Te=rt.getBoundingClientRect().top-$e.top-28;Te>0&&(ce.style.height=`${Te}px`)}}}}})})};Ae([h,()=>r.durationNodes,()=>r.expandedSteps],()=>{te()},{deep:!0});const ee=(E,G)=>{E.preventDefault(),u.value=!0,f.value={x:E.clientX,y:E.clientY},v.value=G},X=()=>{u.value=!1,v.value=null},le=()=>{v.value&&r.addDurationNode(v.value.id),X()},fe=()=>{v.value&&r.removeDurationNode(v.value.id),X()},de=()=>{r.clearDurationNodes(),X()},ne=E=>{if(!E)return"";const G=new Date(E);return isNaN(G.getTime())?"":G.toLocaleTimeString({hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})},ue=E=>({user_message:"User_Query",assistant_thinking:"Agent_Thinking",assistant_message:"Agent_Message",tool_call:"Tool_Use",tool_result:"Tool_Result",agent_child:"Sub_Agent",agent_end:"Sub_Agent",sub_agent:"Sub_Agent"})[E]||E,he=E=>{const G=ue(E.type),ce=ne(E.timestamp);return`${G} - ${ce}`},me=E=>({user_message:"#1890ff",assistant_thinking:"#faad14",assistant_message:"#52c41a",tool_call:"#722ed1",tool_result:"#13c2c2",agent_child:"#eb2f96",agent_end:"#eb2f96",sub_agent:"#eb2f96"})[E]||"#d9d9d9",q=E=>({user_message:"用户查询 - 用户向AI助手提出的问题或请求",assistant_thinking:"AI思考 - AI助手的内部思考过程",assistant_message:"AI回复 - AI助手对用户的回应",tool_call:"工具调用 - AI助手调用外部工具或函数",tool_result:"工具结果 - 外部工具返回的执行结果",agent_child:"子代理 - 启动的子代理进程",agent_end:"对话结束 - 当前对话会话结束",sub_agent:"子代理 - 启动的子代理进程"})[E]||E,K=(E,G=500)=>E?E.length<=G?E:E.substring(0,G)+"...":"",z=(E,G=!1)=>{var ce;if(l("🔍 getToolResultContent called:",{stepId:E.id,stepType:E.type,isExpanded:G,hasToolResult:!!E.toolResult,hasContent:!!E.content,contentLength:((ce=E.content)==null?void 0:ce.length)||0,rawLogEntry:E.rawLogEntry?Object.keys(E.rawLogEntry):[]}),(E.type==="tool_call"||E.type==="agent_child")&&E.toolResult){l("🎯 使用关联的toolResult内容");let re=null;E.toolResult&&(E.toolResult.content?re=E.toolResult.content:E.toolResult.rawLogEntry&&E.toolResult.rawLogEntry.toolUseResult&&(re=E.toolResult.rawLogEntry.toolUseResult));try{return re}catch(W){return o("toolUseResult JSON序列化失败:",W),""}return l("⚠️ 未找到toolUseResult,返回空内容"),""}return l("⚠️ 无法提取Tool Result内容,使用兜底显示"),"No result content available"};lt(()=>{te()});const J=async E=>{var G,ce;if(!(!E.subagent_type||E.subagent_type==="未知"))try{const re=r.selectedMainLog;if(!re||!re.agentLogs){console.warn("未找到当前主日志或其子代理日志列表");return}let W=re.agentLogs.find(ge=>ge.agentName===E.subagent_type);if(!W&&((ce=(G=E.rawLogEntry)==null?void 0:G.toolUseResult)!=null&&ce.agentId)){const ge=E.rawLogEntry.toolUseResult.agentId;W=re.agentLogs.find(Ee=>Ee.agentId===ge)}W&&r.loadFile(W.id)}catch(re){console.error("加载子代理日志失败:",re)}};return t({formatTime:ne,getNodeTypeLabel:ue,getNodeTooltip:he,getNodeColor:me,getStepTypeDescription:q,truncateContent:K,getToolResultContent:z,selectConversation:m,selectStep:y,isCollapsible:k,shouldShowExpandButton:b,getContentForMeasurement:R,getDisplayContent:U,isContentTruncated:j,truncateContentByHeight:A,truncateText:w,extractPromptParam:$,getToolSpecificInfo:P,getSummaryText:O,getSummaryTooltip:L,handleSubAgentClick:J}),(E,G)=>{const ce=oe("a-spin"),re=oe("a-empty");return C(),T("div",{class:"timeline-container",onClick:X},[a.value?(C(),T("div",$N,[d(ce,{size:32}),G[1]||(G[1]=B("p",null,"加载中...",-1))])):(C(),T("div",SN,[!i.value||!i.value.steps||i.value.steps.length===0?(C(),T("div",PN,[d(re,{description:""},{image:pe(()=>[d(it(YC),{size:48})]),default:pe(()=>[G[2]||(G[2]=B("div",{class:"empty-message"},[B("p",{class:"empty-title"},"无对话数据"),B("p",{class:"empty-description"},"未从当前会话日志中提取到对话数据,请选择其他会话。"),B("p",{class:"empty-hint"},"此文件可能是会话摘要或尚未记录任何交互")],-1))]),_:1})])):i.value?(C(),T("div",ON,[B("h2",_N,we(i.value.title),1),B("div",TN,[(C(!0),T(Me,null,Ct(h.value,(W,ge)=>{var Ee,_e;return C(),T("div",{key:W.id,class:_(["timeline-item",[`step-${W.type.toLowerCase().replace("_","-")}`,{selected:((Ee=s.value)==null?void 0:Ee.id)===W.id,"has-tool-result":W.toolResult,expanded:it(r).isExpanded(W.id)}]]),onClick:Ve=>y(W)},[ne(W.timestamp)?(C(),T("div",EN,[De(we(ne(W.timestamp))+" ",1),N(W)?(C(),T("div",IN,we(N(W)),1)):ae("",!0)])):ae("",!0),B("div",BN,[B("div",{class:_(["timeline-dot",{"duration-node":it(r).isDurationNode(W.id)}]),style:Ie({backgroundColor:me(W.type)}),title:`${ue(W.type)} - ${ne(W.timestamp)}`,onContextmenu:Zt(Ve=>ee(Ve,W),["prevent"])},[B("span",xN,we(W.originalIndex),1)],46,AN),ge<h.value.length-1?(C(),T("div",VN)):ae("",!0),it(r).isDurationNode(W.id)&&H(ge)?(C(),T("div",{key:1,class:"duration-connector","data-from-id":W.id,"data-to-id":(_e=H(ge))==null?void 0:_e.id},[B("div",NN,we(V(W,H(ge))),1)],8,MN)):ae("",!0)]),B("div",{class:"timeline-content-card","data-step-id":W.id},[B("div",{class:"card-header",onClick:Zt(Ve=>g(W),["stop"])},[B("div",DN,[!it(r).isExpanded(W.id)&&k(W)?(C(),T(Me,{key:0},[B("div",jN,[B("span",FN,we(ue(W.type)),1)]),d(it(qn),{content:L(W),position:"tl","background-color":"#3491FA",theme:"light"},{default:pe(()=>[B("span",HN,[W.type==="tool_call"?(C(),T("span",WN,we(W.tool_name||"未知工具"),1)):W.type==="agent_child"?(C(),T("span",KN,we(W.subagent_type||"未知"),1)):ae("",!0),G[3]||(G[3]=B("span",{class:"separator"}," | ",-1)),W.type==="tool_call"?(C(),T("span",qN,we(P(W)),1)):W.type==="agent_child"?(C(),T("span",UN,we(w($(W.parameters),80)),1)):ae("",!0)])]),_:2},1032,["content"]),F(W)?(C(),T("span",{key:0,class:_(["duration-tag",F(W).class])},we(F(W).text),3)):ae("",!0)],64)):(C(),T(Me,{key:1},[B("div",YN,[!k(W)||it(r).isExpanded(W.id)?(C(),T("span",{key:0,class:"step-type-tag",title:q(W.type)},we(ue(W.type)),9,ZN)):ae("",!0)]),it(r).isExpanded(W.id)&&k(W)?(C(),T("span",GN,[W.type==="tool_call"?(C(),T("span",XN,we(W.tool_name||"未知工具"),1)):W.type==="agent_child"?(C(),T("span",JN,we(W.subagent_type||"未知"),1)):ae("",!0)])):ae("",!0),F(W)?(C(),T("span",{key:1,class:_(["duration-tag",F(W).class])},we(F(W).text),3)):ae("",!0)],64))]),b(W)?(C(),T("div",{key:0,class:_(["expand-icon",{expanded:it(r).isExpanded(W.id)}]),onClick:Zt(Ve=>it(r).toggleExpanded(W.id),["stop"])},we(it(r).isExpanded(W.id)?"▼":"▶"),11,QN)):ae("",!0)],8,zN),!k(W)||it(r).isExpanded(W.id)?(C(),T("div",{key:0,class:_(["card-content",{"content-collapsed":!it(r).isExpanded(W.id)&&b(W),"content-expanded":it(r).isExpanded(W.id)}])},[W.type==="user_message"?(C(),T("div",eR,[B("div",{class:"content-text",innerHTML:U(W)},null,8,tR)])):W.type==="assistant_thinking"?(C(),T("div",nR,[G[4]||(G[4]=B("div",{class:"thinking-indicator"},[B("span",null,"思考中...")],-1)),B("div",{class:"content-text",innerHTML:U(W)},null,8,lR)])):W.type==="assistant_message"?(C(),T("div",oR,[B("div",{class:"content-text",innerHTML:U(W)},null,8,aR)])):W.type==="tool_call"?(C(),T("div",rR,[it(r).isExpanded(W.id)?(C(),T("div",iR,[B("div",sR,[B("span",uR,"工具名称:"+we(W.tool_name||"工具调用"),1),G[5]||(G[5]=B("br",null,null,-1)),G[6]||(G[6]=B("span",{class:"tool-name"},"工具参数:",-1))]),B("div",cR,[B("pre",{innerHTML:M(W,JSON.stringify(W.parameters||{},null,2))},null,8,dR)]),W.toolResult?(C(),T("div",fR,[G[8]||(G[8]=B("div",{class:"connection-line"},null,-1)),B("div",pR,[G[7]||(G[7]=B("div",{class:"result-header"},[B("span",{class:"result-type-tag"},"Tool Result")],-1)),B("div",vR,[B("pre",{innerHTML:Y(W,!0)},null,8,hR)])])])):ae("",!0)])):ae("",!0)])):W.type==="agent_child"?(C(),T("div",mR,[it(r).isExpanded(W.id)?(C(),T("div",gR,[B("div",yR,[G[9]||(G[9]=B("span",{class:"sub-agent-type"},"子代理类型:",-1)),W.subagent_type&&W.subagent_type!=="未知"?(C(),T("a",{key:0,class:"sub-agent-link",onClick:Zt(Ve=>J(W),["stop"]),title:`点击跳转到 ${W.subagent_type} 的日志文件`},we(W.subagent_type),9,bR)):(C(),T("span",CR,we(W.subagent_type||"未知"),1)),G[10]||(G[10]=B("br",null,null,-1)),G[11]||(G[11]=B("span",{class:"sub-agent-name"},"调用参数:",-1))]),B("div",kR,[B("pre",{innerHTML:M(W,JSON.stringify(W.parameters||{},null,2))},null,8,wR)]),W.toolResult?(C(),T("div",$R,[G[13]||(G[13]=B("div",{class:"connection-line"},null,-1)),B("div",SR,[G[12]||(G[12]=B("div",{class:"result-header"},[B("span",{class:"result-type-tag"},"Sub Agent Result")],-1)),B("div",PR,[B("pre",{innerHTML:Y(W,!0)},null,8,OR)])])])):ae("",!0)])):ae("",!0)])):(C(),T("div",_R,[B("div",{class:"content-text",innerHTML:U(W)},null,8,TR)]))],2)):ae("",!0)],8,RN)],10,LN)}),128))])])):ae("",!0)])),u.value?(C(),T("div",{key:2,class:"context-menu",style:Ie({left:f.value.x+"px",top:f.value.y+"px"}),onClick:G[0]||(G[0]=Zt(()=>{},["stop"]))},[v.value&&!it(r).isDurationNode(v.value.id)?(C(),T("div",{key:0,class:"context-menu-item",onClick:le}," 设置为耗时统计节点 ")):ae("",!0),v.value&&it(r).isDurationNode(v.value.id)?(C(),T("div",{key:1,class:"context-menu-item",onClick:fe}," 取消耗时节点设置 ")):ae("",!0),B("div",{class:"context-menu-item",onClick:de}," 清除所有耗时节点设置 ")],4)):ae("",!0)])}}}),ER=Vo(LR,[["__scopeId","data-v-f36193fb"]]),IR={class:"step-detail"},BR={key:0,class:"step-detail-content"},AR={class:"step-info-header"},xR={class:"detail-item"},VR={class:"value"},MR={class:"detail-item"},NR={class:"value"},RR={class:"detail-item"},zR={class:"value"},DR={key:0,class:"detail-item"},jR={class:"value"},FR={key:0,class:"metadata-section"},HR={class:"metadata-grid"},WR={class:"metadata-key"},KR={class:"metadata-value"},qR={class:"content-container"},UR={class:"content-display"},YR={key:0},ZR={class:"log-section"},GR=["innerHTML"],XR={key:0,class:"log-section"},JR=["innerHTML"],QR={key:1},ez=["innerHTML"],tz=Q({__name:"StepDetail",setup(e){const t=hi(),n=p(()=>t.selectedStep),l=p(()=>t.currentFileId),o=c=>c?c.type==="assistant_message"||c.type==="tool_call":!1,r=()=>{if(!n.value||!l.value)return;const c=`/debug.html?fileId=${l.value}&stepId=${n.value.id}&stepType=${n.value.type}`;window.open(c,"_blank")},a=c=>{if(!c)return"";const u=t.searchKeyword;let v=JSON.stringify(c,null,2).replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(h){let m="json-number";return/^"/.test(h)?/:$/.test(h)?m="json-key":m="json-string":/true|false/.test(h)?m="json-boolean":/null/.test(h)&&(m="json-null"),'<span class="'+m+'">'+h+"</span>"});if(u){const h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),m=new RegExp(`(${h})`,"gi");v=v.replace(m,'<mark class="search-highlight-keyword">$1</mark>')}return v},i=c=>new Date(c).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),s=c=>typeof c=="object"?JSON.stringify(c,null,2):String(c);return(c,u)=>{const f=oe("a-button"),v=oe("a-card");return C(),T("div",IR,[n.value?(C(),T("div",BR,[d(v,{bordered:!1,class:"step-info-card"},{title:pe(()=>[B("div",AR,[u[1]||(u[1]=B("span",null,"步骤信息",-1)),o(n.value)?(C(),ve(f,{key:0,type:"primary",size:"small",onClick:r,class:"debug-button"},{icon:pe(()=>[d(it(MM))]),default:pe(()=>[u[0]||(u[0]=De(" 调试 ",-1))]),_:1})):ae("",!0)])]),default:pe(()=>[B("div",xR,[u[2]||(u[2]=B("span",{class:"label"},"步骤ID:",-1)),B("span",VR,we(n.value.id),1)]),B("div",MR,[u[3]||(u[3]=B("span",{class:"label"},"类型:",-1)),B("span",NR,we(n.value.type),1)]),B("div",RR,[u[4]||(u[4]=B("span",{class:"label"},"时间:",-1)),B("span",zR,we(i(n.value.timestamp)),1)]),n.value.tool_name?(C(),T("div",DR,[u[5]||(u[5]=B("span",{class:"label"},"工具名称:",-1)),B("span",jR,we(n.value.tool_name),1)])):ae("",!0)]),_:1}),n.value.metadata&&Object.keys(n.value.metadata).length>0?(C(),T("div",FR,[u[6]||(u[6]=B("h4",null,"元数据",-1)),B("div",HR,[(C(!0),T(Me,null,Ct(Object.entries(n.value.metadata),([h,m])=>(C(),T("div",{key:h,class:"metadata-item"},[B("span",WR,we(h)+":",1),B("span",KR,we(s(m)),1)]))),128))])])):ae("",!0),d(v,{title:"完整日志",bordered:!1,class:"log-card"},{default:pe(()=>[B("div",qR,[B("div",UR,[n.value.type==="tool_call"?(C(),T("div",YR,[B("div",ZR,[u[7]||(u[7]=B("h5",{class:"log-section-title"},"Tool_Use 日志",-1)),B("pre",{class:"json-content",innerHTML:a(n.value.rawLogEntry||{})},null,8,GR)]),n.value.toolResult?(C(),T("div",XR,[u[8]||(u[8]=B("h5",{class:"log-section-title"},"Tool_Result 日志",-1)),B("pre",{class:"json-content",innerHTML:a(n.value.toolResult.rawLogEntry||{})},null,8,JR)])):ae("",!0)])):(C(),T("div",QR,[B("pre",{class:"json-content",innerHTML:a(n.value.rawLogEntry||{})},null,8,ez)]))])])]),_:1})])):ae("",!0)])}}}),nz=Vo(tz,[["__scopeId","data-v-a56f8487"]]),lz={class:"search-panel"},oz={class:"search-header"},az={key:0,class:"search-summary"},rz={class:"search-content"},iz={key:0,class:"loading-container"},sz={key:1,class:"empty-state"},uz={key:2,class:"results-container"},cz={class:"file-results"},dz=["onClick"],fz={class:"result-header"},pz={class:"step-index"},vz={class:"step-time"},hz={class:"result-content"},mz=["innerHTML"],gz={class:"matched-field"},yz={key:3,class:"initial-state"},bz=Q({__name:"SearchPanel",setup(e){const t=hi(),n=I(""),l=I(!1),o=I([]),r=I([]),a=p(()=>o.value.reduce((y,g)=>y+g.resultCount,0)),i=async y=>{if(!y.trim()){Oo.warning("请输入搜索关键字");return}l.value=!0,r.value=[];try{o.value=await t.performSearch(y.trim()),o.value.length>0&&(r.value=[o.value[0].fileId])}catch(g){console.error("搜索失败:",g),Oo.error("搜索失败,请重试")}finally{l.value=!1}},s=()=>{n.value="",o.value=[],r.value=[],t.searchKeyword=""},c=async y=>{try{y.fileId!==t.currentFileId&&await t.loadFile(y.fileId),setTimeout(()=>{var b,k;let g=(b=t.currentConversation)==null?void 0:b.steps.find(w=>w.id===y.stepId);if(g&&(g.type==="tool_result"||g.type==="agent_child_result")){const w=(k=t.currentConversation)==null?void 0:k.steps.find($=>($.type==="tool_call"||$.type==="agent_child")&&$.tool_use_id?$.tool_use_id===g.tool_use_id:!1);w?g=w:console.warn(`无法找到对应的父节点,${g.type} id:`,g.id)}g&&(t.selectStep(g),t.ensureStepExpanded(g.id),setTimeout(()=>{const w=document.querySelector('.detail-tabs [data-key="detail"]');w&&w.click()},100))},200)}catch(g){console.error("跳转失败:",g),Oo.error("跳转失败,请重试")}},u=y=>{if(!n.value)return y;const g=n.value.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),b=new RegExp(`(${g})`,"gi");return y.replace(b,'<mark class="search-highlight">$1</mark>')},f=(y,g)=>{var k;return y==="tool_result"&&g&&g.tool_use_id&&((k=t.currentConversation)!=null&&k.steps.find($=>$.type==="agent_child"&&$.tool_use_id===g.tool_use_id))&&(y="agent_child_result"),{user_message:"#1890ff",assistant_thinking:"#faad14",assistant_message:"#52c41a",tool_call:"#722ed1",tool_result:"#722ed1",agent_child:"#eb2f96",agent_child_result:"cyan",agent_end:"cyan",sub_agent:"cyan"}[y]||"gray"},v=(y,g)=>{var w;return y==="tool_result"&&g&&g.tool_use_id&&((w=t.currentConversation)!=null&&w.steps.find(S=>S.type==="agent_child"&&S.tool_use_id===g.tool_use_id))&&(y="agent_child_result"),{user_message:"User_Query",assistant_thinking:"Agent_Thinking",assistant_message:"Agent_Message",tool_call:"Tool_Use",tool_result:"Tool_Result",agent_child:"Sub_Agent",agent_child_result:"Sub_Agent_Result",agent_end:"Sub_Agent",sub_agent:"Sub_Agent"}[y]||y},h=y=>new Date(y).toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});let m=null;return Ae(n,y=>{m&&clearTimeout(m),y.trim()?m=setTimeout(()=>{i(y)},300):s()}),(y,g)=>{const b=oe("a-input-search"),k=oe("a-spin"),w=oe("a-empty"),$=oe("a-tag"),S=oe("a-collapse-item"),P=oe("a-collapse");return C(),T("div",lz,[B("div",oz,[d(b,{modelValue:n.value,"onUpdate:modelValue":g[0]||(g[0]=O=>n.value=O),placeholder:"请输入搜索关键字",loading:l.value,onSearch:i,onClear:s,class:"search-input"},null,8,["modelValue","loading"]),o.value.length>0?(C(),T("div",az," 找到 "+we(a.value)+" 个结果,分布在 "+we(o.value.length)+" 个文件中 ",1)):ae("",!0)]),B("div",rz,[l.value?(C(),T("div",iz,[d(k,{size:"large"}),g[2]||(g[2]=B("p",null,"正在搜索中...",-1))])):!l.value&&n.value&&o.value.length===0?(C(),T("div",sz,[d(w,{description:"未找到匹配的结果"})])):o.value.length>0?(C(),T("div",uz,[d(P,{"active-key":r.value,"onUpdate:activeKey":g[1]||(g[1]=O=>r.value=O),bordered:!1,class:"search-collapse"},{default:pe(()=>[(C(!0),T(Me,null,Ct(o.value,O=>(C(),ve(S,{key:O.fileId,header:`${O.fileName} (${O.resultCount}个结果)`,class:"file-result-item"},{default:pe(()=>[B("div",cz,[(C(!0),T(Me,null,Ct(O.results,(L,R)=>(C(),T("div",{key:L.stepId,class:"result-item",onClick:F=>c(L)},[B("div",fz,[d($,{color:f(L.stepType,L),size:"small",class:"step-type-tag"},{default:pe(()=>[De(we(v(L.stepType,L)),1)]),_:2},1032,["color"]),B("span",pz,"#"+we(L.stepIndex),1),B("span",vz,we(h(L.timestamp)),1)]),B("div",hz,[B("div",{class:"matched-text",innerHTML:u(L.matchedContent)},null,8,mz),B("div",gz,"匹配字段: "+we(L.matchedField),1)])],8,dz))),128))])]),_:2},1032,["header"]))),128))]),_:1},8,["active-key"])])):(C(),T("div",yz,[d(w,{description:"请输入关键字开始搜索"})]))])])}}}),Cz=Vo(bz,[["__scopeId","data-v-ffbd5663"]]),kz={class:"detail-panel"},wz={class:"detail-content"},$z=Q({__name:"DetailPanel",setup(e){return(t,n)=>{const l=oe("a-tab-pane"),o=oe("a-tabs");return C(),T("div",kz,[B("div",wz,[d(o,{"default-active-key":"search",class:"detail-tabs"},{default:pe(()=>[d(l,{key:"search",title:"全局搜索"},{default:pe(()=>[d(Cz)]),_:1}),d(l,{key:"detail",title:"步骤详情"},{default:pe(()=>[d(nz)]),_:1})]),_:1})])])}}}),Sz={class:"main-layout"},Pz={class:"header-content"},Oz={class:"header-actions"},_z={class:"content-wrapper"},Tz={class:"timeline-section"},Lz=Q({__name:"MainLayout",setup(e){const t=hi(),n=I(!1),l=I(500),o=I(360),r=I(!1),a=I(!1),i=I(0),s=I(0),c=async()=>{var g;try{const b=new URL(window.location.href);if(b.searchParams.delete("project"),b.searchParams.delete("file"),b.searchParams.delete("step"),b.searchParams.delete("sessionid"),t.currentFileId){b.searchParams.set("file",t.currentFileId),t.selectedStep&&b.searchParams.set("step",t.selectedStep.id);let w=null;(g=t.currentProject)!=null&&g.projectDir?w=t.currentProject.projectDir:w=new URL(window.location.href).searchParams.get("project"),w&&b.searchParams.set("project",w)}const k=b.toString();if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(k);else{const w=document.createElement("textarea");w.value=k,w.style.position="fixed",w.style.left="-999999px",w.style.top="-999999px",document.body.appendChild(w),w.focus(),w.select();try{document.execCommand("copy")}finally{document.body.removeChild(w)}}Oo.success("分享链接已复制到剪贴板")}catch(b){console.error("复制链接失败:",b),Oo.error("复制链接失败,请重试")}},u=g=>{r.value=!0,i.value=g.clientX,s.value=l.value,document.addEventListener("mousemove",v),document.addEventListener("mouseup",m),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},f=g=>{a.value=!0,i.value=g.clientX,s.value=o.value,document.addEventListener("mousemove",h),document.addEventListener("mouseup",y),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},v=g=>{if(!r.value)return;const b=i.value-g.clientX,k=s.value+b,w=300,$=window.innerWidth*.6;l.value=Math.max(w,Math.min($,k))},h=g=>{if(!a.value)return;const b=g.clientX-i.value,k=s.value+b,w=200,$=window.innerWidth*.5;o.value=Math.max(w,Math.min($,k))},m=()=>{r.value=!1,document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",m),document.body.style.cursor="",document.body.style.userSelect=""},y=()=>{a.value=!1,document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",y),document.body.style.cursor="",document.body.style.userSelect=""};return lt(()=>{t.initialize()}),Jt(()=>{document.removeEventListener("mousemove",v),document.removeEventListener("mouseup",m),document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",y)}),(g,b)=>{const k=oe("a-button"),w=oe("a-layout-header"),$=oe("a-layout-sider"),S=oe("a-layout-content"),P=oe("a-layout");return C(),T("div",Sz,[d(P,{class:"layout"},{default:pe(()=>[d(w,{class:"header"},{default:pe(()=>[B("div",Pz,[b[1]||(b[1]=B("h1",{class:"title"},"Claude Code Debug",-1)),B("div",Oz,[d(k,{type:"outline",size:"small",disabled:!it(t).currentFileId,onClick:c,title:"复制分享链接"},{icon:pe(()=>[d(it(BM))]),default:pe(()=>[b[0]||(b[0]=De(" 复制链接 ",-1))]),_:1},8,["disabled"])])])]),_:1}),d(P,{class:"body"},{default:pe(()=>[d($,{width:o.value,collapsed:!1,collapsible:!1,class:"sidebar"},{default:pe(()=>[d(wN)]),_:1},8,["width"]),B("div",{class:"resize-handle resize-handle-left",onMousedown:f},null,32),d(S,{class:"main-content"},{default:pe(()=>[B("div",_z,[B("div",Tz,[d(ER)]),n.value?ae("",!0):(C(),T("div",{key:0,class:"resize-handle",onMousedown:u},null,32)),n.value?ae("",!0):(C(),T("div",{key:1,class:"detail-section",style:Ie({width:l.value+"px"})},[d($z)],4))])]),_:1})]),_:1})]),_:1})])}}}),Ez=Vo(Lz,[["__scopeId","data-v-9f52bc01"]]),Iz={class:"debug-page"},Bz={class:"header"},Az={class:"params-info"},xz={class:"param-item"},Vz={class:"value"},Mz={class:"param-item"},Nz={class:"value"},Rz={class:"param-item"},zz={class:"value"},Dz={class:"param-item"},jz={class:"value"},Fz={class:"content"},Hz={key:0,class:"loading"},Wz={key:1,class:"error"},Kz={key:2,class:"llm-log-container"},qz={class:"main-layout"},Uz={class:"left-panel"},Yz={class:"section"},Zz={class:"user-messages"},Gz={class:"user-messages-header"},Xz={class:"messages-container"},Jz={class:"message-header"},Qz=["onUpdate:modelValue"],eD=["onClick"],tD={key:0,class:"content-list"},nD={class:"content-header"},lD={class:"content-type"},oD=["onClick"],aD=["onUpdate:modelValue"],rD=["value","onInput"],iD=["onUpdate:modelValue"],sD=["onClick"],uD={key:1,class:"single-content"},cD=["onUpdate:modelValue"],dD=["onClick"],fD={class:"right-panel"},pD={class:"section"},vD={class:"response-tabs"},hD={class:"tab-headers"},mD=["onClick"],gD=["onClick"],yD={class:"tab-content"},bD={key:0,class:"response-content"},CD=["innerHTML"],kD={class:"actions"},wD=["disabled"],$D=["disabled"],SD={key:3,class:"no-data"},PD=Q({__name:"DebugPage",setup(e){const t=ox(),n=(()=>{try{return new URLSearchParams(window.location.search).get("debug")==="1"||window.localStorage.getItem("CCDEBUG_DEBUG")==="1"}catch{return!1}})(),l=(...M)=>{n&&console.warn(...M)},o=I(null),r=I(""),a=I(""),i=I(""),s=I(""),c=I(!1),u=I(""),f=I(!1),v=I(!1),h=I([]),m=I({});p(()=>m.value?{...m.value,body:{...m.value.body,messages:h.value}}:{});const y=I([]),g=I(0);function b(){return{fileId:t.query.fileId,stepId:t.query.stepId,stepType:t.query.stepType}}function k(M){return M?JSON.stringify(M,null,2).replace(/(".*?")\s*:/g,'<span class="json-key">$1</span>:').replace(/:\s*(".*?")/g,': <span class="json-string">$1</span>').replace(/:\s*(true|false)/g,': <span class="json-boolean">$1</span>').replace(/:\s*(null)/g,': <span class="json-null">$1</span>').replace(/:\s*(\d+\.?\d*)/g,': <span class="json-number">$1</span>'):""}function w(M){var j,A;if(!M)return;const Y=((A=(j=M.request)==null?void 0:j.body)==null?void 0:A.messages)||[];h.value=Y.map(N=>({role:N.role||"user",content:(typeof N.content=="string",N.content)})),m.value=JSON.parse(JSON.stringify(M.request||{})),y.value=[{title:"原始响应",data:M.response||{}}],g.value=0}function $(){h.value.push({role:"user",content:""})}function S(M){h.value.splice(M,1)}function P(M){const Y=h.value[M];Array.isArray(Y.content)||(Y.content=[{type:"text",text:Y.content||""}]),Y.content.push({type:"text",text:""})}function O(M,Y){const j=h.value[M];Array.isArray(j.content)&&(j.content.splice(Y,1),j.content.length===1&&(j.content=j.content[0].text))}function L(M){const Y=h.value[M];Array.isArray(Y.content)||(Y.content=[{type:"text",text:Y.content||""}])}function R(){if(!o.value){alert("暂无日志数据");return}const M=window.open("","_blank","width=1200,height=800,scrollbars=yes,resizable=yes");if(M){const Y=JSON.stringify(o.value.request,null,2),N=["<!DOCTYPE html>","<html>","<head>"," <title>完整LLM请求日志</title>"," <style>"," body { ",' font-family: "Monaco", "Menlo", "Consolas", "Courier New", monospace; '," margin: 20px; "," background: #f8f9fa; "," line-height: 1.5;"," }"," .container {"," max-width: 100%;"," background: white;"," border-radius: 8px;"," box-shadow: 0 2px 10px rgba(0,0,0,0.1);"," overflow: hidden;"," }"," .header {"," background: #2c3e50;"," color: white;"," padding: 15px 20px;"," margin: 0;"," font-size: 18px;"," font-weight: 500;"," }"," pre { "," background: #ffffff; "," padding: 20px; "," margin: 0;"," overflow: auto; "," white-space: pre-wrap; "," word-break: break-all;"," font-size: 13px;"," line-height: 1.6;"," }"," "," /* JSON语法高亮样式 */"," .json-key {"," color: #0066cc;"," font-weight: 600;"," }"," .json-string {"," color: #22863a;"," }"," .json-number {"," color: #005cc5;"," }"," .json-boolean {"," color: #d73a49;"," font-weight: 600;"," }"," .json-null {"," color: #6f42c1;"," font-weight: 600;"," }"," "," /* 复制按钮 */"," .copy-btn {"," position: fixed;"," top: 20px;"," right: 20px;"," background: #28a745;"," color: white;"," border: none;"," padding: 10px 15px;"," border-radius: 5px;"," cursor: pointer;"," font-size: 14px;"," z-index: 1000;"," }"," .copy-btn:hover {"," background: #218838;"," }"," .copy-btn:active {"," background: #1e7e34;"," }"," </style>","</head>","<body>",' <button class="copy-btn" onclick="copyToClipboard()">复制JSON</button>',' <div class="container">',' <h1 class="header">完整LLM请求日志</h1>',' <pre id="json-content">'+(D=>D.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,V=>{let H="json-number";return/^"/.test(V)?/:$/.test(V)?H="json-key":H="json-string":/true|false/.test(V)?H="json-boolean":/null/.test(V)&&(H="json-null"),'<span class="'+H+'">'+V+"</span>"}))(Y)+"</pre>"," </div>"," "," <script>"," function copyToClipboard() {"," const jsonText = "+JSON.stringify(Y)+";"," navigator.clipboard.writeText(jsonText).then(() => {",' const btn = document.querySelector(".copy-btn");'," const originalText = btn.textContent;",' btn.textContent = "已复制!";',' btn.style.background = "#17a2b8";'," setTimeout(() => {"," btn.textContent = originalText;",' btn.style.background = "#28a745";'," }, 2000);"," }).catch(err => {",' console.error("复制失败:", err);',' alert("复制失败,请手动选择文本复制");'," });"," }"," <\/script>","</body>","</html>"].join(`
41
41
  `);M.document.write(N),M.document.close()}}function F(M){M!==0&&(y.value.splice(M,1),g.value>=M&&(g.value=Math.max(0,g.value-1)))}async function x(){if(!s.value){alert("缺少消息ID");return}f.value=!0;try{const M={...m.value,body:{...m.value.body,messages:h.value}};if(!(await fetch(`/api/llm-requests/${s.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).ok)throw new Error("保存失败");alert("保存成功")}catch(M){console.error("保存失败:",M),alert("保存失败: "+M.message)}finally{f.value=!1}}async function Z(){v.value=!0;try{const M=o.value.request,Y=await(await fetch("/api/llm-request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)})).json();if(!Y.success)throw new Error(`请求失败:${Y.error}`);const A={title:`请求 ${y.value.length}`,data:Y.data};y.value.push(A),g.value=y.value.length-1}catch(M){console.error("发送请求失败:",M),alert("发送请求失败: "+M.message),y.value.length>0&&(y.value[g.value].data={success:!1,error:M.message})}finally{v.value=!1}}async function U(){var Y,j;const M=b();if(!M.fileId||!M.stepId){u.value="缺少必要的参数";return}r.value=M.fileId,a.value=M.stepId,i.value=M.stepType||"",c.value=!0,u.value="";try{let A=M.messageId||M.stepId;if(!M.messageId)try{const D=await fetch(`/api/conversations/${M.fileId}/steps/${M.stepId}`);if(D.ok){const V=await D.json();V.success&&V.data&&((j=(Y=V.data.rawLogEntry)==null?void 0:Y.message)!=null&&j.id)&&(A=V.data.rawLogEntry.message.id)}}catch(D){l("无法获取步骤信息,使用stepId作为messageId:",D)}s.value=A;const N=await(await fetch(`/api/conversations/${M.fileId}/llm-logs/${A}`)).json();if(!N.success)throw new Error(N.error);o.value=N.data,w(N.data)}catch(A){console.error("加载LLM日志失败:",A),u.value=A.message||"加载LLM日志失败"}finally{c.value=!1}}return lt(()=>{U()}),(M,Y)=>{const j=oe("a-alert");return C(),T("div",Iz,[B("div",Bz,[Y[4]||(Y[4]=B("h1",null,"LLM请求调试",-1)),B("div",Az,[B("div",xz,[Y[0]||(Y[0]=B("span",{class:"label"},"文件ID:",-1)),B("span",Vz,we(r.value||"-"),1)]),B("div",Mz,[Y[1]||(Y[1]=B("span",{class:"label"},"步骤ID:",-1)),B("span",Nz,we(a.value||"-"),1)]),B("div",Rz,[Y[2]||(Y[2]=B("span",{class:"label"},"步骤类型:",-1)),B("span",zz,we(i.value||"-"),1)]),B("div",Dz,[Y[3]||(Y[3]=B("span",{class:"label"},"消息ID:",-1)),B("span",jz,we(s.value||"-"),1)])])]),B("div",Fz,[c.value?(C(),T("div",Hz," 正在加载LLM请求日志... ")):u.value?(C(),T("div",Wz,[De(we(u.value)+" ",1),B("button",{onClick:U,class:"retry-button"},"重试")])):o.value?(C(),T("div",Kz,[B("div",qz,[B("div",Uz,[B("div",Yz,[Y[6]||(Y[6]=B("div",{class:"section-header"},[B("h2",null,"LLM请求数据")],-1)),B("div",Zz,[B("div",Gz,[d(j,{title:"您可以修改请求数据,并重新发送请求,以便反复验证LLM回复",type:"info","show-icon":""},{action:pe(()=>[B("button",{onClick:$,class:"add-message-btn-top"},"添加消息")]),_:1})]),B("div",Xz,[(C(!0),T(Me,null,Ct(h.value,(A,N)=>(C(),T("div",{key:N,class:"message-item"},[B("div",Jz,[_n(B("select",{"onUpdate:modelValue":D=>A.role=D,class:"role-select"},[...Y[5]||(Y[5]=[B("option",{value:"user"},"user",-1),B("option",{value:"assistant"},"assistant",-1),B("option",{value:"system"},"system",-1)])],8,Qz),[[w4,A.role]]),B("button",{onClick:D=>S(N),class:"delete-btn"},"删除",8,eD)]),Array.isArray(A.content)?(C(),T("div",tD,[(C(!0),T(Me,null,Ct(A.content,(D,V)=>(C(),T("div",{key:V,class:"content-item"},[B("div",nD,[B("span",lD,we(D.type||"text"),1),B("button",{onClick:H=>O(N,V),class:"delete-content-btn"},"删除内容",8,oD)]),D.type==="text"?_n((C(),T("textarea",{key:0,"onUpdate:modelValue":H=>D.text=H,class:"content-textarea",placeholder:"请输入工具使用的内容..."},null,8,aD)),[[Fc,D.text]]):ae("",!0),D.type==="tool_use"?(C(),T("textarea",{key:1,value:JSON.stringify(D.input,null,2),onInput:H=>{try{D.input=JSON.parse(H.target.value)}catch{D.input=H.target.value}},class:"content-textarea-tool_use",placeholder:"输入内容..."},null,40,rD)):ae("",!0),D.type==="tool_result"?_n((C(),T("textarea",{key:2,"onUpdate:modelValue":H=>D.content=H,class:"content-textarea-tool_use",placeholder:"输入内容..."},null,8,iD)),[[Fc,D.content]]):ae("",!0)]))),128)),B("button",{onClick:D=>P(N),class:"add-content-btn"},"添加内容",8,sD)])):(C(),T("div",uD,[_n(B("textarea",{"onUpdate:modelValue":D=>A.content=D,class:"message-content",rows:"4",placeholder:"输入消息内容..."},null,8,cD),[[Fc,A.content]]),B("button",{onClick:D=>L(N),class:"convert-btn"},"转换为多内容",8,dD)]))]))),128))])])])]),B("div",fD,[B("div",pD,[Y[7]||(Y[7]=B("div",{class:"section-header"},[B("h2",null,"LLM响应数据")],-1)),B("div",vD,[B("div",hD,[(C(!0),T(Me,null,Ct(y.value,(A,N)=>(C(),T("div",{key:N,class:_(["tab-header",{active:g.value===N}]),onClick:D=>g.value=N},[De(we(A.title)+" ",1),N>0?(C(),T("button",{key:0,onClick:Zt(D=>F(N),["stop"]),class:"close-tab-btn"},"×",8,gD)):ae("",!0)],10,mD))),128))]),B("div",yD,[y.value[g.value]?(C(),T("div",bD,[B("pre",{class:"json-display",innerHTML:k(y.value[g.value].data)},null,8,CD)])):ae("",!0)])])])])]),B("div",kD,[B("button",{onClick:x,disabled:f.value,class:"save-button"},we(f.value?"保存中...":"保存"),9,wD),B("button",{onClick:Z,disabled:v.value,class:"send-button"},we(v.value?"发送中...":"单次请求"),9,$D),B("button",{onClick:R,class:"view-log-button"}," 查看请求完整数据 ")])])):(C(),T("div",SD," 暂无数据 "))])])}}}),Uy=Vo(PD,[["__scopeId","data-v-d1788e3c"]]),OD=[{path:"/",name:"Home",component:Ez},{path:"/debug",name:"Debug",component:Uy},{path:"/debug.html",name:"DebugHtml",component:Uy}],_D=lx({history:VA(),routes:OD}),TD={id:"app"},LD=Q({__name:"App",setup(e){return(t,n)=>{const l=oe("router-view");return C(),T("div",TD,[d(l)])}}}),Cc=Yv(LD),ED=L4();Cc.use(ED);Cc.use(XB);Cc.use(_D);Cc.mount("#app");
42
- //# sourceMappingURL=index-CBtN4uj6.js.map
42
+ //# sourceMappingURL=index-CP7tYHG0.js.map