acp-devtools 0.2.0 → 0.2.1
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.
- package/dist/index.js +1785 -1010
- package/dist/ui/CNAME +1 -0
- package/dist/ui/assets/{index-C3oZwSx5.js → index-BnYwNhFF.js} +3 -3
- package/dist/ui/index.html +1 -1
- package/package.json +2 -2
|
@@ -1763,6 +1763,6 @@ Notifications do not expect a response.`,title:"ProtocolLevel"}],MS="Agent Clien
|
|
|
1763
1763
|
missingProperty: ${m},
|
|
1764
1764
|
depsCount: ${c},
|
|
1765
1765
|
deps: ${f}}`};const r={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(l){const[c,f]=i(l);s(l,c),a(l,f)}};function i({schema:l}){const c={},f={};for(const m in l){if(m==="__proto__")continue;const h=Array.isArray(l[m])?c:f;h[m]=l[m]}return[c,f]}function s(l,c=l.schema){const{gen:f,data:m,it:h}=l;if(Object.keys(c).length===0)return;const y=f.let("missing");for(const g in c){const b=c[g];if(b.length===0)continue;const v=(0,o.propertyInData)(f,m,g,h.opts.ownProperties);l.setParams({property:g,depsCount:b.length,deps:b.join(", ")}),h.allErrors?f.if(v,()=>{for(const u of b)(0,o.checkReportMissingProp)(l,u)}):(f.if((0,t._)`${v} && (${(0,o.checkMissingProp)(l,b,y)})`),(0,o.reportMissingProp)(l,y),f.else())}}e.validatePropertyDeps=s;function a(l,c=l.schema){const{gen:f,data:m,keyword:h,it:y}=l,g=f.name("valid");for(const b in c)(0,n.alwaysValidSchema)(y,c[b])||(f.if((0,o.propertyInData)(f,m,b,y.opts.ownProperties),()=>{const v=l.subschema({keyword:h,schemaProp:b},g);l.mergeValidEvaluated(v,g)},()=>f.var(g,!0)),l.ok(g))}e.validateSchemaDeps=a,e.default=r})(Rl);var Ep={};Object.defineProperty(Ep,"__esModule",{value:!0});const Cb=ue,I1=J,O1={message:"property name must be valid",params:({params:e})=>(0,Cb._)`{propertyName: ${e.propertyName}}`},R1={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:O1,code(e){const{gen:t,schema:n,data:o,it:r}=e;if((0,I1.alwaysValidSchema)(r,n))return;const i=t.name("valid");t.forIn("key",o,s=>{e.setParams({propertyName:s}),e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:!0},i),t.if((0,Cb.not)(i),()=>{e.error(!0),r.allErrors||t.break()})}),e.ok(i)}};Ep.default=R1;var Al={};Object.defineProperty(Al,"__esModule",{value:!0});const Zs=ye,en=ue,A1=Dt,ea=J,M1={message:"must NOT have additional properties",params:({params:e})=>(0,en._)`{additionalProperty: ${e.additionalProperty}}`},q1={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:M1,code(e){const{gen:t,schema:n,parentSchema:o,data:r,errsCount:i,it:s}=e;if(!i)throw new Error("ajv implementation error");const{allErrors:a,opts:l}=s;if(s.props=!0,l.removeAdditional!=="all"&&(0,ea.alwaysValidSchema)(s,n))return;const c=(0,Zs.allSchemaProperties)(o.properties),f=(0,Zs.allSchemaProperties)(o.patternProperties);m(),e.ok((0,en._)`${i} === ${A1.default.errors}`);function m(){t.forIn("key",r,v=>{!c.length&&!f.length?g(v):t.if(h(v),()=>g(v))})}function h(v){let u;if(c.length>8){const p=(0,ea.schemaRefOrVal)(s,o.properties,"properties");u=(0,Zs.isOwnProperty)(t,p,v)}else c.length?u=(0,en.or)(...c.map(p=>(0,en._)`${v} === ${p}`)):u=en.nil;return f.length&&(u=(0,en.or)(u,...f.map(p=>(0,en._)`${(0,Zs.usePattern)(e,p)}.test(${v})`))),(0,en.not)(u)}function y(v){t.code((0,en._)`delete ${r}[${v}]`)}function g(v){if(l.removeAdditional==="all"||l.removeAdditional&&n===!1){y(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),a||t.break();return}if(typeof n=="object"&&!(0,ea.alwaysValidSchema)(s,n)){const u=t.name("valid");l.removeAdditional==="failing"?(b(v,u,!1),t.if((0,en.not)(u),()=>{e.reset(),y(v)})):(b(v,u),a||t.if((0,en.not)(u),()=>t.break()))}}function b(v,u,p){const x={keyword:"additionalProperties",dataProp:v,dataPropType:ea.Type.Str};p===!1&&Object.assign(x,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(x,u)}}};Al.default=q1;var Pp={};Object.defineProperty(Pp,"__esModule",{value:!0});const U1=ln,Ym=ye,wc=J,Xm=Al,L1={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,parentSchema:o,data:r,it:i}=e;i.opts.removeAdditional==="all"&&o.additionalProperties===void 0&&Xm.default.code(new U1.KeywordCxt(i,Xm.default,"additionalProperties"));const s=(0,Ym.allSchemaProperties)(n);for(const m of s)i.definedProperties.add(m);i.opts.unevaluated&&s.length&&i.props!==!0&&(i.props=wc.mergeEvaluated.props(t,(0,wc.toHash)(s),i.props));const a=s.filter(m=>!(0,wc.alwaysValidSchema)(i,n[m]));if(a.length===0)return;const l=t.name("valid");for(const m of a)c(m)?f(m):(t.if((0,Ym.propertyInData)(t,r,m,i.opts.ownProperties)),f(m),i.allErrors||t.else().var(l,!0),t.endIf()),e.it.definedProperties.add(m),e.ok(l);function c(m){return i.opts.useDefaults&&!i.compositeRule&&n[m].default!==void 0}function f(m){e.subschema({keyword:"properties",schemaProp:m,dataProp:m},l)}}};Pp.default=L1;var Ip={};Object.defineProperty(Ip,"__esModule",{value:!0});const Zm=ye,ta=ue,eh=J,th=J,D1={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:n,data:o,parentSchema:r,it:i}=e,{opts:s}=i,a=(0,Zm.allSchemaProperties)(n),l=a.filter(b=>(0,eh.alwaysValidSchema)(i,n[b]));if(a.length===0||l.length===a.length&&(!i.opts.unevaluated||i.props===!0))return;const c=s.strictSchema&&!s.allowMatchingProperties&&r.properties,f=t.name("valid");i.props!==!0&&!(i.props instanceof ta.Name)&&(i.props=(0,th.evaluatedPropsToName)(t,i.props));const{props:m}=i;h();function h(){for(const b of a)c&&y(b),i.allErrors?g(b):(t.var(f,!0),g(b),t.if(f))}function y(b){for(const v in c)new RegExp(b).test(v)&&(0,eh.checkStrictMode)(i,`property ${v} matches pattern ${b} (use allowMatchingProperties)`)}function g(b){t.forIn("key",o,v=>{t.if((0,ta._)`${(0,Zm.usePattern)(e,b)}.test(${v})`,()=>{const u=l.includes(b);u||e.subschema({keyword:"patternProperties",schemaProp:b,dataProp:v,dataPropType:th.Type.Str},f),i.opts.unevaluated&&m!==!0?t.assign((0,ta._)`${m}[${v}]`,!0):!u&&!i.allErrors&&t.if((0,ta.not)(f),()=>t.break())})})}}};Ip.default=D1;var Op={};Object.defineProperty(Op,"__esModule",{value:!0});const z1=J,F1={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){const{gen:t,schema:n,it:o}=e;if((0,z1.alwaysValidSchema)(o,n)){e.fail();return}const r=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},r),e.failResult(r,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Op.default=F1;var Rp={};Object.defineProperty(Rp,"__esModule",{value:!0});const B1=ye,H1={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:B1.validateUnion,error:{message:"must match a schema in anyOf"}};Rp.default=H1;var Ap={};Object.defineProperty(Ap,"__esModule",{value:!0});const Sa=ue,V1=J,W1={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Sa._)`{passingSchemas: ${e.passing}}`},K1={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:W1,code(e){const{gen:t,schema:n,parentSchema:o,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(r.opts.discriminator&&o.discriminator)return;const i=n,s=t.let("valid",!1),a=t.let("passing",null),l=t.name("_valid");e.setParams({passing:a}),t.block(c),e.result(s,()=>e.reset(),()=>e.error(!0));function c(){i.forEach((f,m)=>{let h;(0,V1.alwaysValidSchema)(r,f)?t.var(l,!0):h=e.subschema({keyword:"oneOf",schemaProp:m,compositeRule:!0},l),m>0&&t.if((0,Sa._)`${l} && ${s}`).assign(s,!1).assign(a,(0,Sa._)`[${a}, ${m}]`).else(),t.if(l,()=>{t.assign(s,!0),t.assign(a,m),h&&e.mergeEvaluated(h,Sa.Name)})})}}};Ap.default=K1;var Mp={};Object.defineProperty(Mp,"__esModule",{value:!0});const G1=J,J1={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:n,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");const r=t.name("valid");n.forEach((i,s)=>{if((0,G1.alwaysValidSchema)(o,i))return;const a=e.subschema({keyword:"allOf",schemaProp:s},r);e.ok(r),e.mergeEvaluated(a)})}};Mp.default=J1;var qp={};Object.defineProperty(qp,"__esModule",{value:!0});const sl=ue,Eb=J,Q1={message:({params:e})=>(0,sl.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,sl._)`{failingKeyword: ${e.ifClause}}`},Y1={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Q1,code(e){const{gen:t,parentSchema:n,it:o}=e;n.then===void 0&&n.else===void 0&&(0,Eb.checkStrictMode)(o,'"if" without "then" and "else" is ignored');const r=nh(o,"then"),i=nh(o,"else");if(!r&&!i)return;const s=t.let("valid",!0),a=t.name("_valid");if(l(),e.reset(),r&&i){const f=t.let("ifClause");e.setParams({ifClause:f}),t.if(a,c("then",f),c("else",f))}else r?t.if(a,c("then")):t.if((0,sl.not)(a),c("else"));e.pass(s,()=>e.error(!0));function l(){const f=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(f)}function c(f,m){return()=>{const h=e.subschema({keyword:f},a);t.assign(s,a),e.mergeValidEvaluated(h,s),m?t.assign(m,(0,sl._)`${f}`):e.setParams({ifClause:f})}}}};function nh(e,t){const n=e.schema[t];return n!==void 0&&!(0,Eb.alwaysValidSchema)(e,n)}qp.default=Y1;var Up={};Object.defineProperty(Up,"__esModule",{value:!0});const X1=J,Z1={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,X1.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};Up.default=Z1;Object.defineProperty(_p,"__esModule",{value:!0});const e_=Xr,t_=jp,n_=Zr,o_=Np,r_=Cp,i_=Rl,s_=Ep,a_=Al,l_=Pp,c_=Ip,d_=Op,u_=Rp,p_=Ap,f_=Mp,m_=qp,h_=Up;function y_(e=!1){const t=[d_.default,u_.default,p_.default,f_.default,m_.default,h_.default,s_.default,a_.default,i_.default,l_.default,c_.default];return e?t.push(t_.default,o_.default):t.push(e_.default,n_.default),t.push(r_.default),t}_p.default=y_;var Lp={},ei={};Object.defineProperty(ei,"__esModule",{value:!0});ei.dynamicAnchor=void 0;const Sc=ue,g_=Dt,oh=xt,v_=zn,b_={keyword:"$dynamicAnchor",schemaType:"string",code:e=>Pb(e,e.schema)};function Pb(e,t){const{gen:n,it:o}=e;o.schemaEnv.root.dynamicAnchors[t]=!0;const r=(0,Sc._)`${g_.default.dynamicAnchors}${(0,Sc.getProperty)(t)}`,i=o.errSchemaPath==="#"?o.validateName:x_(e);n.if((0,Sc._)`!${r}`,()=>n.assign(r,i))}ei.dynamicAnchor=Pb;function x_(e){const{schemaEnv:t,schema:n,self:o}=e.it,{root:r,baseId:i,localRefs:s,meta:a}=t.root,{schemaId:l}=o.opts,c=new oh.SchemaEnv({schema:n,schemaId:l,root:r,baseId:i,localRefs:s,meta:a});return oh.compileSchema.call(o,c),(0,v_.getValidate)(e,c)}ei.default=b_;var ti={};Object.defineProperty(ti,"__esModule",{value:!0});ti.dynamicRef=void 0;const rh=ue,w_=Dt,ih=zn,S_={keyword:"$dynamicRef",schemaType:"string",code:e=>Ib(e,e.schema)};function Ib(e,t){const{gen:n,keyword:o,it:r}=e;if(t[0]!=="#")throw new Error(`"${o}" only supports hash fragment reference`);const i=t.slice(1);if(r.allErrors)s();else{const l=n.let("valid",!1);s(l),e.ok(l)}function s(l){if(r.schemaEnv.root.dynamicAnchors[i]){const c=n.let("_v",(0,rh._)`${w_.default.dynamicAnchors}${(0,rh.getProperty)(i)}`);n.if(c,a(c,l),a(r.validateName,l))}else a(r.validateName,l)()}function a(l,c){return c?()=>n.block(()=>{(0,ih.callRef)(e,l),n.let(c,!0)}):()=>(0,ih.callRef)(e,l)}}ti.dynamicRef=Ib;ti.default=S_;var Dp={};Object.defineProperty(Dp,"__esModule",{value:!0});const $_=ei,k_=J,T_={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,$_.dynamicAnchor)(e,""):(0,k_.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};Dp.default=T_;var zp={};Object.defineProperty(zp,"__esModule",{value:!0});const __=ti,j_={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,__.dynamicRef)(e,e.schema)};zp.default=j_;Object.defineProperty(Lp,"__esModule",{value:!0});const N_=ei,C_=ti,E_=Dp,P_=zp,I_=[N_.default,C_.default,E_.default,P_.default];Lp.default=I_;var Fp={},Bp={};Object.defineProperty(Bp,"__esModule",{value:!0});const sh=Rl,O_={keyword:"dependentRequired",type:"object",schemaType:"object",error:sh.error,code:e=>(0,sh.validatePropertyDeps)(e)};Bp.default=O_;var Hp={};Object.defineProperty(Hp,"__esModule",{value:!0});const R_=Rl,A_={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,R_.validateSchemaDeps)(e)};Hp.default=A_;var Vp={};Object.defineProperty(Vp,"__esModule",{value:!0});const M_=J,q_={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){t.contains===void 0&&(0,M_.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};Vp.default=q_;Object.defineProperty(Fp,"__esModule",{value:!0});const U_=Bp,L_=Hp,D_=Vp,z_=[U_.default,L_.default,D_.default];Fp.default=z_;var Wp={},Kp={};Object.defineProperty(Kp,"__esModule",{value:!0});const Xn=ue,ah=J,F_=Dt,B_={message:"must NOT have unevaluated properties",params:({params:e})=>(0,Xn._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},H_={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:B_,code(e){const{gen:t,schema:n,data:o,errsCount:r,it:i}=e;if(!r)throw new Error("ajv implementation error");const{allErrors:s,props:a}=i;a instanceof Xn.Name?t.if((0,Xn._)`${a} !== true`,()=>t.forIn("key",o,m=>t.if(c(a,m),()=>l(m)))):a!==!0&&t.forIn("key",o,m=>a===void 0?l(m):t.if(f(a,m),()=>l(m))),i.props=!0,e.ok((0,Xn._)`${r} === ${F_.default.errors}`);function l(m){if(n===!1){e.setParams({unevaluatedProperty:m}),e.error(),s||t.break();return}if(!(0,ah.alwaysValidSchema)(i,n)){const h=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:m,dataPropType:ah.Type.Str},h),s||t.if((0,Xn.not)(h),()=>t.break())}}function c(m,h){return(0,Xn._)`!${m} || !${m}[${h}]`}function f(m,h){const y=[];for(const g in m)m[g]===!0&&y.push((0,Xn._)`${h} !== ${g}`);return(0,Xn.and)(...y)}}};Kp.default=H_;var Gp={};Object.defineProperty(Gp,"__esModule",{value:!0});const Ro=ue,lh=J,V_={message:({params:{len:e}})=>(0,Ro.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Ro._)`{limit: ${e}}`},W_={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:V_,code(e){const{gen:t,schema:n,data:o,it:r}=e,i=r.items||0;if(i===!0)return;const s=t.const("len",(0,Ro._)`${o}.length`);if(n===!1)e.setParams({len:i}),e.fail((0,Ro._)`${s} > ${i}`);else if(typeof n=="object"&&!(0,lh.alwaysValidSchema)(r,n)){const l=t.var("valid",(0,Ro._)`${s} <= ${i}`);t.if((0,Ro.not)(l),()=>a(l,i)),e.ok(l)}r.items=!0;function a(l,c){t.forRange("i",c,s,f=>{e.subschema({keyword:"unevaluatedItems",dataProp:f,dataPropType:lh.Type.Num},l),r.allErrors||t.if((0,Ro.not)(l),()=>t.break())})}}};Gp.default=W_;Object.defineProperty(Wp,"__esModule",{value:!0});const K_=Kp,G_=Gp,J_=[K_.default,G_.default];Wp.default=J_;var Jp={},Qp={};Object.defineProperty(Qp,"__esModule",{value:!0});const We=ue,Q_={message:({schemaCode:e})=>(0,We.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,We._)`{format: ${e}}`},Y_={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Q_,code(e,t){const{gen:n,data:o,$data:r,schema:i,schemaCode:s,it:a}=e,{opts:l,errSchemaPath:c,schemaEnv:f,self:m}=a;if(!l.validateFormats)return;r?h():y();function h(){const g=n.scopeValue("formats",{ref:m.formats,code:l.code.formats}),b=n.const("fDef",(0,We._)`${g}[${s}]`),v=n.let("fType"),u=n.let("format");n.if((0,We._)`typeof ${b} == "object" && !(${b} instanceof RegExp)`,()=>n.assign(v,(0,We._)`${b}.type || "string"`).assign(u,(0,We._)`${b}.validate`),()=>n.assign(v,(0,We._)`"string"`).assign(u,b)),e.fail$data((0,We.or)(p(),x()));function p(){return l.strictSchema===!1?We.nil:(0,We._)`${s} && !${u}`}function x(){const S=f.$async?(0,We._)`(${b}.async ? await ${u}(${o}) : ${u}(${o}))`:(0,We._)`${u}(${o})`,T=(0,We._)`(typeof ${u} == "function" ? ${S} : ${u}.test(${o}))`;return(0,We._)`${u} && ${u} !== true && ${v} === ${t} && !${T}`}}function y(){const g=m.formats[i];if(!g){p();return}if(g===!0)return;const[b,v,u]=x(g);b===t&&e.pass(S());function p(){if(l.strictSchema===!1){m.logger.warn(T());return}throw new Error(T());function T(){return`unknown format "${i}" ignored in schema at path "${c}"`}}function x(T){const C=T instanceof RegExp?(0,We.regexpCode)(T):l.code.formats?(0,We._)`${l.code.formats}${(0,We.getProperty)(i)}`:void 0,$=n.scopeValue("formats",{key:i,ref:T,code:C});return typeof T=="object"&&!(T instanceof RegExp)?[T.type||"string",T.validate,(0,We._)`${$}.validate`]:["string",T,$]}function S(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!f.$async)throw new Error("async format in sync schema");return(0,We._)`await ${u}(${o})`}return typeof v=="function"?(0,We._)`${u}(${o})`:(0,We._)`${u}.test(${o})`}}}};Qp.default=Y_;Object.defineProperty(Jp,"__esModule",{value:!0});const X_=Qp,Z_=[X_.default];Jp.default=Z_;var Kr={};Object.defineProperty(Kr,"__esModule",{value:!0});Kr.contentVocabulary=Kr.metadataVocabulary=void 0;Kr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Kr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"];Object.defineProperty(up,"__esModule",{value:!0});const ej=pp,tj=mp,nj=_p,oj=Lp,rj=Fp,ij=Wp,sj=Jp,ch=Kr,aj=[oj.default,ej.default,tj.default,(0,nj.default)(!0),sj.default,ch.metadataVocabulary,ch.contentVocabulary,rj.default,ij.default];up.default=aj;var Yp={},Ml={};Object.defineProperty(Ml,"__esModule",{value:!0});Ml.DiscrError=void 0;var dh;(function(e){e.Tag="tag",e.Mapping="mapping"})(dh||(Ml.DiscrError=dh={}));Object.defineProperty(Yp,"__esModule",{value:!0});const dr=ue,Ld=Ml,uh=xt,lj=Yr,cj=J,dj={message:({params:{discrError:e,tagName:t}})=>e===Ld.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,dr._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},uj={keyword:"discriminator",type:"object",schemaType:"object",error:dj,code(e){const{gen:t,data:n,schema:o,parentSchema:r,it:i}=e,{oneOf:s}=r;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=o.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(o.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");const l=t.let("valid",!1),c=t.const("tag",(0,dr._)`${n}${(0,dr.getProperty)(a)}`);t.if((0,dr._)`typeof ${c} == "string"`,()=>f(),()=>e.error(!1,{discrError:Ld.DiscrError.Tag,tag:c,tagName:a})),e.ok(l);function f(){const y=h();t.if(!1);for(const g in y)t.elseIf((0,dr._)`${c} === ${g}`),t.assign(l,m(y[g]));t.else(),e.error(!1,{discrError:Ld.DiscrError.Mapping,tag:c,tagName:a}),t.endIf()}function m(y){const g=t.name("valid"),b=e.subschema({keyword:"oneOf",schemaProp:y},g);return e.mergeEvaluated(b,dr.Name),g}function h(){var y;const g={},b=u(r);let v=!0;for(let S=0;S<s.length;S++){let T=s[S];if(T!=null&&T.$ref&&!(0,cj.schemaHasRulesButRef)(T,i.self.RULES)){const $=T.$ref;if(T=uh.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,$),T instanceof uh.SchemaEnv&&(T=T.schema),T===void 0)throw new lj.default(i.opts.uriResolver,i.baseId,$)}const C=(y=T==null?void 0:T.properties)===null||y===void 0?void 0:y[a];if(typeof C!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(b||u(T)),p(C,S)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return g;function u({required:S}){return Array.isArray(S)&&S.includes(a)}function p(S,T){if(S.const)x(S.const,T);else if(S.enum)for(const C of S.enum)x(C,T);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function x(S,T){if(typeof S!="string"||S in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[S]=T}}}};Yp.default=uj;var Xp={};const pj="https://json-schema.org/draft/2020-12/schema",fj="https://json-schema.org/draft/2020-12/schema",mj={"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},hj="meta",yj="Core and Validation specifications meta-schema",gj=[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],vj=["object","boolean"],bj="This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",xj={definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}},wj={$schema:pj,$id:fj,$vocabulary:mj,$dynamicAnchor:hj,title:yj,allOf:gj,type:vj,$comment:bj,properties:xj},Sj="https://json-schema.org/draft/2020-12/schema",$j="https://json-schema.org/draft/2020-12/meta/applicator",kj={"https://json-schema.org/draft/2020-12/vocab/applicator":!0},Tj="meta",_j="Applicator vocabulary meta-schema",jj=["object","boolean"],Nj={prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},Cj={schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}},Ej={$schema:Sj,$id:$j,$vocabulary:kj,$dynamicAnchor:Tj,title:_j,type:jj,properties:Nj,$defs:Cj},Pj="https://json-schema.org/draft/2020-12/schema",Ij="https://json-schema.org/draft/2020-12/meta/unevaluated",Oj={"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},Rj="meta",Aj="Unevaluated applicator vocabulary meta-schema",Mj=["object","boolean"],qj={unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}},Uj={$schema:Pj,$id:Ij,$vocabulary:Oj,$dynamicAnchor:Rj,title:Aj,type:Mj,properties:qj},Lj="https://json-schema.org/draft/2020-12/schema",Dj="https://json-schema.org/draft/2020-12/meta/content",zj={"https://json-schema.org/draft/2020-12/vocab/content":!0},Fj="meta",Bj="Content vocabulary meta-schema",Hj=["object","boolean"],Vj={contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}},Wj={$schema:Lj,$id:Dj,$vocabulary:zj,$dynamicAnchor:Fj,title:Bj,type:Hj,properties:Vj},Kj="https://json-schema.org/draft/2020-12/schema",Gj="https://json-schema.org/draft/2020-12/meta/core",Jj={"https://json-schema.org/draft/2020-12/vocab/core":!0},Qj="meta",Yj="Core vocabulary meta-schema",Xj=["object","boolean"],Zj={$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},eN={anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}},tN={$schema:Kj,$id:Gj,$vocabulary:Jj,$dynamicAnchor:Qj,title:Yj,type:Xj,properties:Zj,$defs:eN},nN="https://json-schema.org/draft/2020-12/schema",oN="https://json-schema.org/draft/2020-12/meta/format-annotation",rN={"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},iN="meta",sN="Format vocabulary meta-schema for annotation results",aN=["object","boolean"],lN={format:{type:"string"}},cN={$schema:nN,$id:oN,$vocabulary:rN,$dynamicAnchor:iN,title:sN,type:aN,properties:lN},dN="https://json-schema.org/draft/2020-12/schema",uN="https://json-schema.org/draft/2020-12/meta/meta-data",pN={"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},fN="meta",mN="Meta-data vocabulary meta-schema",hN=["object","boolean"],yN={title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}},gN={$schema:dN,$id:uN,$vocabulary:pN,$dynamicAnchor:fN,title:mN,type:hN,properties:yN},vN="https://json-schema.org/draft/2020-12/schema",bN="https://json-schema.org/draft/2020-12/meta/validation",xN={"https://json-schema.org/draft/2020-12/vocab/validation":!0},wN="meta",SN="Validation vocabulary meta-schema",$N=["object","boolean"],kN={type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},TN={nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},_N={$schema:vN,$id:bN,$vocabulary:xN,$dynamicAnchor:wN,title:SN,type:$N,properties:kN,$defs:TN};Object.defineProperty(Xp,"__esModule",{value:!0});const jN=wj,NN=Ej,CN=Uj,EN=Wj,PN=tN,IN=cN,ON=gN,RN=_N,AN=["/properties"];function MN(e){return[jN,NN,CN,EN,PN,t(this,IN),ON,t(this,RN)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function t(n,o){return e?n.$dataMetaSchema(o,AN):o}}Xp.default=MN;(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv2020=void 0;const n=Ev,o=up,r=Yp,i=Xp,s="https://json-schema.org/draft/2020-12/schema";class a extends n.default{constructor(y={}){super({...y,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),o.default.forEach(y=>this.addVocabulary(y)),this.opts.discriminator&&this.addKeyword(r.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();const{$data:y,meta:g}=this.opts;g&&(i.default.call(this,y),this.refs["http://json-schema.org/schema"]=s)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(s)?s:void 0)}}t.Ajv2020=a,e.exports=t=a,e.exports.Ajv2020=a,Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var l=ln;Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return l.KeywordCxt}});var c=ue;Object.defineProperty(t,"_",{enumerable:!0,get:function(){return c._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return c.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return c.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return c.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return c.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return c.CodeGen}});var f=Cs;Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return f.default}});var m=Yr;Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return m.default}})})(Id,Id.exports);var qN=Id.exports;const UN=Qd(qN),ph=UN,LN=ph.default??ph,fh="acp";function DN(e){const t={path:e.instancePath||"/",message:e.message??"validation failed"};return e.keyword&&(t.keyword=e.keyword),t}function zN(e){const t=new LN({strict:!1,allErrors:!0,validateFormats:!1});t.addSchema(e,fh);const n=new Map,o=e.$defs??{};for(const[l,c]of Object.entries(o)){const f=c["x-method"];if(typeof f!="string")continue;let m=n.get(f);m||(m={},n.set(f,m)),l.endsWith("Request")?m.requestDef=l:l.endsWith("Response")?m.responseDef=l:l.endsWith("Notification")&&(m.notificationDef=l)}const r=new Map,i=l=>{const c=r.get(l);if(c)return c;const f=t.compile({$ref:`${fh}#/$defs/${l}`});return r.set(l,f),f};function s(l,c={}){if(!l.payload)return{valid:!0,errors:[],skipped:"parse-error"};if(l.kind==="unknown")return{valid:!0,errors:[],skipped:"wrong-kind"};const f=l.method??c.pairedMethod;if(!f)return{valid:!0,errors:[],skipped:"no-method"};const m=n.get(f);if(!m)return{valid:!0,errors:[],skipped:"unknown-method"};let h,y;const g=l.payload;if(l.kind==="request")h=m.requestDef,y=g.params;else if(l.kind==="notification")h=m.notificationDef,y=g.params;else if(l.kind==="response")h=m.responseDef,y=g.result;else return{valid:!0,errors:[],skipped:"wrong-kind"};if(!h)return{valid:!0,errors:[],skipped:"no-schema-for-kind"};const b=i(h);return b(y)?{valid:!0,errors:[],schemaName:h}:{valid:!1,errors:(b.errors??[]).map(DN),schemaName:h}}function a(){return[...n.keys()].sort()}return{validateAcpMessage:s,knownAcpMethods:a}}const FN=zN(Cv),BN=FN.validateAcpMessage;function Zp(e){const t=Cl(e),n=new Map;for(const r of e)r.method&&n.set(r.seq,r.method);const o=new Map;for(const r of e){const i=t.get(r.seq),s=i!==void 0?n.get(i):void 0,a={};s!==void 0&&(a.pairedMethod=s),o.set(r.seq,BN(r,a))}return o}function HN(e){let t=0,n=0,o=0;const r=new Set;for(const[,i]of e)if(!i.skipped&&(t+=1,!i.valid&&(n+=1,o+=i.errors.length,i.schemaName))){const s=i.schemaName.replace(/(Request|Response|Notification)$/,"");r.add(s)}return{checked:t,invalidFrames:n,totalErrors:o,affectedMethods:[...r].sort()}}const VN={"claude-code":{shortName:"claude-code",displayName:"Claude Code",description:"Anthropic Claude Code via @agentclientprotocol/claude-agent-acp",command:"npx",args:["-y","@agentclientprotocol/claude-agent-acp"],aliases:[["npx","-y","@zed-industries/claude-code-acp"]]},codex:{shortName:"codex",displayName:"Codex",description:"OpenAI Codex via @zed-industries/codex-acp",command:"npx",args:["-y","@zed-industries/codex-acp"]},goose:{shortName:"goose",displayName:"Goose",description:"Block Goose — install separately, then this runs `goose acp`",command:"goose",args:["acp"],requiresExternalInstall:!0},opencode:{shortName:"opencode",displayName:"OpenCode",description:"SST OpenCode — install via opencode.ai/install, then `opencode acp`",command:"opencode",args:["acp"],requiresExternalInstall:!0}};function WN(e){const t=e.trim();if(t.length===0)return null;for(const n of Object.values(VN)){const o=[[n.command,...n.args],...n.aliases??[]];for(const r of o){const i=r.join(" ");if(t===i||t.startsWith(i+" "))return n}}return null}function Rt(e){const t=WN(e);if(t)return t.displayName;const n=e.trim().split(/\s+/).filter(Boolean);if(n.length===0)return e;if(n[0]==="npx")for(let o=1;o<n.length;o++){const r=n[o];if(!r.startsWith("-"))return r}return n[0]==="node"&&n[1]?n[1].split("/").pop()??n[1]:n[0]}function ef(e){const t=e.sessionDbId!==null?`#${e.sessionDbId}`:`pid ${e.pid}`;if(e.sessionName)return`${t} · ${e.sessionName}`;const n=Rt(e.agentCommand);return e.clientName?`${t} · ${e.clientName} · ${n}`:`${t} · ${n}`}function ql(e){const t=e.id>0?`#${e.id}`:"ephemeral";if(e.name)return{primary:t,secondary:e.name};const n=Rt(e.agentCommand??""),o=e.clientName?`${e.clientName} · ${n}`:n;return{primary:t,secondary:o}}const KN={};function GN(){const e=KN;return(e==null?void 0:e.VITE_PLAYGROUND)==="1"}const JN={"editor-to-agent":"out","agent-to-editor":"in"},QN={out:"editor-to-agent",in:"agent-to-editor"},YN={request:"req",response:"rsp",notification:"ntf",error:"err",unknown:"unk"},XN={req:"request",rsp:"response",ntf:"notification",err:"error",unk:"unknown"},ZN=["tree","raw","meta"];function mh(e){const t=new URLSearchParams(e),n={},o=t.get("dir");if(o!==null){const g=o.split(",").map(b=>b.trim()).filter(Boolean).map(b=>QN[b]).filter(b=>b!==void 0);g.length>0&&(n.directions=new Set(g))}const r=t.get("kind");if(r!==null){const g=r.split(",").map(b=>b.trim()).filter(Boolean).map(b=>XN[b]).filter(b=>b!==void 0);g.length>0&&(n.kinds=new Set(g))}t.get("streams")==="0"&&(n.showStreams=!1);const i=t.get("q");i!==null&&(n.search=i);const s=t.get("seq"),a=s!==null&&/^\d+$/.test(s)?Number(s):null,l=t.get("tab"),c=l!==null&&ZN.includes(l)?l:null,f=t.get("play"),m=f!==null&&/^\d+$/.test(f)?Number(f):null,h=t.get("ws");return{filters:n,selectedSeq:a,detailTab:c,playbackCap:m,captureUrl:h}}const eC=["ws","dir","kind","streams","q","seq","tab","play"];function tC(e){const t=new URLSearchParams(window.location.search);for(const r of eC)t.delete(r);e.captureUrl&&t.set("ws",e.captureUrl),e.filters.directions.size<ls.length&&t.set("dir",[...e.filters.directions].map(r=>JN[r]).filter(Boolean).join(",")),e.filters.kinds.size<cs.length&&t.set("kind",[...e.filters.kinds].map(r=>YN[r]).filter(Boolean).join(",")),e.filters.showStreams||t.set("streams","0"),e.filters.search&&t.set("q",e.filters.search),e.selectedSeq!==null&&t.set("seq",String(e.selectedSeq)),e.detailTab!=="tree"&&t.set("tab",e.detailTab),e.playbackCap!==null&&t.set("play",String(e.playbackCap));const n=t.toString(),o=`${window.location.pathname}${n?`?${n}`:""}${window.location.hash}`;o!==window.location.pathname+window.location.search+window.location.hash&&window.history.replaceState(window.history.state,"",o)}function Ob(e){var t,n,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=Ob(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}function nC(){for(var e,t,n=0,o="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=Ob(e))&&(o&&(o+=" "),o+=t);return o}const tf="-",oC=e=>{const t=iC(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:o}=e;return{getClassGroupId:s=>{const a=s.split(tf);return a[0]===""&&a.length!==1&&a.shift(),Rb(a,t)||rC(s)},getConflictingClassGroupIds:(s,a)=>{const l=n[s]||[];return a&&o[s]?[...l,...o[s]]:l}}},Rb=(e,t)=>{var s;if(e.length===0)return t.classGroupId;const n=e[0],o=t.nextPart.get(n),r=o?Rb(e.slice(1),o):void 0;if(r)return r;if(t.validators.length===0)return;const i=e.join(tf);return(s=t.validators.find(({validator:a})=>a(i)))==null?void 0:s.classGroupId},hh=/^\[(.+)\]$/,rC=e=>{if(hh.test(e)){const t=hh.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},iC=e=>{const{theme:t,prefix:n}=e,o={nextPart:new Map,validators:[]};return aC(Object.entries(e.classGroups),n).forEach(([i,s])=>{Dd(s,o,i,t)}),o},Dd=(e,t,n,o)=>{e.forEach(r=>{if(typeof r=="string"){const i=r===""?t:yh(t,r);i.classGroupId=n;return}if(typeof r=="function"){if(sC(r)){Dd(r(o),t,n,o);return}t.validators.push({validator:r,classGroupId:n});return}Object.entries(r).forEach(([i,s])=>{Dd(s,yh(t,i),n,o)})})},yh=(e,t)=>{let n=e;return t.split(tf).forEach(o=>{n.nextPart.has(o)||n.nextPart.set(o,{nextPart:new Map,validators:[]}),n=n.nextPart.get(o)}),n},sC=e=>e.isThemeGetter,aC=(e,t)=>t?e.map(([n,o])=>{const r=o.map(i=>typeof i=="string"?t+i:typeof i=="object"?Object.fromEntries(Object.entries(i).map(([s,a])=>[t+s,a])):i);return[n,r]}):e,lC=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,o=new Map;const r=(i,s)=>{n.set(i,s),t++,t>e&&(t=0,o=n,n=new Map)};return{get(i){let s=n.get(i);if(s!==void 0)return s;if((s=o.get(i))!==void 0)return r(i,s),s},set(i,s){n.has(i)?n.set(i,s):r(i,s)}}},Ab="!",cC=e=>{const{separator:t,experimentalParseClassName:n}=e,o=t.length===1,r=t[0],i=t.length,s=a=>{const l=[];let c=0,f=0,m;for(let v=0;v<a.length;v++){let u=a[v];if(c===0){if(u===r&&(o||a.slice(v,v+i)===t)){l.push(a.slice(f,v)),f=v+i;continue}if(u==="/"){m=v;continue}}u==="["?c++:u==="]"&&c--}const h=l.length===0?a:a.substring(f),y=h.startsWith(Ab),g=y?h.substring(1):h,b=m&&m>f?m-f:void 0;return{modifiers:l,hasImportantModifier:y,baseClassName:g,maybePostfixModifierPosition:b}};return n?a=>n({className:a,parseClassName:s}):s},dC=e=>{if(e.length<=1)return e;const t=[];let n=[];return e.forEach(o=>{o[0]==="["?(t.push(...n.sort(),o),n=[]):n.push(o)}),t.push(...n.sort()),t},uC=e=>({cache:lC(e.cacheSize),parseClassName:cC(e),...oC(e)}),pC=/\s+/,fC=(e,t)=>{const{parseClassName:n,getClassGroupId:o,getConflictingClassGroupIds:r}=t,i=[],s=e.trim().split(pC);let a="";for(let l=s.length-1;l>=0;l-=1){const c=s[l],{modifiers:f,hasImportantModifier:m,baseClassName:h,maybePostfixModifierPosition:y}=n(c);let g=!!y,b=o(g?h.substring(0,y):h);if(!b){if(!g){a=c+(a.length>0?" "+a:a);continue}if(b=o(h),!b){a=c+(a.length>0?" "+a:a);continue}g=!1}const v=dC(f).join(":"),u=m?v+Ab:v,p=u+b;if(i.includes(p))continue;i.push(p);const x=r(b,g);for(let S=0;S<x.length;++S){const T=x[S];i.push(u+T)}a=c+(a.length>0?" "+a:a)}return a};function mC(){let e=0,t,n,o="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Mb(t))&&(o&&(o+=" "),o+=n);return o}const Mb=e=>{if(typeof e=="string")return e;let t,n="";for(let o=0;o<e.length;o++)e[o]&&(t=Mb(e[o]))&&(n&&(n+=" "),n+=t);return n};function hC(e,...t){let n,o,r,i=s;function s(l){const c=t.reduce((f,m)=>m(f),e());return n=uC(c),o=n.cache.get,r=n.cache.set,i=a,a(l)}function a(l){const c=o(l);if(c)return c;const f=fC(l,n);return r(l,f),f}return function(){return i(mC.apply(null,arguments))}}const Ie=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},qb=/^\[(?:([a-z-]+):)?(.+)\]$/i,yC=/^\d+\/\d+$/,gC=new Set(["px","full","screen"]),vC=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bC=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xC=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,wC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,SC=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jn=e=>Rr(e)||gC.has(e)||yC.test(e),Jn=e=>ni(e,"length",EC),Rr=e=>!!e&&!Number.isNaN(Number(e)),$c=e=>ni(e,"number",Rr),gi=e=>!!e&&Number.isInteger(Number(e)),$C=e=>e.endsWith("%")&&Rr(e.slice(0,-1)),pe=e=>qb.test(e),Qn=e=>vC.test(e),kC=new Set(["length","size","percentage"]),TC=e=>ni(e,kC,Ub),_C=e=>ni(e,"position",Ub),jC=new Set(["image","url"]),NC=e=>ni(e,jC,IC),CC=e=>ni(e,"",PC),vi=()=>!0,ni=(e,t,n)=>{const o=qb.exec(e);return o?o[1]?typeof t=="string"?o[1]===t:t.has(o[1]):n(o[2]):!1},EC=e=>bC.test(e)&&!xC.test(e),Ub=()=>!1,PC=e=>wC.test(e),IC=e=>SC.test(e),OC=()=>{const e=Ie("colors"),t=Ie("spacing"),n=Ie("blur"),o=Ie("brightness"),r=Ie("borderColor"),i=Ie("borderRadius"),s=Ie("borderSpacing"),a=Ie("borderWidth"),l=Ie("contrast"),c=Ie("grayscale"),f=Ie("hueRotate"),m=Ie("invert"),h=Ie("gap"),y=Ie("gradientColorStops"),g=Ie("gradientColorStopPositions"),b=Ie("inset"),v=Ie("margin"),u=Ie("opacity"),p=Ie("padding"),x=Ie("saturate"),S=Ie("scale"),T=Ie("sepia"),C=Ie("skew"),$=Ie("space"),j=Ie("translate"),R=()=>["auto","contain","none"],M=()=>["auto","hidden","clip","visible","scroll"],F=()=>["auto",pe,t],V=()=>[pe,t],L=()=>["",jn,Jn],U=()=>["auto",Rr,pe],D=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Q=()=>["solid","dashed","dotted","double","none"],ee=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],q=()=>["start","end","center","between","around","evenly","stretch"],G=()=>["","0",pe],I=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>[Rr,pe];return{cacheSize:500,separator:":",theme:{colors:[vi],spacing:[jn,Jn],blur:["none","",Qn,pe],brightness:_(),borderColor:[e],borderRadius:["none","","full",Qn,pe],borderSpacing:V(),borderWidth:L(),contrast:_(),grayscale:G(),hueRotate:_(),invert:G(),gap:V(),gradientColorStops:[e],gradientColorStopPositions:[$C,Jn],inset:F(),margin:F(),opacity:_(),padding:V(),saturate:_(),scale:_(),sepia:G(),skew:_(),space:V(),translate:V()},classGroups:{aspect:[{aspect:["auto","square","video",pe]}],container:["container"],columns:[{columns:[Qn]}],"break-after":[{"break-after":I()}],"break-before":[{"break-before":I()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...D(),pe]}],overflow:[{overflow:M()}],"overflow-x":[{"overflow-x":M()}],"overflow-y":[{"overflow-y":M()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[b]}],"inset-x":[{"inset-x":[b]}],"inset-y":[{"inset-y":[b]}],start:[{start:[b]}],end:[{end:[b]}],top:[{top:[b]}],right:[{right:[b]}],bottom:[{bottom:[b]}],left:[{left:[b]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",gi,pe]}],basis:[{basis:F()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",pe]}],grow:[{grow:G()}],shrink:[{shrink:G()}],order:[{order:["first","last","none",gi,pe]}],"grid-cols":[{"grid-cols":[vi]}],"col-start-end":[{col:["auto",{span:["full",gi,pe]},pe]}],"col-start":[{"col-start":U()}],"col-end":[{"col-end":U()}],"grid-rows":[{"grid-rows":[vi]}],"row-start-end":[{row:["auto",{span:[gi,pe]},pe]}],"row-start":[{"row-start":U()}],"row-end":[{"row-end":U()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",pe]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",pe]}],gap:[{gap:[h]}],"gap-x":[{"gap-x":[h]}],"gap-y":[{"gap-y":[h]}],"justify-content":[{justify:["normal",...q()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...q(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...q(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[p]}],px:[{px:[p]}],py:[{py:[p]}],ps:[{ps:[p]}],pe:[{pe:[p]}],pt:[{pt:[p]}],pr:[{pr:[p]}],pb:[{pb:[p]}],pl:[{pl:[p]}],m:[{m:[v]}],mx:[{mx:[v]}],my:[{my:[v]}],ms:[{ms:[v]}],me:[{me:[v]}],mt:[{mt:[v]}],mr:[{mr:[v]}],mb:[{mb:[v]}],ml:[{ml:[v]}],"space-x":[{"space-x":[$]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[$]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",pe,t]}],"min-w":[{"min-w":[pe,t,"min","max","fit"]}],"max-w":[{"max-w":[pe,t,"none","full","min","max","fit","prose",{screen:[Qn]},Qn]}],h:[{h:[pe,t,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[pe,t,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[pe,t,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[pe,t,"auto","min","max","fit"]}],"font-size":[{text:["base",Qn,Jn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",$c]}],"font-family":[{font:[vi]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",pe]}],"line-clamp":[{"line-clamp":["none",Rr,$c]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",jn,pe]}],"list-image":[{"list-image":["none",pe]}],"list-style-type":[{list:["none","disc","decimal",pe]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[u]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[u]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Q(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",jn,Jn]}],"underline-offset":[{"underline-offset":["auto",jn,pe]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:V()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",pe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",pe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[u]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...D(),_C]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",TC]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},NC]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[g]}],"gradient-via-pos":[{via:[g]}],"gradient-to-pos":[{to:[g]}],"gradient-from":[{from:[y]}],"gradient-via":[{via:[y]}],"gradient-to":[{to:[y]}],rounded:[{rounded:[i]}],"rounded-s":[{"rounded-s":[i]}],"rounded-e":[{"rounded-e":[i]}],"rounded-t":[{"rounded-t":[i]}],"rounded-r":[{"rounded-r":[i]}],"rounded-b":[{"rounded-b":[i]}],"rounded-l":[{"rounded-l":[i]}],"rounded-ss":[{"rounded-ss":[i]}],"rounded-se":[{"rounded-se":[i]}],"rounded-ee":[{"rounded-ee":[i]}],"rounded-es":[{"rounded-es":[i]}],"rounded-tl":[{"rounded-tl":[i]}],"rounded-tr":[{"rounded-tr":[i]}],"rounded-br":[{"rounded-br":[i]}],"rounded-bl":[{"rounded-bl":[i]}],"border-w":[{border:[a]}],"border-w-x":[{"border-x":[a]}],"border-w-y":[{"border-y":[a]}],"border-w-s":[{"border-s":[a]}],"border-w-e":[{"border-e":[a]}],"border-w-t":[{"border-t":[a]}],"border-w-r":[{"border-r":[a]}],"border-w-b":[{"border-b":[a]}],"border-w-l":[{"border-l":[a]}],"border-opacity":[{"border-opacity":[u]}],"border-style":[{border:[...Q(),"hidden"]}],"divide-x":[{"divide-x":[a]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[a]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[u]}],"divide-style":[{divide:Q()}],"border-color":[{border:[r]}],"border-color-x":[{"border-x":[r]}],"border-color-y":[{"border-y":[r]}],"border-color-s":[{"border-s":[r]}],"border-color-e":[{"border-e":[r]}],"border-color-t":[{"border-t":[r]}],"border-color-r":[{"border-r":[r]}],"border-color-b":[{"border-b":[r]}],"border-color-l":[{"border-l":[r]}],"divide-color":[{divide:[r]}],"outline-style":[{outline:["",...Q()]}],"outline-offset":[{"outline-offset":[jn,pe]}],"outline-w":[{outline:[jn,Jn]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[u]}],"ring-offset-w":[{"ring-offset":[jn,Jn]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",Qn,CC]}],"shadow-color":[{shadow:[vi]}],opacity:[{opacity:[u]}],"mix-blend":[{"mix-blend":[...ee(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ee()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[o]}],contrast:[{contrast:[l]}],"drop-shadow":[{"drop-shadow":["","none",Qn,pe]}],grayscale:[{grayscale:[c]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[m]}],saturate:[{saturate:[x]}],sepia:[{sepia:[T]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[o]}],"backdrop-contrast":[{"backdrop-contrast":[l]}],"backdrop-grayscale":[{"backdrop-grayscale":[c]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[m]}],"backdrop-opacity":[{"backdrop-opacity":[u]}],"backdrop-saturate":[{"backdrop-saturate":[x]}],"backdrop-sepia":[{"backdrop-sepia":[T]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",pe]}],duration:[{duration:_()}],ease:[{ease:["linear","in","out","in-out",pe]}],delay:[{delay:_()}],animate:[{animate:["none","spin","ping","pulse","bounce",pe]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[S]}],"scale-x":[{"scale-x":[S]}],"scale-y":[{"scale-y":[S]}],rotate:[{rotate:[gi,pe]}],"translate-x":[{"translate-x":[j]}],"translate-y":[{"translate-y":[j]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",pe]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",pe]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":V()}],"scroll-mx":[{"scroll-mx":V()}],"scroll-my":[{"scroll-my":V()}],"scroll-ms":[{"scroll-ms":V()}],"scroll-me":[{"scroll-me":V()}],"scroll-mt":[{"scroll-mt":V()}],"scroll-mr":[{"scroll-mr":V()}],"scroll-mb":[{"scroll-mb":V()}],"scroll-ml":[{"scroll-ml":V()}],"scroll-p":[{"scroll-p":V()}],"scroll-px":[{"scroll-px":V()}],"scroll-py":[{"scroll-py":V()}],"scroll-ps":[{"scroll-ps":V()}],"scroll-pe":[{"scroll-pe":V()}],"scroll-pt":[{"scroll-pt":V()}],"scroll-pr":[{"scroll-pr":V()}],"scroll-pb":[{"scroll-pb":V()}],"scroll-pl":[{"scroll-pl":V()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",pe]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[jn,Jn,$c]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},RC=hC(OC);function K(...e){return RC(nC(e))}const $a=1;function AC(e,t,n){return{version:$a,exportedAt:n.exportedAt??Date.now(),tool:{name:n.tool.name,version:n.tool.version},session:{id:e.id,name:e.name,agentCommand:e.agentCommand,clientName:e.clientName,startedAt:e.startedAt,endedAt:e.endedAt},messages:[...t]}}function MC(e,t=4){return JSON.stringify(e,null,t)+`
|
|
1766
|
-
`}class Ke extends Error{constructor(t){super(t),this.name="ExportParseError"}}function qC(e){let t;try{t=JSON.parse(e)}catch(l){throw new Ke(`invalid JSON: ${l instanceof Error?l.message:String(l)}`)}if(!ka(t))throw new Ke("expected an object at the top level");const n=t.version;if(n!==$a)throw new Ke(`unsupported export version ${String(n)} (expected ${$a})`);const o=t.exportedAt;if(typeof o!="number")throw new Ke("exportedAt must be a number");if(!ka(t.tool))throw new Ke("tool must be an object");const r=t.tool.name,i=t.tool.version;if(typeof r!="string")throw new Ke("tool.name must be a string");if(typeof i!="string")throw new Ke("tool.version must be a string");const s=t.session;if(!ka(s))throw new Ke("session must be an object");if(typeof s.id!="number")throw new Ke("session.id must be a number");if(typeof s.startedAt!="number")throw new Ke("session.startedAt must be a number");if(s.endedAt!==null&&typeof s.endedAt!="number")throw new Ke("session.endedAt must be a number or null");if(s.name!==null&&typeof s.name!="string")throw new Ke("session.name must be a string or null");if(s.agentCommand!==null&&typeof s.agentCommand!="string")throw new Ke("session.agentCommand must be a string or null");if(s.clientName!==null&&typeof s.clientName!="string")throw new Ke("session.clientName must be a string or null");if(!Array.isArray(t.messages))throw new Ke("messages must be an array");const a=t.messages.map((l,c)=>UC(l,c));return{version:$a,exportedAt:o,tool:{name:r,version:i},session:{id:s.id,name:s.name,agentCommand:s.agentCommand,clientName:s.clientName,startedAt:s.startedAt,endedAt:s.endedAt},messages:a}}function UC(e,t){if(!ka(e))throw new Ke(`messages[${t}] must be an object`);if(typeof e.seq!="number")throw new Ke(`messages[${t}].seq must be a number`);if(typeof e.timestamp!="number")throw new Ke(`messages[${t}].timestamp must be a number`);if(e.direction!=="editor-to-agent"&&e.direction!=="agent-to-editor")throw new Ke(`messages[${t}].direction must be 'editor-to-agent' or 'agent-to-editor'`);const n=e.kind;if(n!=="request"&&n!=="response"&&n!=="error"&&n!=="notification"&&n!=="unknown")throw new Ke(`messages[${t}].kind has unexpected value '${String(n)}'`);if(typeof e.raw!="string")throw new Ke(`messages[${t}].raw must be a string`);const o={seq:e.seq,timestamp:e.timestamp,direction:e.direction,kind:n,raw:e.raw,payload:e.payload===null?null:e.payload};return typeof e.method=="string"&&(o.method=e.method),(typeof e.rpcId=="string"||typeof e.rpcId=="number"||e.rpcId===null)&&(o.rpcId=e.rpcId),typeof e.parseError=="string"&&(o.parseError=e.parseError),o}function ka(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Lb="<REDACTED>",LC=new Set(["authorization","proxy-authorization","proxy-authentication","x-api-key","x-api-token","x-auth-token","api-key","api_key","proxy_key","cookie","set-cookie"]);function DC(e){if(e.payload==null)return{redacted:e,count:0};const{value:t,count:n}=zd(e.payload,{inProxyConfig:!1});if(n===0)return{redacted:e,count:0};const o=t;return{redacted:{...e,payload:o,raw:JSON.stringify(o)},count:n}}function zd(e,t){if(Array.isArray(e)){let n=0;const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=zd(e[r],t);o[r]=i.value,n+=i.count}return{value:o,count:n}}if(e!==null&&typeof e=="object"){let n=0;const o={};for(const[r,i]of Object.entries(e)){if(typeof i=="string"&&LC.has(r.toLowerCase())){o[r]=Lb,n+=1;continue}if(t.inProxyConfig&&r==="headers"&&i!==null&&typeof i=="object"&&!Array.isArray(i)){const l=zC(i);o[r]=l.value,n+=l.count;continue}const s=t.inProxyConfig||r.toLowerCase()==="proxyconfig"?{inProxyConfig:!0}:t,a=zd(i,s);o[r]=a.value,n+=a.count}return{value:o,count:n}}return{value:e,count:0}}function zC(e){let t=0;const n={};for(const[o,r]of Object.entries(e))typeof r=="string"?(n[o]=Lb,t+=1):n[o]=r;return{value:n,count:t}}function FC(e){let t=0,n=0;const o=e.messages.map(r=>{const i=DC(r);return i.count>0&&(t+=1,n+=i.count),i.redacted});return n===0?{export:e,messagesAffected:0,fieldsRedacted:0}:{export:{...e,messages:o},messagesAffected:t,fieldsRedacted:n}}const BC={name:"acp-devtools-ui",version:"0.2.0"};function HC(e,t=Date.now()){const n=e.id>0?String(e.id):"live",o=new Date(t).toISOString().slice(0,19).replace(/[:T]/g,"-");return`acp-session-${n}-${o}.json`}function VC(e,t,n=Date.now()){const o=AC(e,t,{tool:BC,exportedAt:n}),{export:r}=FC(o);return MC(r)}function Db(e,t,n=Date.now()){const o=VC(e,t,n),r=new Blob([o],{type:"application/json"}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=HC(e,n),s.rel="noopener",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function WC({open:e,onClose:t}){const[n,o]=P.useState(""),[r,i]=P.useState(0),s=P.useRef(null);P.useEffect(()=>{if(!e)return;o(""),i(0);const c=setTimeout(()=>{var f;return(f=s.current)==null?void 0:f.focus()},0);return()=>clearTimeout(c)},[e]);const a=P.useMemo(()=>KC(),[t,e]),l=P.useMemo(()=>GC(a,n),[a,n]);return P.useEffect(()=>{r>=l.length&&i(0)},[l.length,r]),P.useEffect(()=>{if(!e)return;const c=f=>{if(f.key==="Escape"){f.preventDefault(),t();return}if(f.key==="ArrowDown"){f.preventDefault(),i(m=>l.length===0?0:(m+1)%l.length);return}if(f.key==="ArrowUp"){f.preventDefault(),i(m=>l.length===0?0:(m-1+l.length)%l.length);return}if(f.key==="Enter"){f.preventDefault();const m=l[r];m&&(m.run(),t())}};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,l,r,t]),e?d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] flex items-start justify-center bg-black/60 pt-[8vh] backdrop-blur-sm",onMouseDown:c=>{c.target===c.currentTarget&&t()},children:d.jsxs("div",{className:"w-[min(620px,92vw)] overflow-hidden rounded-md border border-line-strong bg-surface-elev shadow-2xl",children:[d.jsx("div",{className:"border-b border-line bg-surface-base/60",children:d.jsx("input",{ref:s,value:n,onChange:c=>{o(c.target.value),i(0)},placeholder:"type a command… esc closes ↑↓ navigate ↵ run",className:"w-full bg-transparent px-4 py-3 font-mono text-[13px] text-ink-primary placeholder-ink-muted outline-none"})}),d.jsxs("ul",{className:"max-h-[60vh] overflow-y-auto py-1",children:[l.length===0&&d.jsx("li",{className:"px-4 py-3 text-center font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:"no match"}),l.map((c,f)=>{const m=f===r,h=l[f-1],y=!h||h.section!==c.section;return d.jsxs("li",{children:[y&&d.jsx("div",{className:"px-4 pt-2 pb-1 font-mono text-[9px] uppercase tracking-widest text-ink-muted",children:c.section}),d.jsxs("button",{type:"button",onClick:()=>{c.run(),t()},onMouseEnter:()=>i(f),className:K("flex w-full items-center justify-between px-4 py-1.5 text-left font-mono text-[12px] transition-colors",m?"bg-accent-out/10 text-ink-primary":"text-ink-secondary hover:bg-surface-rowHover hover:text-ink-primary"),children:[d.jsx("span",{className:"truncate",children:c.label}),c.hint&&d.jsx("span",{className:"ml-3 shrink-0 rounded-sm border border-line px-1.5 py-0.5 text-[10px] uppercase tracking-widest text-ink-muted",children:c.hint})]})]},c.id)})]})]})}):null}function KC(e){const t=ne.getState(),n=ft.getState(),o=[];o.push({id:"session.import",label:"Import session JSON from disk…",section:"session",run:()=>{const r=document.createElement("input");r.type="file",r.accept="application/json,.json",r.addEventListener("change",()=>{var s;const i=(s=r.files)==null?void 0:s[0];i&&(async()=>{try{const a=await $v(i);await Qu(),n.setSelected(tl(a.id))}catch(a){const l=a instanceof Error?a.message:String(a);window.alert(`Import failed: ${l}`)}})()}),r.click()}}),t.session!==null&&t.messages.length>0&&o.push({id:"session.export",label:"Export current session as JSON (redacted — auth tokens hidden)",section:"session",run:()=>Db(t.session,t.messages)}),o.push({id:"view.deselect",label:"Deselect message",hint:"esc",section:"view",run:()=>t.select(null)}),o.push({id:"view.toggle-streams",label:t.filters.showStreams?"Hide streaming chunks":"Show streaming chunks",section:"filter",run:()=>t.toggleStreams()}),o.push({id:"filter.reset",label:"Reset all filters",section:"filter",run:()=>{const r={directions:new Set(ls),kinds:new Set(cs),showStreams:!0,search:""};ne.setState({filters:r})}});for(const r of ls){const i=t.filters.directions.has(r);o.push({id:`filter.dir.${r}`,label:`${i?"Hide":"Show"} ${r==="editor-to-agent"?"editor → agent":"agent → editor"} messages`,section:"filter",run:()=>t.toggleDirection(r)})}for(const r of cs){const i=t.filters.kinds.has(r);o.push({id:`filter.kind.${r}`,label:`${i?"Hide":"Show"} ${r} kind`,section:"filter",run:()=>t.toggleKind(r)})}if(t.selectedSeq!==null){const r=t.messages.find(i=>i.seq===t.selectedSeq);r&&(o.push({id:"copy.raw",label:`Copy selected message raw line (seq ${r.seq})`,section:"copy",run:()=>{navigator.clipboard.writeText(r.raw)}}),r.payload&&o.push({id:"copy.payload",label:`Copy selected payload as JSON (seq ${r.seq})`,section:"copy",run:()=>{navigator.clipboard.writeText(JSON.stringify(r.payload,null,2))}}))}for(const r of n.captures)o.push({id:`switch.live.${r.url}`,label:`Switch to live: ${ef(r)}`,section:"switch",run:()=>n.setSelected(r.url)});for(const r of n.savedSessions.slice(0,25)){const i=Rt(r.agent_command??""),s=r.name??(r.client_name?`${r.client_name} · ${i}`:i);o.push({id:`switch.saved.${r.id}`,label:`Open saved #${r.id} · ${s} (${r.message_count} msg)`,section:"switch",run:()=>n.setSelected(tl(r.id))})}return o}function GC(e,t){const n=t.trim().toLowerCase();if(n==="")return e;const o=n.split(/\s+/);return e.filter(r=>{const i=r.label.toLowerCase();return o.every(s=>i.includes(s))})}const JC={idle:"idle",connecting:"connecting",open:"restoring view",closed:"disconnected",error:"connection error"};function QC({status:e,url:t,lastError:n}){const o=JC[e],r=e==="connecting"||e==="open";return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-surface-base",children:d.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block h-2 w-2 rounded-full",r?"animate-pulse-soft bg-accent-out":"bg-ink-dim",e==="error"&&"bg-accent-error")}),d.jsx("span",{children:o}),d.jsx("span",{className:"text-ink-dim",children:"·"}),d.jsx("span",{className:"lowercase tracking-normal text-ink-secondary",children:t}),n&&e==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-dim",children:"·"}),d.jsx("span",{className:"lowercase tracking-normal text-accent-error",children:n})]})]})})}function YC(e){const t=e.$defs??{},n=new Map;for(const[g,b]of Object.entries(t)){const v=b["x-method"];if(typeof v!="string")continue;let u=n.get(v);u||(u={},n.set(v,u)),g.endsWith("Request")?u.requestDef=g:g.endsWith("Response")?u.responseDef=g:g.endsWith("Notification")&&(u.notificationDef=g)}function o(g,b){var v,u,p;switch(g.kind){case"request":{const x=g.method;return x?((v=n.get(x))==null?void 0:v.requestDef)??null:null}case"notification":{const x=g.method;return x?((u=n.get(x))==null?void 0:u.notificationDef)??null:null}case"response":case"error":return b?((p=n.get(b))==null?void 0:p.responseDef)??null:null;default:return null}}function r(g){return g==="request"||g==="notification"?"params":g==="response"?"result":g==="error"?"error":null}function i(g){return typeof g=="object"&&g!==null&&!Array.isArray(g)}function s(g,b){const v=g.properties;if(!v)return!0;for(const[u,p]of Object.entries(v))if(!(!p||typeof p!="object")){if("const"in p){if(b[u]!==p.const)return!1}else if(Array.isArray(p.enum)&&!p.enum.includes(b[u]))return!1}return!0}function a(g,b){const v=g.type;if(typeof v=="string"){if(v==="null")return b===null;if(v==="string")return typeof b=="string";if(v==="boolean")return typeof b=="boolean";if(v==="number"||v==="integer")return typeof b=="number";if(v==="array")return Array.isArray(b);if(v==="object")return i(b)&&s(g,b)}return g.$ref||g.properties||g.allOf?i(b)&&s(g,b):!1}function l(g,b=void 0){if(!g)return null;if(g.$ref){const v=g.$ref.replace(/^#\/\$defs\//,""),u=t[v];return u?l(u,b):null}if(g.allOf&&g.allOf.length>0){const v={properties:{}};for(const u of g.allOf){const p=l(u,b);p!=null&&p.properties&&(v.properties={...v.properties,...p.properties}),p!=null&&p.type&&!v.type&&(v.type=p.type),p!=null&&p.items&&!v.items&&(v.items=p.items)}return g.description&&!v.description&&(v.description=g.description),v}if(g.anyOf||g.oneOf){const v=g.anyOf??g.oneOf;if(b!==void 0){for(const u of v)if(u.type!=="null"&&a(u,b))return l(u,b)}for(const u of v){if(u.type==="null")continue;const p=l(u,b);if(p)return p}return null}return g}function c(g,b){let v=g;for(const u of b){if(v==null)return;if(Array.isArray(v)&&/^\d+$/.test(u))v=v[Number(u)];else if(typeof v=="object")v=v[u];else return}return v}function f(g){if(!g)return;if(g.$ref)return g.$ref.replace(/^#\/\$defs\//,"");const b=g.type;if(typeof b=="string")return b;if(Array.isArray(b))return b.find(u=>u!=="null")}function m(g,b){const v=t[g];return{typeName:g,typeDescription:(v==null?void 0:v.description)??null,resolve(u){var R;if(u.length===0)return{inSpec:!0,isExtension:!1,description:v==null?void 0:v.description,type:g};const p=u.slice(1);if(p.length===0)return null;let x=!1,S=v??null;for(let M=0;M<p.length;M++){const F=p[M];F==="_meta"&&(x=!0);const V=/^\d+$/.test(F),L=c(b,u.slice(0,M+1));if(S=l(S,L),!S)return null;if(V){const D=c(b,u.slice(0,M+2));S=l(S.items,D);continue}if(x&&F!=="_meta")return{inSpec:!1,isExtension:!0};const U=(R=S.properties)==null?void 0:R[F];if(!U)return{inSpec:!1,isExtension:x};S=U}const T=c(b,u),C=l(S,T),$={inSpec:!0,isExtension:x};S!=null&&S.description?$.description=S.description:C!=null&&C.description&&($.description=C.description);const j=f(S??null)??f(C);return j&&($.type=j),C!=null&&C.enum&&($.enumValues=C.enum),$}}}function h(g,b={}){const v=o(g,b.pairedMethod);return!v||!r(g.kind)?null:m(v,g.payload)}function y(){return[...n.keys()].sort()}return{resolveForMessage:h,knownMethods:y}}const XC=YC(Cv),ZC=XC.resolveForMessage,eE={info:"border-line bg-surface-base text-ink-primary",warn:"border-accent-warn/40 bg-accent-warn/10 text-ink-primary",error:"border-accent-error/40 bg-accent-error/10 text-ink-primary"};function ps({label:e,children:t,delay:n=60,tone:o="info",className:r,focusable:i=!1}){const s=P.useRef(null),a=P.useRef(null),[l,c]=P.useState(null),f=l!==null,m=()=>{const g=s.current;if(!g)return null;const b=g.getBoundingClientRect(),u=window.innerHeight-b.bottom<120;return{top:u?b.top-8:b.bottom+8,left:Math.min(b.left,window.innerWidth-380),flipUp:u}},h=()=>{a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{const g=m();g&&c(g)},n)},y=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null),c(null)};return P.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),P.useEffect(()=>{if(!f)return;const g=()=>y();return window.addEventListener("scroll",g,!0),()=>window.removeEventListener("scroll",g,!0)},[f]),d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:s,className:K("cursor-help",r),onMouseEnter:h,onMouseLeave:y,...i?{onFocus:h,onBlur:y,tabIndex:0}:{},children:t}),l&&Vu.createPortal(d.jsx("div",{role:"tooltip",className:K("pointer-events-none fixed z-[200] max-w-[360px] rounded-sm border px-3 py-2 font-mono text-[11px] leading-snug shadow-lg backdrop-blur-sm",eE[o]),style:{top:l.flipUp?void 0:l.top,bottom:l.flipUp?window.innerHeight-l.top:void 0,left:l.left},children:e}),document.body)]})}const tE=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function Ta(e){return tE.format(e)}function fs(e){const t=e%1e3;return`${Ta(e)}.${String(t).padStart(3,"0")}`}const nE=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oE(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function _a(e,t=Date.now()){const n=new Date(e),o=new Date(t);if(oE(n,o))return Ta(e);if(n.getFullYear()===o.getFullYear())return`${nE[n.getMonth()]} ${n.getDate()} ${Ta(e)}`;const r=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${n.getFullYear()}-${r}-${i} ${Ta(e)}`}function Ul(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Vt(e){return e<1?"<1ms":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function rE(e){return e<250?"ok":e<1500?"warn":"error"}function zb(e){return e==="editor-to-agent"?"OUT":"IN"}function Fb(e){return e==="editor-to-agent"?"→":"←"}const iE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function sE(e){const t=String(e);return iE.test(t)?t.slice(0,8)+"…":t.length>12?t.slice(0,10)+"…":t}function Ar(e,t=Date.now()){const n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n}s`;const o=Math.floor(n/60);if(o<60)return`${o}m`;const r=Math.floor(o/60);if(r<24){const a=o%60;return`${r}h${String(a).padStart(2,"0")}m`}const i=Math.floor(r/24),s=r%24;return`${i}d${String(s).padStart(2,"0")}h`}function gh(e,t){if(e.length===0)return 0;const n=t/100*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=e[o],s=e[r];return i===void 0||s===void 0?i??0:o===r?i:i+(s-i)*(n-o)}const aE=6;function vh(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function lE(e){if(e===null)return"text-accent-error";switch(typeof e){case"string":return"text-accent-out";case"number":return"text-accent-in";case"boolean":return"text-accent-note";default:return"text-ink-secondary"}}function cE(e){return e===null?"null":typeof e=="string"?JSON.stringify(e):String(e)}function al({value:e,name:t,depth:n=0,defaultExpanded:o,path:r=[],getSpec:i}){const s=vh(e)||Array.isArray(e),a=vh(e)?Object.keys(e).length:Array.isArray(e)?e.length:0,l=o??(n<2&&a<=aE),[c,f]=P.useState(l),m=t!==void 0&&i?i(r):null,h=t!==void 0?d.jsx(dE,{name:t,spec:m}):null;if(!s)return d.jsxs("div",{className:"flex items-baseline gap-2 font-mono text-xs leading-relaxed",children:[h,d.jsx("span",{className:K("whitespace-pre-wrap break-all",lE(e)),children:cE(e)})]});const y=Array.isArray(e),g=y?"[":"{",b=y?"]":"}";return d.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[d.jsxs("button",{type:"button",onClick:()=>f(v=>!v),className:"group/expand flex items-baseline gap-2 text-left hover:text-ink-primary",children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block w-3 text-ink-muted transition-transform",c?"rotate-90":""),children:"▸"}),h,d.jsx("span",{className:"text-ink-secondary",children:g}),!c&&d.jsxs("span",{className:"text-ink-muted",children:[a," ",y?"items":"keys"]}),!c&&d.jsx("span",{className:"text-ink-secondary",children:b})]}),c&&d.jsxs("div",{className:"ml-3 border-l border-line-grid pl-3",children:[y?e.map((v,u)=>d.jsx(al,{value:v,name:String(u),depth:n+1,path:[...r,String(u)],...i?{getSpec:i}:{}},u)):Object.entries(e).map(([v,u])=>d.jsx(al,{value:u,name:v,depth:n+1,path:[...r,v],...i?{getSpec:i}:{}},v)),d.jsx("div",{className:"text-ink-secondary",children:b})]})]})}function dE({name:e,spec:t}){const n=/^\d+$/.test(e),o=(t==null?void 0:t.description)??null;return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:K(n?"text-ink-muted":"text-ink-secondary"),children:n?`${e}:`:`"${e}":`}),t&&!t.inSpec&&d.jsx(bh,{tone:t.isExtension?"extension":"unknown",explanation:t.isExtension?"Extension — not declared in the ACP spec; contents are implementation-defined.":"Unknown — this field is not declared in the ACP schema for this message."}),(t==null?void 0:t.inSpec)&&t.isExtension&&d.jsx(bh,{tone:"extension",explanation:"Extension — _meta payload is implementation-defined per ACP spec."}),o&&d.jsx(ps,{label:d.jsx(uE,{text:o,type:t==null?void 0:t.type,enumValues:t==null?void 0:t.enumValues}),tone:"info",className:"text-ink-muted hover:text-ink-primary",focusable:!0,children:d.jsx("span",{"aria-label":`spec: ${o.split(`
|
|
1767
|
-
`)[0]}`,children:"ⓘ"})})]})}function uE({text:e,type:t,enumValues:n}){return d.jsxs("div",{className:"space-y-1.5",children:[t&&d.jsx("div",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:d.jsx("span",{className:"text-accent-info",children:t})}),d.jsx("div",{className:"whitespace-pre-wrap font-sans text-[12px] leading-snug text-ink-secondary",children:e}),n&&n.length>0&&d.jsxs("div",{className:"font-mono text-[10px] text-ink-muted",children:["enum: ",n.map(o=>JSON.stringify(o)).join(" · ")]})]})}function bh({tone:e,explanation:t}){const n=e==="extension"?"border-accent-warn/40 bg-accent-warn/10 text-accent-warn":"border-accent-error/40 bg-accent-error/10 text-accent-error";return d.jsx(ps,{label:d.jsx("span",{className:"font-sans",children:t}),tone:e==="extension"?"warn":"error",focusable:!0,children:d.jsx("span",{className:K("inline-flex items-center rounded-sm border px-1 font-mono text-[9px] uppercase tracking-widest",n),children:e==="extension"?"⚠ ext":"⚠ unknown"})})}function pE({message:e,latencyMs:t,pairedRequest:n,onJumpToPaired:o,validation:r}){const i=ne(c=>c.detailTab),s=ne(c=>c.setDetailTab),a=P.useMemo(()=>{if(!e)return null;const c=(n==null?void 0:n.method)??void 0;return ZC(e,c?{pairedMethod:c}:void 0)},[e,n]);if(!e)return d.jsx("div",{className:"flex h-full items-center justify-center bg-surface-elev/40",children:d.jsx("div",{className:"text-center font-mono text-xs uppercase tracking-widest text-ink-muted",children:"select a message to inspect"})});const l=e.direction==="editor-to-agent";return d.jsxs("div",{className:"flex h-full flex-col bg-surface-elev/30",children:[d.jsxs("header",{className:"border-b border-line bg-surface-elev px-5 py-3",children:[d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsxs("span",{className:K("font-mono text-[11px] font-semibold tracking-widest",l?"text-accent-out":"text-accent-in"),children:[Fb(e.direction)," ",zb(e.direction)]}),d.jsxs("span",{className:"font-mono text-xs text-ink-muted",children:["seq ",e.seq]}),d.jsx("span",{className:"font-mono text-xs text-ink-muted",children:fs(e.timestamp)})]}),d.jsx("h2",{className:"mt-1 truncate font-display text-lg uppercase tracking-tight text-ink-primary",children:e.method??e.kind}),d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-[11px] text-ink-secondary",children:[d.jsx(gE,{message:e,resolver:a}),e.rpcId!==void 0&&e.rpcId!==null&&d.jsx(ja,{label:"id",value:String(e.rpcId)}),d.jsx(ja,{label:"bytes",value:Ul(e.raw.length)}),t!==void 0&&d.jsx(ja,{label:"latency",value:`+${Vt(t)}`,accent:!0}),n&&d.jsxs("button",{type:"button",onClick:o?()=>o(n.seq):void 0,className:"inline-flex items-baseline gap-1 transition-colors hover:text-ink-primary",title:"jump to paired message",children:[d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:"paired"}),d.jsxs("span",{className:"text-ink-primary underline decoration-line-strong decoration-dotted underline-offset-4",children:["seq ",n.seq," ",n.method??""]})]})]})]}),d.jsxs("nav",{className:"flex gap-1 border-b border-line bg-surface-elev/70 px-4",children:[d.jsx(na,{active:i==="tree",onClick:()=>s("tree"),children:"Tree"}),d.jsx(na,{active:i==="raw",onClick:()=>s("raw"),children:"Raw"}),d.jsx(na,{active:i==="meta",onClick:()=>s("meta"),children:"Meta"}),d.jsx(na,{active:i==="spec",onClick:()=>s("spec"),badge:r&&!r.skipped&&!r.valid?r.errors.length:void 0,children:"Spec"})]}),d.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[i==="tree"&&d.jsx(mE,{message:e,resolver:a}),i==="raw"&&d.jsx(hE,{raw:e.raw}),i==="meta"&&d.jsx(yE,{message:e}),i==="spec"&&d.jsx(fE,{validation:r})]})]})}function fE({validation:e}){if(!e)return d.jsx("div",{className:"font-mono text-[11px] text-ink-muted",children:"no validation result yet"});if(e.skipped){const t={"parse-error":"this frame failed to parse as JSON-RPC — already surfaced in the Tree tab as a parse error","no-method":"no method available for validation (e.g. response without a paired request)","unknown-method":"the ACP spec has no schema for this method — likely an extension or a future addition","no-schema-for-kind":"the spec has no schema for this kind of frame for this method (e.g. notification-only method)","wrong-kind":"no per-method ACP schema applies (e.g. JSON-RPC error envelope, parse failure)"};return d.jsxs("div",{className:"space-y-2 font-mono text-[11px]",children:[d.jsx("div",{className:"text-ink-muted uppercase tracking-widest text-[10px]",children:"not validated"}),d.jsx("div",{className:"text-ink-secondary",children:t[e.skipped]})]})}return e.valid?d.jsx("div",{className:"space-y-2 font-mono text-[11px]",children:d.jsxs("div",{className:"inline-flex items-baseline gap-2",children:[d.jsx("span",{className:"rounded-sm border border-accent-ok/40 bg-accent-ok/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-accent-ok",children:"✓ conforms"}),d.jsxs("span",{className:"text-ink-muted",children:["matched ",d.jsx("span",{className:"text-ink-secondary",children:e.schemaName})," ","from the ACP schema"]})]})}):d.jsxs("div",{className:"space-y-3 font-mono text-[11px]",children:[d.jsxs("div",{className:"inline-flex items-baseline gap-2",children:[d.jsxs("span",{className:"rounded-sm border border-accent-error/40 bg-accent-error/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-accent-error",children:["⚠ ",e.errors.length," violation",e.errors.length===1?"":"s"]}),d.jsxs("span",{className:"text-ink-muted",children:["against ",d.jsx("span",{className:"text-ink-secondary",children:e.schemaName})]})]}),d.jsx("ul",{className:"space-y-1.5",children:e.errors.map((t,n)=>d.jsxs("li",{className:"rounded-sm border border-accent-error/25 bg-accent-error/[0.04] px-2 py-1.5",children:[d.jsxs("div",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:[t.keyword??"error"," · ",t.path==="/"?"(root)":t.path]}),d.jsx("div",{className:"mt-0.5 text-ink-primary",children:t.message})]},`${t.path}-${t.keyword}-${n}`))})]})}function mE({message:e,resolver:t}){const n=P.useMemo(()=>{if(t)return o=>t.resolve(o)},[t]);return e.payload===null?d.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[d.jsxs("div",{className:"text-accent-error",children:["parse error: ",e.parseError??"unknown"]}),d.jsx("pre",{className:"whitespace-pre-wrap break-all text-ink-secondary",children:e.raw})]}):d.jsx(al,{value:e.payload,defaultExpanded:!0,...n?{getSpec:n}:{}})}function hE({raw:e}){const[t,n]=P.useState(!1),o=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return d.jsxs("div",{className:"group relative",children:[d.jsx("button",{type:"button",onClick:o,"aria-label":"Copy raw frame to clipboard",title:"Copy raw frame to clipboard",className:K("absolute right-0 top-0 inline-flex h-6 items-center rounded-sm border bg-surface-elev/70 px-2 font-mono text-[10px] uppercase tracking-widest opacity-0 transition-[opacity,background-color,border-color,color] duration-150","group-hover:opacity-100 focus-visible:opacity-100",t?"border-accent-ok/60 bg-surface-elev text-accent-ok opacity-100":"border-line text-ink-secondary hover:border-accent-info/70 hover:bg-surface-rowHover hover:text-accent-info"),children:t?"✓ copied":"copy"}),d.jsx("pre",{className:"whitespace-pre-wrap break-all font-mono text-[11px] leading-relaxed text-ink-primary",children:e})]})}function yE({message:e}){const t=[["seq",String(e.seq)],["direction",e.direction],["kind",e.kind],["method",e.method??"(none)"],["rpcId",String(e.rpcId??"(none)")],["timestamp",`${fs(e.timestamp)} (${e.timestamp})`],["raw size",Ul(e.raw.length)],["parse error",e.parseError??"(none)"]];return d.jsx("dl",{className:"grid grid-cols-[110px_1fr] gap-x-4 gap-y-1 font-mono text-[12px]",children:t.map(([n,o])=>d.jsxs("div",{className:"contents",children:[d.jsx("dt",{className:"text-ink-muted uppercase tracking-widest text-[10px]",children:n}),d.jsx("dd",{className:"text-ink-primary",children:o})]},n))})}function gE({message:e,resolver:t}){const n=d.jsx(ja,{label:"kind",value:e.kind});return t!=null&&t.typeDescription?d.jsx(ps,{label:d.jsx("div",{className:"whitespace-pre-wrap font-sans text-[12px] leading-snug text-ink-secondary",children:t.typeDescription}),tone:"info",children:n}):n}function ja({label:e,value:t,accent:n}){return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:K(n?"text-accent-warn":"text-ink-primary"),children:t})]})}function na({children:e,active:t,onClick:n,badge:o,tab:r}){return d.jsxs("button",{type:"button",onClick:n,className:K("relative flex items-baseline gap-1.5 px-4 py-2 font-mono text-[11px] uppercase tracking-widest transition-colors",t?"text-ink-primary":"text-ink-muted hover:text-ink-secondary"),children:[d.jsx("span",{children:e}),o!==void 0&&d.jsx("span",{className:"rounded-sm border border-accent-error/40 bg-accent-error/10 px-1 text-[9px] font-semibold text-accent-error",children:o}),t&&d.jsx("span",{className:"absolute inset-x-2 -bottom-px h-px bg-accent-out","aria-hidden":!0})]})}function nf(e){const t=new Map,n=new Map;for(const o of e){if(o.rpcId===void 0||o.rpcId===null)continue;const r=String(o.rpcId);if(o.kind==="request")t.set(r,o);else if(o.kind==="response"||o.kind==="error"){const i=t.get(r);if(!i)continue;const s=Math.max(0,o.timestamp-i.timestamp);n.set(i.seq,{pairSeq:o.seq,latencyMs:s}),n.set(o.seq,{pairSeq:i.seq,latencyMs:s})}}return n}function Fd(e){const t=nf(e),n=new Map,o=new Map;for(const i of e)if(i.method){if(i.kind==="request"){let s=n.get(i.method);s||(s={count:0,latencies:[]},n.set(i.method,s)),s.count+=1;const a=t.get(i.seq);a&&s.latencies.push(a.latencyMs)}else if(i.kind==="notification"){let s=o.get(i.method);s||(s={count:0,latencies:[]},o.set(i.method,s)),s.count+=1}}const r=[];for(const[i,s]of n)s.latencies.sort((a,l)=>a-l),r.push({method:i,kind:"request",count:s.count,sampleSize:s.latencies.length,p50:s.latencies.length?xh(s.latencies,50):null,p99:s.latencies.length?xh(s.latencies,99):null,max:s.latencies.length?s.latencies[s.latencies.length-1]:null,totalLatencyMs:s.latencies.length?s.latencies.reduce((a,l)=>a+l,0):null,latencies:s.latencies});for(const[i,s]of o)r.push({method:i,kind:"notification",count:s.count,sampleSize:0,p50:null,p99:null,max:null,totalLatencyMs:null,latencies:[]});return r.sort((i,s)=>s.count-i.count||(i.kind==="request"?-1:1)),r}function xh(e,t){if(e.length===0)return 0;const n=t/100*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=e[o],s=e[r];return i===void 0||s===void 0?i??0:o===r?i:i+(s-i)*(n-o)}const Bb=100;function vE(e,t,n={}){const o=n.maxChangesPerRow??Bb,r=wh(e),i=wh(t),s=bE(r,i),a=[],l={equal:0,changed:0,added:0,removed:0,total:0};for(const c of s)if(c.kind==="match"){const f=e[c.i],m=t[c.j],h=xE(f,m,o),y=h.length===0?"equal":"changed";a.push({op:y,a:f,b:m,signature:r[c.i],changes:h}),y==="equal"?l.equal+=1:l.changed+=1}else if(c.kind==="removed"){const f=e[c.i];a.push({op:"removed",a:f,b:null,signature:r[c.i],changes:[]}),l.removed+=1}else{const f=t[c.j];a.push({op:"added",a:null,b:f,signature:i[c.j],changes:[]}),l.added+=1}return l.total=a.length,{rows:a,summary:l}}function wh(e){const t=nf(e),n=new Map;for(const o of e)o.method&&n.set(o.seq,o.method);return e.map(o=>{let r=o.method??"";if(!r&&(o.kind==="response"||o.kind==="error")){const i=t.get(o.seq);i&&(r=n.get(i.pairSeq)??"")}return`${o.direction}|${o.kind}|${r}`})}function bE(e,t){const n=e.length,o=t.length,r=o+1,i=new Uint32Array((n+1)*r);for(let c=n-1;c>=0;c--)for(let f=o-1;f>=0;f--){const m=c*r+f;if(e[c]===t[f])i[m]=i[(c+1)*r+(f+1)]+1;else{const h=i[(c+1)*r+f],y=i[c*r+(f+1)];i[m]=h>=y?h:y}}const s=[];let a=0,l=0;for(;a<n&&l<o;)e[a]===t[l]?(s.push({kind:"match",i:a,j:l}),a++,l++):i[(a+1)*r+l]>=i[a*r+(l+1)]?(s.push({kind:"removed",i:a}),a++):(s.push({kind:"added",j:l}),l++);for(;a<n;)s.push({kind:"removed",i:a}),a++;for(;l<o;)s.push({kind:"added",j:l}),l++;return s}function Sh(e){const t=e.payload;if(t===null||typeof t!="object")return{raw:e.raw,parseError:e.parseError??null};const n=t,o={};return"method"in n&&(o.method=n.method),"params"in n&&(o.params=n.params),"result"in n&&(o.result=n.result),"error"in n&&(o.error=n.error),o}function xE(e,t,n){const o=[];return ll(Sh(e),Sh(t),"",o,n),o}function wE(e,t,n=Bb){const o=[];return ll(e,t,"",o,n),o}function $h(e){return Array.isArray(e)?"array":e!==null&&typeof e=="object"?"object":"leaf"}function ll(e,t,n,o,r){if(o.length>=r||Object.is(e,t))return;const i=$h(e),s=$h(t);if(i!==s||i==="leaf"){if(SE(e,t))return;o.push({path:n||"$",kind:"change",a:e,b:t});return}if(i==="array"){const f=e,m=t,h=Math.max(f.length,m.length);for(let y=0;y<h;y++){if(o.length>=r)return;const g=`${n}[${y}]`,b=y<f.length,v=y<m.length;b&&v?ll(f[y],m[y],g,o,r):v?o.push({path:g,kind:"add",b:m[y]}):o.push({path:g,kind:"remove",a:f[y]})}return}const a=e,l=t,c=[...new Set([...Object.keys(a),...Object.keys(l)])].sort();for(const f of c){if(o.length>=r)return;const m=n?`${n}.${f}`:f,h=f in a,y=f in l;h&&y?ll(a[f],l[f],m,o,r):y?o.push({path:m,kind:"add",b:l[f]}):o.push({path:m,kind:"remove",a:a[f]})}}function SE(e,t){return Object.is(e,t)}function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function xn(e){return typeof e=="string"&&e.length>0?e:null}function Ao(e){return e===!0}function $E(e){for(const t of e)if(t.kind==="request"&&t.method==="initialize"&&t.direction==="editor-to-agent")return t;return null}function kE(e,t){if(t==null)return null;for(const n of e)if(n.kind==="response"&&n.direction==="agent-to-editor"&&n.rpcId===t)return n;return null}function TE(e){var r,i;const t={name:null,title:null,version:null,platform:null};if(!e)return t;const n=Ne((r=Ne(e.payload))==null?void 0:r.params),o=Ne(n==null?void 0:n.clientInfo);return o?{name:xn(o.name),title:xn(o.title),version:xn(o.version),platform:xn((i=Ne(o._meta))==null?void 0:i.platform)}:t}function _E(e){var s,a;const t={fsReadTextFile:!1,fsWriteTextFile:!1,terminal:!1,authTerminal:!1,authGateway:!1};if(!e)return t;const n=Ne((s=Ne(e.payload))==null?void 0:s.params),o=Ne(n==null?void 0:n.clientCapabilities);if(!o)return t;const r=Ne(o.fs),i=Ne(o.auth);return{fsReadTextFile:Ao(r==null?void 0:r.readTextFile),fsWriteTextFile:Ao(r==null?void 0:r.writeTextFile),terminal:Ao(o.terminal),authTerminal:Ao(i==null?void 0:i.terminal),authGateway:Ao((a=Ne(i==null?void 0:i._meta))==null?void 0:a.gateway)}}function jE(e){var i;const t={name:null,version:null,authMethods:0};if(!e)return t;const n=Ne((i=Ne(e.payload))==null?void 0:i.result);if(!n)return t;const o=Ne(n.agentInfo),r=n.authMethods;return{name:xn(o==null?void 0:o.name),version:xn(o==null?void 0:o.version),authMethods:Array.isArray(r)?r.length:0}}function NE(e){var r;const t={prompt:!1,loadSession:!1};if(!e)return t;const n=Ne((r=Ne(e.payload))==null?void 0:r.result),o=Ne(n==null?void 0:n.agentCapabilities);return o?{prompt:Ao(o.promptCapabilities)||o.promptCapabilities!==void 0,loadSession:Ao(o.loadSession)}:t}function CE(e,t){const n=t??e;if(!n)return null;const o=Ne(n.payload),r=Ne(o==null?void 0:o.result)??Ne(o==null?void 0:o.params),i=r==null?void 0:r.protocolVersion;return typeof i=="number"?i:null}function EE(e){var s,a;let t=null,n=0,o=null,r=0,i=[];for(const l of e){l.direction!=="editor-to-agent"&&l.kind;const c=Ne((s=Ne(l.payload))==null?void 0:s.params);if(c){if(l.method==="session/set_mode"){const f=xn(c.modeId);f!==null&&(t!==null&&t!==f&&(n+=1),t=f)}else if(l.method==="session/set_model"){const f=xn(c.modelId);f!==null&&(o!==null&&o!==f&&(r+=1),o=f)}else if(l.method==="session/update"){const f=Ne(c.update);if((f==null?void 0:f.sessionUpdate)==="available_commands_update"){const m=f.availableCommands;if(Array.isArray(m)){const h=[];for(const y of m){const g=xn((a=Ne(y))==null?void 0:a.name);g!==null&&h.push(g)}h.length>0&&(i=h)}}else if((f==null?void 0:f.sessionUpdate)==="current_mode_update"){const m=xn(f.currentModeId);m!==null&&(t!==null&&t!==m&&(n+=1),t=m)}}}}return{currentMode:t,modeChanges:n,currentModel:o,modelChanges:r,availableCommands:i}}function PE(e){if(!e)return{jetbrainsProxyConfig:null};const t=Ne(e.payload),n=Ne(t==null?void 0:t.params),o=Ne(n==null?void 0:n._meta);return{jetbrainsProxyConfig:(o==null?void 0:o.proxyConfig)??null}}function cl(e){const t=$E(e),n=kE(e,t==null?void 0:t.rpcId);return{protocolVersion:CE(t,n),client:TE(t),agent:jE(n),clientCapabilities:_E(t),agentCapabilities:NE(n),runtime:EE(e),extensions:PE(t)}}function kh(e){return{protocolVersion:e.protocolVersion,client:e.client,agent:e.agent,clientCapabilities:e.clientCapabilities,agentCapabilities:e.agentCapabilities,runtime:e.runtime}}function IE(e,t){const n=cl(e),o=cl(t);return{a:n,b:o,changes:wE(kh(n),kh(o))}}function OE(e,t){const n=Fd(e),o=Fd(t),r=l=>`${l.kind}:${l.method}`,i=new Map(n.map(l=>[r(l),l])),s=new Map(o.map(l=>[r(l),l])),a=[];for(const l of new Set([...i.keys(),...s.keys()])){const c=i.get(l)??null,f=s.get(l)??null,m=c??f;a.push({method:m.method,kind:m.kind,a:c,b:f,countDelta:((f==null?void 0:f.count)??0)-((c==null?void 0:c.count)??0),p50Delta:kc(c==null?void 0:c.p50,f==null?void 0:f.p50),p99Delta:kc(c==null?void 0:c.p99,f==null?void 0:f.p99),maxDelta:kc(c==null?void 0:c.max,f==null?void 0:f.max)})}return a.sort((l,c)=>Math.abs(c.p99Delta??0)-Math.abs(l.p99Delta??0)||Math.abs(c.countDelta)-Math.abs(l.countDelta)||l.method.localeCompare(c.method)),a}function kc(e,t){return e==null||t===null||t===void 0?null:t-e}function of(e,t=200){const[n,o]=P.useState(e),[r,i]=P.useState(!1);return P.useEffect(()=>{if(e){o(!0);let a=null;const l=requestAnimationFrame(()=>{a=requestAnimationFrame(()=>i(!0))});return()=>{cancelAnimationFrame(l),a!==null&&cancelAnimationFrame(a)}}i(!1);const s=setTimeout(()=>o(!1),t);return()=>clearTimeout(s)},[e,t]),{rendered:n,visible:r}}const rf="flex h-9 items-center gap-4 border-b border-line bg-surface-base px-5",RE={request:"REQ",response:"RSP",notification:"NTF",error:"ERR",unknown:"UNK"};function AE(e){return e.direction==="editor-to-agent"?"→A":"A←"}function Hb(e){if(e.name)return`#${e.id} · ${e.name}`;const t=e.agent_command?Rt(e.agent_command):"agent";return e.client_name?`#${e.id} · ${e.client_name} · ${t}`:`#${e.id} · ${t}`}const Th={messages:null,loading:!1,error:null};function _h(e){const[t,n]=P.useState(Th);return P.useEffect(()=>{if(e===null){n(Th);return}let o=!1;return n({messages:null,loading:!0,error:null}),xS(e).then(r=>{o||n({messages:r.messages,loading:!1,error:null})}).catch(r=>{o||n({messages:null,loading:!1,error:r instanceof Error?r.message:String(r)})}),()=>{o=!0}},[e]),t}function ME({open:e,onClose:t}){const n=ne(D=>D.messages),o=ne(D=>D.session),r=ft(D=>D.savedSessions),i=(o==null?void 0:o.id)??null,[s,a]=P.useState(null),[l,c]=P.useState(null),[f,m]=P.useState("frames"),[h,y]=P.useState(!0),[g,b]=P.useState(null),{rendered:v,visible:u}=of(e);P.useEffect(()=>{if(!e)return;const D=Q=>{Q.key==="Escape"&&(Q.preventDefault(),t())};return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[e,t]),P.useEffect(()=>{e&&(a(i),c(null),b(null))},[e,i]),P.useEffect(()=>b(null),[s,l]);const p=_h(s!==null&&s!==i?s:null),x=_h(l!==null&&l!==i?l:null),S=s===null?null:s===i?n:p.messages,T=l===null?null:l===i?n:x.messages,C=p.loading||x.loading,$=p.error??x.error,j=P.useMemo(()=>S===null||T===null?null:vE(S,T),[S,T]),R=P.useMemo(()=>{if(!j)return[];const D=[];return j.rows.forEach((Q,ee)=>{h&&Q.op==="equal"||D.push({row:Q,index:ee})}),D},[j,h]),M=P.useMemo(()=>{const D=r.find(Q=>Q.id===l);return D?Hb(D):null},[r,l]),F=P.useMemo(()=>S&&T?IE(S,T):null,[S,T]),V=P.useMemo(()=>S&&T?OE(S,T):null,[S,T]);if(!v)return null;const L=r.filter(D=>D.id!==l),U=r.filter(D=>D.id!==s);return d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Session diff",className:K("fixed inset-0 z-[100] flex flex-col bg-surface-base/95 backdrop-blur-sm transition-opacity duration-200 ease-out",u?"opacity-100":"opacity-0"),children:d.jsxs("div",{className:K("flex h-full w-full flex-col transition-transform duration-200 ease-out",u?"translate-y-0":"-translate-y-2"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Diff — compare two sessions"}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close diff panel",children:"close"})]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line bg-surface-elev px-5 py-2.5",children:[d.jsx("span",{className:"font-mono text-[11px] text-accent-out",title:"baseline (left)",children:"A"}),d.jsx(Eh,{ariaLabel:"Baseline session",sessions:L,selectedId:s,onSelect:a}),d.jsx("span",{className:"text-ink-muted",children:"→"}),d.jsx("span",{className:"font-mono text-[11px] text-ink-secondary",title:"comparison (right)",children:"B"}),d.jsx(Eh,{ariaLabel:"Comparison session",sessions:U,selectedId:l,onSelect:c})]}),s===null?d.jsx(bi,{children:"Pick a baseline session (A) to compare from."}):l===null?d.jsx(bi,{children:"Pick a session in the B selector above to compare against A."}):C?d.jsx(bi,{children:"Loading sessions…"}):$?d.jsxs(bi,{tone:"error",children:["Could not load a session: ",$]}):!j||!F||!V?d.jsx(bi,{children:"No data."}):d.jsxs(d.Fragment,{children:[d.jsx(qE,{tab:f,onTab:m,summary:j.summary,infoCount:F.changes.length}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[f==="frames"&&d.jsx(UE,{diff:j,bLabel:M,hideEqual:h,onHideEqual:y,visibleRows:R,expanded:g,onToggleExpand:D=>b(Q=>Q===D?null:D)}),f==="info"&&d.jsx(LE,{meta:F}),f==="perf"&&d.jsx(zE,{perf:V})]})]})]})})}function qE({tab:e,onTab:t,summary:n,infoCount:o}){const i=[{id:"frames",label:"frames",badge:n.changed+n.added+n.removed},{id:"info",label:"info",badge:o},{id:"perf",label:"perf",badge:0}];return d.jsx("div",{className:"flex items-center gap-1 border-b border-line bg-surface-elev px-5 py-1.5",children:i.map(s=>d.jsxs("button",{type:"button",onClick:()=>t(s.id),className:K("inline-flex items-center gap-1.5 rounded-sm px-3 py-1 font-mono text-[10px] uppercase tracking-widest transition-colors",e===s.id?"bg-surface-rowHover text-ink-primary":"text-ink-muted hover:text-ink-secondary"),children:[s.label,s.badge>0&&d.jsx("span",{className:"rounded-sm border border-line px-1 text-[9px] text-ink-secondary",children:s.badge})]},s.id))})}function UE({diff:e,bLabel:t,hideEqual:n,onHideEqual:o,visibleRows:r,expanded:i,onToggleExpand:s}){const a=e.summary.changed===0&&e.summary.added===0&&e.summary.removed===0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K(rf,"font-mono text-[11px]"),children:[d.jsxs("span",{className:"text-ink-muted",children:[e.summary.equal," same"]}),d.jsxs("span",{className:"text-accent-warn",children:[e.summary.changed," differs"]}),d.jsxs("span",{className:"text-accent-error",children:[e.summary.removed," only in A"]}),d.jsxs("span",{className:"text-accent-ok",children:[e.summary.added," only in B"]}),d.jsxs("label",{className:"ml-auto flex cursor-pointer select-none items-center gap-2 text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx("input",{type:"checkbox",checked:n,onChange:l=>o(l.target.checked),className:"accent-accent-info"}),"hide unchanged"]})]}),a?d.jsxs(ms,{tone:"ok",children:["Sessions are identical",t?` — every frame in B (${t}) matches A`:"","."]}):r.length===0?d.jsx(ms,{children:"Only unchanged frames — toggle “hide unchanged” to see them."}):d.jsxs("table",{className:"w-full table-fixed border-collapse font-mono text-[11px]",children:[d.jsxs("colgroup",{children:[d.jsx("col",{className:"w-[24px]"}),d.jsx("col",{className:"w-1/2"}),d.jsx("col",{className:"w-1/2"})]}),d.jsx("tbody",{children:r.map(({row:l,index:c})=>d.jsx(HE,{row:l,expanded:i===c,onToggle:()=>s(c)},c))})]})]})}function Vb(){return d.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-warn",children:"~"})," changed"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-ok",children:"+"})," only in B"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-error",children:"−"})," only in A"]})]})}function LE({meta:e}){return e.changes.length===0?d.jsx(ms,{tone:"ok",children:"Metadata identical — same client, agent, capabilities, protocol and runtime."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:rf,children:d.jsx(Vb,{})}),d.jsx("ul",{className:"space-y-1 px-5 py-3 font-mono text-[11px]",children:e.changes.map((t,n)=>d.jsx("li",{className:"leading-snug",children:d.jsx(Wb,{change:t})},n))})]})}function jh(e){return e==null?"—":Vt(e)}function DE(e){return e===null?{text:"—",tone:"text-ink-dim"}:e===0?{text:"0",tone:"text-ink-muted"}:{text:(e>0?"+":"−")+Vt(Math.abs(e)),tone:e>0?"text-accent-error":"text-accent-ok"}}function zE({perf:e}){return e.length===0?d.jsx(ms,{children:"No methods to compare."}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K(rf,"font-mono text-[10px] uppercase tracking-widest text-ink-muted"),children:[d.jsx("span",{children:"Δ = B − A · sorted by |Δ p99|"}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-error",children:"+"})," slower in B"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-ok",children:"−"})," faster in B"]})]}),d.jsxs("table",{className:"w-full text-[11px]",children:[d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-base",children:d.jsxs("tr",{className:"border-b border-line text-left font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx("th",{className:"py-2 pl-5 pr-3",children:"method"}),d.jsx("th",{className:"px-3 py-2",children:"kind"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"A p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"B p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"Δ p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"count"})]})}),d.jsx("tbody",{className:"font-mono",children:e.map(t=>{var o,r,i,s;const n=DE(t.p99Delta);return d.jsxs("tr",{className:"border-b border-line/40 hover:bg-surface-rowHover/50",children:[d.jsx("td",{className:"truncate py-1.5 pl-5 pr-3 text-ink-primary",title:t.method,children:t.method}),d.jsx("td",{className:"px-3 py-1.5 text-[10px] uppercase tracking-widest text-ink-muted",children:t.kind==="request"?"req":"ntf"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:jh(((o=t.a)==null?void 0:o.p99)??null)}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:jh(((r=t.b)==null?void 0:r.p99)??null)}),d.jsx("td",{className:K("px-3 py-1.5 text-right",n.tone),children:n.text}),d.jsxs("td",{className:"px-3 py-1.5 text-right text-ink-muted",children:[((i=t.a)==null?void 0:i.count)??0,"→",((s=t.b)==null?void 0:s.count)??0]})]},`${t.kind}:${t.method}`)})})]})]})}function bi({children:e,tone:t}){return d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:d.jsx(ms,{...t?{tone:t}:{},children:e})})}const FE={equal:"",changed:"bg-accent-warn/5",added:"bg-accent-ok/5",removed:"bg-accent-error/5"},BE={equal:{glyph:"=",tone:"text-ink-dim"},changed:{glyph:"≠",tone:"text-accent-warn"},added:{glyph:"▸",tone:"text-accent-ok"},removed:{glyph:"◂",tone:"text-accent-error"}};function HE({row:e,expanded:t,onToggle:n}){const o=BE[e.op],r=e.op==="changed"&&e.changes.length>0;return d.jsxs(d.Fragment,{children:[d.jsxs("tr",{className:K("border-b border-line/40 align-top",FE[e.op],r&&"cursor-pointer hover:bg-accent-warn/10"),onClick:r?n:void 0,children:[d.jsx("td",{className:K("py-1.5 pl-5 text-center",o.tone),children:o.glyph}),d.jsx("td",{className:"px-3 py-1.5",children:d.jsx(Nh,{frame:e.a,muted:e.op==="added"})}),d.jsxs("td",{className:"px-3 py-1.5",children:[d.jsx(Nh,{frame:e.b,muted:e.op==="removed"}),r&&d.jsxs("span",{className:"ml-2 text-[10px] text-accent-warn",children:[t?"▾":"▸"," ",e.changes.length," field",e.changes.length===1?"":"s"]})]})]}),r&&t&&d.jsxs("tr",{className:"border-b border-line/40 bg-surface-elev",children:[d.jsx("td",{}),d.jsxs("td",{colSpan:2,className:"px-5 py-2",children:[d.jsx("div",{className:"mb-1.5",children:d.jsx(Vb,{})}),d.jsx("ul",{className:"space-y-1",children:e.changes.map((i,s)=>d.jsx("li",{className:"leading-snug",children:d.jsx(Wb,{change:i})},s))})]})]})]})}function Nh({frame:e,muted:t}){if(e===null)return d.jsx("span",{className:"text-ink-dim",children:"—"});const n=e.method??(e.parseError?`! ${e.parseError}`:"—");return d.jsxs("span",{className:K("inline-flex items-baseline gap-2",t&&"opacity-60"),children:[d.jsx("span",{className:"text-ink-dim",children:AE(e)}),d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:RE[e.kind]}),d.jsx("span",{className:"truncate text-ink-primary",title:n,children:n}),d.jsxs("span",{className:"text-ink-dim",children:["#",e.seq]})]})}const Ch=80;function oa(e){let t;try{t=JSON.stringify(e)}catch{t=String(e)}return t===void 0&&(t="undefined"),t.length>Ch&&(t=t.slice(0,Ch-1)+"…"),t}function Wb({change:e}){return e.kind==="add"?d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-ok",children:"+ "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-ok",children:oa(e.b)})]}):e.kind==="remove"?d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-error",children:"− "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-error line-through",children:oa(e.a)})]}):d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-warn",children:"~ "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-error line-through",children:oa(e.a)}),d.jsx("span",{className:"text-ink-muted",children:" → "}),d.jsx("span",{className:"text-accent-ok",children:oa(e.b)})]})}function ms({children:e,tone:t="muted"}){const n=t==="error"?"text-accent-error":t==="ok"?"text-accent-ok":"text-ink-muted";return d.jsx("div",{className:K("px-5 py-8 text-center font-mono text-[12px]",n),children:e})}function Eh({ariaLabel:e,sessions:t,selectedId:n,onSelect:o}){const[r,i]=P.useState(!1),s=P.useRef(null);P.useEffect(()=>{if(!r)return;const m=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);const a=t.filter(m=>m.imported_at===null),l=t.filter(m=>m.imported_at!==null),c=n!==null?t.find(m=>m.id===n)??null:null,f=c?Hb(c):n!==null?`#${n}`:"select a session…";return d.jsxs("div",{ref:s,className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-label":e,"aria-haspopup":"listbox","aria-expanded":r,className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] uppercase tracking-widest transition-colors","border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",r?"border-line-strong text-ink-primary":""),title:`${e} — pick which session to compare`,children:[d.jsx("span",{className:"inline-block w-[240px] truncate text-left",children:f}),d.jsx("span",{"aria-hidden":!0,className:K("transition-transform",r?"rotate-180":""),children:"▾"})]}),r&&d.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[460px] rounded-md border border-line bg-surface-elev shadow-xl",children:[d.jsxs(Ph,{children:["saved · ",a.length," session",a.length===1?"":"s"]}),a.length===0&&d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:"no other saved sessions to compare"}),d.jsx("ul",{className:"max-h-[300px] overflow-y-auto",children:a.map(m=>d.jsx(Ih,{s:m,active:m.id===n,onPick:()=>{o(m.id),i(!1)}},m.id))}),l.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs(Ph,{children:["imported · ",l.length," file",l.length===1?"":"s"]}),d.jsx("ul",{className:"max-h-[200px] overflow-y-auto",children:l.map(m=>d.jsx(Ih,{s:m,active:m.id===n,onPick:()=>{o(m.id),i(!1)}},m.id))})]})]})]})}function Ph({children:e}){return d.jsx("div",{className:"border-b border-line bg-surface-base/50 px-3 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e})}function Ih({s:e,active:t,onPick:n}){return d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:n,title:`session #${e.id} · ${e.agent_command??""} · ${e.message_count} messages`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",t?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",t?"bg-accent-note animate-pulse-soft":"bg-ink-dim")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsxs("span",{className:"text-accent-note",children:["#",e.id]}),d.jsx("span",{className:"text-ink-muted",children:" · "}),e.name??(e.client_name?`${e.client_name} · ${Rt(e.agent_command??"")}`:Rt(e.agent_command??""))]}),d.jsxs("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[e.message_count,"msg · ",Ar(e.started_at)]})]})})}let Tc=null,xi=null;async function VE(){if(Tc)return Tc;if(xi)return xi;xi=(async()=>{const e=await fetch("/api/info",{headers:{accept:"application/json"}});if(!e.ok)throw new Error(`info: HTTP ${e.status}`);const t=await e.json();return Tc=t,t})();try{return await xi}finally{xi=null}}const WE=[{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"}],KE="/absolute/path/to/acp-devtools";function GE(e){return JSON.stringify({agent_servers:{"Claude Code (via ACP Devtools)":{type:"custom",command:e}}},null,4)}function Kb({text:e,label:t="Copy"}){const[n,o]=P.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1400)}catch{o(!1)}};return d.jsx("button",{type:"button",onClick:r,className:K("rounded border border-line px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest transition-colors",n?"border-accent-out text-accent-out":"text-ink-secondary hover:border-ink-secondary hover:text-ink-primary"),children:n?"Copied":t})}function JE(){const[e,t]=P.useState("zed"),[n,o]=P.useState(null);P.useEffect(()=>{let a=!0;return VE().then(l=>{a&&o(l.binaryPath)}).catch(()=>{}),()=>{a=!1}},[]);const r=n??KE,i=n===null,s=P.useMemo(()=>({zed:GE(r),jetbrainsName:"Claude Code (via ACP Devtools)"}),[r]);return d.jsxs("div",{className:"rounded border border-line bg-surface-base",children:[d.jsx("div",{className:"flex items-center gap-1 border-b border-line px-3 py-2",children:WE.map(a=>d.jsx("button",{type:"button",onClick:()=>t(a.id),className:K("rounded px-2 py-1 font-mono text-[10px] uppercase tracking-widest transition-colors",e===a.id?"bg-surface-elev text-ink-primary":"text-ink-secondary hover:text-ink-primary"),children:a.label},a.id))}),e==="zed"&&d.jsxs("div",{className:"px-3 py-3",children:[d.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"~/.config/zed/settings.json"}),d.jsx(Kb,{text:s.zed})]}),d.jsx("pre",{className:"overflow-x-auto rounded border border-line bg-surface-elev/60 px-3 py-2 font-mono text-[11px] leading-relaxed text-ink-primary",children:s.zed}),d.jsxs("p",{className:"mt-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["Open Zed, paste into ",d.jsx("span",{className:"font-mono",children:"settings.json"})," ","(Cmd+,), pick the new agent in the right-side panel, send a prompt. The CLI auto-proxies ",d.jsx("span",{className:"font-mono",children:"@zed-industries/claude-code-acp"})," ","when launched with no args."]}),d.jsx(Oh,{isPlaceholder:i})]}),e==="jetbrains"&&d.jsxs("div",{className:"px-3 py-3",children:[d.jsxs("p",{className:"mb-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["Settings (Cmd+,) → search ",d.jsx("span",{className:"font-mono",children:"agent"})," → open the AI Assistant / Junie agent-servers page → add a new entry with these fields (no arguments needed):"]}),d.jsxs("div",{className:"grid gap-2",children:[d.jsx(Rh,{label:"Name",value:s.jetbrainsName}),d.jsx(Rh,{label:"Command",value:r})]}),d.jsxs("p",{className:"mt-3 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["JetBrains IDEs require an absolute ",d.jsx("span",{className:"font-mono",children:"command"}),". See ",d.jsx("span",{className:"font-mono",children:"examples/jetbrains-config.md"})," if the agent-servers page is not where the search suggests."]}),d.jsx(Oh,{isPlaceholder:i})]})]})}function Oh({isPlaceholder:e}){return e?d.jsxs("div",{className:"mt-3 rounded border border-line border-dashed bg-surface-elev/40 px-3 py-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["You're viewing the UI through a development server, so the absolute binary path couldn't be auto-detected. After running"," ",d.jsx("span",{className:"font-mono",children:"npm run build:full"})," in the repo and"," ",d.jsx("span",{className:"font-mono",children:"npm link"})," inside"," ",d.jsx("span",{className:"font-mono",children:"packages/cli/"}),", find the path with"," ",d.jsx("span",{className:"font-mono",children:"which acp-devtools"})," and replace the placeholder above."]}):d.jsxs("p",{className:"mt-3 font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:["path auto-resolved · verify with ",d.jsx("span",{className:"text-ink-secondary",children:"which acp-devtools"})]})}function Rh({label:e,value:t}){return d.jsxs("div",{className:"flex items-center gap-2 rounded border border-line bg-surface-elev/60 px-3 py-1.5",children:[d.jsx("span",{className:"w-20 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:"flex-1 truncate font-mono text-[11px] text-ink-primary",children:t}),d.jsx(Kb,{text:t})]})}function QE({status:e,lastError:t,url:n,captureCount:o}){const r=e==="open"?"Awaiting messages":e==="connecting"?"Connecting":e==="closed"?"Disconnected":e==="error"?"Connection error":"No live capture",i=e==="open"?"text-accent-out":e==="error"?"text-accent-error":"text-ink-secondary";return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-grid",children:d.jsxs("div",{className:"relative w-[min(720px,92%)] rounded-md border border-line bg-surface-elev/80 p-6 backdrop-blur-sm",children:[d.jsxs("div",{className:"mb-1 flex items-baseline gap-3",children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:"acp.devtools"}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"v0.2.0 / pre-alpha"})]}),d.jsx("h2",{className:K("font-display text-2xl uppercase tracking-tight",i),children:r}),d.jsx("p",{className:"mt-2 font-sans text-sm leading-relaxed text-ink-secondary",children:"Connect an IDE to start streaming ACP frames. Pick yours below — the snippet plugs acp-devtools between editor and agent so every message is captured live."}),o>0&&d.jsxs("p",{className:"mt-2 font-mono text-[11px] uppercase tracking-widest text-accent-out",children:[o," live capture",o===1?"":"s"," discovered — pick one in the picker above"]}),d.jsx("div",{className:"mt-4",children:d.jsx(JE,{})}),d.jsxs("div",{className:"mt-4 flex items-center gap-3 font-mono text-[11px]",children:[d.jsx(YE,{status:e}),d.jsx("span",{className:"text-ink-secondary",children:n}),t&&d.jsx("span",{className:"text-accent-error",children:t})]})]})})}function YE({status:e}){const t=e==="open"?"bg-accent-out":e==="connecting"?"bg-accent-warn animate-pulse-soft":e==="error"?"bg-accent-error":"bg-ink-dim";return d.jsx("span",{className:K("h-2 w-2 rounded-full",t),"aria-hidden":!0})}function XE(){const e=ne(i=>i.filters),t=ne(i=>i.toggleDirection),n=ne(i=>i.toggleKind),o=ne(i=>i.toggleStreams),r=ne(i=>i.setSearch);return d.jsxs("div",{className:"flex items-center gap-3 border-b border-line bg-surface-elev/70 px-4 py-2",children:[d.jsx("div",{className:"flex items-center gap-1",children:ls.map(i=>d.jsx(tP,{dir:i,active:e.directions.has(i),onClick:()=>t(i)},i))}),d.jsx(rP,{}),d.jsxs("div",{className:"flex items-center gap-1",children:[cs.map(i=>d.jsx(nP,{kind:i,active:e.kinds.has(i),onClick:()=>n(i)},i)),d.jsx(oP,{active:e.showStreams,onClick:o})]}),d.jsx("div",{className:"ml-auto",children:d.jsx("input",{type:"search",placeholder:"search payload…",value:e.search,onChange:i=>r(i.target.value),className:K("h-7 w-64 rounded border border-line bg-surface-base px-2 font-mono text-[11px] text-ink-primary placeholder-ink-muted","focus:border-accent-out focus:outline-none")})})]})}const ZE={"editor-to-agent":"editor → agent (toggle to filter messages flowing from your IDE to the AI)","agent-to-editor":"agent → editor (toggle to filter messages coming back from the AI)"},eP={request:"request — expects a response",response:"response — answer to a previous request",notification:"notification — one-way event, no response",error:"error — response carrying an error object",unknown:"unknown — frames that could not be classified as JSON-RPC"};function tP({dir:e,active:t,onClick:n}){const o=e==="editor-to-agent",r=o?"→ OUT":"← IN",i=o?"text-accent-out":"text-accent-in";return d.jsx("button",{type:"button",onClick:n,title:ZE[e],className:K("inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold tracking-widest transition-colors",t?K(i,o?"border-accent-out/50 bg-accent-out/10":"border-accent-in/50 bg-accent-in/10"):"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:r})}function nP({kind:e,active:t,onClick:n}){const r={request:{color:"text-accent-out",border:"border-accent-out/50",bg:"bg-accent-out/10"},response:{color:"text-accent-in",border:"border-accent-in/50",bg:"bg-accent-in/10"},notification:{color:"text-accent-note",border:"border-accent-note/50",bg:"bg-accent-note/10"},error:{color:"text-accent-error",border:"border-accent-error/50",bg:"bg-accent-error/10"},unknown:{color:"text-ink-muted",border:"border-line",bg:"bg-surface-row"}}[e];return d.jsx("button",{type:"button",onClick:n,title:eP[e],className:K("rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",t?K(r.color,r.border,r.bg):"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:e})}function oP({active:e,onClick:t}){return d.jsx("button",{type:"button",onClick:t,title:"stream — collapse runs of agent_message_chunk notifications into a single row",className:K("rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",e?"border-accent-note/50 bg-accent-note/10 text-accent-note":"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:"stream"})}function rP(){return d.jsx("span",{"aria-hidden":!0,className:"h-5 w-px bg-line"})}const iP={minSamplesForTail:3,longTailRatio:5,minBusiestCount:50,minBusiestRatio:2.5,minHotspotShare:.4,minSamplesForOutlier:5,outlierRatio:3};function sP(e,t,n={}){const o={...iP,...n},r=[],i=t.reduce((y,g)=>y+(g.totalLatencyMs??0),0);if(i>0){const g=t.filter(b=>b.totalLatencyMs!==null&&b.totalLatencyMs>0).sort((b,v)=>(v.totalLatencyMs??0)-(b.totalLatencyMs??0))[0];if(g&&g.totalLatencyMs!==null){const b=g.totalLatencyMs/i;b>=o.minHotspotShare&&r.push({kind:"hotspot",summary:`${g.method} consumed ${ar(g.totalLatencyMs)} of total wall time`,detail:`${Math.round(b*100)}% of ${ar(i)} sampled latency`,methods:[g.method]})}}const a=t.filter(y=>y.sampleSize>=o.minSamplesForTail&&y.p50!==null&&y.p99!==null&&y.p50>0&&y.p99/y.p50>=o.longTailRatio).sort((y,g)=>(g.p99??0)/(g.p50??1)-(y.p99??0)/(y.p50??1))[0];if(a&&a.p99!==null&&a.p50!==null){const y=Math.round(a.p99/a.p50);r.push({kind:"long-tail",summary:`${a.method} has a long tail — p99 is ${y}× the p50`,detail:`p50 ${ar(a.p50)} · p99 ${ar(a.p99)} · ${a.sampleSize} samples`,methods:[a.method]})}const l=[...t].filter(y=>y.sampleSize>=o.minSamplesForOutlier&&y.p99!==null&&y.max!==null&&y.p99>0&&y.max/y.p99>=o.outlierRatio).sort((y,g)=>(g.max??0)-(y.max??0))[0];if(l&&l.max!==null&&l.p99!==null){const y=Math.round(l.max/l.p99);r.push({kind:"outlier",summary:`${l.method} had one ${ar(l.max)} call — ${y}× its p99`,detail:`p99 ${ar(l.p99)} · ${l.sampleSize} samples`,methods:[l.method]})}const c=[...t].sort((y,g)=>g.count-y.count),f=c[0],m=c[1];if(f&&f.count>=o.minBusiestCount){const y=m&&m.count>0?f.count/m.count:1/0;if(y>=o.minBusiestRatio){const g=f.kind==="notification"?"notifications":"calls";r.push({kind:"busiest",summary:`${f.method} sent ${f.count} ${g}`,detail:m?`${y.toFixed(1)}× the next-busiest method (${m.method} · ${m.count})`:"no other methods to compare against",methods:[f.method]})}}const h=aP(e);if(h.length>0){const y=h.slice(0,3),g=h.length>3?` (+${h.length-3} more)`:"";r.push({kind:"errors",summary:`${h.length} method${h.length===1?"":"s"} returned an error`,detail:y.join(", ")+g,methods:h})}return r}function aP(e){const t=new Map,n=new Set;for(const o of e){const r=o.rpcId===void 0||o.rpcId===null?null:String(o.rpcId);if(o.kind==="request"&&o.method&&r!==null)t.set(r,o.method);else if(o.kind==="error"&&r!==null){const i=t.get(r);i&&n.add(i)}}return[...n].sort()}function ar(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<1e4)return`${(e/1e3).toFixed(2)}s`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m${n}s`}function lP(e,t){if(e.length<=t)return e;const n=[];for(let o=0;o<t;o++){const r=Math.round(o*(e.length-1)/(t-1));n.push(e[r])}return n}function cP({values:e,width:t=64,height:n=14,className:o,title:r}){if(e.length===0)return null;const i=e[e.length-1]??0;if(i===0)return null;const s=Math.max(1,Math.floor(t/4)),a=lP(e,s),l=1,c=(t-l*(a.length-1))/a.length;return d.jsx("svg",{viewBox:`0 0 ${t} ${n}`,width:t,height:n,className:K("inline-block align-middle",o),role:"img","aria-label":r??`latency distribution, ${e.length} samples`,children:a.map((f,m)=>{const h=Math.max(1,f/i*n);return d.jsx("rect",{x:m*(c+l),y:n-h,width:c,height:h,fill:"currentColor",opacity:.4+f/i*.6},m)})})}function dP(e){const t={events:[],startTs:0,endTs:0,durationMs:0,laneCounts:{"editor-req":0,"agent-req":0,notification:0}};if(e.length===0)return t;const n=nf(e),o=new Map;for(const l of e)o.set(l.seq,l);let r=1/0,i=-1/0;const s=[],a={"editor-req":0,"agent-req":0,notification:0};for(const l of e)if(l.timestamp<r&&(r=l.timestamp),l.timestamp>i&&(i=l.timestamp),l.kind==="request"){const c=l.direction==="editor-to-agent"?"editor-req":"agent-req",f=n.get(l.seq),m=f?o.get(f.pairSeq):void 0,h=(m==null?void 0:m.kind)==="error",y=m?m.timestamp:l.timestamp;y>i&&(i=y),s.push({seq:l.seq,startTs:l.timestamp,endTs:y,lane:c,method:l.method??null,kind:l.kind,erroredOut:h,pairedSeq:m?m.seq:null}),a[c]+=1}else l.kind==="notification"&&(s.push({seq:l.seq,startTs:l.timestamp,endTs:l.timestamp,lane:"notification",method:l.method??null,kind:l.kind,erroredOut:!1,pairedSeq:null}),a.notification+=1);return!Number.isFinite(r)||!Number.isFinite(i)?t:{events:s,startTs:r,endTs:i,durationMs:Math.max(0,i-r),laneCounts:a}}const dl=["editor-req","agent-req","notification"],uP={"editor-req":"editor → agent","agent-req":"agent → editor",notification:"notifications"},oo=48,sf=6,Ll=24,wn=132,hs=20,Dl=8,pP=20,Ah=3e4,Mh=50;function fP(e,t,n,o,r,i){if(e.length===0||n<=t)return{segments:[{kind:"active",tStart:t,tEnd:n,pxStart:0,pxEnd:o*r}],tsToX:()=>wn-i,totalActiveMs:0};const s=[...e].sort((p,x)=>p.startTs-x.startTs),a=[];let l=t,c=t;for(const p of s)p.startTs-c>Ah&&(c>l&&a.push({kind:"active",tStart:l,tEnd:c}),a.push({kind:"gap",tStart:c,tEnd:p.startTs}),l=p.startTs),c=Math.max(c,p.endTs);c>l&&a.push({kind:"active",tStart:l,tEnd:c}),n>c+Ah?a.push({kind:"gap",tStart:c,tEnd:n}):n>c&&a.length>0&&(a[a.length-1].tEnd=n);const f=a.filter(p=>p.kind==="gap").length,m=a.filter(p=>p.kind==="active").reduce((p,x)=>p+(x.tEnd-x.tStart),0),h=o*r,y=Math.max(50,h-f*Mh),g=m>0?y/m:0;let b=0;const v=[];for(const p of a){const x=p.kind==="gap"?Mh:(p.tEnd-p.tStart)*g;v.push({...p,pxStart:b,pxEnd:b+x}),b+=x}return{segments:v,tsToX:p=>{if(p<=v[0].tStart)return wn+v[0].pxStart-i;for(const S of v)if(p>=S.tStart&&p<=S.tEnd){const T=S.tEnd>S.tStart?(p-S.tStart)/(S.tEnd-S.tStart):0,C=S.pxStart+T*(S.pxEnd-S.pxStart);return wn+C-i}const x=v[v.length-1];return wn+x.pxEnd-i},totalActiveMs:m}}function mP({messages:e,onSelectSeq:t,height:n=220,controlsRef:o,onZoomChange:r}){const i=P.useMemo(()=>dP(e),[e]),s=P.useRef(null),a=P.useRef(null),[l,c]=P.useState({width:800,height:n}),[f,m]=P.useState(1),[h,y]=P.useState(0),[g,b]=P.useState(null),[v,u]=P.useState({x:0,y:0}),p=P.useRef(null);P.useEffect(()=>{const L=s.current;if(!L||typeof ResizeObserver>"u")return;const U=new ResizeObserver(D=>{const Q=D[0];if(!Q)return;const ee=Q.contentRect;c({width:Math.max(320,ee.width),height:Math.max(120,ee.height)})});return U.observe(L),()=>U.disconnect()},[]),P.useEffect(()=>{m(1),y(0),b(null)},[i.startTs,i.endTs]);const x=P.useMemo(()=>{const L=Math.max(50,l.width-wn-hs);return fP(i.events,i.startTs,i.endTs,L,f,h)},[i,l.width,f,h]),S=P.useMemo(()=>{if(i.events.length===0)return[];const L=[];for(const U of i.events){const D=x.tsToX(U.startTs),Q=x.tsToX(U.endTs),ee=Math.max(2,Q-D),q=dl.indexOf(U.lane),G=Dl+Ll+q*(oo+sf)+oo/2-9;L.push({...U,x:D,y:G,width:ee,height:18})}return L},[i,x]);P.useEffect(()=>{const L=a.current;if(!L)return;const U=window.devicePixelRatio||1;L.width=l.width*U,L.height=l.height*U,L.style.width=`${l.width}px`,L.style.height=`${l.height}px`;const D=L.getContext("2d");if(!D)return;D.setTransform(U,0,0,U,0,0);const Q=getComputedStyle(document.documentElement),ee=G=>`rgb(${Q.getPropertyValue(`--${G}`).trim()})`,q=(G,I)=>`rgba(${Q.getPropertyValue(`--${G}`).trim()} / ${I})`;D.clearRect(0,0,l.width,l.height),hP(D,l,ee),gP(D,x,l,ee,q),yP(D,l,x,ee),xP(D,S,g,ee,q)},[S,x,l,g]);const T=(L,U)=>{for(const D of S){const Q=Math.max(D.width,6);if(L>=D.x&&L<=D.x+Q&&U>=D.y&&U<=D.y+D.height)return D}return null},C=L=>{const U=L.currentTarget.getBoundingClientRect(),D=L.clientX-U.left,Q=L.clientY-U.top;if(p.current){const q=D-p.current.startX;y(Math.max(0,p.current.startPan-q));return}const ee=T(D,Q);b(ee),u({x:L.clientX,y:L.clientY})},$=L=>{const U=L.currentTarget.getBoundingClientRect(),D=L.clientX-U.left,Q=L.clientY-U.top,ee=T(D,Q);if(ee&&t){t(ee.seq);return}p.current={startX:D,startPan:h}},j=()=>{p.current=null},R=L=>{if(!L.metaKey&&!L.ctrlKey)return;L.preventDefault();const U=L.deltaY<0?1.15:1/1.15;m(D=>Math.min(50,Math.max(.3,D*U)))},M=()=>m(L=>Math.min(50,L*1.5)),F=()=>m(L=>Math.max(.3,L/1.5)),V=()=>{m(1),y(0)};return P.useEffect(()=>{if(o)return o.current={zoomIn:M,zoomOut:F,reset:V,getZoom:()=>f},()=>{o.current&&(o.current=null)}}),P.useEffect(()=>{r==null||r(f)},[f,r]),i.events.length===0?d.jsx("div",{className:"flex h-full items-center justify-center font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:"no messages — capture or load a session first"}):d.jsxs("div",{ref:s,className:"relative h-full w-full",style:{minHeight:0},children:[d.jsx("canvas",{ref:a,className:K("block h-full w-full",p.current?"cursor-grabbing":g?"cursor-pointer":"cursor-grab"),onMouseMove:C,onMouseDown:$,onMouseUp:j,onMouseLeave:()=>{b(null),p.current=null},onWheel:R}),g&&d.jsxs("div",{role:"tooltip",className:"pointer-events-none fixed z-[150] rounded-sm border border-line bg-surface-base px-3 py-2 font-mono text-[11px] shadow-lg",style:{left:Math.min(window.innerWidth-280,v.x+12),top:v.y+12,maxWidth:280},children:[d.jsxs("div",{className:"text-ink-primary",children:[d.jsxs("span",{className:"text-ink-muted",children:["seq ",g.seq]})," · ",g.method??g.kind]}),d.jsx("div",{className:"text-ink-muted",children:g.endTs>g.startTs?`${Vt(g.endTs-g.startTs)}${g.erroredOut?" · error":""}`:g.lane==="notification"?"notification":"pending"}),t&&d.jsx("div",{className:"mt-1 text-[10px] text-ink-dim",children:"click to inspect"})]})]})}function hP(e,t,n){e.font="10px monospace",e.textBaseline="middle",e.textAlign="start";for(let o=0;o<dl.length;o++){const r=dl[o],i=Dl+Ll+o*(oo+sf);e.fillStyle=n("surface-elev"),e.fillRect(wn,i,t.width-wn-hs,oo),e.fillStyle=n("ink-muted"),e.fillText(uP[r],pP,i+oo/2),e.strokeStyle=n("line"),e.lineWidth=1,e.beginPath(),e.moveTo(wn,i+oo),e.lineTo(t.width-hs,i+oo),e.stroke()}}function yP(e,t,n,o){var g;const r=Dl+Ll-4;e.strokeStyle=o("line"),e.fillStyle=o("ink-muted"),e.font="10px monospace",e.textBaseline="bottom",e.textAlign="center",e.lineWidth=1;const i=n.segments.filter(b=>b.kind==="active").reduce((b,v)=>Math.max(b,v.tEnd-v.tStart),0),s=n.segments.reduce((b,v)=>b+(v.kind==="active"?v.pxEnd-v.pxStart:0),0),l=(i>0?s/n.totalActiveMs:0)*1e3,c=[.1,.25,.5,1,2,5,10,30,60,120,300],f=80;let m=c[c.length-1];for(const b of c)if(b*l>=f){m=b;break}const h=m*1e3,y=((g=n.segments[0])==null?void 0:g.tStart)??0;for(const b of n.segments){if(b.kind!=="active")continue;const v=Math.ceil((b.tStart-y)/h)*h+y;for(let u=v;u<=b.tEnd;u+=h){const p=n.tsToX(u);p<wn||p>t.width-hs||(e.beginPath(),e.moveTo(p,r),e.lineTo(p,r+4),e.stroke(),e.fillText(bP(u-y),p,r-2))}}}function gP(e,t,n,o,r){const i=Dl+Ll,s=i+dl.length*(oo+sf);for(const a of t.segments){if(a.kind!=="gap")continue;const l=t.tsToX(a.tStart),f=t.tsToX(a.tEnd)-l;if(l>n.width-hs||l+f<wn)continue;e.fillStyle=r("ink-muted",.06),e.fillRect(l,i,f,s-i),e.strokeStyle=o("line"),e.setLineDash([3,3]),e.lineWidth=1,e.beginPath(),e.moveTo(l+.5,i),e.lineTo(l+.5,s),e.moveTo(l+f-.5,i),e.lineTo(l+f-.5,s),e.stroke(),e.setLineDash([]),e.fillStyle=o("ink-muted"),e.font="10px monospace",e.textBaseline="middle",e.textAlign="center";const m=l+f/2,h=i+(s-i)/2;e.fillText(vP(a.tEnd-a.tStart),m,h)}}function vP(e){if(e<6e4)return`${Math.round(e/1e3)}s idle`;if(e<36e5)return`${Math.round(e/6e4)}m idle`;const t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return n>0?`${t}h${n}m idle`:`${t}h idle`}function bP(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(e<1e4?1:0)}s`;const t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m${n}s`}function xP(e,t,n,o,r){for(const i of t){const s=(n==null?void 0:n.seq)===i.seq,a=i.erroredOut?r("accent-error",.6):i.kind==="notification"?r("accent-note",.7):i.lane==="editor-req"?r("accent-out",.7):r("accent-in",.7);e.fillStyle=s?a.replace(/0\.\d+/,"0.95"):a,e.fillRect(i.x,i.y,Math.max(i.width,2),i.height),s&&(e.strokeStyle=o("ink-primary"),e.lineWidth=1,e.strokeRect(i.x-.5,i.y-.5,Math.max(i.width,2)+1,i.height+1))}}function wP({open:e,onClose:t,onNavigateToSeq:n}){const o=ne(S=>S.messages),r=ne(S=>S.session),i=ne(S=>S.select),s=P.useRef(null),[a,l]=P.useState(1),c=P.useMemo(()=>Fd(o),[o]),f=P.useMemo(()=>sP(o,c),[o,c]),m=P.useMemo(()=>c.reduce((S,T)=>Math.max(S,T.count),0),[c]),[h,y]=P.useState("count"),[g,b]=P.useState("desc"),{rendered:v,visible:u}=of(e);P.useEffect(()=>{if(!e)return;const S=T=>{T.key==="Escape"&&(T.preventDefault(),t())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[e,t]);const p=P.useMemo(()=>CP(c,h,g),[c,h,g]),x=P.useMemo(()=>NP(c),[c]);return v?d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Performance dashboard",className:K("fixed inset-0 z-[100] flex flex-col bg-surface-base/95 backdrop-blur-sm transition-opacity duration-200 ease-out",u?"opacity-100":"opacity-0"),children:d.jsxs("div",{className:K("flex h-full w-full flex-col transition-transform duration-200 ease-out",u?"translate-y-0":"-translate-y-2"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsxs("div",{className:"flex min-w-0 items-baseline gap-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Performance — per-method latency"}),r&&d.jsx("span",{className:"truncate font-mono text-[11px] text-ink-secondary",children:(()=>{const S=ql(r);let T=S.secondary;if(!r.clientName){const C=cl(o),$=C.client.title??C.client.name??null;if($){const j=S.secondary;T=j?`${$} · ${j}`:$}}return T?`${S.primary} · ${T}`:S.primary})()})]}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close performance panel",children:"close"})]}),f.length>0&&d.jsx(TP,{insights:f}),d.jsx("div",{className:"border-b border-line bg-surface-elev px-5 py-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:c.length===0?d.jsx("span",{children:"no messages — capture or load a session first"}):d.jsxs("span",{children:[x.methods," methods · ",x.requests," requests ·"," ",x.notifications," notifications · ",x.samples," latency samples"]})}),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx("div",{className:"flex-1 overflow-y-auto",children:p.length===0?null:d.jsxs("table",{className:"w-full table-fixed text-[11px]",children:[d.jsxs("colgroup",{children:[d.jsx("col",{}),d.jsx("col",{className:"w-[64px]"}),d.jsx("col",{className:"w-[88px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[120px]"})]}),d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-base",children:d.jsxs("tr",{className:"border-b border-line text-left font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx(cr,{sk:"method",current:h,dir:g,onSort:lr(y,b,g),className:"!pl-5",children:"method"}),d.jsx("th",{className:"px-3 py-2",children:"kind"}),d.jsx(cr,{sk:"count",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"count"}),d.jsx(cr,{sk:"p50",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"p50"}),d.jsx(cr,{sk:"p99",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"p99"}),d.jsx(cr,{sk:"max",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"max"}),d.jsx(cr,{sk:"total",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"total"}),d.jsx("th",{className:"py-2 pl-3 pr-5 text-right",children:"dist"})]})}),d.jsx("tbody",{className:"font-mono",children:p.map(S=>d.jsxs("tr",{className:"border-b border-line/40 transition-colors hover:bg-surface-rowHover/50",children:[d.jsx("td",{className:"truncate py-1.5 pl-5 pr-3 text-ink-primary",title:S.method,children:S.method}),d.jsx("td",{className:"px-3 py-1.5 text-ink-muted",children:d.jsx(jP,{kind:S.kind})}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-primary",children:d.jsx(_P,{count:S.count,max:m,kind:S.kind})}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.p50!==null?Vt(S.p50):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.p99!==null?Vt(S.p99):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.max!==null?Vt(S.max):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.totalLatencyMs!==null?Vt(S.totalLatencyMs):"—"}),d.jsx("td",{className:"py-1.5 pl-3 pr-5 text-right",children:S.latencies.length>0?d.jsx(cP,{values:S.latencies,width:88,height:14,className:"text-accent-info",title:`${S.method} latency distribution`}):d.jsx("span",{className:"text-ink-dim",children:"—"})})]},`${S.kind}:${S.method}`))})]})}),o.length>0&&d.jsxs("div",{className:"flex h-[260px] shrink-0 flex-col border-t border-line bg-surface-elev",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line bg-surface-base px-5 py-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("div",{className:"flex min-w-0 items-baseline gap-2 truncate",children:[d.jsx("span",{children:"timeline — wall-clock waterfall"}),d.jsx("span",{className:"text-ink-dim",children:"· drag to pan · Cmd/Ctrl + wheel zoom · click to inspect"})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[d.jsxs("span",{className:"text-ink-secondary",children:[a.toFixed(a<1?2:1),"×"]}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.zoomOut()},className:"inline-flex h-5 w-5 items-center justify-center rounded-sm border border-line hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Zoom out",title:"Zoom out",children:"−"}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.zoomIn()},className:"inline-flex h-5 w-5 items-center justify-center rounded-sm border border-line hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Zoom in",title:"Zoom in",children:"+"}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.reset()},className:"inline-flex h-5 items-center justify-center rounded-sm border border-line px-2 hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Reset zoom and pan",title:"Reset zoom and pan to defaults",children:"reset"})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(mP,{messages:o,controlsRef:s,onZoomChange:l,onSelectSeq:S=>{n?n(S):(i(S),t())}})})]})]})]})}):null}const SP={hotspot:"●","long-tail":"▲",outlier:"◆",busiest:"■",errors:"✗"},$P={hotspot:"text-accent-warn","long-tail":"text-accent-warn",outlier:"text-accent-warn",busiest:"text-accent-info",errors:"text-accent-error"},kP={hotspot:"hotspot","long-tail":"long tail",outlier:"outlier",busiest:"busiest",errors:"errors"};function TP({insights:e}){return d.jsxs("div",{className:"border-b border-line bg-surface-base px-5 py-2.5",children:[d.jsx("div",{className:"mb-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"insights"}),d.jsx("ul",{className:"space-y-1.5",children:e.map(t=>d.jsxs("li",{className:"flex items-start gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:K("mt-[3px] inline-block text-[9px] leading-none",$P[t.kind]),children:SP[t.kind]}),d.jsx("div",{className:"min-w-[68px] font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:kP[t.kind]}),d.jsxs("div",{className:"flex-1 text-[11px] leading-snug",children:[d.jsx("div",{className:"text-ink-primary",children:t.summary}),t.detail&&d.jsx("div",{className:"text-[10px] text-ink-muted",children:t.detail})]})]},t.kind))})]})}function _P({count:e,max:t,kind:n}){const o=t>0?e/t*100:0,r=n==="request"?"bg-accent-out/15":"bg-accent-note/15";return d.jsxs("div",{className:"relative inline-block w-[44px] text-right",children:[d.jsx("div",{"aria-hidden":!0,className:K("absolute inset-y-[1px] right-0 rounded-sm",r),style:{width:`${o}%`}}),d.jsx("span",{className:"relative",children:e})]})}function lr(e,t,n){return(o,r)=>{r?t(n==="asc"?"desc":"asc"):(e(o),t(o==="method"?"asc":"desc"))}}function cr({sk:e,current:t,dir:n,onSort:o,align:r="left",className:i,children:s}){const a=t===e;return d.jsxs("th",{className:K("cursor-pointer select-none px-3 py-2 transition-colors hover:text-ink-primary",r==="right"?"text-right":"",a?"text-ink-primary":"",i),onClick:()=>o(e,a),"aria-sort":a?n==="asc"?"ascending":"descending":"none",children:[d.jsx("span",{children:s}),a&&d.jsx("span",{className:"ml-1 text-accent-warn",children:n==="asc"?"↑":"↓"})]})}function jP({kind:e}){const t=e==="request"?"text-accent-out":"text-accent-note",n=e==="request"?"req":"ntf";return d.jsx("span",{className:K("text-[10px] uppercase tracking-widest",t),title:e,children:n})}function NP(e){let t=0,n=0,o=0;for(const r of e)r.kind==="request"?t+=r.count:n+=r.count,o+=r.sampleSize;return{methods:e.length,requests:t,notifications:n,samples:o}}function CP(e,t,n){const o=n==="asc"?1:-1,r=[...e];return r.sort((i,s)=>{const a=qh(i,t),l=qh(s,t);return a===null&&l!==null?1:a!==null&&l===null?-1:t==="method"?o*i.method.localeCompare(s.method):a===null||l===null?0:o*(a-l)}),r}function qh(e,t){switch(t){case"method":return 0;case"count":return e.count;case"p50":return e.p50;case"p99":return e.p99;case"max":return e.max;case"total":return e.totalLatencyMs}}const af=["raw.githubusercontent.com","gist.githubusercontent.com"];function Gb(e){try{return{ok:!0,export:qC(e)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function EP(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol!=="https:"?!1:af.includes(t.host)}async function PP(e){if(!EP(e))return{ok:!1,error:`host not in playground allowlist (${af.join(", ")})`};let t;try{t=await fetch(e,{redirect:"follow"})}catch(o){return{ok:!1,error:`fetch failed: ${o instanceof Error?o.message:String(o)}`}}if(!t.ok)return{ok:!1,error:`HTTP ${t.status} ${t.statusText}`};const n=await t.text();return Gb(n)}function IP({initialUrl:e=null}){const[t,n]=P.useState(null),[o,r]=P.useState(e!==null),[i,s]=P.useState(!1),[a,l]=P.useState(""),c=P.useRef(null),f=(b,v)=>{b.ok?(ne.getState().loadFromExport(b.export),n(null)):n(`${v}: ${b.error}`),r(!1)},m=async b=>{r(!0),n(null);try{const v=await b.text();f(Gb(v),b.name)}catch(v){n(`${b.name}: ${v instanceof Error?v.message:String(v)}`),r(!1)}},h=async b=>{r(!0),n(null),f(await PP(b),b)},y=P.useRef(e);if(y.current!==null){const b=y.current;y.current=null,h(b)}const g=b=>{var u;b.preventDefault(),s(!1);const v=(u=b.dataTransfer.files)==null?void 0:u[0];v&&m(v)};return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-grid",children:d.jsxs("div",{className:"relative w-[min(720px,92%)] rounded-md border border-line bg-surface-elev/80 p-6 backdrop-blur-sm",children:[d.jsxs("div",{className:"mb-1 flex items-baseline gap-3",children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:"acp.devtools"}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"playground"})]}),d.jsx("h2",{className:"font-display text-2xl uppercase tracking-tight text-ink-primary",children:"Drop an exported session"}),d.jsxs("p",{className:"mt-2 font-sans text-sm leading-relaxed text-ink-secondary",children:["The playground renders ACP session exports client-side. Nothing leaves your browser. Generate exports with ",d.jsx("code",{className:"font-mono",children:"acp-devtools export <id>"})," ","— auth headers and proxy tokens are redacted by default."]}),d.jsxs("div",{role:"button",tabIndex:0,"aria-label":"Drop session export here or click to pick a file",onClick:()=>{var b;return(b=c.current)==null?void 0:b.click()},onKeyDown:b=>{var v;(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),(v=c.current)==null||v.click())},onDragOver:b=>{b.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:g,className:K("mt-5 flex h-40 cursor-pointer flex-col items-center justify-center rounded-md border-2 border-dashed text-center transition-colors",i?"border-accent-out bg-accent-out/10":"border-line bg-surface-base/40 hover:border-ink-muted"),children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:o?"Loading…":"Drop .json here"}),d.jsx("span",{className:"mt-1 font-mono text-[11px] text-ink-dim",children:"or click to pick a file"}),d.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:b=>{var u;const v=(u=b.target.files)==null?void 0:u[0];v&&m(v),b.target.value=""}})]}),d.jsxs("form",{className:"mt-4 flex items-center gap-2",onSubmit:b=>{b.preventDefault();const v=a.trim();v&&h(v)},children:[d.jsx("input",{type:"url",value:a,onChange:b=>l(b.target.value),placeholder:"https://raw.githubusercontent.com/…/session.json",className:"flex-1 rounded-sm border border-line bg-surface-base px-3 py-2 font-mono text-[12px] text-ink-primary outline-none focus:border-ink-muted","aria-label":"Load session from URL"}),d.jsx("button",{type:"submit",disabled:o||a.trim().length===0,className:"rounded-sm border border-line bg-surface-base px-3 py-2 font-display text-[11px] uppercase tracking-widest text-ink-secondary transition-colors hover:border-ink-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Load"})]}),d.jsxs("p",{className:"mt-2 font-mono text-[10px] leading-relaxed text-ink-dim",children:["URL allowlist: ",af.join(", "),". Gists are public — don't use this for anything you wouldn't post on Twitter."]}),t&&d.jsx("p",{className:"mt-3 font-mono text-[11px] text-accent-error",children:t})]})})}const OP=[.5,1,2,4,8];function RP(){const e=ne(h=>h.messages),t=ne(h=>h.playback),n=ne(h=>h.setPlaybackCap),o=ne(h=>h.setPlaying),r=ne(h=>h.setPlaybackSpeed),i=e.length>0?e[0].seq:0,s=e.length>0?e[e.length-1].seq:0,a=t.cap??s,l=a>=s,c=P.useRef(null);if(P.useEffect(()=>{if(!t.playing)return;if(l){o(!1);return}const h=e.findIndex(u=>u.seq===a),y=e[h+1];if(!y){o(!1);return}const g=e[h],b=g?y.timestamp-g.timestamp:0,v=Math.max(15,Math.min(1500,b/t.speed));return c.current=setTimeout(()=>{n(y.seq)},v),()=>{c.current&&(clearTimeout(c.current),c.current=null)}},[t.playing,t.speed,a,e,l,n,o]),e.length===0)return null;const f=h=>{h>=s?n(null):n(h),t.playing&&o(!1)},m=()=>{l?(n(i),o(!0)):o(!t.playing)};return d.jsxs("div",{className:"flex items-center gap-3 border-t border-line bg-surface-elev/70 px-4 py-2 font-mono text-[11px]",children:[d.jsx("button",{type:"button",onClick:m,className:K("inline-flex h-6 w-12 items-center justify-center rounded-sm border font-semibold uppercase tracking-widest transition-colors",t.playing?"border-accent-warn/50 bg-accent-warn/10 text-accent-warn":"border-accent-out/50 bg-accent-out/10 text-accent-out"),title:t.playing?"pause":l?"restart playback":"play",children:t.playing?"❚❚":l?"↺":"▶"}),d.jsxs("span",{className:"w-20 shrink-0 text-right text-ink-secondary",children:[String(a).padStart(3,"0")," / ",String(s).padStart(3,"0")]}),d.jsx("input",{type:"range",min:i,max:s,value:a,onChange:h=>f(Number(h.target.value)),className:"h-1 flex-1 cursor-pointer accent-accent-out"}),d.jsx("div",{className:"flex shrink-0 items-center gap-1",children:OP.map(h=>d.jsxs("button",{type:"button",onClick:()=>r(h),className:K("rounded-sm border px-1.5 py-0.5 text-[10px] uppercase tracking-widest transition-colors",t.speed===h?"border-accent-out/50 bg-accent-out/10 text-accent-out":"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),title:`${h}× speed`,children:[h,"×"]},h))}),d.jsx("button",{type:"button",onClick:()=>{n(null),o(!1)},className:"rounded-sm border border-line px-2 py-0.5 text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:border-line-strong hover:text-ink-secondary",title:"show all messages, exit playback",children:"show all"})]})}function Jb(e=5e3){const[t,n]=P.useState(()=>Date.now());return P.useEffect(()=>{const o=setInterval(()=>n(Date.now()),e);return()=>clearInterval(o)},[e]),t}function AP({open:e,onClose:t}){const n=ne(a=>a.session),o=ne(a=>a.messages),r=P.useMemo(()=>cl(o),[o]),{rendered:i,visible:s}=of(e);return P.useEffect(()=>{if(!e)return;const a=l=>{l.key==="Escape"&&(l.preventDefault(),t())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[e,t]),i?d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Session info",className:K("fixed inset-0 z-[100] flex items-start justify-end bg-black/60 backdrop-blur-sm transition-opacity duration-200 ease-out",s?"opacity-100":"opacity-0"),onMouseDown:a=>{a.target===a.currentTarget&&t()},children:d.jsxs("div",{className:K("flex h-full w-full max-w-[440px] flex-col border-l border-line bg-surface-base shadow-2xl transition-transform duration-200 ease-out",s?"translate-x-0":"translate-x-full"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsx("div",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Session info"}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close session info panel",children:"close"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:n?d.jsx(MP,{session:n,meta:r,messages:o}):d.jsx("div",{className:"font-mono text-[11px] text-ink-muted",children:"No session attached."})})]})}):null}function MP({session:e,meta:t,messages:n}){const o=Jb(5e3),{primary:r}=ql(e),i=P.useMemo(()=>UP(n),[n]);return d.jsxs("div",{className:"space-y-5 text-[12px]",children:[d.jsxs(wi,{title:"Summary",children:[d.jsx(mn,{label:"Session",value:r}),d.jsx(mn,{label:"Client",value:t.client.title||t.client.name||e.clientName||"—",secondary:t.client.version?`v${t.client.version}${t.client.platform?` · ${t.client.platform}`:""}`:null}),d.jsx(mn,{label:"Agent",value:t.agent.name||qP(e.agentCommand)||"—",secondary:t.agent.version?`v${t.agent.version}`:null}),d.jsx(mn,{label:"Protocol",value:t.protocolVersion!==null?`ACP v${t.protocolVersion}`:"—"}),d.jsx(mn,{label:"Started",value:_a(e.startedAt,o)}),d.jsx(mn,{label:"Messages",value:`${n.length} (req ${i.req} · rsp ${i.rsp} · ntf ${i.note} · err ${i.err})`})]}),d.jsxs(wi,{title:"Client capabilities",children:[d.jsx(No,{label:"fs.readTextFile",enabled:t.clientCapabilities.fsReadTextFile}),d.jsx(No,{label:"fs.writeTextFile",enabled:t.clientCapabilities.fsWriteTextFile}),d.jsx(No,{label:"terminal",enabled:t.clientCapabilities.terminal}),d.jsx(No,{label:"auth.terminal",enabled:t.clientCapabilities.authTerminal}),d.jsx(No,{label:"auth.gateway",enabled:t.clientCapabilities.authGateway})]}),d.jsxs(wi,{title:"Agent capabilities",children:[d.jsx(No,{label:"prompt",enabled:t.agentCapabilities.prompt}),d.jsx(No,{label:"loadSession",enabled:t.agentCapabilities.loadSession}),d.jsx(mn,{label:"Auth methods",value:String(t.agent.authMethods)})]}),d.jsxs(wi,{title:"Runtime state",children:[d.jsx(mn,{label:"Mode",value:t.runtime.currentMode??"—",secondary:t.runtime.modeChanges>0?`changed ${t.runtime.modeChanges}× this session`:null}),d.jsx(mn,{label:"Model",value:t.runtime.currentModel??"—",secondary:t.runtime.modelChanges>0?`changed ${t.runtime.modelChanges}× this session`:null}),d.jsx(mn,{label:"Commands",value:t.runtime.availableCommands.length>0?t.runtime.availableCommands.join(", "):"—",wrap:!0})]}),t.extensions.jetbrainsProxyConfig!==null&&d.jsx(wi,{title:"JetBrains extensions",children:d.jsx("div",{className:"rounded-sm border border-line bg-surface-elev p-3 font-mono text-[11px] text-ink-secondary",children:d.jsx(al,{value:t.extensions.jetbrainsProxyConfig})})})]})}function qP(e){if(!e)return null;const t=e.trim().split(/\s+/);if(t[0]==="npx")for(let n=1;n<t.length;n++){const o=t[n];if(!o.startsWith("-"))return o}return t[0]??null}function UP(e){let t=0,n=0,o=0,r=0;for(const i of e)i.kind==="request"?t++:i.kind==="response"?n++:i.kind==="notification"?o++:i.kind==="error"&&r++;return{req:t,rsp:n,note:o,err:r}}function wi({title:e,children:t}){return d.jsxs("div",{children:[d.jsx("h3",{className:"mb-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("div",{className:"space-y-1.5",children:t})]})}function mn({label:e,value:t,secondary:n,wrap:o=!1}){return d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsx("span",{className:"w-[120px] shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsxs("span",{className:K("flex-1 text-ink-primary",o?"whitespace-normal break-words":"truncate"),title:o?void 0:t,children:[t,n&&d.jsx("span",{className:"ml-2 text-[10px] text-ink-muted",children:n})]})]})}function No({label:e,enabled:t}){return d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsx("span",{className:"w-[120px] shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:K("flex-1 font-mono text-[11px]",t?"text-accent-ok":"text-ink-dim"),children:t?"✓ enabled":"— not advertised"})]})}function LP({left:e,right:t,storageKey:n,initialLeftFraction:o=.6,minLeft:r=320,minRight:i=320}){const s=P.useRef(null),[a,l]=P.useState(null),c=P.useRef(!1);P.useEffect(()=>{if(!s.current)return;const y=s.current.clientWidth,g=n?Number(localStorage.getItem(n)):NaN;n&&Number.isFinite(g)&&g>0&&g<y?l(g):l(Math.round(y*o))},[o,n]);const f=P.useCallback(y=>{y.preventDefault(),c.current=!0,y.currentTarget.setPointerCapture(y.pointerId)},[]),m=P.useCallback(y=>{if(!c.current||!s.current)return;const g=s.current.getBoundingClientRect(),b=y.clientX-g.left,v=g.width,u=Math.min(Math.max(b,r),v-i);l(u),n&&localStorage.setItem(n,String(Math.round(u)))},[r,i,n]),h=P.useCallback(y=>{c.current=!1;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}},[]);return d.jsxs("div",{ref:s,className:"flex h-full w-full overflow-hidden",children:[d.jsx("div",{style:{width:a??"60%"},className:"flex h-full min-w-0 flex-col",children:e}),d.jsx("div",{role:"separator","aria-orientation":"vertical",className:K("group relative w-px shrink-0 cursor-col-resize bg-line",'before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-[""]'),onPointerDown:f,onPointerMove:m,onPointerUp:h,onPointerCancel:h,children:d.jsx("div",{className:"absolute inset-y-0 left-0 w-px bg-line transition-colors group-hover:bg-accent-out/40"})}),d.jsx("div",{className:"flex h-full min-w-0 flex-1 flex-col",children:t})]})}function DP(){const e=ne(n=>n.messages),t=P.useMemo(()=>{let n=0,o=0,r=0,i=0,s=0;const a=new Map;for(const y of e)switch(a.set(y.seq,y.timestamp),s+=y.raw.length,y.kind){case"request":n+=1;break;case"response":o+=1;break;case"notification":r+=1;break;case"error":i+=1;break}const l=Cl(e),c=[];for(const y of e){if(y.kind!=="response"&&y.kind!=="error")continue;const g=l.get(y.seq);if(g===void 0)continue;const b=a.get(g);b!==void 0&&c.push(y.timestamp-b)}c.sort((y,g)=>y-g);const f=c.length?gh(c,50):null,m=c.length?gh(c,99):null,h=HN(Zp(e));return{total:e.length,req:n,res:o,note:r,err:i,bytes:s,p50:f,p99:m,spec:h}},[e]);return d.jsxs("footer",{className:"flex items-center justify-between gap-6 border-t border-line bg-surface-elev/80 px-5 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsx(Yn,{label:"msgs",value:t.total,tone:"primary"}),d.jsx(Yn,{label:"req",value:t.req,tone:"out"}),d.jsx(Yn,{label:"rsp",value:t.res,tone:"in"}),d.jsx(Yn,{label:"ntf",value:t.note,tone:"note"}),d.jsx(Yn,{label:"err",value:t.err,tone:t.err>0?"error":"muted"})]}),d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsx(Yn,{label:"p50",value:t.p50!==null?Vt(t.p50):"—",tone:"primary"}),d.jsx(Yn,{label:"p99",value:t.p99!==null?Vt(t.p99):"—",tone:"primary"}),d.jsx(Yn,{label:"bytes",value:t.total>0?Ul(t.bytes):"—",tone:"primary"}),t.spec.checked>0&&d.jsx(FP,{invalidFrames:t.spec.invalidFrames,totalErrors:t.spec.totalErrors,affectedMethods:t.spec.affectedMethods}),d.jsx(zP,{})]})]})}function zP(){return d.jsxs("a",{href:"https://github.com/maksugr/acp-devtools",target:"_blank",rel:"noreferrer noopener",title:"Enjoying acp-devtools? Star it on GitHub — thank you!","aria-label":"Star acp-devtools on GitHub",className:"inline-flex items-baseline gap-1 text-ink-muted transition-colors hover:text-accent-warn focus-visible:text-accent-warn focus-visible:outline-none",children:[d.jsx("span",{"aria-hidden":"true",className:"text-[10px]",children:"★"}),d.jsx("span",{className:"text-[9px] tracking-normal",children:"Star on GitHub"})]})}function FP({invalidFrames:e,totalErrors:t,affectedMethods:n}){if(e===0)return d.jsx(ps,{label:d.jsx("span",{className:"font-sans",children:"every frame validates against the ACP schema"}),tone:"info",children:d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:"spec"}),d.jsx("span",{className:"text-accent-ok",children:"✓"})]})});const o=`${t} schema error${t===1?"":"s"} in ${e} frame${e===1?"":"s"}`;return d.jsx(ps,{tone:"warn",label:d.jsxs("div",{className:"space-y-1.5 font-sans",children:[d.jsx("div",{children:o}),n.length>0&&d.jsxs("div",{className:"font-mono text-[10px] text-ink-muted",children:["methods: ",n.join(", ")]})]}),children:d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:"spec"}),d.jsxs("span",{className:"text-accent-error",children:["⚠ ",e]})]})})}function Yn({label:e,value:t,tone:n}){const o=n==="primary"?"text-ink-primary":n==="out"?"text-accent-out":n==="in"?"text-accent-in":n==="note"?"text-accent-note":n==="error"?"text-accent-error":"text-ink-muted";return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:e}),d.jsx("span",{className:o,children:t})]})}const zl=0,$o=1,oi=2,Qb=4;function Uh(e){return()=>e}function BP(e){e()}function Yb(e,t){return n=>e(t(n))}function Lh(e,t){return()=>e(t)}function HP(e,t){return n=>e(t,n)}function lf(e){return e!==void 0}function VP(...e){return()=>{e.map(BP)}}function ri(){}function Fl(e,t){return t(e),e}function WP(e,t){return t(e)}function Ue(...e){return e}function $e(e,t){return e($o,t)}function me(e,t){e(zl,t)}function cf(e){e(oi)}function Le(e){return e(Qb)}function oe(e,t){return $e(e,HP(t,zl))}function cn(e,t){const n=e($o,o=>{n(),t(o)});return n}function Dh(e){let t,n;return o=>r=>{t=r,n&&clearTimeout(n),n=setTimeout(()=>{o(t)},e)}}function Xb(e,t){return e===t}function Me(e=Xb){let t;return n=>o=>{e(t,o)||(t=o,n(o))}}function ae(e){return t=>n=>{e(n)&&t(n)}}function X(e){return t=>Yb(t,e)}function yn(e){return t=>()=>{t(e)}}function z(e,...t){const n=KP(...t);return(o,r)=>{switch(o){case oi:cf(e);return;case $o:return $e(e,n(r))}}}function Sn(e,t){return n=>o=>{n(t=e(t,o))}}function Qo(e){return t=>n=>{e>0?e--:t(n)}}function On(e){let t=null,n;return o=>r=>{t=r,!n&&(n=setTimeout(()=>{n=void 0,o(t)},e))}}function he(...e){const t=new Array(e.length);let n=0,o=null;const r=2**e.length-1;return e.forEach((i,s)=>{const a=2**s;$e(i,l=>{const c=n;n|=a,t[s]=l,c!==r&&n===r&&o&&(o(),o=null)})}),i=>s=>{const a=()=>{i([s].concat(t))};n===r?a():o=a}}function KP(...e){return t=>e.reduceRight(WP,t)}function GP(e){let t,n;const o=()=>t==null?void 0:t();return function(r,i){switch(r){case $o:return i?n===i?void 0:(o(),n=i,t=$e(e,i),t):(o(),ri);case oi:o(),n=null;return}}}function W(e){let t=e;const n=ve();return(o,r)=>{switch(o){case zl:t=r;break;case $o:{r(t);break}case Qb:return t}return n(o,r)}}function yt(e,t){return Fl(W(t),n=>oe(e,n))}function ve(){const e=[];return(t,n)=>{switch(t){case zl:e.slice().forEach(o=>{o(n)});return;case oi:e.splice(0,e.length);return;case $o:return e.push(n),()=>{const o=e.indexOf(n);o>-1&&e.splice(o,1)}}}}function Mt(e){return Fl(ve(),t=>oe(e,t))}function xe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:JP(),singleton:n}}const JP=()=>Symbol();function QP(e){const t=new Map,n=({constructor:o,dependencies:r,id:i,singleton:s})=>{if(s&&t.has(i))return t.get(i);const a=o(r.map(l=>n(l)));return s&&t.set(i,a),a};return n(e)}function Qe(...e){const t=ve(),n=new Array(e.length);let o=0;const r=2**e.length-1;return e.forEach((i,s)=>{const a=2**s;$e(i,l=>{n[s]=l,o|=a,o===r&&me(t,n)})}),function(i,s){switch(i){case oi:{cf(t);return}case $o:return o===r&&s(n),$e(t,s)}}}function se(e,t=Xb){return z(e,Me(t))}function Bd(...e){return function(t,n){switch(t){case oi:return;case $o:return VP(...e.map(o=>$e(o,n)))}}}const nt={DEBUG:0,INFO:1,WARN:2,ERROR:3},YP={[nt.DEBUG]:"debug",[nt.ERROR]:"error",[nt.INFO]:"log",[nt.WARN]:"warn"},XP=()=>typeof globalThis>"u"?window:globalThis,ko=xe(()=>{const e=W(nt.ERROR);return{log:W((t,n,o=nt.INFO)=>{const r=XP().VIRTUOSO_LOG_LEVEL??Le(e);o>=r&&console[YP[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0}),Hd=new WeakMap;function Zb(e){return"self"in e?e.document.documentElement:e}function ZP(e){const t=Zb(e),n=Hd.get(t);if(n!==void 0)return n;const o=t.ownerDocument.defaultView.getComputedStyle(t).direction==="rtl";return Hd.set(t,o),o}function zh(e){Hd.delete(Zb(e))}function ex(e,t){return ZP(e)?-t:t}const Lo=ex;function Fh(e,t){return ex(e,t)}function Zo(e,t,n){return df(e,t,n).callbackRef}function df(e,t,n){const o=te.useRef(null);let r=s=>{};const i=te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(s=>{const a=()=>{const l=s[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return r=s=>{s&&t?(i==null||i.observe(s),o.current=s):(o.current&&(i==null||i.unobserve(o.current)),o.current=null)},{callbackRef:r,ref:o}}function eI(e,t,n,o,r,i,s,a,l){const c=te.useCallback(f=>{const m=tI(f.children,t,a?"offsetWidth":"offsetHeight",r);let h=f.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const y=h.lastElementChild.dataset.viewportType==="window";let g;y&&(g=h.ownerDocument.defaultView);const b=s?a?s.scrollWidth:s.scrollHeight:y?a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=s?a?s.offsetWidth:s.offsetHeight:y?a?g.innerWidth:g.innerHeight:a?h.offsetWidth:h.offsetHeight,u=s?a?Lo(s,s.scrollLeft):s.scrollTop:y?a?Lo(g,g.scrollX||g.document.documentElement.scrollLeft):g.scrollY||g.document.documentElement.scrollTop:a?Lo(h,h.scrollLeft):h.scrollTop;o({scrollHeight:b,scrollTop:Math.max(u,0),viewportHeight:v}),i==null||i(a?Bh("column-gap",getComputedStyle(f).columnGap,r):Bh("row-gap",getComputedStyle(f).rowGap,r)),m!==null&&e(m)},[e,t,r,i,s,o,a]);return df(c,n,l)}function tI(e,t,n,o){const r=e.length;if(r===0)return null;const i=[];for(let s=0;s<r;s++){const a=e.item(s);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),f=t(a,n);if(f===0&&o("Zero-sized element, this should not happen",{child:a},nt.ERROR),f===c)continue;const m=i[i.length-1];i.length===0||m.size!==f||m.endIndex!==l-1?i.push({endIndex:l,size:f,startIndex:l}):i[i.length-1].endIndex++}return i}function Bh(e,t,n){return t!=="normal"&&(t==null?void 0:t.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function tx(e,t,n){const o=te.useRef(null),r=te.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),f=c.width;let m,h;if(t){const y=t.getBoundingClientRect(),g=c.top-y.top;h=y.height-Math.max(0,g),m=g+t.scrollTop}else{const y=s.current.ownerDocument.defaultView;h=y.innerHeight-Math.max(0,c.top),m=c.top+y.scrollY}o.current={listHeight:c.height,offsetTop:m,visibleHeight:h,visibleWidth:f},e(o.current)},[e,t]),{callbackRef:i,ref:s}=df(r,!0,n),a=te.useCallback(()=>{r(s.current)},[r,s]);return te.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const f=new ResizeObserver(()=>{requestAnimationFrame(a)});return f.observe(t),()=>{t.removeEventListener("scroll",a),f.unobserve(t)}}const l=(c=s.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}},[a,t,s]),i}const kt=xe(()=>{const e=ve(),t=ve(),n=W(0),o=ve(),r=W(0),i=ve(),s=ve(),a=W(0),l=W(0),c=W(0),f=W(0),m=ve(),h=ve(),y=W(!1),g=W(!1),b=W(!1);return oe(z(e,X(({scrollTop:v})=>v)),t),oe(z(e,X(({scrollHeight:v})=>v)),s),oe(t,r),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:f,headerHeight:a,horizontalDirection:g,scrollBy:h,scrollContainerState:e,scrollHeight:s,scrollingInProgress:y,scrollTo:m,scrollTop:t,skipAnimationFrameInResizeObserver:b,smoothScrollTargetReached:o,statefulScrollTop:r,viewportHeight:i}},[],{singleton:!0}),ys={lvl:0};function nx(e,t){const n=e.length;if(n===0)return[];let{index:o,value:r}=t(e[0]);const i=[];for(let s=1;s<n;s++){const{index:a,value:l}=t(e[s]);i.push({end:a-1,start:o,value:r}),o=a,r=l}return i.push({end:1/0,start:o,value:r}),i}function Te(e){return e===ys}function gs(e,t){if(!Te(e))return t===e.k?e.v:t<e.k?gs(e.l,t):gs(e.r,t)}function un(e,t,n="k"){if(Te(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const o=un(e.r,t,n);return o[0]===-1/0?[e.k,e.v]:o}return un(e.l,t,n)}function It(e,t,n){return Te(e)?ix(t,n,1):t===e.k?Ze(e,{k:t,v:n}):t<e.k?Hh(Ze(e,{l:It(e.l,t,n)})):Hh(Ze(e,{r:It(e.r,t,n)}))}function Mr(){return ys}function qr(e,t,n){if(Te(e))return[];const o=un(e,t)[0];return nI(Wd(e,o,n))}function Vd(e,t){if(Te(e))return ys;const{k:n,l:o,r}=e;if(t===n){if(Te(o))return r;if(Te(r))return o;const[i,s]=rx(o);return Na(Ze(e,{k:i,l:ox(o),v:s}))}return t<n?Na(Ze(e,{l:Vd(o,t)})):Na(Ze(e,{r:Vd(r,t)}))}function Do(e){return Te(e)?[]:[...Do(e.l),{k:e.k,v:e.v},...Do(e.r)]}function Wd(e,t,n){if(Te(e))return[];const{k:o,l:r,r:i,v:s}=e;let a=[];return o>t&&(a=a.concat(Wd(r,t,n))),o>=t&&o<=n&&a.push({k:o,v:s}),o<=n&&(a=a.concat(Wd(i,t,n))),a}function Na(e){const{l:t,lvl:n,r:o}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(_c(t))return sx(Ze(e,{lvl:n-1}));if(!Te(t)&&!Te(t.r))return Ze(t.r,{l:Ze(t,{r:t.r.l}),lvl:n,r:Ze(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(_c(e))return Kd(Ze(e,{lvl:n-1}));if(!Te(o)&&!Te(o.l)){const r=o.l,i=_c(r)?o.lvl-1:o.lvl;return Ze(r,{l:Ze(e,{lvl:n-1,r:r.l}),lvl:r.lvl+1,r:Kd(Ze(o,{l:r.r,lvl:i}))})}throw new Error("Unexpected empty nodes")}function Ze(e,t){return ix(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ox(e){return Te(e.r)?e.l:Na(Ze(e,{r:ox(e.r)}))}function _c(e){return Te(e)||e.lvl>e.r.lvl}function rx(e){return Te(e.r)?[e.k,e.v]:rx(e.r)}function ix(e,t,n,o=ys,r=ys){return{k:e,l:o,lvl:n,r,v:t}}function Hh(e){return Kd(sx(e))}function sx(e){const{l:t}=e;return!Te(t)&&t.lvl===e.lvl?Ze(t,{r:Ze(e,{l:t.r})}):e}function Kd(e){const{lvl:t,r:n}=e;return!Te(n)&&!Te(n.r)&&n.lvl===t&&n.r.lvl===t?Ze(n,{l:Ze(e,{r:n.l}),lvl:t+1}):e}function nI(e){return nx(e,({k:t,v:n})=>({index:t,value:n}))}function ax(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vs(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const uf=xe(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function lx(e,t,n){return e[ul(e,t,n)]}function ul(e,t,n,o=0){let r=e.length-1;for(;o<=r;){const i=Math.floor((o+r)/2),s=e[i],a=n(s,t);if(a===0)return i;if(a===-1){if(r-o<2)return i-1;r=i-1}else{if(r===o)return i;o=i+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function oI(e,t,n,o){const r=ul(e,t,o),i=ul(e,n,o,r);return e.slice(r,i+1)}function bo(e,t){return Math.round(e.getBoundingClientRect()[t])}function Bl(e){return!Te(e.groupOffsetTree)}function pf({index:e},t){return t===e?0:t<e?-1:1}function rI(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function iI(e,t){let n=Te(e)?0:1/0;for(const o of t){const{endIndex:r,size:i,startIndex:s}=o;if(n=Math.min(n,s),Te(e)){e=It(e,0,i);continue}const a=qr(e,s-1,r+1);if(a.some(pI(o)))continue;let l=!1,c=!1;for(const{end:f,start:m,value:h}of a)l?(r>=m||i===h)&&(e=Vd(e,m)):(c=h!==i,l=!0),f>r&&r>=m&&h!==i&&(e=It(e,r+1,h));c&&(e=It(e,s,i))}return[e,n]}function sI(e){return typeof e.groupIndex<"u"}function aI({offset:e},t){return t===e?0:t<e?-1:1}function bs(e,t,n){if(t.length===0)return 0;const{index:o,offset:r,size:i}=lx(t,e,pf),s=e-o,a=i*s+(s-1)*n+r;return a>0?a+n:a}function cx(e,t){if(!Bl(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function dx(e,t,n){if(sI(e))return t.groupIndices[e.groupIndex]+1;const o=e.index==="LAST"?n:e.index;let r=cx(o,t);return r=Math.max(0,r,Math.min(n,r)),r}function lI(e,t,n,o=0){return o>0&&(t=Math.max(t,lx(e,o,pf).offset)),nx(oI(e,t,n,aI),uI)}function cI(e,[t,n,o,r]){t.length>0&&o("received item sizes",t,nt.DEBUG);const i=e.sizeTree;let s=i,a=0;if(n.length>0&&Te(i)&&t.length===2){const h=t[0].size,y=t[1].size;s=n.reduce((g,b)=>It(It(g,b,h),b+1,y),s)}else[s,a]=iI(s,t);if(s===i)return e;const{lastIndex:l,lastOffset:c,lastSize:f,offsetTree:m}=Gd(e.offsetTree,a,s,r);return{groupIndices:n,groupOffsetTree:n.reduce((h,y)=>It(h,y,bs(y,m,r)),Mr()),lastIndex:l,lastOffset:c,lastSize:f,offsetTree:m,sizeTree:s}}function dI(e){return Do(e).map(({k:t,v:n},o,r)=>{const i=r[o+1];return{endIndex:i!==void 0?i.k-1:1/0,size:n,startIndex:t}})}function Vh(e,t){let n=0,o=0;for(;n<e;)n+=t[o+1]-t[o]-1,o++;return o-(n===e?0:1)}function Gd(e,t,n,o){let r=e,i=0,s=0,a=0,l=0;if(t!==0){l=ul(r,t-1,pf),a=r[l].offset;const c=un(n,t-1);i=c[0],s=c[1],r.length&&r[l].size===un(n,t)[1]&&(l-=1),r=r.slice(0,l+1)}else r=[];for(const{start:c,value:f}of qr(n,t,1/0)){const m=c-i,h=m*s+a+m*o;r.push({index:c,offset:h,size:f}),i=c,a=h,s=f}return{lastIndex:i,lastOffset:a,lastSize:s,offsetTree:r}}function uI(e){return{index:e.index,value:e}}function pI(e){const{endIndex:t,size:n,startIndex:o}=e;return r=>r.start===o&&(r.end===t||r.end===1/0)&&r.value===n}const fI={offsetHeight:"height",offsetWidth:"width"},Tn=xe(([{log:e},{recalcInProgress:t}])=>{const n=ve(),o=ve(),r=yt(o,0),i=ve(),s=ve(),a=W(0),l=W([]),c=W(void 0),f=W(void 0),m=W(void 0),h=W(void 0),y=W(($,j)=>bo($,fI[j])),g=W(void 0),b=W(0),v=rI(),u=yt(z(n,he(l,e,b),Sn(cI,v),Me()),v),p=yt(z(l,Me(),Sn(($,j)=>({current:j,prev:$.current}),{current:[],prev:[]}),X(({prev:$})=>$)),[]);oe(z(l,ae($=>$.length>0),he(u,b),X(([$,j,R])=>{const M=$.reduce((F,V,L)=>It(F,V,bs(V,j.offsetTree,R)||L),Mr());return{...j,groupIndices:$,groupOffsetTree:M}})),u),oe(z(o,he(u),ae(([$,{lastIndex:j}])=>$<j),X(([$,{lastIndex:j,lastSize:R}])=>[{endIndex:j,size:R,startIndex:$}])),n),oe(c,f);const x=yt(z(c,X($=>$===void 0)),!0);oe(z(f,ae($=>$!==void 0&&Te(Le(u).sizeTree)),X($=>{const j=Le(m),R=Le(l).length>0;return j!==void 0&&j!==0?R?[{endIndex:0,size:j,startIndex:0},{endIndex:1,size:$,startIndex:1}]:[]:[{endIndex:0,size:$,startIndex:0}]})),n),oe(z(h,ae($=>$!==void 0&&$.length>0&&Te(Le(u).sizeTree)),X($=>{const j=[];let R=$[0],M=0;for(let F=1;F<$.length;F++){const V=$[F];V!==R&&(j.push({endIndex:F-1,size:R,startIndex:M}),R=V,M=F)}return j.push({endIndex:$.length-1,size:R,startIndex:M}),j})),n),oe(z(l,he(m,f),ae(([,$,j])=>$!==void 0&&j!==void 0),X(([$,j,R])=>{const M=[];for(let F=0;F<$.length;F++){const V=$[F],L=$[F+1];M.push({startIndex:V,endIndex:V,size:j}),L!==void 0&&M.push({startIndex:V+1,endIndex:L-1,size:R})}return M})),n);const S=Mt(z(n,he(u),Sn(({sizes:$},[j,R])=>({changed:R!==$,sizes:R}),{changed:!1,sizes:v}),X($=>$.changed)));$e(z(a,Sn(($,j)=>({diff:$.prev-j,prev:j}),{diff:0,prev:0}),X($=>$.diff)),$=>{const{groupIndices:j}=Le(u);if($>0)me(t,!0),me(i,$+Vh($,j));else if($<0){const R=Le(p);R.length>0&&($-=Vh(-$,R)),me(s,$)}}),$e(z(a,he(e)),([$,j])=>{$<0&&j("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},nt.ERROR)});const T=Mt(i);oe(z(i,he(u),X(([$,j])=>{const R=j.groupIndices.length>0,M=[],F=j.lastSize;if(R){const V=gs(j.sizeTree,0);let L=0,U=0;for(;L<$;){const Q=j.groupIndices[U],ee=j.groupIndices.length===U+1?1/0:j.groupIndices[U+1]-Q-1;M.push({endIndex:Q,size:V,startIndex:Q}),M.push({endIndex:Q+1+ee-1,size:F,startIndex:Q+1}),U++,L+=ee+1}const D=Do(j.sizeTree);return L!==$&&D.shift(),D.reduce((Q,{k:ee,v:q})=>{let G=Q.ranges;return Q.prevSize!==0&&(G=[...Q.ranges,{endIndex:ee+$-1,size:Q.prevSize,startIndex:Q.prevIndex}]),{prevIndex:ee+$,prevSize:q,ranges:G}},{prevIndex:$,prevSize:0,ranges:M}).ranges}return Do(j.sizeTree).reduce((V,{k:L,v:U})=>({prevIndex:L+$,prevSize:U,ranges:[...V.ranges,{endIndex:L+$-1,size:V.prevSize,startIndex:V.prevIndex}]}),{prevIndex:0,prevSize:F,ranges:[]}).ranges})),n);const C=Mt(z(s,he(u,b),X(([$,{offsetTree:j},R])=>{const M=-$;return bs(M,j,R)})));return oe(z(s,he(u,b),X(([$,j,R])=>{if(j.groupIndices.length>0){if(Te(j.sizeTree))return j;let F=Mr();const V=Le(p);let L=0,U=0,D=0;for(;L<-$;){D=V[U];const Q=V[U+1]-D-1;U++,L+=Q+1}if(F=Do(j.sizeTree).reduce((Q,{k:ee,v:q})=>It(Q,Math.max(0,ee+$),q),F),L!==-$){const Q=gs(j.sizeTree,D);F=It(F,0,Q);const ee=un(j.sizeTree,-$+1)[1];F=It(F,1,ee)}return{...j,sizeTree:F,...Gd(j.offsetTree,0,F,R)}}const M=Do(j.sizeTree).reduce((F,{k:V,v:L})=>It(F,Math.max(0,V+$),L),Mr());return{...j,sizeTree:M,...Gd(j.offsetTree,0,M,R)}})),u),{beforeUnshiftWith:T,data:g,defaultItemSize:f,firstItemIndex:a,fixedItemSize:c,fixedGroupSize:m,gap:b,groupIndices:l,heightEstimates:h,itemSize:y,listRefresh:S,shiftWith:s,shiftWithOffset:C,sizeRanges:n,sizes:u,statefulTotalCount:r,totalCount:o,trackItemSizes:x,unshiftWith:i}},Ue(ko,uf),{singleton:!0});function mI(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ux=xe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:o,scrollTop:r}])=>{const i=ve(),s=ve(),a=Mt(z(i,X(mI)));return oe(z(a,X(l=>l.totalCount)),n),oe(z(a,X(l=>l.groupIndices)),e),oe(z(Qe(r,t,o),ae(([l,c])=>Bl(c)),X(([l,c,f])=>un(c.groupOffsetTree,Math.max(l-f,0),"v")[0]),Me(),X(l=>[l])),s),{groupCounts:i,topItemsIndexes:s}},Ue(Tn,kt)),To=xe(([{log:e}])=>{const t=W(!1),n=Mt(z(t,ae(o=>o),Me()));return $e(t,o=>{o&&Le(e)("props updated",{},nt.DEBUG)}),{didMount:n,propsReady:t}},Ue(ko),{singleton:!0}),hI=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function px(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!hI)&&(t.behavior="auto"),t.offset===void 0&&(t.offset=0),t}const Ps=xe(([{gap:e,listRefresh:t,sizes:n,totalCount:o},{fixedFooterHeight:r,fixedHeaderHeight:i,footerHeight:s,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:f,viewportHeight:m},{log:h}])=>{const y=ve(),g=ve(),b=W(0);let v=null,u=null,p=null;function x(){v!==null&&(v(),v=null),p!==null&&(p(),p=null),u&&(clearTimeout(u),u=null),me(l,!1)}return oe(z(y,he(n,m,o,b,a,s,h),he(e,i,r),X(([[S,T,C,$,j,R,M,F],V,L,U])=>{const D=px(S),{align:Q,behavior:ee,offset:q}=D,G=$-1,I=dx(D,T,G);let _=bs(I,T.offsetTree,V)+R;Q==="end"?(_+=L+un(T.sizeTree,I)[1]-C+U,I===G&&(_+=M)):Q==="center"?_+=(L+un(T.sizeTree,I)[1]-C+U)/2:_-=j,q!==void 0&&q!==0&&(_+=q);const A=E=>{x(),E?(F("retrying to scroll to",{location:S},nt.DEBUG),me(y,S)):(me(g,!0),F("list did not change, scroll successful",{},nt.DEBUG))};if(x(),ee==="smooth"){let E=!1;p=$e(t,w=>{E=E||w}),v=cn(f,()=>{A(E)})}else v=cn(z(t,yI(150)),A);return u=setTimeout(()=>{x()},1200),me(l,!0),F("scrolling from index to",{behavior:ee,index:I,top:_},nt.DEBUG),{behavior:ee,top:_}})),c),{scrollTargetReached:g,scrollToIndex:y,topListHeight:b}},Ue(Tn,kt,ko),{singleton:!0});function yI(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(n))}}}function ff(e,t){e===0?t():requestAnimationFrame(()=>{ff(e-1,t)})}function mf(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Is=xe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:o},{scrollTargetReached:r,scrollToIndex:i},{didMount:s}])=>{const a=W(!0),l=W(0),c=W(!0);return oe(z(s,he(l),ae(([f,m])=>m!==0),yn(!1)),a),oe(z(s,he(l),ae(([f,m])=>m!==0),yn(!1)),c),$e(z(Qe(t,s),he(a,n,e,c),ae(([[,f],m,{sizeTree:h},y,g])=>f&&(!Te(h)||lf(y))&&!m&&!g),he(l)),([,f])=>{cn(r,()=>{me(c,!0)}),ff(4,()=>{cn(o,()=>{me(a,!0)}),me(i,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},Ue(Tn,kt,Ps,To),{singleton:!0});function fx(e,t){return Math.abs(e-t)<1.01}const xs="up",Bi="down",gI="none",vI={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},bI=0,Os=xe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:o,scrollTop:r,viewportHeight:i}])=>{const s=W(!1),a=W(!0),l=ve(),c=ve(),f=W(4),m=W(bI),h=yt(z(Bd(z(se(r),Qo(1),yn(!0)),z(se(r),Qo(1),yn(!1),Dh(100))),Me()),!1),y=yt(z(Bd(z(n,yn(!0)),z(n,yn(!1),Dh(200))),Me()),!1);oe(z(Qe(se(r),se(m)),X(([p,x])=>p<=x),Me()),a),oe(z(a,On(50)),c);const g=Mt(z(Qe(o,se(i),se(t),se(e),se(f)),Sn((p,[{scrollHeight:x,scrollTop:S},T,C,$,j])=>{const R=S+T-x>-j,M={scrollHeight:x,scrollTop:S,viewportHeight:T};if(R){let V,L;return S>p.state.scrollTop?(V="SCROLLED_DOWN",L=p.state.scrollTop-S):(V="SIZE_DECREASED",L=p.state.scrollTop-S||p.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:L,state:M}}let F;return M.scrollHeight>p.state.scrollHeight?F="SIZE_INCREASED":T<p.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":S<p.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:M}},vI),Me((p,x)=>p!==void 0&&p.atBottom===x.atBottom))),b=yt(z(o,Sn((p,{scrollHeight:x,scrollTop:S,viewportHeight:T})=>{if(!fx(p.scrollHeight,x)){const C=x-(S+T)<1;return p.scrollTop!==S&&C?{changed:!0,jump:p.scrollTop-S,scrollHeight:x,scrollTop:S}:{changed:!0,jump:0,scrollHeight:x,scrollTop:S}}return{changed:!1,jump:0,scrollHeight:x,scrollTop:S}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ae(p=>p.changed),X(p=>p.jump)),0);oe(z(g,X(p=>p.atBottom)),s),oe(z(s,On(50)),l);const v=W(Bi);oe(z(o,X(({scrollTop:p})=>p),Me(),Sn((p,x)=>Le(y)?{direction:p.direction,prevScrollTop:x}:{direction:x<p.prevScrollTop?xs:Bi,prevScrollTop:x},{direction:Bi,prevScrollTop:0}),X(p=>p.direction)),v),oe(z(o,On(50),yn(gI)),v);const u=W(0);return oe(z(h,ae(p=>!p),yn(0)),u),oe(z(r,On(100),he(h),ae(([p,x])=>x),Sn(([p,x],[S])=>[x,S],[0,0]),X(([p,x])=>x-p)),u),{atBottomState:g,atBottomStateChange:l,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:m,isAtBottom:s,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:b,scrollDirection:v,scrollVelocity:u}},Ue(kt)),ws="top",Ss="bottom",Wh="none";function Kh(e,t,n){return typeof e=="number"?n===xs&&t===ws||n===Bi&&t===Ss?e:0:n===xs?t===ws?e.main:e.reverse:t===Ss?e.main:e.reverse}function Gh(e,t){return typeof e=="number"?e:e[t]??0}const hf=xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:o,viewportHeight:r}])=>{const i=ve(),s=W(0),a=W(0),l=W(0),c=yt(z(Qe(se(o),se(r),se(n),se(i,vs),se(l),se(s),se(t),se(e),se(a)),X(([f,m,h,[y,g],b,v,u,p,x])=>{const S=f-p,T=v+u,C=Math.max(h-S,0);let $=Wh;const j=Gh(x,ws),R=Gh(x,Ss);return y-=p,y+=h+u,g+=h+u,g-=p,y>f+T-j&&($=xs),g<f-C+m+R&&($=Bi),$!==Wh?[Math.max(S-h-Kh(b,ws,$)-j,0),S-C-u+m+Kh(b,Ss,$)+R]:null}),ae(f=>f!==null),Me(vs)),[0,0]);return{increaseViewportBy:a,listBoundary:i,overscan:l,topListHeight:s,visibleRange:c}},Ue(kt),{singleton:!0});function xI(e,t,n){if(Bl(t)){const o=cx(e,t);return[{index:un(t.groupOffsetTree,o)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:o,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const jc={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ca(e,t,n,o,r,i){const{lastIndex:s,lastOffset:a,lastSize:l}=r;let c=0,f=0;if(e.length>0){c=e[0].offset;const b=e[e.length-1];f=b.offset+b.size}const m=n-s,h=a+m*l+(m-1)*o,y=c,g=h-f;return{bottom:f,firstItemIndex:i,items:Jh(e,r,i),offsetBottom:g,offsetTop:c,top:y,topItems:Jh(t,r,i),topListHeight:t.reduce((b,v)=>v.size+b,0),totalCount:n}}function mx(e,t,n,o,r,i){let s=0;if(n.groupIndices.length>0)for(const f of n.groupIndices){if(f-s>=e)break;s++}const a=e+s,l=mf(t,a),c=Array.from({length:a}).map((f,m)=>({data:i[m+l],index:m+l,offset:0,size:0}));return Ca(c,[],a,r,n,o)}function Jh(e,t,n){if(e.length===0)return[];if(!Bl(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const o=e[0].index,r=e[e.length-1].index,i=[],s=qr(t.groupOffsetTree,o,r);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=s.shift(),l=t.groupIndices.indexOf(a.start));let f;c.index===a.start?f={index:l,type:"group"}:f={groupIndex:l,index:c.index-(l+1)+n},i.push({...f,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return i}function Qh(e,t){return e===void 0?0:typeof e=="number"?e:e[t]??0}const er=xe(([{data:e,firstItemIndex:t,gap:n,sizes:o,totalCount:r},i,{listBoundary:s,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:f},{topListHeight:m},h,{didMount:y},{recalcInProgress:g}])=>{const b=W([]),v=W(0),u=ve(),p=W(0);oe(i.topItemsIndexes,b);const x=yt(z(Qe(y,g,se(l,vs),se(r),se(o),se(c),f,se(b),se(t),se(n),se(p),e),ae(([$,j,,R,,,,,,,,M])=>{const F=M!==void 0&&M.length!==R;return $&&!j&&!F}),X(([,,[$,j],R,M,F,V,L,U,D,Q,ee])=>{var Y,ie;const q=M,{offsetTree:G,sizeTree:I}=q,_=Le(v);if(R===0)return{...jc,totalCount:R};if($===0&&j===0)return _===0?{...jc,totalCount:R}:mx(_,F,M,U,D,ee||[]);if(Te(I))return _>0?null:Ca(xI(mf(F,R),q,ee),[],R,D,q,U);const A=[];if(L.length>0){const de=L[0],we=L[L.length-1];let ze=0;for(const Ee of qr(I,de,we)){const Se=Ee.value,_e=Math.max(Ee.start,de),Ye=Math.min(Ee.end,we);for(let Pe=_e;Pe<=Ye;Pe++)A.push({data:ee==null?void 0:ee[Pe],index:Pe,offset:ze,size:Se}),ze+=Se}}if(!V)return Ca([],A,R,D,q,U);const E=L.length>0?L[L.length-1]+1:0,w=lI(G,$,j,E);if(w.length===0)return null;const k=R-1,N=Fl([],de=>{for(const we of w){const ze=we.value;let Ee=ze.offset,Se=we.start;const _e=ze.size;if(ze.offset<$){Se+=Math.floor(($-ze.offset+D)/(_e+D));const Pe=Se-we.start;Ee+=Pe*_e+Pe*D}Se<E&&(Ee+=(E-Se)*_e,Se=E);const Ye=Math.min(we.end,k);for(let Pe=Se;Pe<=Ye&&!(Ee>=j);Pe++)de.push({data:ee==null?void 0:ee[Pe],index:Pe,offset:Ee,size:_e}),Ee+=_e+D}}),B=Qh(Q,ws),O=Qh(Q,Ss);if(N.length>0&&(B>0||O>0)){const de=N[0],we=N[N.length-1];if(B>0&&de.index>E){const ze=Math.min(B,de.index-E),Ee=[];let Se=de.offset;for(let _e=de.index-1;_e>=de.index-ze;_e--){const Ye=((Y=qr(I,_e,_e)[0])==null?void 0:Y.value)??de.size;Se-=Ye+D,Ee.unshift({data:ee==null?void 0:ee[_e],index:_e,offset:Se,size:Ye})}N.unshift(...Ee)}if(O>0&&we.index<k){const ze=Math.min(O,k-we.index);let Ee=we.offset+we.size+D;for(let Se=we.index+1;Se<=we.index+ze;Se++){const _e=((ie=qr(I,Se,Se)[0])==null?void 0:ie.value)??we.size;N.push({data:ee==null?void 0:ee[Se],index:Se,offset:Ee,size:_e}),Ee+=_e+D}}}return Ca(N,A,R,D,q,U)}),ae($=>$!==null),Me()),jc);oe(z(e,ae(lf),X($=>$==null?void 0:$.length)),r),oe(z(x,X($=>$.topListHeight)),m),oe(m,a),oe(z(x,X($=>[$.top,$.bottom])),s),oe(z(x,X($=>$.items)),u);const S=Mt(z(x,ae(({items:$})=>$.length>0),he(r,e),ae(([{items:$},j])=>$[$.length-1].originalIndex===j-1),X(([,$,j])=>[$-1,j]),Me(vs),X(([$])=>$))),T=Mt(z(x,On(200),ae(({items:$,topItems:j})=>$.length>0&&$[0].originalIndex===j.length),X(({items:$})=>$[0].index),Me())),C=Mt(z(x,ae(({items:$})=>$.length>0),X(({items:$})=>{let j=0,R=$.length-1;for(;$[j].type==="group"&&j<R;)j++;for(;$[R].type==="group"&&R>j;)R--;return{endIndex:$[R].index,startIndex:$[j].index}}),Me(ax)));return{endReached:S,initialItemCount:v,itemsRendered:u,listState:x,minOverscanItemCount:p,rangeChanged:C,startReached:T,topItemsIndexes:b,...h}},Ue(Tn,ux,hf,Is,Ps,Os,To,uf),{singleton:!0}),hx=xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:o},{listState:r}])=>{const i=ve(),s=yt(z(Qe(n,e,o,t,r),X(([a,l,c,f,m])=>a+l+c+f+m.offsetBottom+m.bottom)),0);return oe(se(s),i),{totalListHeight:s,totalListHeightChanged:i}},Ue(kt,er),{singleton:!0}),wI=xe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),o=yt(z(Qe(n,e,t),ae(([r])=>r),X(([,r,i])=>Math.max(0,r-i)),On(0),Me()),0);return{alignToBottom:n,paddingTopAddition:o}},Ue(kt,hx),{singleton:!0}),yx=xe(()=>({context:W(null)})),SI=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:o,...r},viewportBottom:i,viewportTop:s})=>t<s?{...r,align:n??"start",...o!==void 0?{behavior:o}:{}}:e>i?{...r,align:n??"end",...o!==void 0?{behavior:o}:{}}:null,gx=xe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:o,fixedHeaderHeight:r,headerHeight:i,scrollingInProgress:s,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const f=ve();return oe(z(f,he(t,l,n,i,r,o,a),he(e),X(([[m,h,y,g,b,v,u,p],x])=>{const{calculateViewLocation:S=SI,done:T,...C}=m,$=dx(m,h,g-1),j=bs($,h.offsetTree,x)+b+v,R=j+un(h.sizeTree,$)[1],M=p+v,F=p+y-u,V=S({itemBottom:R,itemTop:j,locationParams:C,viewportBottom:F,viewportTop:M});return V!==null?T&&cn(z(s,ae(L=>!L),Qo(Le(s)?1:2)),T):T==null||T(),V}),ae(m=>m!==null)),c),{scrollIntoView:f}},Ue(Tn,kt,Ps,er,ko),{singleton:!0});function Yh(e){return e===!1?!1:e==="smooth"?"smooth":"auto"}const $I=(e,t)=>typeof e=="function"?Yh(e(t)):t&&Yh(e),kI=xe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:o},{atBottomState:r,isAtBottom:i},{scrollToIndex:s},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:f},{scrollingInProgress:m},{context:h},{scrollIntoView:y}])=>{const g=W(!1),b=ve();let v=null;function u(T){me(s,{align:"end",behavior:T,index:"LAST"})}$e(z(Qe(z(se(t),Qo(1)),l),he(se(g),i,a,m),X(([[T,C],$,j,R,M])=>{let F=C&&R,V="auto";return F&&(V=$I($,j||M),F=F&&V!==!1),{followOutputBehavior:V,shouldFollow:F,totalCount:T}}),ae(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{v!==null&&(v(),v=null),Le(n)!==void 0?requestAnimationFrame(()=>{Le(f)("following output to ",{totalCount:C},nt.DEBUG),u(T)}):v=cn(e,()=>{Le(f)("following output to ",{totalCount:C},nt.DEBUG),u(T),v=null})});function p(T){const C=cn(r,$=>{T&&!$.atBottom&&$.notAtBottomBecause==="SIZE_INCREASED"&&v===null&&(Le(f)("scrolling to bottom due to increased size",{},nt.DEBUG),u("auto"))});setTimeout(C,100)}$e(z(Qe(se(g),t,c),ae(([T,,C])=>T!==!1&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),ae(({refreshed:T})=>T),he(g,t)),([,T])=>{Le(a)&&p(T!==!1)}),$e(b,()=>{p(Le(g)!==!1)}),$e(Qe(se(g),r),([T,C])=>{T!==!1&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&u("auto")});const x=W(null),S=ve();return oe(Bd(z(se(o),X(T=>(T==null?void 0:T.length)??0)),z(se(t))),S),$e(z(Qe(z(S,Qo(1)),l),he(se(x),a,m,h),X(([[T,C],$,j,R,M])=>C&&j&&($==null?void 0:$({context:M,totalCount:T,scrollingInProgress:R}))),ae(T=>!!T),On(0)),T=>{v!==null&&(v(),v=null),Le(n)!==void 0?requestAnimationFrame(()=>{Le(f)("scrolling into view",{}),me(y,T)}):v=cn(e,()=>{Le(f)("scrolling into view",{}),me(y,T),v=null})}),{autoscrollToBottom:b,followOutput:g,scrollIntoViewOnChange:x}},Ue(Tn,Os,Ps,Is,To,ko,kt,yx,gx)),TI=xe(([{data:e,firstItemIndex:t,gap:n,sizes:o},{initialTopMostItemIndex:r},{initialItemCount:i,listState:s},{didMount:a}])=>(oe(z(a,he(i),ae(([,l])=>l!==0),he(r,o,t,n,e),X(([[,l],c,f,m,h,y=[]])=>mx(l,c,f,m,h,y))),s),{}),Ue(Tn,Is,er,To),{singleton:!0}),_I=xe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const o=W(0);return $e(z(e,he(o),ae(([,r])=>r!==0),X(([,r])=>({top:r}))),r=>{cn(z(n,Qo(1),ae(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{me(t,r)})})}),{initialScrollTop:o}},Ue(To,kt,er),{singleton:!0}),vx=xe(([{scrollVelocity:e}])=>{const t=W(!1),n=ve(),o=W(!1);return oe(z(e,he(o,t,n),ae(([r,i])=>i!==!1&&i!==void 0),X(([r,i,s,a])=>{const{enter:l,exit:c}=i;if(s){if(c(r,a))return!1}else if(l(r,a))return!0;return s}),Me()),t),$e(z(Qe(t,e,n),he(o)),([[r,i,s],a])=>{r&&a!==!1&&a!==void 0&&a.change&&a.change(i,s)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:n,scrollVelocity:e}},Ue(Os),{singleton:!0}),yf=xe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ve(),o=ve(),r=ve(),i=W(!1),s=W(void 0);return oe(z(Qe(n,o),X(([{scrollTop:a,viewportHeight:l},{offsetTop:c,listHeight:f}])=>({scrollHeight:f,scrollTop:Math.max(0,a-c),viewportHeight:l}))),e),oe(z(t,he(o),X(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),r),{customScrollParent:s,useWindowScroll:i,windowScrollContainerState:n,windowScrollTo:r,windowViewportRect:o}},Ue(kt)),jI=xe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:o},{initialTopMostItemIndex:r},{didMount:i},{useWindowScroll:s,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ve(),f=W(void 0),m=W(null),h=W(null);return oe(a,m),oe(l,h),$e(z(c,he(t,o,s,m,h,n)),([y,g,b,v,u,p,x])=>{const S=dI(g.sizeTree);v&&u!==null&&p!==null&&(b=u.scrollTop-p.offsetTop),b-=x,y({ranges:S,scrollTop:b})}),oe(z(f,ae(lf),X(NI)),r),oe(z(i,he(f),ae(([,y])=>y!==void 0),Me(),X(([,y])=>y.ranges)),e),{getState:c,restoreStateFrom:f}},Ue(Tn,kt,Is,To,yf));function NI(e){return{align:"start",index:0,offset:e.scrollTop}}const CI=xe(([{topItemsIndexes:e}])=>{const t=W(0);return oe(z(t,ae(n=>n>=0),X(n=>Array.from({length:n}).map((o,r)=>r))),e),{topItemCount:t}},Ue(er));function bx(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EI=bx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),PI=xe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:o},{isAtBottom:r,isScrolling:i,lastJumpDueToItemResize:s,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:f,shiftWithOffset:m,sizes:h},{log:y},{recalcInProgress:g}])=>{const b=Mt(z(l,he(s),Sn(([,u,p,x],[{bottom:S,items:T,offsetBottom:C,totalCount:$},j])=>{const R=S+C;let M=0;return p===$&&u.length>0&&T.length>0&&(T[0].originalIndex===0&&u[0].originalIndex===0||(M=R-x,M!==0&&(M+=j))),[M,T,$,R]},[0,[],0,0]),ae(([u])=>u!==0),he(o,a,n,r,y,g),ae(([,u,p,x,,,S])=>!S&&!x&&u!==0&&p===xs),X(([[u],,,,,p])=>(p("Upward scrolling compensation",{amount:u},nt.DEBUG),u))));function v(u){u>0?(me(t,{behavior:"auto",top:-u}),me(e,0)):(me(e,0),me(t,{behavior:"auto",top:-u}))}return $e(z(b,he(e,i)),([u,p,x])=>{x&&EI()?me(e,p-u):v(-u)}),$e(z(Qe(yt(i,!1),e,g),ae(([u,p,x])=>!u&&!x&&p!==0),X(([u,p])=>p),On(1)),v),oe(z(m,X(u=>({top:-u}))),t),$e(z(c,he(h,f),X(([u,{groupIndices:p,lastSize:x,sizeTree:S},T])=>{function C(F){return F*(x+T)}if(p.length===0)return C(u);let $=0;const j=gs(S,0);let R=0,M=0;for(;R<u;){R++,$+=j;let F=p.length===M+1?1/0:p[M+1]-p[M]-1;R+F>u&&($-=j,F=u-R+1),R+=F,$+=C(F),M++}return $})),u=>{me(e,u),requestAnimationFrame(()=>{me(t,{top:u}),requestAnimationFrame(()=>{me(e,0),me(g,!1)})})}),{deviation:e}},Ue(kt,Os,er,Tn,ko,uf)),II=xe(([e,t,n,o,r,i,s,a,l,c,f])=>({...e,...t,...n,...o,...r,...i,...s,...a,...l,...c,...f}),Ue(hf,TI,To,vx,hx,_I,wI,yf,gx,ko,yx)),xx=xe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:o,fixedGroupSize:r,gap:i,groupIndices:s,heightEstimates:a,itemSize:l,sizeRanges:c,sizes:f,statefulTotalCount:m,totalCount:h,trackItemSizes:y},{initialItemFinalLocationReached:g,initialTopMostItemIndex:b,scrolledToInitialItem:v},u,p,x,S,{scrollToIndex:T},C,{topItemCount:$},{groupCounts:j},R])=>{const{listState:M,minOverscanItemCount:F,topItemsIndexes:V,rangeChanged:L,...U}=S;return oe(L,R.scrollSeekRangeChanged),oe(z(R.windowViewportRect,X(D=>D.visibleHeight)),u.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:o,fixedGroupHeight:r,gap:i,groupCounts:j,heightEstimates:a,initialItemFinalLocationReached:g,initialTopMostItemIndex:b,scrolledToInitialItem:v,sizeRanges:c,topItemCount:$,topItemsIndexes:V,totalCount:h,...x,groupIndices:s,itemSize:l,listState:M,minOverscanItemCount:F,scrollToIndex:T,statefulTotalCount:m,trackItemSizes:y,rangeChanged:L,...U,...R,...u,sizes:f,...p}},Ue(Tn,Is,kt,jI,kI,er,Ps,PI,CI,ux,II));function OI(e,t){const n={},o={};let r=0;const i=e.length;for(;r<i;)o[e[r]]=1,r+=1;for(const s in t)Object.hasOwn(o,s)||(n[s]=t[s]);return n}const ra=typeof document<"u"?te.useLayoutEffect:te.useEffect;function wx(e,t,n){const o=Object.keys(t.required||{}),r=Object.keys(t.optional||{}),i=Object.keys(t.methods||{}),s=Object.keys(t.events||{}),a=te.createContext({});function l(v,u){v.propsReady!==void 0&&me(v.propsReady,!1);for(const p of o){const x=v[t.required[p]];me(x,u[p])}for(const p of r)if(p in u){const x=v[t.optional[p]];me(x,u[p])}v.propsReady!==void 0&&me(v.propsReady,!0)}function c(v){return i.reduce((u,p)=>(u[p]=x=>{const S=v[t.methods[p]];me(S,x)},u),{})}function f(v){return s.reduce((u,p)=>(u[p]=GP(v[t.events[p]]),u),{})}const m=te.forwardRef(function(v,u){const{children:p,...x}=v,[S]=te.useState(()=>Fl(QP(e),$=>{l($,x)})),[T]=te.useState(Lh(f,S));ra(()=>{for(const $ of s)$ in x&&$e(T[$],x[$]);return()=>{Object.values(T).map(cf)}},[x,T,S]),ra(()=>{l(S,x)}),te.useImperativeHandle(u,Uh(c(S)));const C=n;return d.jsx(a.Provider,{value:S,children:n!==void 0?d.jsx(C,{...OI([...o,...r,...s],x),children:p}):p})}),h=v=>{const u=te.useContext(a);return te.useCallback(p=>{me(u[v],p)},[u,v])},y=v=>{const u=te.useContext(a)[v],p=te.useCallback(x=>$e(u,x),[u]);return te.useSyncExternalStore(p,()=>Le(u),()=>Le(u))},g=v=>{const u=te.useContext(a)[v],[p,x]=te.useState(Lh(Le,u));return ra(()=>$e(u,S=>{S!==p&&x(Uh(S))}),[u,p]),p},b=parseInt(te.version)>=18?y:g;return{Component:m,useEmitter:(v,u)=>{const p=te.useContext(a)[v];ra(()=>$e(p,u),[u,p])},useEmitterValue:b,usePublisher:h}}const Sx=te.createContext(void 0),$x=te.createContext(void 0),Nc="-webkit-sticky",Xh="sticky",gf=bx(()=>{if(typeof document>"u")return Xh;const e=document.createElement("div");return e.style.position=Nc,e.style.position===Nc?Nc:Xh}),kx=typeof document<"u"?te.useLayoutEffect:te.useEffect;function Cc(e){return"self"in e}function RI(e){return"body"in e}function Tx(e,t,n,o=ri,r,i){const s=te.useRef(null),a=te.useRef(null),l=te.useRef(null),c=te.useCallback(h=>{let y,g,b;const v=h.target;if(RI(v)||Cc(v)){const p=Cc(v)?v:v.defaultView;b=i===!0?Lo(p,p.scrollX):p.scrollY,y=i===!0?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,g=i===!0?p.innerWidth:p.innerHeight}else b=i===!0?Lo(v,v.scrollLeft):v.scrollTop,y=i===!0?v.scrollWidth:v.scrollHeight,g=i===!0?v.offsetWidth:v.offsetHeight;const u=()=>{e({scrollHeight:y,scrollTop:Math.max(b,0),viewportHeight:g})};h.suppressFlushSync===!0?u():iS.flushSync(u),a.current!==null&&(b===a.current||b<=0||b===y-g)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,i]);te.useEffect(()=>{const h=r||s.current;return zh(h),o(r||s.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{zh(h),o(null),h.removeEventListener("scroll",c)}},[s,c,n,o,r]);function f(h){const y=s.current;if(!y||(i===!0?"offsetWidth"in y&&y.offsetWidth===0:"offsetHeight"in y&&y.offsetHeight===0))return;const g=h.behavior==="smooth";let b,v,u;Cc(y)?(v=Math.max(bo(y.document.documentElement,i===!0?"width":"height"),i===!0?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight),b=i===!0?y.innerWidth:y.innerHeight,u=i===!0?Lo(y,y.scrollX):y.scrollY):(v=y[i===!0?"scrollWidth":"scrollHeight"],b=bo(y,i===!0?"width":"height"),u=i===!0?Lo(y,y.scrollLeft):y.scrollTop);const p=v-b;if(h.top===void 0){y.scrollTo(h);return}const x=Math.ceil(Math.max(Math.min(p,h.top),0));if(h.top=x,fx(b,v)||x===u){e({scrollHeight:v,scrollTop:u,viewportHeight:b}),g&&t(!0);return}g?(a.current=x,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,i===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:Fh(y,x)}),y.scrollTo(h)}function m(h){i===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:Fh(s.current,h.top)}:{}}),s.current.scrollBy(h)}return{scrollByCallback:m,scrollerRef:s,scrollToCallback:f}}function vf(e){return e}const AI=xe(()=>{const e=W(a=>`Item ${a}`),t=W(a=>`Group ${a}`),n=W({}),o=W(vf),r=W("div"),i=W(ri),s=(a,l=null)=>yt(z(n,X(c=>c[a]),Me()),l);return{components:n,computeItemKey:o,EmptyPlaceholder:s("EmptyPlaceholder"),FooterComponent:s("Footer"),GroupComponent:s("Group","div"),groupContent:t,HeaderComponent:s("Header"),HeaderFooterTag:r,ItemComponent:s("Item","div"),itemContent:e,ListComponent:s("List","div"),ScrollerComponent:s("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:s("ScrollSeekPlaceholder"),TopItemListComponent:s("TopItemList")}}),MI=xe(([e,t])=>({...e,...t}),Ue(xx,AI)),qI=({height:e})=>d.jsx("div",{style:{height:e}}),UI={overflowAnchor:"none",position:gf(),zIndex:1},_x={overflowAnchor:"none"},LI={..._x,display:"inline-block",height:"100%"},Zh=te.memo(function({showTopList:e=!1}){const t=ce("listState"),n=Wt("sizeRanges"),o=ce("useWindowScroll"),r=ce("customScrollParent"),i=Wt("windowScrollContainerState"),s=Wt("scrollContainerState"),a=r||o?i:s,l=ce("itemContent"),c=ce("context"),f=ce("groupContent"),m=ce("trackItemSizes"),h=ce("itemSize"),y=ce("log"),g=Wt("gap"),b=ce("horizontalDirection"),{callbackRef:v}=eI(n,h,m,e?ri:a,y,g,r,b,ce("skipAnimationFrameInResizeObserver")),[u,p]=te.useState(0);xf("deviation",U=>{u!==U&&p(U)});const x=ce("EmptyPlaceholder"),S=ce("ScrollSeekPlaceholder")??qI,T=ce("ListComponent"),C=ce("ItemComponent"),$=ce("GroupComponent"),j=ce("computeItemKey"),R=ce("isSeeking"),M=ce("groupIndices").length>0,F=ce("alignToBottom"),V=ce("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...b?{display:"inline-block",height:"100%",marginInlineStart:u!==0?u:F?"auto":0,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:"nowrap"}:{marginTop:u!==0?u:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&x!==null&&x!==void 0?d.jsx(x,{...ht(x,c)}):d.jsx(T,{...ht(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:L,children:(e?t.topItems:t.items).map(U=>{const D=U.originalIndex,Q=j(D+t.firstItemIndex,U.data,c);return R?P.createElement(S,{...ht(S,c),height:U.size,index:U.index,key:Q,type:U.type||"item",...U.type==="group"?{}:{groupIndex:U.groupIndex}}):U.type==="group"?P.createElement($,{...ht($,c),"data-index":D,"data-item-index":U.index,"data-known-size":U.size,key:Q,style:UI},f(U.index,c)):P.createElement(C,{...ht(C,c),...BI(C,U.data),"data-index":D,"data-item-group-index":U.groupIndex,"data-item-index":U.index,"data-known-size":U.size,key:Q,style:b?LI:_x},M?l(U.index,U.groupIndex,U.data,c):l(U.index,U.data,c))})})}),DI={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},zI={outline:"none",overflowX:"auto",position:"relative"},bf=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:void 0}),jx=(e,t,n=0)=>({...bf(e),position:t?"relative":"absolute",top:t?-n:0}),FI={position:gf(),top:0,width:"100%",zIndex:1};function ht(e,t){if(typeof e!="string")return{context:t}}function BI(e,t){return{item:typeof e=="string"?void 0:t}}const HI=te.memo(function(){const e=ce("HeaderComponent"),t=Wt("headerHeight"),n=ce("HeaderFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,ce("skipAnimationFrameInResizeObserver")),r=ce("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),VI=te.memo(function(){const e=ce("FooterComponent"),t=Wt("footerHeight"),n=ce("HeaderFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,ce("skipAnimationFrameInResizeObserver")),r=ce("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null});function Nx({useEmitter:e,useEmitterValue:t,usePublisher:n}){return te.memo(function({children:o,style:r,context:i,...s}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),f=t("scrollerRef"),m=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:y,scrollToCallback:g}=Tx(a,c,l,f,void 0,m);return e("scrollTo",g),e("scrollBy",h),d.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:y,style:{...m?zI:DI,...r},tabIndex:0,...s,...ht(l,i),children:o})})}function Cx({useEmitter:e,useEmitterValue:t,usePublisher:n}){return te.memo(function({children:o,style:r,context:i,...s}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),f=t("totalListHeight"),m=t("deviation"),h=t("customScrollParent"),y=te.useRef(null),g=t("scrollerRef"),{scrollByCallback:b,scrollerRef:v,scrollToCallback:u}=Tx(a,c,l,g,h);return kx(()=>{var p;return v.current=h||((p=y.current)==null?void 0:p.ownerDocument.defaultView),()=>{v.current=null}},[v,h]),e("windowScrollTo",u),e("scrollBy",b),d.jsx(l,{ref:y,"data-virtuoso-scroller":!0,style:{position:"relative",...r,...f!==0?{height:f+m}:void 0},...s,...ht(l,i),children:o})})}const WI=({children:e})=>{const t=te.useContext(Sx),n=Wt("viewportHeight"),o=Wt("fixedItemHeight"),r=ce("alignToBottom"),i=ce("horizontalDirection"),s=te.useMemo(()=>Yb(n,l=>bo(l,i?"width":"height")),[n,i]),a=Zo(s,!0,ce("skipAnimationFrameInResizeObserver"));return te.useEffect(()=>{t&&(n(t.viewportHeight),o(t.itemHeight))},[t,n,o]),d.jsx("div",{"data-viewport-type":"element",ref:a,style:bf(r),children:e})},KI=({children:e})=>{const t=te.useContext(Sx),n=Wt("windowViewportRect"),o=Wt("fixedItemHeight"),r=ce("customScrollParent"),i=ce("useWindowScroll"),s=ce("topListHeight"),a=tx(n,r,ce("skipAnimationFrameInResizeObserver")),l=ce("alignToBottom");return te.useEffect(()=>{t&&(o(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,o]),d.jsx("div",{"data-viewport-type":"window",ref:a,style:jx(l,i,s),children:e})},GI=({children:e})=>{const t=ce("TopItemListComponent")??"div",n=ce("headerHeight"),o={...FI,marginTop:`${n}px`},r=ce("context");return d.jsx(t,{style:o,...ht(t,r),children:e})},JI=te.memo(function(e){const t=ce("useWindowScroll"),n=ce("topItemsIndexes").length>0,o=ce("customScrollParent"),r=ce("context");return d.jsxs(o||t?XI:YI,{...e,context:r,children:[n&&d.jsx(GI,{children:d.jsx(Zh,{showTopList:!0})}),d.jsxs(o||t?KI:WI,{children:[d.jsx(HI,{}),d.jsx(Zh,{}),d.jsx(VI,{})]})]})}),{Component:QI,useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}=wx(MI,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},JI),YI=Nx({useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}),XI=Cx({useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}),ZI=QI,eO=xe(()=>{const e=W(c=>d.jsxs("td",{children:["Item $",c]})),t=W(null),n=W(c=>d.jsxs("td",{colSpan:1e3,children:["Group ",c]})),o=W(null),r=W(null),i=W({}),s=W(vf),a=W(ri),l=(c,f=null)=>yt(z(i,X(m=>m[c]),Me()),f);return{components:i,computeItemKey:s,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:r,fixedHeaderContent:o,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});Ue(xx,eO);gf();const ey={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},tO={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ty,floor:pl,max:Hi,min:Ec,round:ny}=Math;function oy(e,t,n){return Array.from({length:t-e+1}).map((o,r)=>({data:n===null?null:n[r+e],index:r+e}))}function nO(e){return{...tO,items:e}}function ia(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function oO(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}const rO=xe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:o},{footerHeight:r,headerHeight:i,scrollBy:s,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:f,viewportHeight:m},h,y,{didMount:g,propsReady:b},{customScrollParent:v,useWindowScroll:u,windowScrollContainerState:p,windowScrollTo:x,windowViewportRect:S},T])=>{const C=W(0),$=W(0),j=W(ey),R=W({height:0,width:0}),M=W({height:0,width:0}),F=ve(),V=ve(),L=W(0),U=W(null),D=W({column:0,row:0}),Q=ve(),ee=ve(),q=W(!1),G=W(0),I=W(!0),_=W(!1),A=W(!1);$e(z(g,he(G),ae(([O,Y])=>Y!==0)),()=>{me(I,!1)}),$e(z(Qe(g,I,M,R,G,_),ae(([O,Y,ie,de,,we])=>O&&!Y&&ie.height!==0&&de.height!==0&&!we)),([,,,,O])=>{me(_,!0),ff(1,()=>{me(F,O)}),cn(z(c),()=>{me(t,[0,0]),me(I,!0)})}),oe(z(ee,ae(O=>O!=null&&O.scrollTop>0),yn(0)),$),$e(z(g,he(ee),ae(([,O])=>O!=null)),([,O])=>{O&&(me(R,O.viewport),me(M,O.item),me(D,O.gap),O.scrollTop>0&&(me(q,!0),cn(z(c,Qo(1)),Y=>{me(q,!1)}),me(l,{top:O.scrollTop})))}),oe(z(R,X(({height:O})=>O)),m),oe(z(Qe(se(R,ia),se(M,ia),se(D,(O,Y)=>O!==void 0&&O.column===Y.column&&O.row===Y.row),se(c)),X(([O,Y,ie,de])=>({gap:ie,item:Y,scrollTop:de,viewport:O}))),Q),oe(z(Qe(se(C),o,se(D,oO),se(M,ia),se(R,ia),se(U),se($),se(q),se(I),se(G)),ae(([,,,,,,,O])=>!O),X(([O,[Y,ie],de,we,ze,Ee,Se,,_e,Ye])=>{const{column:Pe,row:_n}=de,{height:Bn,width:_o}=we,{width:tr}=ze;if(Se===0&&(O===0||tr===0))return ey;if(_o===0){const wf=mf(Ye,O),Ox=wf+Math.max(Se-1,0);return nO(oy(wf,Ox,Ee))}const Hn=Ex(tr,_o,Pe);let pn,Yt;_e?Y===0&&ie===0&&Se>0?(pn=0,Yt=Se-1):(pn=Hn*pl((Y+_n)/(Bn+_n)),Yt=Hn*ty((ie+_n)/(Bn+_n))-1,Yt=Ec(O-1,Hi(Yt,Hn-1)),pn=Ec(Yt,Hi(0,pn))):(pn=0,Yt=-1);const Vn=oy(pn,Yt,Ee),{bottom:nr,top:ii}=ry(ze,de,we,Vn),si=ty(O/Hn),Hl=si*Bn+(si-1)*_n-nr;return{bottom:nr,itemHeight:Bn,items:Vn,itemWidth:_o,offsetBottom:Hl,offsetTop:ii,top:ii}})),j),oe(z(U,ae(O=>O!==null),X(O=>O.length)),C),oe(z(Qe(R,M,j,D),ae(([O,Y,{items:ie}])=>ie.length>0&&Y.height!==0&&O.height!==0),X(([O,Y,{items:ie},de])=>{const{bottom:we,top:ze}=ry(O,de,Y,ie);return[ze,we]}),Me(vs)),t);const E=W(!1);oe(z(c,he(E),X(([O,Y])=>Y||O!==0)),E);const w=Mt(z(Qe(j,C),ae(([{items:O}])=>O.length>0),he(E),ae(([[O,Y],ie])=>{const de=O.items[O.items.length-1].index===Y-1;return(ie||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===Y)&&de}),X(([[,O]])=>O-1),Me())),k=Mt(z(se(j),ae(({items:O})=>O.length>0&&O[0].index===0),yn(0),Me())),N=Mt(z(se(j),he(q),ae(([{items:O},Y])=>O.length>0&&!Y),X(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),Me(ax),On(0)));oe(N,y.scrollSeekRangeChanged),oe(z(F,he(R,M,C,D),X(([O,Y,ie,de,we])=>{const ze=px(O),{align:Ee,behavior:Se,offset:_e}=ze;let Ye=ze.index;Ye==="LAST"&&(Ye=de-1),Ye=Hi(0,Ye,Ec(de-1,Ye));let Pe=Jd(Y,we,ie,Ye);return Ee==="end"?Pe=ny(Pe-Y.height+ie.height):Ee==="center"&&(Pe=ny(Pe-Y.height/2+ie.height/2)),_e!==void 0&&_e!==0&&(Pe+=_e),{behavior:Se,top:Pe}})),l);const B=yt(z(j,X(O=>O.offsetBottom+O.bottom)),0);return oe(z(S,X(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:v,data:U,deviation:L,footerHeight:r,gap:D,headerHeight:i,increaseViewportBy:e,initialItemCount:$,itemDimensions:M,overscan:n,restoreStateFrom:ee,scrollBy:s,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:f,totalCount:C,useWindowScroll:u,viewportDimensions:R,windowScrollContainerState:p,windowScrollTo:x,windowViewportRect:S,...y,gridState:j,horizontalDirection:A,initialTopMostItemIndex:G,totalListHeight:B,...h,endReached:w,propsReady:b,rangeChanged:N,startReached:k,stateChanged:Q,stateRestoreInProgress:q,...T}},Ue(hf,kt,Os,vx,To,yf,ko));function Ex(e,t,n){return Hi(1,pl((e+n)/(pl(t)+n)))}function ry(e,t,n,o){const{height:r}=n;if(r===void 0||o.length===0)return{bottom:0,top:0};const i=Jd(e,t,n,o[0].index);return{bottom:Jd(e,t,n,o[o.length-1].index)+r,top:i}}function Jd(e,t,n,o){const r=Ex(e.width,n.width,t.column),i=pl(o/r),s=i*n.height+Hi(0,i-1)*t.row;return s>0?s+t.row:s}const iO=xe(()=>{const e=W(m=>`Item ${m}`),t=W({}),n=W(null),o=W("virtuoso-grid-item"),r=W("virtuoso-grid-list"),i=W(vf),s=W("div"),a=W(ri),l=(m,h=null)=>yt(z(t,X(y=>y[m]),Me()),h),c=W(!1),f=W(!1);return oe(se(f),c),{components:t,computeItemKey:i,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:s,itemClassName:o,ItemComponent:l("Item","div"),itemContent:e,listClassName:r,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:f,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),sO=xe(([e,t])=>({...e,...t}),Ue(rO,iO)),aO=te.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),o=Re("itemContent"),r=Re("computeItemKey"),i=Re("isSeeking"),s=Kt("scrollHeight"),a=Re("ItemComponent"),l=Re("ListComponent"),c=Re("ScrollSeekPlaceholder"),f=Re("context"),m=Kt("itemDimensions"),h=Kt("gap"),y=Re("log"),g=Re("stateRestoreInProgress"),b=Kt("reportReadyState"),v=Zo(te.useMemo(()=>u=>{const p=u.parentElement.parentElement.scrollHeight;s(p);const x=u.firstChild;if(x!==null){const{height:S,width:T}=x.getBoundingClientRect();m({height:S,width:T})}h({column:iy("column-gap",getComputedStyle(u).columnGap,y),row:iy("row-gap",getComputedStyle(u).rowGap,y)})},[s,m,h,y]),!0,!1);return kx(()=>{e.itemHeight>0&&e.itemWidth>0&&b(!0)},[e]),g?null:d.jsx(l,{className:t,ref:v,...ht(l,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(u=>{const p=r(u.index,u.data,f);return i?d.jsx(c,{...ht(c,f),height:e.itemHeight,index:u.index,width:e.itemWidth},p):P.createElement(a,{...ht(a,f),className:n,"data-index":u.index,key:p},o(u.index,u.data,f))})})}),lO=te.memo(function(){const e=Re("HeaderComponent"),t=Kt("headerHeight"),n=Re("headerFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,!1),r=Re("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),cO=te.memo(function(){const e=Re("FooterComponent"),t=Kt("footerHeight"),n=Re("headerFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,!1),r=Re("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),dO=({children:e})=>{const t=te.useContext($x),n=Kt("itemDimensions"),o=Kt("viewportDimensions"),r=Zo(te.useMemo(()=>i=>{o(i.getBoundingClientRect())},[o]),!0,!1);return te.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,o,n]),d.jsx("div",{ref:r,style:bf(!1),children:e})},uO=({children:e})=>{const t=te.useContext($x),n=Kt("windowViewportRect"),o=Kt("itemDimensions"),r=Re("customScrollParent"),i=Re("useWindowScroll"),s=tx(n,r,!1);return te.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,o]),d.jsx("div",{ref:s,style:jx(!1,i),children:e})},pO=te.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),o=n||t?mO:fO,r=n||t?uO:dO,i=Re("context");return d.jsx(o,{...e,...ht(o,i),children:d.jsxs(r,{children:[d.jsx(lO,{}),d.jsx(aO,{}),d.jsx(cO,{})]})})}),{useEmitter:Px,useEmitterValue:Re,usePublisher:Kt}=wx(sO,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},pO),fO=Nx({useEmitter:Px,useEmitterValue:Re,usePublisher:Kt}),mO=Cx({useEmitter:Px,useEmitterValue:Re,usePublisher:Kt});function iy(e,t,n){return t!=="normal"&&(t==null?void 0:t.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function hO(e){var o,r,i;if(e.kind!=="notification"||e.method!=="session/update")return null;const t=e.payload;if(!t||typeof t!="object")return null;const n=t.params;return!n||((o=n.update)==null?void 0:o.sessionUpdate)!=="agent_message_chunk"?null:{sessionId:String(n.sessionId??""),text:((i=(r=n.update)==null?void 0:r.content)==null?void 0:i.text)??""}}function yO(e){const t=[];let n=null;const o=()=>{if(n){if(n.messages.length===1){const r=n.messages[0];t.push({type:"message",message:r})}else{const r=n.messages[0],i=n.messages[n.messages.length-1];t.push({type:"stream-cluster",sessionId:n.sessionId,messages:n.messages,firstSeq:r.seq,lastSeq:i.seq,combinedText:n.text,firstTimestamp:r.timestamp,lastTimestamp:i.timestamp})}n=null}};for(const r of e){const i=hO(r);if(i&&n&&n.sessionId===i.sessionId){n.messages.push(r),n.text+=i.text;continue}o(),i?n={sessionId:i.sessionId,messages:[r],text:i.text}:t.push({type:"message",message:r})}return o(),t}function gO(e){var n;if(!e.payload||typeof e.payload!="object")return null;const t=e.payload.params;if(!t||typeof t!="object")return null;if(e.method==="session/prompt"){const o=t.prompt;if(!Array.isArray(o))return null;const r=[];for(const s of o)(s==null?void 0:s.type)==="text"&&typeof s.text=="string"&&r.push(s.text);const i=r.join(" ").trim();return i.length>0?i:null}if(e.method==="session/update"){const o=t.update;if(!o)return null;const r=((n=o.content)==null?void 0:n.text)??o.text;return typeof r=="string"&&r.length>0?r:null}return null}function vO(e){return e.method==="session/prompt"&&e.kind==="request"}const bO={request:"REQ",response:"RSP",notification:"NTF",error:"ERR",unknown:"???"},xO={request:"request — expects a response",response:"response — answer to a previous request",notification:"notification — one-way event, no response",error:"error — response carrying an error object",unknown:"unknown — could not classify as JSON-RPC"},wO={"editor-to-agent":"editor → agent (e.g. JetBrains/Zed sending to the AI)","agent-to-editor":"agent → editor (AI replying or calling the host)"};function SO(e){switch(e){case"error":return"text-accent-error";case"notification":return"text-accent-note";case"request":return"text-accent-out";case"response":return"text-accent-in";default:return"text-ink-muted"}}function $O({message:e,selected:t,paired:n=!1,latencyMs:o,validation:r,onSelect:i}){const s=e.direction==="editor-to-agent",a=e.kind==="error",l=o!==void 0?rE(o):null,c=gO(e),f=vO(e),m=r&&!r.skipped&&!r.valid;return d.jsxs("button",{type:"button",onClick:()=>i(e.seq),className:K("relative flex w-full items-center gap-3 px-4 py-1.5 text-left font-mono text-[12px] leading-5","border-b border-line-grid/70 transition-colors","hover:bg-surface-rowHover",t?"bg-surface-rowHover ring-1 ring-inset ring-accent-out/40":"",n&&!t?"bg-accent-out/[0.04] ring-1 ring-inset ring-accent-out/15":"",a?"bg-accent-error/[0.06]":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("absolute inset-y-0 left-0 w-[3px]",s?"bg-accent-out":"bg-accent-in",a?"bg-accent-error":"")}),d.jsx("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:String(e.seq).padStart(3,"0")}),d.jsx("span",{className:"w-24 shrink-0 text-ink-secondary",children:fs(e.timestamp)}),d.jsxs("span",{className:K("flex w-16 shrink-0 items-center gap-1 font-semibold",s?"text-accent-out":"text-accent-in"),title:wO[e.direction],children:[d.jsx("span",{"aria-hidden":!0,children:Fb(e.direction)}),d.jsx("span",{className:"text-[10px] tracking-widest",children:zb(e.direction)})]}),d.jsx("span",{className:K("inline-flex w-12 shrink-0 items-center justify-center rounded-sm border px-1 text-[10px] font-semibold tracking-widest",SO(e.kind),"border-current/40"),title:xO[e.kind],children:bO[e.kind]}),d.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-3 overflow-hidden",children:[d.jsx("span",{className:K("shrink-0",f?"text-accent-out":"text-ink-primary"),children:e.method?e.method:"—"}),m&&r&&d.jsxs("span",{className:K("inline-flex shrink-0 items-center gap-0.5 rounded-sm border border-accent-error/40","bg-accent-error/10 px-1 text-[9px] font-semibold uppercase tracking-widest text-accent-error"),title:`fails ACP schema (${r.schemaName??"?"}): ${r.errors.map(h=>`${h.path==="/"?"":h.path+" "}${h.message}`).join(" · ")}`,children:["⚠ SPEC ",r.errors.length]}),c&&d.jsxs("span",{className:K("truncate",f?"text-accent-out/85":"text-ink-secondary"),title:c,children:["“",c,"”"]})]}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",title:e.rpcId!==void 0&&e.rpcId!==null?`id:${String(e.rpcId)}`:void 0,children:e.rpcId!==void 0&&e.rpcId!==null?`id:${sE(e.rpcId)}`:""}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:Ul(e.raw.length)}),d.jsx("span",{className:K("w-20 shrink-0 text-right",l==="ok"&&"text-accent-ok",l==="warn"&&"text-accent-warn",l==="error"&&"text-accent-error",!l&&"text-ink-dim"),children:o!==void 0?`+${Vt(o)}`:""})]})}const kO=P.memo($O);function TO({messages:e,combinedText:t,firstTimestamp:n,lastTimestamp:o,selectedSeq:r,onSelect:i}){const[s,a]=P.useState(!1),l=e[0],c=e[e.length-1],f=o-n,m=t.length>140?`${t.slice(0,140)}…`:t,h=r!==null&&e.some(y=>y.seq===r);return d.jsxs("div",{className:"border-b border-line-grid/70",children:[d.jsxs("button",{type:"button",onClick:()=>{a(y=>!y),i(l.seq)},className:K("relative flex w-full items-center gap-3 px-4 py-1.5 text-left font-mono text-[12px] leading-5","transition-colors hover:bg-surface-rowHover",h?"bg-surface-rowHover ring-1 ring-inset ring-accent-note/40":""),children:[d.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent-note"}),d.jsxs("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:[String(l.seq).padStart(3,"0"),"…",String(c.seq).padStart(3,"0")]}),d.jsx("span",{className:"w-24 shrink-0 text-ink-secondary",children:fs(n)}),d.jsxs("span",{className:"flex w-16 shrink-0 items-center gap-1 font-semibold text-accent-in",title:"agent → editor (AI replying or calling the host)",children:[d.jsx("span",{"aria-hidden":!0,children:"←"}),d.jsx("span",{className:"text-[10px] tracking-widest",children:"IN"})]}),d.jsx("span",{className:K("inline-flex w-12 shrink-0 items-center justify-center rounded-sm border border-accent-note/40 px-1 text-[10px] font-semibold tracking-widest text-accent-note"),title:`stream — ${e.length} consecutive agent_message_chunk notifications collapsed into one row`,children:"STR"}),d.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate text-ink-primary",children:[d.jsx("span",{className:"inline-flex h-[14px] w-1 rounded-sm bg-accent-note/60","aria-hidden":!0}),d.jsx("span",{className:"truncate text-ink-secondary",children:m||d.jsx("span",{className:"text-ink-muted",children:"(empty stream)"})})]}),d.jsxs("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:[e.length," chunks"]}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:Vt(f)}),d.jsx("span",{"aria-hidden":!0,className:K("w-3 shrink-0 text-ink-muted transition-transform",s?"rotate-90":""),children:"▸"})]}),s&&d.jsx("div",{className:"border-l border-line-grid/70 bg-surface-base/40",children:e.map((y,g)=>d.jsxs("button",{type:"button",onClick:()=>i(y.seq),className:K("flex w-full items-center gap-3 px-8 py-1 text-left font-mono text-[11px] leading-5 text-ink-secondary","transition-colors hover:bg-surface-rowHover",r===y.seq?"bg-surface-rowHover text-ink-primary":""),children:[d.jsx("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:String(y.seq).padStart(3,"0")}),d.jsx("span",{className:"w-24 shrink-0 text-ink-muted",children:fs(y.timestamp)}),d.jsxs("span",{className:"w-8 shrink-0 text-ink-muted",children:["#",g+1]}),d.jsx("span",{className:"flex-1 truncate text-ink-primary",children:_O(y)})]},y.seq))})]})}function _O(e){var o,r;const t=e.payload;if(!t||typeof t!="object")return"";const n=t.params;return((r=(o=n==null?void 0:n.update)==null?void 0:o.content)==null?void 0:r.text)??""}const jO=80;function NO(){const e=ne(u=>u.messages),t=ne(u=>u.selectedSeq),n=ne(u=>u.filters),o=ne(u=>u.playback.cap),r=ne(u=>u.select),i=P.useMemo(()=>mS(e,n,o),[e,n,o]),s=P.useMemo(()=>yO(i),[i]),a=P.useMemo(()=>Cl(e),[e]),l=P.useMemo(()=>Zp(e),[e]),c=P.useMemo(()=>{const u=new Map;for(const p of e)u.set(p.seq,p.timestamp);return u},[e]),f=P.useMemo(()=>{if(t===null)return null;const u=a.get(t);if(u!==void 0)return u;for(const[p,x]of a)if(x===t)return p;return null},[t,a]),m=P.useRef(null),h=ne(u=>{var p;return((p=u.session)==null?void 0:p.id)??null}),y=ne(u=>u.replayDone),g=P.useRef(h),b=P.useRef(!1);P.useEffect(()=>{g.current!==h&&(g.current=h,b.current=!1)},[h]),P.useEffect(()=>{if(!y||h===null||b.current||s.length===0)return;b.current=!0;const u=s.length-1,p=window.setTimeout(()=>{var x;(x=m.current)==null||x.scrollToIndex({index:u,align:"end",behavior:"smooth"})},50);return()=>window.clearTimeout(p)},[y,h,s.length]);const v=u=>{const p=s[u];return p?CO(p,{selectedSeq:t,pairedSeq:f,onSelect:r,responseToRequest:a,reqTimestampBySeq:c,validationBySeq:l}):null};return d.jsxs("div",{className:"relative flex h-full flex-col",children:[s.length===0?d.jsx("div",{className:"flex h-full items-center justify-center bg-surface-base font-mono text-xs text-ink-muted",children:"no messages match current filters"}):d.jsx(ZI,{ref:m,className:"flex-1 bg-surface-base",totalCount:s.length,itemContent:v,atBottomThreshold:jO,initialTopMostItemIndex:Math.max(0,s.length-1),followOutput:u=>u?"auto":!1,computeItemKey:u=>EO(s[u])}),d.jsx(PO,{total:e.length,shown:i.length})]})}function CO(e,t){if(e.type==="message"){const n=e.message,o=t.responseToRequest.get(n.seq),r=o!==void 0?n.timestamp-(t.reqTimestampBySeq.get(o)??n.timestamp):void 0,i=t.validationBySeq.get(n.seq);return d.jsx(kO,{message:n,selected:t.selectedSeq===n.seq,paired:t.pairedSeq===n.seq,...r!==void 0?{latencyMs:r}:{},...i!==void 0?{validation:i}:{},onSelect:t.onSelect})}return d.jsx(TO,{messages:e.messages,combinedText:e.combinedText,firstTimestamp:e.firstTimestamp,lastTimestamp:e.lastTimestamp,selectedSeq:t.selectedSeq,onSelect:t.onSelect})}function EO(e){return e.type==="message"?`m-${e.message.seq}`:`c-${e.firstSeq}-${e.lastSeq}`}function PO({total:e,shown:t}){return e===0||t===e?null:d.jsxs("div",{className:"border-t border-line bg-surface-elev/60 px-4 py-1 text-right font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:["showing ",t," of ",e]})}function IO({message:e,tone:t="info"}){if(!e)return null;const n=t==="success"?"border-accent-out/50 bg-accent-out/10 text-accent-out":t==="warn"?"border-accent-warn/50 bg-accent-warn/10 text-accent-warn":"border-accent-info/50 bg-accent-info/10 text-accent-info";return d.jsx("div",{role:"status",className:K("pointer-events-none fixed right-4 top-[60px] z-50 rounded-sm border px-3 py-2 font-mono text-[11px] uppercase tracking-widest shadow-lg backdrop-blur-sm",n),children:e})}function OO({onImportResult:e}){const[t,n]=P.useState(!1),[o,r]=P.useState(!1),i=P.useRef(null),s=P.useRef(null),a=ne(y=>y.session),l=ne(y=>y.messages.length),c=a!==null&&l>0;P.useEffect(()=>{if(!t)return;const y=b=>{i.current&&!i.current.contains(b.target)&&n(!1)},g=b=>{b.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t]);const f=()=>{var y;n(!1),(y=s.current)==null||y.click()},m=()=>{n(!1);const y=ne.getState();y.session&&y.messages.length>0&&Db(y.session,y.messages)},h=async y=>{var b;const g=(b=y.target.files)==null?void 0:b[0];if(y.target.value="",!!g){r(!0);try{const v=await $v(g);await Qu(),ft.getState().setSelected(tl(v.id)),e==null||e(`imported ${g.name} · #${v.id} · ${v.messageCount} message${v.messageCount===1?"":"s"}`,"success")}catch(v){const u=v instanceof Error?v.message:String(v);e==null||e(`import failed: ${u}`,"warn")}finally{r(!1)}}};return d.jsxs("div",{ref:i,className:"relative",children:[d.jsx("input",{ref:s,type:"file",accept:"application/json,.json",onChange:h,className:"hidden","aria-hidden":"true",tabIndex:-1}),d.jsx("button",{type:"button",onClick:()=>n(y=>!y),title:"Session actions — import file · export","aria-haspopup":"menu","aria-expanded":t,"aria-label":"session actions",disabled:o,className:K("inline-flex h-7 w-7 items-center justify-center rounded-sm border font-mono text-[14px] leading-none transition-colors",t?"border-line-strong bg-surface-rowHover text-ink-primary":"border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",o&&"cursor-progress opacity-60"),children:d.jsx("span",{"aria-hidden":!0,children:"⋯"})}),t&&d.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+6px)] z-50 w-max overflow-hidden rounded-sm border border-line bg-surface-elev p-1 font-mono text-[11px] uppercase tracking-widest shadow-lg",children:[d.jsx(sy,{icon:"↑",label:"import",onClick:f,title:"Open a session JSON exported earlier — yours or someone else's."}),d.jsx(sy,{icon:"↓",label:"export",onClick:m,disabled:!c,title:"Download this session as JSON. Auth headers and proxy tokens (Authorization, X-Api-Key, JetBrains proxy_key) are redacted — safe to attach to a bug report. For an un-redacted copy (self-debug only), use 'acp-devtools export <id> --raw' in the CLI.",disabledTitle:"Nothing to export yet — wait for the first message."})]})]})}function sy({icon:e,label:t,onClick:n,disabled:o,title:r,disabledTitle:i}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,title:o?i:r,className:K("flex w-full items-center gap-2 rounded-[2px] px-2 py-1.5 text-left transition-colors",o?"cursor-not-allowed text-ink-dim opacity-50":"text-ink-muted hover:bg-surface-rowHover hover:text-ink-secondary"),children:[d.jsx("span",{"aria-hidden":!0,className:"w-4 text-center text-[13px] leading-none",children:e}),d.jsx("span",{className:"flex-1",children:t})]})}function RO({onSelect:e,activeUrl:t,overrideUrl:n}){const o=ft(p=>p.captures),r=ft(p=>p.savedSessions),i=ft(p=>p.lastFetchAt),[s,a]=P.useState(!1),l=P.useRef(null);P.useEffect(()=>{if(!s)return;const p=x=>{l.current&&!l.current.contains(x.target)&&a(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const c=o.find(p=>p.url===t)??null,f=t!==null&&SS(t)?$S(t):null,m=P.useMemo(()=>new Set(o.map(p=>p.sessionDbId).filter(p=>p!==null)),[o]),h=P.useMemo(()=>r.filter(p=>!m.has(p.id)),[r,m]),y=P.useMemo(()=>h.filter(p=>p.imported_at===null),[h]),g=P.useMemo(()=>h.filter(p=>p.imported_at!==null),[h]),b=f!==null?h.find(p=>p.id===f)??null:null,v=o.length+h.length;let u;return n?u="?ws override":c?u=ef(c):b?u=`#${b.id} · ${b.name??(b.client_name?`${b.client_name} · ${Rt(b.agent_command??"")}`:Rt(b.agent_command??""))}`:v===0?u="no captures":u="pick capture",d.jsxs("div",{ref:l,className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] uppercase tracking-widest transition-colors","border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",s?"border-line-strong text-ink-primary":""),title:"Select a live capture or saved session",children:[d.jsx("span",{className:"inline-block w-[200px] truncate text-left",children:u}),v>1&&!n&&d.jsx("span",{className:"rounded-sm border border-line-strong px-1 text-[9px] text-ink-secondary",children:v}),d.jsx("span",{"aria-hidden":!0,className:K("transition-transform",s?"rotate-180":""),children:"▾"})]}),s&&d.jsxs("div",{className:K("absolute right-0 top-[calc(100%+6px)] z-50 w-[460px] rounded-md border border-line bg-surface-elev shadow-xl"),children:[d.jsxs(Pc,{children:["live captures · last poll"," ",i?`${Math.round((Date.now()-i)/1e3)}s ago`:"—"]}),o.length===0&&d.jsxs("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:["none. start a proxy with"," ",d.jsx("span",{className:"text-ink-secondary",children:"acp-devtools proxy …"})]}),d.jsx("ul",{className:"max-h-[260px] overflow-y-auto",children:o.map(p=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>{e(p.url),a(!1)},title:`${p.agentCommand} · ${p.url}${p.saveTo?" · saved to local store":" · not persisted"}`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",p.url===t?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",p.url===t?"bg-accent-out animate-pulse-soft":"bg-accent-warn/50")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsx("span",{className:"text-accent-out",children:p.sessionDbId!==null?`#${p.sessionDbId}`:`pid ${p.pid}`}),d.jsx("span",{className:"text-ink-muted",children:" · "}),p.sessionName??(p.clientName?`${p.clientName} · ${Rt(p.agentCommand)}`:Rt(p.agentCommand))]}),d.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:Ar(p.startedAt)})]})},p.url))}),d.jsxs(Pc,{children:["saved · ",y.length," session",y.length===1?"":"s"]}),y.length===0&&d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:r.length===0?"no saved sessions yet":g.length>0?"no live-captured sessions yet":"all saved sessions are currently live"}),d.jsx("ul",{className:"max-h-[300px] overflow-y-auto",children:y.map(p=>d.jsx(ay,{s:p,activeUrl:t,onPick:x=>{e(x),a(!1)}},p.id))}),(g.length>0||r.some(p=>p.imported_at!==null))&&d.jsxs(d.Fragment,{children:[d.jsxs(Pc,{children:["imported · ",g.length," file",g.length===1?"":"s"]}),g.length===0?d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:"no imported files"}):d.jsx("ul",{className:"max-h-[200px] overflow-y-auto",children:g.map(p=>d.jsx(ay,{s:p,activeUrl:t,onPick:x=>{e(x),a(!1)}},p.id))})]}),n&&d.jsx("div",{className:"border-t border-line px-3 py-2 font-mono text-[10px] uppercase tracking-widest text-accent-warn",children:"?ws override active — discovery selection ignored"})]})]})}function Pc({children:e}){return d.jsx("div",{className:"border-b border-line bg-surface-base/50 px-3 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e})}function ay({s:e,activeUrl:t,onPick:n}){const o=tl(e.id),r=o===t,i=s=>{s.stopPropagation();const a=e.name??Rt(e.agent_command??"");window.confirm(`Delete session #${e.id} ${a} forever?`)&&(async()=>{try{await wS(e.id),r&&ft.getState().setSelected(null),await Qu()}catch(l){const c=l instanceof Error?l.message:String(l);window.alert(`Delete failed: ${c}`)}})()};return d.jsxs("li",{className:"group relative",children:[d.jsxs("button",{type:"button",onClick:()=>n(o),title:`session #${e.id} · ${e.agent_command??""} · ${e.message_count} messages`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",r?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",r?"bg-accent-note animate-pulse-soft":"bg-ink-dim")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsxs("span",{className:"text-accent-note",children:["#",e.id]}),d.jsx("span",{className:"text-ink-muted",children:" · "}),e.name??(e.client_name?`${e.client_name} · ${Rt(e.agent_command??"")}`:Rt(e.agent_command??""))]}),d.jsxs("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors group-hover:text-ink-secondary",children:[e.message_count,"msg · ",Ar(e.started_at)]})]}),d.jsx("button",{type:"button",onClick:i,"aria-label":`delete session #${e.id} forever`,title:"Delete this session permanently",className:K("absolute right-2 top-1/2 hidden h-6 w-6 -translate-y-1/2 items-center justify-center rounded-sm border border-line bg-surface-elev/70 text-[12px] leading-none text-ink-muted transition-colors","group-hover:flex hover:border-accent-error/70 hover:bg-surface-rowHover hover:text-accent-error"),children:d.jsx("span",{"aria-hidden":!0,children:"×"})})]})}const Ic=[{mode:"system",label:"AUTO",title:"follow OS theme",icon:"◐"},{mode:"light",label:"LIGHT",title:"force light theme",icon:"☀"},{mode:"dark",label:"DARK",title:"force dark theme",icon:"☾"}];function AO(){const e=Pd(s=>s.mode),t=Pd(s=>s.setMode),[n,o]=P.useState(!1),r=P.useRef(null);P.useEffect(()=>{if(!n)return;const s=a=>{r.current&&!r.current.contains(a.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[n]);const i=Ic.find(s=>s.mode===e)??Ic[0];return d.jsxs("div",{ref:r,className:"relative",children:[d.jsx("button",{type:"button",onClick:()=>o(s=>!s),title:`theme · ${i.title}`,"aria-haspopup":"menu","aria-expanded":n,className:K("inline-flex h-7 w-7 items-center justify-center rounded-sm border font-mono text-[12px] transition-colors",n?"border-line-strong bg-surface-rowHover text-ink-primary":"border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary"),children:d.jsx("span",{"aria-hidden":!0,children:i.icon})}),n&&d.jsx("div",{role:"menu",className:"absolute right-0 top-[calc(100%+6px)] z-50 inline-flex items-center gap-px rounded-sm border border-line bg-surface-elev p-px font-mono text-[10px] uppercase tracking-widest shadow-lg",children:Ic.map(s=>{const a=s.mode===e;return d.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a,onClick:()=>{t(s.mode),o(!1)},title:s.title,className:K("inline-flex items-center gap-1 rounded-[2px] px-2 py-1 transition-colors",a?"bg-accent-out/15 text-accent-out":"text-ink-muted hover:bg-surface-rowHover hover:text-ink-secondary"),children:[d.jsx("span",{"aria-hidden":!0,children:s.icon}),d.jsx("span",{children:s.label})]},s.mode)})})]})}function MO({wsUrl:e,overrideUrl:t,activeUrl:n,isReplay:o,isImported:r=!1,onPickCapture:i,onImportResult:s,onOpenInfo:a,onOpenPerf:l,onOpenDiff:c}){const f=ne(b=>b.connection),m=ne(b=>b.session),h=ne(b=>b.lastError),y=ne(b=>b.messages.length>0?b.messages[b.messages.length-1].timestamp:null),g=Jb(5e3);return d.jsxs("header",{className:"flex items-center justify-between border-b border-line bg-surface-base px-5 py-2.5",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("div",{className:"wordmark-rule",children:d.jsx("span",{className:"font-display text-[18px] uppercase tracking-[0.18em] text-ink-primary",children:"acp.devtools"})}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"v0.2.0"})]}),d.jsxs("div",{className:"flex items-center gap-4",children:[m&&(()=>{const{primary:b}=ql(m),v=o||r,u=m.endedAt!==null?m.endedAt:y??m.startedAt,p=v?Ar(m.startedAt,u):Ar(m.startedAt,g),x=y!==null?g-y:null,S=!v&&x!==null&&x>5e3,T=_a(m.startedAt,g),C=r?"IMPORTED":o?"REPLAY":"SESSION",$=r?"session loaded from a JSON file on disk — not connected to any proxy":o?"replay of a saved session — proxy has ended":"live capture — proxy process is still running",j=r?"text-accent-warn":o?"text-accent-note":"text-accent-out";return d.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px] text-ink-secondary",children:[d.jsx("span",{className:"text-ink-muted",title:$,children:C}),d.jsx("span",{className:j,title:m.agentCommand?`session #${m.id} · ${m.agentCommand}`:"persisted session id",children:b}),d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsx("span",{title:`session started at ${T}`,children:_a(m.startedAt,g)}),p&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsxs("span",{className:"text-ink-muted",title:v?"capture duration (start → end of recorded session)":"how long the proxy process has been alive",children:[v?"lasted":"alive"," ",p]})]}),S&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsxs("span",{className:"text-ink-dim",title:`time since the most recent ACP frame · last event ${_a(y,g)}`,children:["idle ",Ar(y,g)]})]})]})})(),d.jsxs("div",{className:"flex items-center gap-1.5",children:[i&&d.jsx(RO,{onSelect:i,activeUrl:n,overrideUrl:t}),d.jsx(qO,{status:f,wsUrl:e,lastError:h,isReplay:o,isImported:r,onReconnect:bS})]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[a&&m&&d.jsx("button",{type:"button",onClick:a,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Show session info — client/agent capabilities, runtime state","aria-label":"Open session info panel",children:"info"}),l&&m&&d.jsx("button",{type:"button",onClick:l,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Show performance dashboard — per-method latency stats and waterfall timeline","aria-label":"Open performance dashboard",children:"perf"}),c&&m&&d.jsx("button",{type:"button",onClick:c,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Compare this session against another — metadata, per-method latency, and frame-level differences","aria-label":"Open session diff",children:"diff"}),d.jsx(OO,{...s?{onImportResult:s}:{}})]}),d.jsx("div",{className:"flex items-center gap-1.5",children:d.jsx(AO,{})})]})]})}function qO({status:e,wsUrl:t,lastError:n,isReplay:o,isImported:r,onReconnect:i}){if(r)return d.jsxs("div",{className:"inline-flex h-7 cursor-default items-center gap-2 rounded-sm border border-accent-warn/40 bg-accent-warn/10 px-3 font-mono text-[10px] font-semibold uppercase tracking-widest text-accent-warn",title:`viewing data from a JSON file · ${t}`,children:[d.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 rounded-full bg-accent-warn"}),d.jsx("span",{className:"inline-block min-w-[52px] text-center",children:"FILE"})]});const a=e==="open"?o?"REPLAY":"LIVE":e==="connecting"?"WAITING":e==="idle"?"IDLE":e==="closed"?"CLOSED":"ERROR",c={idle:"text-ink-secondary bg-surface-row border-line",connecting:"text-accent-warn/80 bg-accent-warn/10 border-accent-warn/30",open:o?"text-accent-note bg-accent-note/10 border-accent-note/40":"text-accent-out bg-accent-out/10 border-accent-out/40",closed:"text-ink-secondary bg-surface-row border-line",error:"text-accent-error bg-accent-error/10 border-accent-error/40"},m=e==="open"?o?"bg-accent-note animate-pulse-soft":"bg-accent-out animate-pulse-soft":e==="connecting"?"bg-accent-warn/60 animate-pulse-soft":e==="error"?"bg-accent-error":"bg-ink-dim",h=e==="idle"||e==="closed"||e==="error",g=n||(e==="open"?`${o?"serving a recorded session from the local store":"connected to a live proxy capture"} · ${t}`:h?`click to reconnect · ${t}`:t);return d.jsxs("button",{type:"button",onClick:h?i:void 0,disabled:!h,className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",c[e],h?"cursor-pointer hover:bg-surface-rowHover":"cursor-default"),title:g,children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block h-2 w-2 rounded-full",m)}),d.jsx("span",{className:"inline-block min-w-[52px] text-center",children:a})]})}const ur=GN(),UO=ur?new URLSearchParams(typeof window<"u"?window.location.search:"").get("url"):null;function LO(){const e=ft(w=>w.captures),t=ft(w=>w.selectedUrl),n=ft(w=>w.setSelected),o=ne(w=>{var k;return((k=w.session)==null?void 0:k.importedAt)??null}),r=t,i=t!==null&&/\/replay\/\d+$/.test(t),s=o!==null;P.useEffect(()=>ur?void 0:CS(),[]),P.useEffect(()=>IS(),[]);const[a,l]=P.useState(null),c=P.useRef(new Set);P.useEffect(()=>{const w=mh(window.location.search),k=ne.getState(),N={};Object.keys(w.filters).length>0&&(N.filters={...k.filters,...w.filters}),w.selectedSeq!==null&&(N.selectedSeq=w.selectedSeq),w.detailTab!==null&&(N.detailTab=w.detailTab),w.playbackCap!==null&&(N.playback={...k.playback,cap:w.playbackCap}),Object.keys(N).length>0&&ne.setState(N),w.captureUrl&&ft.getState().setSelected(w.captureUrl)},[]);const[f,m]=P.useState(!1),[h,y]=P.useState(!1),[g,b]=P.useState(!1);P.useEffect(()=>{const w=()=>{const B=ne.getState(),O=ft.getState();tC({filters:B.filters,selectedSeq:B.selectedSeq,detailTab:B.detailTab,playbackCap:B.playback.cap,captureUrl:O.selectedUrl})},k=ne.subscribe(w),N=ft.subscribe(w);return w(),()=>{k(),N()}},[]);const v=()=>{f||(window.history.pushState({drawer:"info"},"",window.location.href),m(!0))},u=()=>{h||(window.history.pushState({drawer:"perf"},"",window.location.href),y(!0))},p=()=>{g||(window.history.pushState({drawer:"diff"},"",window.location.href),b(!0))},x=()=>{f&&window.history.back()},S=()=>{h&&window.history.back()},T=()=>{g&&window.history.back()},C=w=>{window.history.pushState({drawer:null},"",window.location.href),ne.getState().select(w),m(!1),y(!1),b(!1)};P.useEffect(()=>{const w=k=>{const N=k.state;m((N==null?void 0:N.drawer)==="info"),y((N==null?void 0:N.drawer)==="perf"),b((N==null?void 0:N.drawer)==="diff");const B=mh(window.location.search),O=ne.getState(),Y=ft.getState(),ie={};Object.keys(B.filters).length>0&&(ie.filters={...O.filters,...B.filters}),ie.selectedSeq=B.selectedSeq,ie.detailTab=B.detailTab??"tree",ie.playback={...O.playback,cap:B.playbackCap},ne.setState(ie),B.captureUrl!==Y.selectedUrl&&B.captureUrl&&Y.setSelected(B.captureUrl)};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),P.useEffect(()=>{const w=new Set(e.map(Y=>Y.url));if(c.current=c.current,i){c.current=w;return}const k=e[0]??null,N=t===null,B=t!==null&&w.has(t),O=k!==null&&!c.current.has(k.url)&&c.current.size>0;e.length===0?t!==null&&n(null):N||!B?n(k.url):O&&k.url!==t&&(n(k.url),l({message:`switched → ${ef(k)}`,tone:"success"})),c.current=w},[e,t,n,i]),P.useEffect(()=>{if(!a)return;let w=3e3,k=Date.now(),N=null;const B=()=>{N===null&&document.visibilityState==="visible"&&(k=Date.now(),N=setTimeout(()=>l(null),w))},O=()=>{N!==null&&(clearTimeout(N),N=null,w=Math.max(0,w-(Date.now()-k)))},Y=()=>{document.visibilityState==="visible"?B():O()};return document.addEventListener("visibilitychange",Y),B(),()=>{document.removeEventListener("visibilitychange",Y),N&&clearTimeout(N)}},[a]),P.useEffect(()=>{if(ur){Cd();return}if(!r){Cd();return}Gu(r)},[r]);const[$,j]=P.useState(!1);P.useEffect(()=>{const w=k=>{if((k.metaKey||k.ctrlKey)&&(k.key==="k"||k.key==="K")){k.preventDefault(),j(B=>!B);return}if($)return;const N=k.target;if(!(N&&(N.tagName==="INPUT"||N.tagName==="TEXTAREA"))){if(k.key==="Escape"){ne.getState().select(null);return}if(k.key==="j"||k.key==="J"){ly(1);return}if(k.key==="k"||k.key==="K"){ly(-1);return}}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[$]);const R=ne(w=>w.messages),M=ne(w=>w.session),F=ne(w=>w.selectedSeq),V=ne(w=>w.connection),L=ne(w=>w.lastError);P.useEffect(()=>{const w="ACP Devtools";if(!M){document.title=w;return}const{primary:k,secondary:N}=ql(M),B=N?`${k} · ${N}`:k;document.title=`${B} — ${w}`},[M]);const U=P.useMemo(()=>hS(R,F),[R,F]),D=P.useMemo(()=>{const w=Cl(R),k=new Map;for(const[N,B]of w.entries())k.set(B,N);return{responseToRequest:w,requestToResponse:k}},[R]),Q=P.useMemo(()=>Zp(R),[R]);let ee,q=null;if(U){if(U.kind==="response"||U.kind==="error"){const w=D.responseToRequest.get(U.seq);w!==void 0&&(q=R.find(k=>k.seq===w)??null,q&&(ee=U.timestamp-q.timestamp))}else if(U.kind==="request"){const w=D.requestToResponse.get(U.seq);w!==void 0&&(q=R.find(k=>k.seq===w)??null,q&&(ee=q.timestamp-U.timestamp))}}const G=R.length===0&&!M,I=r??"no capture selected",_=ur&&G,A=!ur&&G&&r===null&&e.length===0,E=!ur&&G&&!A;return d.jsxs("div",{className:"flex h-full flex-col bg-surface-base text-ink-primary",children:[d.jsx(IO,{message:(a==null?void 0:a.message)??null,tone:(a==null?void 0:a.tone)??"info"}),d.jsx(WC,{open:$,onClose:()=>j(!1)}),d.jsx(AP,{open:f,onClose:x}),d.jsx(wP,{open:h,onClose:S,onNavigateToSeq:C}),d.jsx(ME,{open:g,onClose:T}),d.jsx(MO,{wsUrl:I,overrideUrl:null,isReplay:i,isImported:s,onPickCapture:w=>{n(w),c.current.add(w)},onImportResult:(w,k)=>l({message:w,tone:k}),activeUrl:r,onOpenInfo:v,onOpenPerf:u,onOpenDiff:p}),d.jsx(XE,{}),d.jsx("main",{className:"flex-1 overflow-hidden",children:_?d.jsx(IP,{initialUrl:UO}):A?d.jsx(QE,{status:V,lastError:L,url:I,captureCount:e.length}):E?d.jsx(QC,{status:V,url:I,lastError:L}):d.jsx(LP,{storageKey:"acp.split.leftPx",initialLeftFraction:.62,minLeft:420,minRight:360,left:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"min-h-0 flex-1",children:d.jsx(NO,{})}),(i||s)&&d.jsx(RP,{})]}),right:d.jsx(pE,{message:U,...ee!==void 0?{latencyMs:ee}:{},...q?{pairedRequest:q}:{},...U?(()=>{const w=Q.get(U.seq);return w?{validation:w}:{}})():{},onJumpToPaired:w=>ne.getState().select(w)})})}),d.jsx(DP,{})]})}function ly(e){const t=ne.getState(),{messages:n,selectedSeq:o}=t;if(n.length===0)return;if(o===null){const s=e===1?n[0]:n[n.length-1];s&&t.select(s.seq);return}const r=n.findIndex(s=>s.seq===o);if(r===-1){const s=n[0];s&&t.select(s.seq);return}const i=n[r+e];i&&t.select(i.seq)}const Ix=document.getElementById("root");if(!Ix)throw new Error("#root not found");Oc.createRoot(Ix).render(d.jsx(te.StrictMode,{children:d.jsx(LO,{})}));
|
|
1768
|
-
//# sourceMappingURL=index-
|
|
1766
|
+
`}class Ke extends Error{constructor(t){super(t),this.name="ExportParseError"}}function qC(e){let t;try{t=JSON.parse(e)}catch(l){throw new Ke(`invalid JSON: ${l instanceof Error?l.message:String(l)}`)}if(!ka(t))throw new Ke("expected an object at the top level");const n=t.version;if(n!==$a)throw new Ke(`unsupported export version ${String(n)} (expected ${$a})`);const o=t.exportedAt;if(typeof o!="number")throw new Ke("exportedAt must be a number");if(!ka(t.tool))throw new Ke("tool must be an object");const r=t.tool.name,i=t.tool.version;if(typeof r!="string")throw new Ke("tool.name must be a string");if(typeof i!="string")throw new Ke("tool.version must be a string");const s=t.session;if(!ka(s))throw new Ke("session must be an object");if(typeof s.id!="number")throw new Ke("session.id must be a number");if(typeof s.startedAt!="number")throw new Ke("session.startedAt must be a number");if(s.endedAt!==null&&typeof s.endedAt!="number")throw new Ke("session.endedAt must be a number or null");if(s.name!==null&&typeof s.name!="string")throw new Ke("session.name must be a string or null");if(s.agentCommand!==null&&typeof s.agentCommand!="string")throw new Ke("session.agentCommand must be a string or null");if(s.clientName!==null&&typeof s.clientName!="string")throw new Ke("session.clientName must be a string or null");if(!Array.isArray(t.messages))throw new Ke("messages must be an array");const a=t.messages.map((l,c)=>UC(l,c));return{version:$a,exportedAt:o,tool:{name:r,version:i},session:{id:s.id,name:s.name,agentCommand:s.agentCommand,clientName:s.clientName,startedAt:s.startedAt,endedAt:s.endedAt},messages:a}}function UC(e,t){if(!ka(e))throw new Ke(`messages[${t}] must be an object`);if(typeof e.seq!="number")throw new Ke(`messages[${t}].seq must be a number`);if(typeof e.timestamp!="number")throw new Ke(`messages[${t}].timestamp must be a number`);if(e.direction!=="editor-to-agent"&&e.direction!=="agent-to-editor")throw new Ke(`messages[${t}].direction must be 'editor-to-agent' or 'agent-to-editor'`);const n=e.kind;if(n!=="request"&&n!=="response"&&n!=="error"&&n!=="notification"&&n!=="unknown")throw new Ke(`messages[${t}].kind has unexpected value '${String(n)}'`);if(typeof e.raw!="string")throw new Ke(`messages[${t}].raw must be a string`);const o={seq:e.seq,timestamp:e.timestamp,direction:e.direction,kind:n,raw:e.raw,payload:e.payload===null?null:e.payload};return typeof e.method=="string"&&(o.method=e.method),(typeof e.rpcId=="string"||typeof e.rpcId=="number"||e.rpcId===null)&&(o.rpcId=e.rpcId),typeof e.parseError=="string"&&(o.parseError=e.parseError),o}function ka(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Lb="<REDACTED>",LC=new Set(["authorization","proxy-authorization","proxy-authentication","x-api-key","x-api-token","x-auth-token","api-key","api_key","proxy_key","cookie","set-cookie"]);function DC(e){if(e.payload==null)return{redacted:e,count:0};const{value:t,count:n}=zd(e.payload,{inProxyConfig:!1});if(n===0)return{redacted:e,count:0};const o=t;return{redacted:{...e,payload:o,raw:JSON.stringify(o)},count:n}}function zd(e,t){if(Array.isArray(e)){let n=0;const o=new Array(e.length);for(let r=0;r<e.length;r++){const i=zd(e[r],t);o[r]=i.value,n+=i.count}return{value:o,count:n}}if(e!==null&&typeof e=="object"){let n=0;const o={};for(const[r,i]of Object.entries(e)){if(typeof i=="string"&&LC.has(r.toLowerCase())){o[r]=Lb,n+=1;continue}if(t.inProxyConfig&&r==="headers"&&i!==null&&typeof i=="object"&&!Array.isArray(i)){const l=zC(i);o[r]=l.value,n+=l.count;continue}const s=t.inProxyConfig||r.toLowerCase()==="proxyconfig"?{inProxyConfig:!0}:t,a=zd(i,s);o[r]=a.value,n+=a.count}return{value:o,count:n}}return{value:e,count:0}}function zC(e){let t=0;const n={};for(const[o,r]of Object.entries(e))typeof r=="string"?(n[o]=Lb,t+=1):n[o]=r;return{value:n,count:t}}function FC(e){let t=0,n=0;const o=e.messages.map(r=>{const i=DC(r);return i.count>0&&(t+=1,n+=i.count),i.redacted});return n===0?{export:e,messagesAffected:0,fieldsRedacted:0}:{export:{...e,messages:o},messagesAffected:t,fieldsRedacted:n}}const BC={name:"acp-devtools-ui",version:"0.2.1"};function HC(e,t=Date.now()){const n=e.id>0?String(e.id):"live",o=new Date(t).toISOString().slice(0,19).replace(/[:T]/g,"-");return`acp-session-${n}-${o}.json`}function VC(e,t,n=Date.now()){const o=AC(e,t,{tool:BC,exportedAt:n}),{export:r}=FC(o);return MC(r)}function Db(e,t,n=Date.now()){const o=VC(e,t,n),r=new Blob([o],{type:"application/json"}),i=URL.createObjectURL(r),s=document.createElement("a");s.href=i,s.download=HC(e,n),s.rel="noopener",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function WC({open:e,onClose:t}){const[n,o]=P.useState(""),[r,i]=P.useState(0),s=P.useRef(null);P.useEffect(()=>{if(!e)return;o(""),i(0);const c=setTimeout(()=>{var f;return(f=s.current)==null?void 0:f.focus()},0);return()=>clearTimeout(c)},[e]);const a=P.useMemo(()=>KC(),[t,e]),l=P.useMemo(()=>GC(a,n),[a,n]);return P.useEffect(()=>{r>=l.length&&i(0)},[l.length,r]),P.useEffect(()=>{if(!e)return;const c=f=>{if(f.key==="Escape"){f.preventDefault(),t();return}if(f.key==="ArrowDown"){f.preventDefault(),i(m=>l.length===0?0:(m+1)%l.length);return}if(f.key==="ArrowUp"){f.preventDefault(),i(m=>l.length===0?0:(m-1+l.length)%l.length);return}if(f.key==="Enter"){f.preventDefault();const m=l[r];m&&(m.run(),t())}};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,l,r,t]),e?d.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-[100] flex items-start justify-center bg-black/60 pt-[8vh] backdrop-blur-sm",onMouseDown:c=>{c.target===c.currentTarget&&t()},children:d.jsxs("div",{className:"w-[min(620px,92vw)] overflow-hidden rounded-md border border-line-strong bg-surface-elev shadow-2xl",children:[d.jsx("div",{className:"border-b border-line bg-surface-base/60",children:d.jsx("input",{ref:s,value:n,onChange:c=>{o(c.target.value),i(0)},placeholder:"type a command… esc closes ↑↓ navigate ↵ run",className:"w-full bg-transparent px-4 py-3 font-mono text-[13px] text-ink-primary placeholder-ink-muted outline-none"})}),d.jsxs("ul",{className:"max-h-[60vh] overflow-y-auto py-1",children:[l.length===0&&d.jsx("li",{className:"px-4 py-3 text-center font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:"no match"}),l.map((c,f)=>{const m=f===r,h=l[f-1],y=!h||h.section!==c.section;return d.jsxs("li",{children:[y&&d.jsx("div",{className:"px-4 pt-2 pb-1 font-mono text-[9px] uppercase tracking-widest text-ink-muted",children:c.section}),d.jsxs("button",{type:"button",onClick:()=>{c.run(),t()},onMouseEnter:()=>i(f),className:K("flex w-full items-center justify-between px-4 py-1.5 text-left font-mono text-[12px] transition-colors",m?"bg-accent-out/10 text-ink-primary":"text-ink-secondary hover:bg-surface-rowHover hover:text-ink-primary"),children:[d.jsx("span",{className:"truncate",children:c.label}),c.hint&&d.jsx("span",{className:"ml-3 shrink-0 rounded-sm border border-line px-1.5 py-0.5 text-[10px] uppercase tracking-widest text-ink-muted",children:c.hint})]})]},c.id)})]})]})}):null}function KC(e){const t=ne.getState(),n=ft.getState(),o=[];o.push({id:"session.import",label:"Import session JSON from disk…",section:"session",run:()=>{const r=document.createElement("input");r.type="file",r.accept="application/json,.json",r.addEventListener("change",()=>{var s;const i=(s=r.files)==null?void 0:s[0];i&&(async()=>{try{const a=await $v(i);await Qu(),n.setSelected(tl(a.id))}catch(a){const l=a instanceof Error?a.message:String(a);window.alert(`Import failed: ${l}`)}})()}),r.click()}}),t.session!==null&&t.messages.length>0&&o.push({id:"session.export",label:"Export current session as JSON (redacted — auth tokens hidden)",section:"session",run:()=>Db(t.session,t.messages)}),o.push({id:"view.deselect",label:"Deselect message",hint:"esc",section:"view",run:()=>t.select(null)}),o.push({id:"view.toggle-streams",label:t.filters.showStreams?"Hide streaming chunks":"Show streaming chunks",section:"filter",run:()=>t.toggleStreams()}),o.push({id:"filter.reset",label:"Reset all filters",section:"filter",run:()=>{const r={directions:new Set(ls),kinds:new Set(cs),showStreams:!0,search:""};ne.setState({filters:r})}});for(const r of ls){const i=t.filters.directions.has(r);o.push({id:`filter.dir.${r}`,label:`${i?"Hide":"Show"} ${r==="editor-to-agent"?"editor → agent":"agent → editor"} messages`,section:"filter",run:()=>t.toggleDirection(r)})}for(const r of cs){const i=t.filters.kinds.has(r);o.push({id:`filter.kind.${r}`,label:`${i?"Hide":"Show"} ${r} kind`,section:"filter",run:()=>t.toggleKind(r)})}if(t.selectedSeq!==null){const r=t.messages.find(i=>i.seq===t.selectedSeq);r&&(o.push({id:"copy.raw",label:`Copy selected message raw line (seq ${r.seq})`,section:"copy",run:()=>{navigator.clipboard.writeText(r.raw)}}),r.payload&&o.push({id:"copy.payload",label:`Copy selected payload as JSON (seq ${r.seq})`,section:"copy",run:()=>{navigator.clipboard.writeText(JSON.stringify(r.payload,null,2))}}))}for(const r of n.captures)o.push({id:`switch.live.${r.url}`,label:`Switch to live: ${ef(r)}`,section:"switch",run:()=>n.setSelected(r.url)});for(const r of n.savedSessions.slice(0,25)){const i=Rt(r.agent_command??""),s=r.name??(r.client_name?`${r.client_name} · ${i}`:i);o.push({id:`switch.saved.${r.id}`,label:`Open saved #${r.id} · ${s} (${r.message_count} msg)`,section:"switch",run:()=>n.setSelected(tl(r.id))})}return o}function GC(e,t){const n=t.trim().toLowerCase();if(n==="")return e;const o=n.split(/\s+/);return e.filter(r=>{const i=r.label.toLowerCase();return o.every(s=>i.includes(s))})}const JC={idle:"idle",connecting:"connecting",open:"restoring view",closed:"disconnected",error:"connection error"};function QC({status:e,url:t,lastError:n}){const o=JC[e],r=e==="connecting"||e==="open";return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-surface-base",children:d.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block h-2 w-2 rounded-full",r?"animate-pulse-soft bg-accent-out":"bg-ink-dim",e==="error"&&"bg-accent-error")}),d.jsx("span",{children:o}),d.jsx("span",{className:"text-ink-dim",children:"·"}),d.jsx("span",{className:"lowercase tracking-normal text-ink-secondary",children:t}),n&&e==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-dim",children:"·"}),d.jsx("span",{className:"lowercase tracking-normal text-accent-error",children:n})]})]})})}function YC(e){const t=e.$defs??{},n=new Map;for(const[g,b]of Object.entries(t)){const v=b["x-method"];if(typeof v!="string")continue;let u=n.get(v);u||(u={},n.set(v,u)),g.endsWith("Request")?u.requestDef=g:g.endsWith("Response")?u.responseDef=g:g.endsWith("Notification")&&(u.notificationDef=g)}function o(g,b){var v,u,p;switch(g.kind){case"request":{const x=g.method;return x?((v=n.get(x))==null?void 0:v.requestDef)??null:null}case"notification":{const x=g.method;return x?((u=n.get(x))==null?void 0:u.notificationDef)??null:null}case"response":case"error":return b?((p=n.get(b))==null?void 0:p.responseDef)??null:null;default:return null}}function r(g){return g==="request"||g==="notification"?"params":g==="response"?"result":g==="error"?"error":null}function i(g){return typeof g=="object"&&g!==null&&!Array.isArray(g)}function s(g,b){const v=g.properties;if(!v)return!0;for(const[u,p]of Object.entries(v))if(!(!p||typeof p!="object")){if("const"in p){if(b[u]!==p.const)return!1}else if(Array.isArray(p.enum)&&!p.enum.includes(b[u]))return!1}return!0}function a(g,b){const v=g.type;if(typeof v=="string"){if(v==="null")return b===null;if(v==="string")return typeof b=="string";if(v==="boolean")return typeof b=="boolean";if(v==="number"||v==="integer")return typeof b=="number";if(v==="array")return Array.isArray(b);if(v==="object")return i(b)&&s(g,b)}return g.$ref||g.properties||g.allOf?i(b)&&s(g,b):!1}function l(g,b=void 0){if(!g)return null;if(g.$ref){const v=g.$ref.replace(/^#\/\$defs\//,""),u=t[v];return u?l(u,b):null}if(g.allOf&&g.allOf.length>0){const v={properties:{}};for(const u of g.allOf){const p=l(u,b);p!=null&&p.properties&&(v.properties={...v.properties,...p.properties}),p!=null&&p.type&&!v.type&&(v.type=p.type),p!=null&&p.items&&!v.items&&(v.items=p.items)}return g.description&&!v.description&&(v.description=g.description),v}if(g.anyOf||g.oneOf){const v=g.anyOf??g.oneOf;if(b!==void 0){for(const u of v)if(u.type!=="null"&&a(u,b))return l(u,b)}for(const u of v){if(u.type==="null")continue;const p=l(u,b);if(p)return p}return null}return g}function c(g,b){let v=g;for(const u of b){if(v==null)return;if(Array.isArray(v)&&/^\d+$/.test(u))v=v[Number(u)];else if(typeof v=="object")v=v[u];else return}return v}function f(g){if(!g)return;if(g.$ref)return g.$ref.replace(/^#\/\$defs\//,"");const b=g.type;if(typeof b=="string")return b;if(Array.isArray(b))return b.find(u=>u!=="null")}function m(g,b){const v=t[g];return{typeName:g,typeDescription:(v==null?void 0:v.description)??null,resolve(u){var R;if(u.length===0)return{inSpec:!0,isExtension:!1,description:v==null?void 0:v.description,type:g};const p=u.slice(1);if(p.length===0)return null;let x=!1,S=v??null;for(let M=0;M<p.length;M++){const F=p[M];F==="_meta"&&(x=!0);const V=/^\d+$/.test(F),L=c(b,u.slice(0,M+1));if(S=l(S,L),!S)return null;if(V){const D=c(b,u.slice(0,M+2));S=l(S.items,D);continue}if(x&&F!=="_meta")return{inSpec:!1,isExtension:!0};const U=(R=S.properties)==null?void 0:R[F];if(!U)return{inSpec:!1,isExtension:x};S=U}const T=c(b,u),C=l(S,T),$={inSpec:!0,isExtension:x};S!=null&&S.description?$.description=S.description:C!=null&&C.description&&($.description=C.description);const j=f(S??null)??f(C);return j&&($.type=j),C!=null&&C.enum&&($.enumValues=C.enum),$}}}function h(g,b={}){const v=o(g,b.pairedMethod);return!v||!r(g.kind)?null:m(v,g.payload)}function y(){return[...n.keys()].sort()}return{resolveForMessage:h,knownMethods:y}}const XC=YC(Cv),ZC=XC.resolveForMessage,eE={info:"border-line bg-surface-base text-ink-primary",warn:"border-accent-warn/40 bg-accent-warn/10 text-ink-primary",error:"border-accent-error/40 bg-accent-error/10 text-ink-primary"};function ps({label:e,children:t,delay:n=60,tone:o="info",className:r,focusable:i=!1}){const s=P.useRef(null),a=P.useRef(null),[l,c]=P.useState(null),f=l!==null,m=()=>{const g=s.current;if(!g)return null;const b=g.getBoundingClientRect(),u=window.innerHeight-b.bottom<120;return{top:u?b.top-8:b.bottom+8,left:Math.min(b.left,window.innerWidth-380),flipUp:u}},h=()=>{a.current!==null&&clearTimeout(a.current),a.current=setTimeout(()=>{const g=m();g&&c(g)},n)},y=()=>{a.current!==null&&(clearTimeout(a.current),a.current=null),c(null)};return P.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),P.useEffect(()=>{if(!f)return;const g=()=>y();return window.addEventListener("scroll",g,!0),()=>window.removeEventListener("scroll",g,!0)},[f]),d.jsxs(d.Fragment,{children:[d.jsx("span",{ref:s,className:K("cursor-help",r),onMouseEnter:h,onMouseLeave:y,...i?{onFocus:h,onBlur:y,tabIndex:0}:{},children:t}),l&&Vu.createPortal(d.jsx("div",{role:"tooltip",className:K("pointer-events-none fixed z-[200] max-w-[360px] rounded-sm border px-3 py-2 font-mono text-[11px] leading-snug shadow-lg backdrop-blur-sm",eE[o]),style:{top:l.flipUp?void 0:l.top,bottom:l.flipUp?window.innerHeight-l.top:void 0,left:l.left},children:e}),document.body)]})}const tE=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function Ta(e){return tE.format(e)}function fs(e){const t=e%1e3;return`${Ta(e)}.${String(t).padStart(3,"0")}`}const nE=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function oE(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function _a(e,t=Date.now()){const n=new Date(e),o=new Date(t);if(oE(n,o))return Ta(e);if(n.getFullYear()===o.getFullYear())return`${nE[n.getMonth()]} ${n.getDate()} ${Ta(e)}`;const r=String(n.getMonth()+1).padStart(2,"0"),i=String(n.getDate()).padStart(2,"0");return`${n.getFullYear()}-${r}-${i} ${Ta(e)}`}function Ul(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Vt(e){return e<1?"<1ms":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function rE(e){return e<250?"ok":e<1500?"warn":"error"}function zb(e){return e==="editor-to-agent"?"OUT":"IN"}function Fb(e){return e==="editor-to-agent"?"→":"←"}const iE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function sE(e){const t=String(e);return iE.test(t)?t.slice(0,8)+"…":t.length>12?t.slice(0,10)+"…":t}function Ar(e,t=Date.now()){const n=Math.max(0,Math.round((t-e)/1e3));if(n<60)return`${n}s`;const o=Math.floor(n/60);if(o<60)return`${o}m`;const r=Math.floor(o/60);if(r<24){const a=o%60;return`${r}h${String(a).padStart(2,"0")}m`}const i=Math.floor(r/24),s=r%24;return`${i}d${String(s).padStart(2,"0")}h`}function gh(e,t){if(e.length===0)return 0;const n=t/100*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=e[o],s=e[r];return i===void 0||s===void 0?i??0:o===r?i:i+(s-i)*(n-o)}const aE=6;function vh(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function lE(e){if(e===null)return"text-accent-error";switch(typeof e){case"string":return"text-accent-out";case"number":return"text-accent-in";case"boolean":return"text-accent-note";default:return"text-ink-secondary"}}function cE(e){return e===null?"null":typeof e=="string"?JSON.stringify(e):String(e)}function al({value:e,name:t,depth:n=0,defaultExpanded:o,path:r=[],getSpec:i}){const s=vh(e)||Array.isArray(e),a=vh(e)?Object.keys(e).length:Array.isArray(e)?e.length:0,l=o??(n<2&&a<=aE),[c,f]=P.useState(l),m=t!==void 0&&i?i(r):null,h=t!==void 0?d.jsx(dE,{name:t,spec:m}):null;if(!s)return d.jsxs("div",{className:"flex items-baseline gap-2 font-mono text-xs leading-relaxed",children:[h,d.jsx("span",{className:K("whitespace-pre-wrap break-all",lE(e)),children:cE(e)})]});const y=Array.isArray(e),g=y?"[":"{",b=y?"]":"}";return d.jsxs("div",{className:"font-mono text-xs leading-relaxed",children:[d.jsxs("button",{type:"button",onClick:()=>f(v=>!v),className:"group/expand flex items-baseline gap-2 text-left hover:text-ink-primary",children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block w-3 text-ink-muted transition-transform",c?"rotate-90":""),children:"▸"}),h,d.jsx("span",{className:"text-ink-secondary",children:g}),!c&&d.jsxs("span",{className:"text-ink-muted",children:[a," ",y?"items":"keys"]}),!c&&d.jsx("span",{className:"text-ink-secondary",children:b})]}),c&&d.jsxs("div",{className:"ml-3 border-l border-line-grid pl-3",children:[y?e.map((v,u)=>d.jsx(al,{value:v,name:String(u),depth:n+1,path:[...r,String(u)],...i?{getSpec:i}:{}},u)):Object.entries(e).map(([v,u])=>d.jsx(al,{value:u,name:v,depth:n+1,path:[...r,v],...i?{getSpec:i}:{}},v)),d.jsx("div",{className:"text-ink-secondary",children:b})]})]})}function dE({name:e,spec:t}){const n=/^\d+$/.test(e),o=(t==null?void 0:t.description)??null;return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:K(n?"text-ink-muted":"text-ink-secondary"),children:n?`${e}:`:`"${e}":`}),t&&!t.inSpec&&d.jsx(bh,{tone:t.isExtension?"extension":"unknown",explanation:t.isExtension?"Extension — not declared in the ACP spec; contents are implementation-defined.":"Unknown — this field is not declared in the ACP schema for this message."}),(t==null?void 0:t.inSpec)&&t.isExtension&&d.jsx(bh,{tone:"extension",explanation:"Extension — _meta payload is implementation-defined per ACP spec."}),o&&d.jsx(ps,{label:d.jsx(uE,{text:o,type:t==null?void 0:t.type,enumValues:t==null?void 0:t.enumValues}),tone:"info",className:"text-ink-muted hover:text-ink-primary",focusable:!0,children:d.jsx("span",{"aria-label":`spec: ${o.split(`
|
|
1767
|
+
`)[0]}`,children:"ⓘ"})})]})}function uE({text:e,type:t,enumValues:n}){return d.jsxs("div",{className:"space-y-1.5",children:[t&&d.jsx("div",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:d.jsx("span",{className:"text-accent-info",children:t})}),d.jsx("div",{className:"whitespace-pre-wrap font-sans text-[12px] leading-snug text-ink-secondary",children:e}),n&&n.length>0&&d.jsxs("div",{className:"font-mono text-[10px] text-ink-muted",children:["enum: ",n.map(o=>JSON.stringify(o)).join(" · ")]})]})}function bh({tone:e,explanation:t}){const n=e==="extension"?"border-accent-warn/40 bg-accent-warn/10 text-accent-warn":"border-accent-error/40 bg-accent-error/10 text-accent-error";return d.jsx(ps,{label:d.jsx("span",{className:"font-sans",children:t}),tone:e==="extension"?"warn":"error",focusable:!0,children:d.jsx("span",{className:K("inline-flex items-center rounded-sm border px-1 font-mono text-[9px] uppercase tracking-widest",n),children:e==="extension"?"⚠ ext":"⚠ unknown"})})}function pE({message:e,latencyMs:t,pairedRequest:n,onJumpToPaired:o,validation:r}){const i=ne(c=>c.detailTab),s=ne(c=>c.setDetailTab),a=P.useMemo(()=>{if(!e)return null;const c=(n==null?void 0:n.method)??void 0;return ZC(e,c?{pairedMethod:c}:void 0)},[e,n]);if(!e)return d.jsx("div",{className:"flex h-full items-center justify-center bg-surface-elev/40",children:d.jsx("div",{className:"text-center font-mono text-xs uppercase tracking-widest text-ink-muted",children:"select a message to inspect"})});const l=e.direction==="editor-to-agent";return d.jsxs("div",{className:"flex h-full flex-col bg-surface-elev/30",children:[d.jsxs("header",{className:"border-b border-line bg-surface-elev px-5 py-3",children:[d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsxs("span",{className:K("font-mono text-[11px] font-semibold tracking-widest",l?"text-accent-out":"text-accent-in"),children:[Fb(e.direction)," ",zb(e.direction)]}),d.jsxs("span",{className:"font-mono text-xs text-ink-muted",children:["seq ",e.seq]}),d.jsx("span",{className:"font-mono text-xs text-ink-muted",children:fs(e.timestamp)})]}),d.jsx("h2",{className:"mt-1 truncate font-display text-lg uppercase tracking-tight text-ink-primary",children:e.method??e.kind}),d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-[11px] text-ink-secondary",children:[d.jsx(gE,{message:e,resolver:a}),e.rpcId!==void 0&&e.rpcId!==null&&d.jsx(ja,{label:"id",value:String(e.rpcId)}),d.jsx(ja,{label:"bytes",value:Ul(e.raw.length)}),t!==void 0&&d.jsx(ja,{label:"latency",value:`+${Vt(t)}`,accent:!0}),n&&d.jsxs("button",{type:"button",onClick:o?()=>o(n.seq):void 0,className:"inline-flex items-baseline gap-1 transition-colors hover:text-ink-primary",title:"jump to paired message",children:[d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:"paired"}),d.jsxs("span",{className:"text-ink-primary underline decoration-line-strong decoration-dotted underline-offset-4",children:["seq ",n.seq," ",n.method??""]})]})]})]}),d.jsxs("nav",{className:"flex gap-1 border-b border-line bg-surface-elev/70 px-4",children:[d.jsx(na,{active:i==="tree",onClick:()=>s("tree"),children:"Tree"}),d.jsx(na,{active:i==="raw",onClick:()=>s("raw"),children:"Raw"}),d.jsx(na,{active:i==="meta",onClick:()=>s("meta"),children:"Meta"}),d.jsx(na,{active:i==="spec",onClick:()=>s("spec"),badge:r&&!r.skipped&&!r.valid?r.errors.length:void 0,children:"Spec"})]}),d.jsxs("div",{className:"flex-1 overflow-auto px-5 py-4",children:[i==="tree"&&d.jsx(mE,{message:e,resolver:a}),i==="raw"&&d.jsx(hE,{raw:e.raw}),i==="meta"&&d.jsx(yE,{message:e}),i==="spec"&&d.jsx(fE,{validation:r})]})]})}function fE({validation:e}){if(!e)return d.jsx("div",{className:"font-mono text-[11px] text-ink-muted",children:"no validation result yet"});if(e.skipped){const t={"parse-error":"this frame failed to parse as JSON-RPC — already surfaced in the Tree tab as a parse error","no-method":"no method available for validation (e.g. response without a paired request)","unknown-method":"the ACP spec has no schema for this method — likely an extension or a future addition","no-schema-for-kind":"the spec has no schema for this kind of frame for this method (e.g. notification-only method)","wrong-kind":"no per-method ACP schema applies (e.g. JSON-RPC error envelope, parse failure)"};return d.jsxs("div",{className:"space-y-2 font-mono text-[11px]",children:[d.jsx("div",{className:"text-ink-muted uppercase tracking-widest text-[10px]",children:"not validated"}),d.jsx("div",{className:"text-ink-secondary",children:t[e.skipped]})]})}return e.valid?d.jsx("div",{className:"space-y-2 font-mono text-[11px]",children:d.jsxs("div",{className:"inline-flex items-baseline gap-2",children:[d.jsx("span",{className:"rounded-sm border border-accent-ok/40 bg-accent-ok/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-accent-ok",children:"✓ conforms"}),d.jsxs("span",{className:"text-ink-muted",children:["matched ",d.jsx("span",{className:"text-ink-secondary",children:e.schemaName})," ","from the ACP schema"]})]})}):d.jsxs("div",{className:"space-y-3 font-mono text-[11px]",children:[d.jsxs("div",{className:"inline-flex items-baseline gap-2",children:[d.jsxs("span",{className:"rounded-sm border border-accent-error/40 bg-accent-error/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-widest text-accent-error",children:["⚠ ",e.errors.length," violation",e.errors.length===1?"":"s"]}),d.jsxs("span",{className:"text-ink-muted",children:["against ",d.jsx("span",{className:"text-ink-secondary",children:e.schemaName})]})]}),d.jsx("ul",{className:"space-y-1.5",children:e.errors.map((t,n)=>d.jsxs("li",{className:"rounded-sm border border-accent-error/25 bg-accent-error/[0.04] px-2 py-1.5",children:[d.jsxs("div",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:[t.keyword??"error"," · ",t.path==="/"?"(root)":t.path]}),d.jsx("div",{className:"mt-0.5 text-ink-primary",children:t.message})]},`${t.path}-${t.keyword}-${n}`))})]})}function mE({message:e,resolver:t}){const n=P.useMemo(()=>{if(t)return o=>t.resolve(o)},[t]);return e.payload===null?d.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[d.jsxs("div",{className:"text-accent-error",children:["parse error: ",e.parseError??"unknown"]}),d.jsx("pre",{className:"whitespace-pre-wrap break-all text-ink-secondary",children:e.raw})]}):d.jsx(al,{value:e.payload,defaultExpanded:!0,...n?{getSpec:n}:{}})}function hE({raw:e}){const[t,n]=P.useState(!1),o=async()=>{try{await navigator.clipboard.writeText(e),n(!0),setTimeout(()=>n(!1),1500)}catch{}};return d.jsxs("div",{className:"group relative",children:[d.jsx("button",{type:"button",onClick:o,"aria-label":"Copy raw frame to clipboard",title:"Copy raw frame to clipboard",className:K("absolute right-0 top-0 inline-flex h-6 items-center rounded-sm border bg-surface-elev/70 px-2 font-mono text-[10px] uppercase tracking-widest opacity-0 transition-[opacity,background-color,border-color,color] duration-150","group-hover:opacity-100 focus-visible:opacity-100",t?"border-accent-ok/60 bg-surface-elev text-accent-ok opacity-100":"border-line text-ink-secondary hover:border-accent-info/70 hover:bg-surface-rowHover hover:text-accent-info"),children:t?"✓ copied":"copy"}),d.jsx("pre",{className:"whitespace-pre-wrap break-all font-mono text-[11px] leading-relaxed text-ink-primary",children:e})]})}function yE({message:e}){const t=[["seq",String(e.seq)],["direction",e.direction],["kind",e.kind],["method",e.method??"(none)"],["rpcId",String(e.rpcId??"(none)")],["timestamp",`${fs(e.timestamp)} (${e.timestamp})`],["raw size",Ul(e.raw.length)],["parse error",e.parseError??"(none)"]];return d.jsx("dl",{className:"grid grid-cols-[110px_1fr] gap-x-4 gap-y-1 font-mono text-[12px]",children:t.map(([n,o])=>d.jsxs("div",{className:"contents",children:[d.jsx("dt",{className:"text-ink-muted uppercase tracking-widest text-[10px]",children:n}),d.jsx("dd",{className:"text-ink-primary",children:o})]},n))})}function gE({message:e,resolver:t}){const n=d.jsx(ja,{label:"kind",value:e.kind});return t!=null&&t.typeDescription?d.jsx(ps,{label:d.jsx("div",{className:"whitespace-pre-wrap font-sans text-[12px] leading-snug text-ink-secondary",children:t.typeDescription}),tone:"info",children:n}):n}function ja({label:e,value:t,accent:n}){return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:K(n?"text-accent-warn":"text-ink-primary"),children:t})]})}function na({children:e,active:t,onClick:n,badge:o,tab:r}){return d.jsxs("button",{type:"button",onClick:n,className:K("relative flex items-baseline gap-1.5 px-4 py-2 font-mono text-[11px] uppercase tracking-widest transition-colors",t?"text-ink-primary":"text-ink-muted hover:text-ink-secondary"),children:[d.jsx("span",{children:e}),o!==void 0&&d.jsx("span",{className:"rounded-sm border border-accent-error/40 bg-accent-error/10 px-1 text-[9px] font-semibold text-accent-error",children:o}),t&&d.jsx("span",{className:"absolute inset-x-2 -bottom-px h-px bg-accent-out","aria-hidden":!0})]})}function nf(e){const t=new Map,n=new Map;for(const o of e){if(o.rpcId===void 0||o.rpcId===null)continue;const r=String(o.rpcId);if(o.kind==="request")t.set(r,o);else if(o.kind==="response"||o.kind==="error"){const i=t.get(r);if(!i)continue;const s=Math.max(0,o.timestamp-i.timestamp);n.set(i.seq,{pairSeq:o.seq,latencyMs:s}),n.set(o.seq,{pairSeq:i.seq,latencyMs:s})}}return n}function Fd(e){const t=nf(e),n=new Map,o=new Map;for(const i of e)if(i.method){if(i.kind==="request"){let s=n.get(i.method);s||(s={count:0,latencies:[]},n.set(i.method,s)),s.count+=1;const a=t.get(i.seq);a&&s.latencies.push(a.latencyMs)}else if(i.kind==="notification"){let s=o.get(i.method);s||(s={count:0,latencies:[]},o.set(i.method,s)),s.count+=1}}const r=[];for(const[i,s]of n)s.latencies.sort((a,l)=>a-l),r.push({method:i,kind:"request",count:s.count,sampleSize:s.latencies.length,p50:s.latencies.length?xh(s.latencies,50):null,p99:s.latencies.length?xh(s.latencies,99):null,max:s.latencies.length?s.latencies[s.latencies.length-1]:null,totalLatencyMs:s.latencies.length?s.latencies.reduce((a,l)=>a+l,0):null,latencies:s.latencies});for(const[i,s]of o)r.push({method:i,kind:"notification",count:s.count,sampleSize:0,p50:null,p99:null,max:null,totalLatencyMs:null,latencies:[]});return r.sort((i,s)=>s.count-i.count||(i.kind==="request"?-1:1)),r}function xh(e,t){if(e.length===0)return 0;const n=t/100*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=e[o],s=e[r];return i===void 0||s===void 0?i??0:o===r?i:i+(s-i)*(n-o)}const Bb=100;function vE(e,t,n={}){const o=n.maxChangesPerRow??Bb,r=wh(e),i=wh(t),s=bE(r,i),a=[],l={equal:0,changed:0,added:0,removed:0,total:0};for(const c of s)if(c.kind==="match"){const f=e[c.i],m=t[c.j],h=xE(f,m,o),y=h.length===0?"equal":"changed";a.push({op:y,a:f,b:m,signature:r[c.i],changes:h}),y==="equal"?l.equal+=1:l.changed+=1}else if(c.kind==="removed"){const f=e[c.i];a.push({op:"removed",a:f,b:null,signature:r[c.i],changes:[]}),l.removed+=1}else{const f=t[c.j];a.push({op:"added",a:null,b:f,signature:i[c.j],changes:[]}),l.added+=1}return l.total=a.length,{rows:a,summary:l}}function wh(e){const t=nf(e),n=new Map;for(const o of e)o.method&&n.set(o.seq,o.method);return e.map(o=>{let r=o.method??"";if(!r&&(o.kind==="response"||o.kind==="error")){const i=t.get(o.seq);i&&(r=n.get(i.pairSeq)??"")}return`${o.direction}|${o.kind}|${r}`})}function bE(e,t){const n=e.length,o=t.length,r=o+1,i=new Uint32Array((n+1)*r);for(let c=n-1;c>=0;c--)for(let f=o-1;f>=0;f--){const m=c*r+f;if(e[c]===t[f])i[m]=i[(c+1)*r+(f+1)]+1;else{const h=i[(c+1)*r+f],y=i[c*r+(f+1)];i[m]=h>=y?h:y}}const s=[];let a=0,l=0;for(;a<n&&l<o;)e[a]===t[l]?(s.push({kind:"match",i:a,j:l}),a++,l++):i[(a+1)*r+l]>=i[a*r+(l+1)]?(s.push({kind:"removed",i:a}),a++):(s.push({kind:"added",j:l}),l++);for(;a<n;)s.push({kind:"removed",i:a}),a++;for(;l<o;)s.push({kind:"added",j:l}),l++;return s}function Sh(e){const t=e.payload;if(t===null||typeof t!="object")return{raw:e.raw,parseError:e.parseError??null};const n=t,o={};return"method"in n&&(o.method=n.method),"params"in n&&(o.params=n.params),"result"in n&&(o.result=n.result),"error"in n&&(o.error=n.error),o}function xE(e,t,n){const o=[];return ll(Sh(e),Sh(t),"",o,n),o}function wE(e,t,n=Bb){const o=[];return ll(e,t,"",o,n),o}function $h(e){return Array.isArray(e)?"array":e!==null&&typeof e=="object"?"object":"leaf"}function ll(e,t,n,o,r){if(o.length>=r||Object.is(e,t))return;const i=$h(e),s=$h(t);if(i!==s||i==="leaf"){if(SE(e,t))return;o.push({path:n||"$",kind:"change",a:e,b:t});return}if(i==="array"){const f=e,m=t,h=Math.max(f.length,m.length);for(let y=0;y<h;y++){if(o.length>=r)return;const g=`${n}[${y}]`,b=y<f.length,v=y<m.length;b&&v?ll(f[y],m[y],g,o,r):v?o.push({path:g,kind:"add",b:m[y]}):o.push({path:g,kind:"remove",a:f[y]})}return}const a=e,l=t,c=[...new Set([...Object.keys(a),...Object.keys(l)])].sort();for(const f of c){if(o.length>=r)return;const m=n?`${n}.${f}`:f,h=f in a,y=f in l;h&&y?ll(a[f],l[f],m,o,r):y?o.push({path:m,kind:"add",b:l[f]}):o.push({path:m,kind:"remove",a:a[f]})}}function SE(e,t){return Object.is(e,t)}function Ne(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}function xn(e){return typeof e=="string"&&e.length>0?e:null}function Ao(e){return e===!0}function $E(e){for(const t of e)if(t.kind==="request"&&t.method==="initialize"&&t.direction==="editor-to-agent")return t;return null}function kE(e,t){if(t==null)return null;for(const n of e)if(n.kind==="response"&&n.direction==="agent-to-editor"&&n.rpcId===t)return n;return null}function TE(e){var r,i;const t={name:null,title:null,version:null,platform:null};if(!e)return t;const n=Ne((r=Ne(e.payload))==null?void 0:r.params),o=Ne(n==null?void 0:n.clientInfo);return o?{name:xn(o.name),title:xn(o.title),version:xn(o.version),platform:xn((i=Ne(o._meta))==null?void 0:i.platform)}:t}function _E(e){var s,a;const t={fsReadTextFile:!1,fsWriteTextFile:!1,terminal:!1,authTerminal:!1,authGateway:!1};if(!e)return t;const n=Ne((s=Ne(e.payload))==null?void 0:s.params),o=Ne(n==null?void 0:n.clientCapabilities);if(!o)return t;const r=Ne(o.fs),i=Ne(o.auth);return{fsReadTextFile:Ao(r==null?void 0:r.readTextFile),fsWriteTextFile:Ao(r==null?void 0:r.writeTextFile),terminal:Ao(o.terminal),authTerminal:Ao(i==null?void 0:i.terminal),authGateway:Ao((a=Ne(i==null?void 0:i._meta))==null?void 0:a.gateway)}}function jE(e){var i;const t={name:null,version:null,authMethods:0};if(!e)return t;const n=Ne((i=Ne(e.payload))==null?void 0:i.result);if(!n)return t;const o=Ne(n.agentInfo),r=n.authMethods;return{name:xn(o==null?void 0:o.name),version:xn(o==null?void 0:o.version),authMethods:Array.isArray(r)?r.length:0}}function NE(e){var r;const t={prompt:!1,loadSession:!1};if(!e)return t;const n=Ne((r=Ne(e.payload))==null?void 0:r.result),o=Ne(n==null?void 0:n.agentCapabilities);return o?{prompt:Ao(o.promptCapabilities)||o.promptCapabilities!==void 0,loadSession:Ao(o.loadSession)}:t}function CE(e,t){const n=t??e;if(!n)return null;const o=Ne(n.payload),r=Ne(o==null?void 0:o.result)??Ne(o==null?void 0:o.params),i=r==null?void 0:r.protocolVersion;return typeof i=="number"?i:null}function EE(e){var s,a;let t=null,n=0,o=null,r=0,i=[];for(const l of e){l.direction!=="editor-to-agent"&&l.kind;const c=Ne((s=Ne(l.payload))==null?void 0:s.params);if(c){if(l.method==="session/set_mode"){const f=xn(c.modeId);f!==null&&(t!==null&&t!==f&&(n+=1),t=f)}else if(l.method==="session/set_model"){const f=xn(c.modelId);f!==null&&(o!==null&&o!==f&&(r+=1),o=f)}else if(l.method==="session/update"){const f=Ne(c.update);if((f==null?void 0:f.sessionUpdate)==="available_commands_update"){const m=f.availableCommands;if(Array.isArray(m)){const h=[];for(const y of m){const g=xn((a=Ne(y))==null?void 0:a.name);g!==null&&h.push(g)}h.length>0&&(i=h)}}else if((f==null?void 0:f.sessionUpdate)==="current_mode_update"){const m=xn(f.currentModeId);m!==null&&(t!==null&&t!==m&&(n+=1),t=m)}}}}return{currentMode:t,modeChanges:n,currentModel:o,modelChanges:r,availableCommands:i}}function PE(e){if(!e)return{jetbrainsProxyConfig:null};const t=Ne(e.payload),n=Ne(t==null?void 0:t.params),o=Ne(n==null?void 0:n._meta);return{jetbrainsProxyConfig:(o==null?void 0:o.proxyConfig)??null}}function cl(e){const t=$E(e),n=kE(e,t==null?void 0:t.rpcId);return{protocolVersion:CE(t,n),client:TE(t),agent:jE(n),clientCapabilities:_E(t),agentCapabilities:NE(n),runtime:EE(e),extensions:PE(t)}}function kh(e){return{protocolVersion:e.protocolVersion,client:e.client,agent:e.agent,clientCapabilities:e.clientCapabilities,agentCapabilities:e.agentCapabilities,runtime:e.runtime}}function IE(e,t){const n=cl(e),o=cl(t);return{a:n,b:o,changes:wE(kh(n),kh(o))}}function OE(e,t){const n=Fd(e),o=Fd(t),r=l=>`${l.kind}:${l.method}`,i=new Map(n.map(l=>[r(l),l])),s=new Map(o.map(l=>[r(l),l])),a=[];for(const l of new Set([...i.keys(),...s.keys()])){const c=i.get(l)??null,f=s.get(l)??null,m=c??f;a.push({method:m.method,kind:m.kind,a:c,b:f,countDelta:((f==null?void 0:f.count)??0)-((c==null?void 0:c.count)??0),p50Delta:kc(c==null?void 0:c.p50,f==null?void 0:f.p50),p99Delta:kc(c==null?void 0:c.p99,f==null?void 0:f.p99),maxDelta:kc(c==null?void 0:c.max,f==null?void 0:f.max)})}return a.sort((l,c)=>Math.abs(c.p99Delta??0)-Math.abs(l.p99Delta??0)||Math.abs(c.countDelta)-Math.abs(l.countDelta)||l.method.localeCompare(c.method)),a}function kc(e,t){return e==null||t===null||t===void 0?null:t-e}function of(e,t=200){const[n,o]=P.useState(e),[r,i]=P.useState(!1);return P.useEffect(()=>{if(e){o(!0);let a=null;const l=requestAnimationFrame(()=>{a=requestAnimationFrame(()=>i(!0))});return()=>{cancelAnimationFrame(l),a!==null&&cancelAnimationFrame(a)}}i(!1);const s=setTimeout(()=>o(!1),t);return()=>clearTimeout(s)},[e,t]),{rendered:n,visible:r}}const rf="flex h-9 items-center gap-4 border-b border-line bg-surface-base px-5",RE={request:"REQ",response:"RSP",notification:"NTF",error:"ERR",unknown:"UNK"};function AE(e){return e.direction==="editor-to-agent"?"→A":"A←"}function Hb(e){if(e.name)return`#${e.id} · ${e.name}`;const t=e.agent_command?Rt(e.agent_command):"agent";return e.client_name?`#${e.id} · ${e.client_name} · ${t}`:`#${e.id} · ${t}`}const Th={messages:null,loading:!1,error:null};function _h(e){const[t,n]=P.useState(Th);return P.useEffect(()=>{if(e===null){n(Th);return}let o=!1;return n({messages:null,loading:!0,error:null}),xS(e).then(r=>{o||n({messages:r.messages,loading:!1,error:null})}).catch(r=>{o||n({messages:null,loading:!1,error:r instanceof Error?r.message:String(r)})}),()=>{o=!0}},[e]),t}function ME({open:e,onClose:t}){const n=ne(D=>D.messages),o=ne(D=>D.session),r=ft(D=>D.savedSessions),i=(o==null?void 0:o.id)??null,[s,a]=P.useState(null),[l,c]=P.useState(null),[f,m]=P.useState("frames"),[h,y]=P.useState(!0),[g,b]=P.useState(null),{rendered:v,visible:u}=of(e);P.useEffect(()=>{if(!e)return;const D=Q=>{Q.key==="Escape"&&(Q.preventDefault(),t())};return window.addEventListener("keydown",D,!0),()=>window.removeEventListener("keydown",D,!0)},[e,t]),P.useEffect(()=>{e&&(a(i),c(null),b(null))},[e,i]),P.useEffect(()=>b(null),[s,l]);const p=_h(s!==null&&s!==i?s:null),x=_h(l!==null&&l!==i?l:null),S=s===null?null:s===i?n:p.messages,T=l===null?null:l===i?n:x.messages,C=p.loading||x.loading,$=p.error??x.error,j=P.useMemo(()=>S===null||T===null?null:vE(S,T),[S,T]),R=P.useMemo(()=>{if(!j)return[];const D=[];return j.rows.forEach((Q,ee)=>{h&&Q.op==="equal"||D.push({row:Q,index:ee})}),D},[j,h]),M=P.useMemo(()=>{const D=r.find(Q=>Q.id===l);return D?Hb(D):null},[r,l]),F=P.useMemo(()=>S&&T?IE(S,T):null,[S,T]),V=P.useMemo(()=>S&&T?OE(S,T):null,[S,T]);if(!v)return null;const L=r.filter(D=>D.id!==l),U=r.filter(D=>D.id!==s);return d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Session diff",className:K("fixed inset-0 z-[100] flex flex-col bg-surface-base/95 backdrop-blur-sm transition-opacity duration-200 ease-out",u?"opacity-100":"opacity-0"),children:d.jsxs("div",{className:K("flex h-full w-full flex-col transition-transform duration-200 ease-out",u?"translate-y-0":"-translate-y-2"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Diff — compare two sessions"}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close diff panel",children:"close"})]}),d.jsxs("div",{className:"flex flex-wrap items-center gap-3 border-b border-line bg-surface-elev px-5 py-2.5",children:[d.jsx("span",{className:"font-mono text-[11px] text-accent-out",title:"baseline (left)",children:"A"}),d.jsx(Eh,{ariaLabel:"Baseline session",sessions:L,selectedId:s,onSelect:a}),d.jsx("span",{className:"text-ink-muted",children:"→"}),d.jsx("span",{className:"font-mono text-[11px] text-ink-secondary",title:"comparison (right)",children:"B"}),d.jsx(Eh,{ariaLabel:"Comparison session",sessions:U,selectedId:l,onSelect:c})]}),s===null?d.jsx(bi,{children:"Pick a baseline session (A) to compare from."}):l===null?d.jsx(bi,{children:"Pick a session in the B selector above to compare against A."}):C?d.jsx(bi,{children:"Loading sessions…"}):$?d.jsxs(bi,{tone:"error",children:["Could not load a session: ",$]}):!j||!F||!V?d.jsx(bi,{children:"No data."}):d.jsxs(d.Fragment,{children:[d.jsx(qE,{tab:f,onTab:m,summary:j.summary,infoCount:F.changes.length}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[f==="frames"&&d.jsx(UE,{diff:j,bLabel:M,hideEqual:h,onHideEqual:y,visibleRows:R,expanded:g,onToggleExpand:D=>b(Q=>Q===D?null:D)}),f==="info"&&d.jsx(LE,{meta:F}),f==="perf"&&d.jsx(zE,{perf:V})]})]})]})})}function qE({tab:e,onTab:t,summary:n,infoCount:o}){const i=[{id:"frames",label:"frames",badge:n.changed+n.added+n.removed},{id:"info",label:"info",badge:o},{id:"perf",label:"perf",badge:0}];return d.jsx("div",{className:"flex items-center gap-1 border-b border-line bg-surface-elev px-5 py-1.5",children:i.map(s=>d.jsxs("button",{type:"button",onClick:()=>t(s.id),className:K("inline-flex items-center gap-1.5 rounded-sm px-3 py-1 font-mono text-[10px] uppercase tracking-widest transition-colors",e===s.id?"bg-surface-rowHover text-ink-primary":"text-ink-muted hover:text-ink-secondary"),children:[s.label,s.badge>0&&d.jsx("span",{className:"rounded-sm border border-line px-1 text-[9px] text-ink-secondary",children:s.badge})]},s.id))})}function UE({diff:e,bLabel:t,hideEqual:n,onHideEqual:o,visibleRows:r,expanded:i,onToggleExpand:s}){const a=e.summary.changed===0&&e.summary.added===0&&e.summary.removed===0;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K(rf,"font-mono text-[11px]"),children:[d.jsxs("span",{className:"text-ink-muted",children:[e.summary.equal," same"]}),d.jsxs("span",{className:"text-accent-warn",children:[e.summary.changed," differs"]}),d.jsxs("span",{className:"text-accent-error",children:[e.summary.removed," only in A"]}),d.jsxs("span",{className:"text-accent-ok",children:[e.summary.added," only in B"]}),d.jsxs("label",{className:"ml-auto flex cursor-pointer select-none items-center gap-2 text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx("input",{type:"checkbox",checked:n,onChange:l=>o(l.target.checked),className:"accent-accent-info"}),"hide unchanged"]})]}),a?d.jsxs(ms,{tone:"ok",children:["Sessions are identical",t?` — every frame in B (${t}) matches A`:"","."]}):r.length===0?d.jsx(ms,{children:"Only unchanged frames — toggle “hide unchanged” to see them."}):d.jsxs("table",{className:"w-full table-fixed border-collapse font-mono text-[11px]",children:[d.jsxs("colgroup",{children:[d.jsx("col",{className:"w-[24px]"}),d.jsx("col",{className:"w-1/2"}),d.jsx("col",{className:"w-1/2"})]}),d.jsx("tbody",{children:r.map(({row:l,index:c})=>d.jsx(HE,{row:l,expanded:i===c,onToggle:()=>s(c)},c))})]})]})}function Vb(){return d.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-warn",children:"~"})," changed"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-ok",children:"+"})," only in B"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-error",children:"−"})," only in A"]})]})}function LE({meta:e}){return e.changes.length===0?d.jsx(ms,{tone:"ok",children:"Metadata identical — same client, agent, capabilities, protocol and runtime."}):d.jsxs(d.Fragment,{children:[d.jsx("div",{className:rf,children:d.jsx(Vb,{})}),d.jsx("ul",{className:"space-y-1 px-5 py-3 font-mono text-[11px]",children:e.changes.map((t,n)=>d.jsx("li",{className:"leading-snug",children:d.jsx(Wb,{change:t})},n))})]})}function jh(e){return e==null?"—":Vt(e)}function DE(e){return e===null?{text:"—",tone:"text-ink-dim"}:e===0?{text:"0",tone:"text-ink-muted"}:{text:(e>0?"+":"−")+Vt(Math.abs(e)),tone:e>0?"text-accent-error":"text-accent-ok"}}function zE({perf:e}){return e.length===0?d.jsx(ms,{children:"No methods to compare."}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:K(rf,"font-mono text-[10px] uppercase tracking-widest text-ink-muted"),children:[d.jsx("span",{children:"Δ = B − A · sorted by |Δ p99|"}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-error",children:"+"})," slower in B"]}),d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{className:"text-accent-ok",children:"−"})," faster in B"]})]}),d.jsxs("table",{className:"w-full text-[11px]",children:[d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-base",children:d.jsxs("tr",{className:"border-b border-line text-left font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx("th",{className:"py-2 pl-5 pr-3",children:"method"}),d.jsx("th",{className:"px-3 py-2",children:"kind"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"A p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"B p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"Δ p99"}),d.jsx("th",{className:"px-3 py-2 text-right",children:"count"})]})}),d.jsx("tbody",{className:"font-mono",children:e.map(t=>{var o,r,i,s;const n=DE(t.p99Delta);return d.jsxs("tr",{className:"border-b border-line/40 hover:bg-surface-rowHover/50",children:[d.jsx("td",{className:"truncate py-1.5 pl-5 pr-3 text-ink-primary",title:t.method,children:t.method}),d.jsx("td",{className:"px-3 py-1.5 text-[10px] uppercase tracking-widest text-ink-muted",children:t.kind==="request"?"req":"ntf"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:jh(((o=t.a)==null?void 0:o.p99)??null)}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:jh(((r=t.b)==null?void 0:r.p99)??null)}),d.jsx("td",{className:K("px-3 py-1.5 text-right",n.tone),children:n.text}),d.jsxs("td",{className:"px-3 py-1.5 text-right text-ink-muted",children:[((i=t.a)==null?void 0:i.count)??0,"→",((s=t.b)==null?void 0:s.count)??0]})]},`${t.kind}:${t.method}`)})})]})]})}function bi({children:e,tone:t}){return d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:d.jsx(ms,{...t?{tone:t}:{},children:e})})}const FE={equal:"",changed:"bg-accent-warn/5",added:"bg-accent-ok/5",removed:"bg-accent-error/5"},BE={equal:{glyph:"=",tone:"text-ink-dim"},changed:{glyph:"≠",tone:"text-accent-warn"},added:{glyph:"▸",tone:"text-accent-ok"},removed:{glyph:"◂",tone:"text-accent-error"}};function HE({row:e,expanded:t,onToggle:n}){const o=BE[e.op],r=e.op==="changed"&&e.changes.length>0;return d.jsxs(d.Fragment,{children:[d.jsxs("tr",{className:K("border-b border-line/40 align-top",FE[e.op],r&&"cursor-pointer hover:bg-accent-warn/10"),onClick:r?n:void 0,children:[d.jsx("td",{className:K("py-1.5 pl-5 text-center",o.tone),children:o.glyph}),d.jsx("td",{className:"px-3 py-1.5",children:d.jsx(Nh,{frame:e.a,muted:e.op==="added"})}),d.jsxs("td",{className:"px-3 py-1.5",children:[d.jsx(Nh,{frame:e.b,muted:e.op==="removed"}),r&&d.jsxs("span",{className:"ml-2 text-[10px] text-accent-warn",children:[t?"▾":"▸"," ",e.changes.length," field",e.changes.length===1?"":"s"]})]})]}),r&&t&&d.jsxs("tr",{className:"border-b border-line/40 bg-surface-elev",children:[d.jsx("td",{}),d.jsxs("td",{colSpan:2,className:"px-5 py-2",children:[d.jsx("div",{className:"mb-1.5",children:d.jsx(Vb,{})}),d.jsx("ul",{className:"space-y-1",children:e.changes.map((i,s)=>d.jsx("li",{className:"leading-snug",children:d.jsx(Wb,{change:i})},s))})]})]})]})}function Nh({frame:e,muted:t}){if(e===null)return d.jsx("span",{className:"text-ink-dim",children:"—"});const n=e.method??(e.parseError?`! ${e.parseError}`:"—");return d.jsxs("span",{className:K("inline-flex items-baseline gap-2",t&&"opacity-60"),children:[d.jsx("span",{className:"text-ink-dim",children:AE(e)}),d.jsx("span",{className:"text-[10px] uppercase tracking-widest text-ink-muted",children:RE[e.kind]}),d.jsx("span",{className:"truncate text-ink-primary",title:n,children:n}),d.jsxs("span",{className:"text-ink-dim",children:["#",e.seq]})]})}const Ch=80;function oa(e){let t;try{t=JSON.stringify(e)}catch{t=String(e)}return t===void 0&&(t="undefined"),t.length>Ch&&(t=t.slice(0,Ch-1)+"…"),t}function Wb({change:e}){return e.kind==="add"?d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-ok",children:"+ "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-ok",children:oa(e.b)})]}):e.kind==="remove"?d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-error",children:"− "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-error line-through",children:oa(e.a)})]}):d.jsxs("span",{children:[d.jsx("span",{className:"text-accent-warn",children:"~ "}),d.jsx("span",{className:"text-ink-secondary",children:e.path}),d.jsx("span",{className:"text-ink-muted",children:": "}),d.jsx("span",{className:"text-accent-error line-through",children:oa(e.a)}),d.jsx("span",{className:"text-ink-muted",children:" → "}),d.jsx("span",{className:"text-accent-ok",children:oa(e.b)})]})}function ms({children:e,tone:t="muted"}){const n=t==="error"?"text-accent-error":t==="ok"?"text-accent-ok":"text-ink-muted";return d.jsx("div",{className:K("px-5 py-8 text-center font-mono text-[12px]",n),children:e})}function Eh({ariaLabel:e,sessions:t,selectedId:n,onSelect:o}){const[r,i]=P.useState(!1),s=P.useRef(null);P.useEffect(()=>{if(!r)return;const m=h=>{s.current&&!s.current.contains(h.target)&&i(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[r]);const a=t.filter(m=>m.imported_at===null),l=t.filter(m=>m.imported_at!==null),c=n!==null?t.find(m=>m.id===n)??null:null,f=c?Hb(c):n!==null?`#${n}`:"select a session…";return d.jsxs("div",{ref:s,className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>i(m=>!m),"aria-label":e,"aria-haspopup":"listbox","aria-expanded":r,className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] uppercase tracking-widest transition-colors","border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",r?"border-line-strong text-ink-primary":""),title:`${e} — pick which session to compare`,children:[d.jsx("span",{className:"inline-block w-[240px] truncate text-left",children:f}),d.jsx("span",{"aria-hidden":!0,className:K("transition-transform",r?"rotate-180":""),children:"▾"})]}),r&&d.jsxs("div",{className:"absolute left-0 top-[calc(100%+6px)] z-50 w-[460px] rounded-md border border-line bg-surface-elev shadow-xl",children:[d.jsxs(Ph,{children:["saved · ",a.length," session",a.length===1?"":"s"]}),a.length===0&&d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:"no other saved sessions to compare"}),d.jsx("ul",{className:"max-h-[300px] overflow-y-auto",children:a.map(m=>d.jsx(Ih,{s:m,active:m.id===n,onPick:()=>{o(m.id),i(!1)}},m.id))}),l.length>0&&d.jsxs(d.Fragment,{children:[d.jsxs(Ph,{children:["imported · ",l.length," file",l.length===1?"":"s"]}),d.jsx("ul",{className:"max-h-[200px] overflow-y-auto",children:l.map(m=>d.jsx(Ih,{s:m,active:m.id===n,onPick:()=>{o(m.id),i(!1)}},m.id))})]})]})]})}function Ph({children:e}){return d.jsx("div",{className:"border-b border-line bg-surface-base/50 px-3 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e})}function Ih({s:e,active:t,onPick:n}){return d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:n,title:`session #${e.id} · ${e.agent_command??""} · ${e.message_count} messages`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",t?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",t?"bg-accent-note animate-pulse-soft":"bg-ink-dim")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsxs("span",{className:"text-accent-note",children:["#",e.id]}),d.jsx("span",{className:"text-ink-muted",children:" · "}),e.name??(e.client_name?`${e.client_name} · ${Rt(e.agent_command??"")}`:Rt(e.agent_command??""))]}),d.jsxs("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[e.message_count,"msg · ",Ar(e.started_at)]})]})})}let Tc=null,xi=null;async function VE(){if(Tc)return Tc;if(xi)return xi;xi=(async()=>{const e=await fetch("/api/info",{headers:{accept:"application/json"}});if(!e.ok)throw new Error(`info: HTTP ${e.status}`);const t=await e.json();return Tc=t,t})();try{return await xi}finally{xi=null}}const WE=[{id:"zed",label:"Zed"},{id:"jetbrains",label:"JetBrains"}],KE="/absolute/path/to/acp-devtools";function GE(e){return JSON.stringify({agent_servers:{"Claude Code (via ACP Devtools)":{type:"custom",command:e}}},null,4)}function Kb({text:e,label:t="Copy"}){const[n,o]=P.useState(!1),r=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),1400)}catch{o(!1)}};return d.jsx("button",{type:"button",onClick:r,className:K("rounded border border-line px-2 py-0.5 font-mono text-[10px] uppercase tracking-widest transition-colors",n?"border-accent-out text-accent-out":"text-ink-secondary hover:border-ink-secondary hover:text-ink-primary"),children:n?"Copied":t})}function JE(){const[e,t]=P.useState("zed"),[n,o]=P.useState(null);P.useEffect(()=>{let a=!0;return VE().then(l=>{a&&o(l.binaryPath)}).catch(()=>{}),()=>{a=!1}},[]);const r=n??KE,i=n===null,s=P.useMemo(()=>({zed:GE(r),jetbrainsName:"Claude Code (via ACP Devtools)"}),[r]);return d.jsxs("div",{className:"rounded border border-line bg-surface-base",children:[d.jsx("div",{className:"flex items-center gap-1 border-b border-line px-3 py-2",children:WE.map(a=>d.jsx("button",{type:"button",onClick:()=>t(a.id),className:K("rounded px-2 py-1 font-mono text-[10px] uppercase tracking-widest transition-colors",e===a.id?"bg-surface-elev text-ink-primary":"text-ink-secondary hover:text-ink-primary"),children:a.label},a.id))}),e==="zed"&&d.jsxs("div",{className:"px-3 py-3",children:[d.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"~/.config/zed/settings.json"}),d.jsx(Kb,{text:s.zed})]}),d.jsx("pre",{className:"overflow-x-auto rounded border border-line bg-surface-elev/60 px-3 py-2 font-mono text-[11px] leading-relaxed text-ink-primary",children:s.zed}),d.jsxs("p",{className:"mt-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["Open Zed, paste into ",d.jsx("span",{className:"font-mono",children:"settings.json"})," ","(Cmd+,), pick the new agent in the right-side panel, send a prompt. The CLI auto-proxies ",d.jsx("span",{className:"font-mono",children:"@zed-industries/claude-code-acp"})," ","when launched with no args."]}),d.jsx(Oh,{isPlaceholder:i})]}),e==="jetbrains"&&d.jsxs("div",{className:"px-3 py-3",children:[d.jsxs("p",{className:"mb-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["Settings (Cmd+,) → search ",d.jsx("span",{className:"font-mono",children:"agent"})," → open the AI Assistant / Junie agent-servers page → add a new entry with these fields (no arguments needed):"]}),d.jsxs("div",{className:"grid gap-2",children:[d.jsx(Rh,{label:"Name",value:s.jetbrainsName}),d.jsx(Rh,{label:"Command",value:r})]}),d.jsxs("p",{className:"mt-3 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["JetBrains IDEs require an absolute ",d.jsx("span",{className:"font-mono",children:"command"}),". See ",d.jsx("span",{className:"font-mono",children:"examples/jetbrains-config.md"})," if the agent-servers page is not where the search suggests."]}),d.jsx(Oh,{isPlaceholder:i})]})]})}function Oh({isPlaceholder:e}){return e?d.jsxs("div",{className:"mt-3 rounded border border-line border-dashed bg-surface-elev/40 px-3 py-2 font-sans text-[11px] leading-relaxed text-ink-secondary",children:["You're viewing the UI through a development server, so the absolute binary path couldn't be auto-detected. After running"," ",d.jsx("span",{className:"font-mono",children:"npm run build:full"})," in the repo and"," ",d.jsx("span",{className:"font-mono",children:"npm link"})," inside"," ",d.jsx("span",{className:"font-mono",children:"packages/cli/"}),", find the path with"," ",d.jsx("span",{className:"font-mono",children:"which acp-devtools"})," and replace the placeholder above."]}):d.jsxs("p",{className:"mt-3 font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:["path auto-resolved · verify with ",d.jsx("span",{className:"text-ink-secondary",children:"which acp-devtools"})]})}function Rh({label:e,value:t}){return d.jsxs("div",{className:"flex items-center gap-2 rounded border border-line bg-surface-elev/60 px-3 py-1.5",children:[d.jsx("span",{className:"w-20 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:"flex-1 truncate font-mono text-[11px] text-ink-primary",children:t}),d.jsx(Kb,{text:t})]})}function QE({status:e,lastError:t,url:n,captureCount:o}){const r=e==="open"?"Awaiting messages":e==="connecting"?"Connecting":e==="closed"?"Disconnected":e==="error"?"Connection error":"No live capture",i=e==="open"?"text-accent-out":e==="error"?"text-accent-error":"text-ink-secondary";return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-grid",children:d.jsxs("div",{className:"relative w-[min(720px,92%)] rounded-md border border-line bg-surface-elev/80 p-6 backdrop-blur-sm",children:[d.jsxs("div",{className:"mb-1 flex items-baseline gap-3",children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:"acp.devtools"}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"v0.2.1 / pre-alpha"})]}),d.jsx("h2",{className:K("font-display text-2xl uppercase tracking-tight",i),children:r}),d.jsx("p",{className:"mt-2 font-sans text-sm leading-relaxed text-ink-secondary",children:"Connect an IDE to start streaming ACP frames. Pick yours below — the snippet plugs acp-devtools between editor and agent so every message is captured live."}),o>0&&d.jsxs("p",{className:"mt-2 font-mono text-[11px] uppercase tracking-widest text-accent-out",children:[o," live capture",o===1?"":"s"," discovered — pick one in the picker above"]}),d.jsx("div",{className:"mt-4",children:d.jsx(JE,{})}),d.jsxs("div",{className:"mt-4 flex items-center gap-3 font-mono text-[11px]",children:[d.jsx(YE,{status:e}),d.jsx("span",{className:"text-ink-secondary",children:n}),t&&d.jsx("span",{className:"text-accent-error",children:t})]})]})})}function YE({status:e}){const t=e==="open"?"bg-accent-out":e==="connecting"?"bg-accent-warn animate-pulse-soft":e==="error"?"bg-accent-error":"bg-ink-dim";return d.jsx("span",{className:K("h-2 w-2 rounded-full",t),"aria-hidden":!0})}function XE(){const e=ne(i=>i.filters),t=ne(i=>i.toggleDirection),n=ne(i=>i.toggleKind),o=ne(i=>i.toggleStreams),r=ne(i=>i.setSearch);return d.jsxs("div",{className:"flex items-center gap-3 border-b border-line bg-surface-elev/70 px-4 py-2",children:[d.jsx("div",{className:"flex items-center gap-1",children:ls.map(i=>d.jsx(tP,{dir:i,active:e.directions.has(i),onClick:()=>t(i)},i))}),d.jsx(rP,{}),d.jsxs("div",{className:"flex items-center gap-1",children:[cs.map(i=>d.jsx(nP,{kind:i,active:e.kinds.has(i),onClick:()=>n(i)},i)),d.jsx(oP,{active:e.showStreams,onClick:o})]}),d.jsx("div",{className:"ml-auto",children:d.jsx("input",{type:"search",placeholder:"search payload…",value:e.search,onChange:i=>r(i.target.value),className:K("h-7 w-64 rounded border border-line bg-surface-base px-2 font-mono text-[11px] text-ink-primary placeholder-ink-muted","focus:border-accent-out focus:outline-none")})})]})}const ZE={"editor-to-agent":"editor → agent (toggle to filter messages flowing from your IDE to the AI)","agent-to-editor":"agent → editor (toggle to filter messages coming back from the AI)"},eP={request:"request — expects a response",response:"response — answer to a previous request",notification:"notification — one-way event, no response",error:"error — response carrying an error object",unknown:"unknown — frames that could not be classified as JSON-RPC"};function tP({dir:e,active:t,onClick:n}){const o=e==="editor-to-agent",r=o?"→ OUT":"← IN",i=o?"text-accent-out":"text-accent-in";return d.jsx("button",{type:"button",onClick:n,title:ZE[e],className:K("inline-flex items-center gap-1 rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold tracking-widest transition-colors",t?K(i,o?"border-accent-out/50 bg-accent-out/10":"border-accent-in/50 bg-accent-in/10"):"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:r})}function nP({kind:e,active:t,onClick:n}){const r={request:{color:"text-accent-out",border:"border-accent-out/50",bg:"bg-accent-out/10"},response:{color:"text-accent-in",border:"border-accent-in/50",bg:"bg-accent-in/10"},notification:{color:"text-accent-note",border:"border-accent-note/50",bg:"bg-accent-note/10"},error:{color:"text-accent-error",border:"border-accent-error/50",bg:"bg-accent-error/10"},unknown:{color:"text-ink-muted",border:"border-line",bg:"bg-surface-row"}}[e];return d.jsx("button",{type:"button",onClick:n,title:eP[e],className:K("rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",t?K(r.color,r.border,r.bg):"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:e})}function oP({active:e,onClick:t}){return d.jsx("button",{type:"button",onClick:t,title:"stream — collapse runs of agent_message_chunk notifications into a single row",className:K("rounded-sm border px-2 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",e?"border-accent-note/50 bg-accent-note/10 text-accent-note":"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),children:"stream"})}function rP(){return d.jsx("span",{"aria-hidden":!0,className:"h-5 w-px bg-line"})}const iP={minSamplesForTail:3,longTailRatio:5,minBusiestCount:50,minBusiestRatio:2.5,minHotspotShare:.4,minSamplesForOutlier:5,outlierRatio:3};function sP(e,t,n={}){const o={...iP,...n},r=[],i=t.reduce((y,g)=>y+(g.totalLatencyMs??0),0);if(i>0){const g=t.filter(b=>b.totalLatencyMs!==null&&b.totalLatencyMs>0).sort((b,v)=>(v.totalLatencyMs??0)-(b.totalLatencyMs??0))[0];if(g&&g.totalLatencyMs!==null){const b=g.totalLatencyMs/i;b>=o.minHotspotShare&&r.push({kind:"hotspot",summary:`${g.method} consumed ${ar(g.totalLatencyMs)} of total wall time`,detail:`${Math.round(b*100)}% of ${ar(i)} sampled latency`,methods:[g.method]})}}const a=t.filter(y=>y.sampleSize>=o.minSamplesForTail&&y.p50!==null&&y.p99!==null&&y.p50>0&&y.p99/y.p50>=o.longTailRatio).sort((y,g)=>(g.p99??0)/(g.p50??1)-(y.p99??0)/(y.p50??1))[0];if(a&&a.p99!==null&&a.p50!==null){const y=Math.round(a.p99/a.p50);r.push({kind:"long-tail",summary:`${a.method} has a long tail — p99 is ${y}× the p50`,detail:`p50 ${ar(a.p50)} · p99 ${ar(a.p99)} · ${a.sampleSize} samples`,methods:[a.method]})}const l=[...t].filter(y=>y.sampleSize>=o.minSamplesForOutlier&&y.p99!==null&&y.max!==null&&y.p99>0&&y.max/y.p99>=o.outlierRatio).sort((y,g)=>(g.max??0)-(y.max??0))[0];if(l&&l.max!==null&&l.p99!==null){const y=Math.round(l.max/l.p99);r.push({kind:"outlier",summary:`${l.method} had one ${ar(l.max)} call — ${y}× its p99`,detail:`p99 ${ar(l.p99)} · ${l.sampleSize} samples`,methods:[l.method]})}const c=[...t].sort((y,g)=>g.count-y.count),f=c[0],m=c[1];if(f&&f.count>=o.minBusiestCount){const y=m&&m.count>0?f.count/m.count:1/0;if(y>=o.minBusiestRatio){const g=f.kind==="notification"?"notifications":"calls";r.push({kind:"busiest",summary:`${f.method} sent ${f.count} ${g}`,detail:m?`${y.toFixed(1)}× the next-busiest method (${m.method} · ${m.count})`:"no other methods to compare against",methods:[f.method]})}}const h=aP(e);if(h.length>0){const y=h.slice(0,3),g=h.length>3?` (+${h.length-3} more)`:"";r.push({kind:"errors",summary:`${h.length} method${h.length===1?"":"s"} returned an error`,detail:y.join(", ")+g,methods:h})}return r}function aP(e){const t=new Map,n=new Set;for(const o of e){const r=o.rpcId===void 0||o.rpcId===null?null:String(o.rpcId);if(o.kind==="request"&&o.method&&r!==null)t.set(r,o.method);else if(o.kind==="error"&&r!==null){const i=t.get(r);i&&n.add(i)}}return[...n].sort()}function ar(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<1e4)return`${(e/1e3).toFixed(2)}s`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m${n}s`}function lP(e,t){if(e.length<=t)return e;const n=[];for(let o=0;o<t;o++){const r=Math.round(o*(e.length-1)/(t-1));n.push(e[r])}return n}function cP({values:e,width:t=64,height:n=14,className:o,title:r}){if(e.length===0)return null;const i=e[e.length-1]??0;if(i===0)return null;const s=Math.max(1,Math.floor(t/4)),a=lP(e,s),l=1,c=(t-l*(a.length-1))/a.length;return d.jsx("svg",{viewBox:`0 0 ${t} ${n}`,width:t,height:n,className:K("inline-block align-middle",o),role:"img","aria-label":r??`latency distribution, ${e.length} samples`,children:a.map((f,m)=>{const h=Math.max(1,f/i*n);return d.jsx("rect",{x:m*(c+l),y:n-h,width:c,height:h,fill:"currentColor",opacity:.4+f/i*.6},m)})})}function dP(e){const t={events:[],startTs:0,endTs:0,durationMs:0,laneCounts:{"editor-req":0,"agent-req":0,notification:0}};if(e.length===0)return t;const n=nf(e),o=new Map;for(const l of e)o.set(l.seq,l);let r=1/0,i=-1/0;const s=[],a={"editor-req":0,"agent-req":0,notification:0};for(const l of e)if(l.timestamp<r&&(r=l.timestamp),l.timestamp>i&&(i=l.timestamp),l.kind==="request"){const c=l.direction==="editor-to-agent"?"editor-req":"agent-req",f=n.get(l.seq),m=f?o.get(f.pairSeq):void 0,h=(m==null?void 0:m.kind)==="error",y=m?m.timestamp:l.timestamp;y>i&&(i=y),s.push({seq:l.seq,startTs:l.timestamp,endTs:y,lane:c,method:l.method??null,kind:l.kind,erroredOut:h,pairedSeq:m?m.seq:null}),a[c]+=1}else l.kind==="notification"&&(s.push({seq:l.seq,startTs:l.timestamp,endTs:l.timestamp,lane:"notification",method:l.method??null,kind:l.kind,erroredOut:!1,pairedSeq:null}),a.notification+=1);return!Number.isFinite(r)||!Number.isFinite(i)?t:{events:s,startTs:r,endTs:i,durationMs:Math.max(0,i-r),laneCounts:a}}const dl=["editor-req","agent-req","notification"],uP={"editor-req":"editor → agent","agent-req":"agent → editor",notification:"notifications"},oo=48,sf=6,Ll=24,wn=132,hs=20,Dl=8,pP=20,Ah=3e4,Mh=50;function fP(e,t,n,o,r,i){if(e.length===0||n<=t)return{segments:[{kind:"active",tStart:t,tEnd:n,pxStart:0,pxEnd:o*r}],tsToX:()=>wn-i,totalActiveMs:0};const s=[...e].sort((p,x)=>p.startTs-x.startTs),a=[];let l=t,c=t;for(const p of s)p.startTs-c>Ah&&(c>l&&a.push({kind:"active",tStart:l,tEnd:c}),a.push({kind:"gap",tStart:c,tEnd:p.startTs}),l=p.startTs),c=Math.max(c,p.endTs);c>l&&a.push({kind:"active",tStart:l,tEnd:c}),n>c+Ah?a.push({kind:"gap",tStart:c,tEnd:n}):n>c&&a.length>0&&(a[a.length-1].tEnd=n);const f=a.filter(p=>p.kind==="gap").length,m=a.filter(p=>p.kind==="active").reduce((p,x)=>p+(x.tEnd-x.tStart),0),h=o*r,y=Math.max(50,h-f*Mh),g=m>0?y/m:0;let b=0;const v=[];for(const p of a){const x=p.kind==="gap"?Mh:(p.tEnd-p.tStart)*g;v.push({...p,pxStart:b,pxEnd:b+x}),b+=x}return{segments:v,tsToX:p=>{if(p<=v[0].tStart)return wn+v[0].pxStart-i;for(const S of v)if(p>=S.tStart&&p<=S.tEnd){const T=S.tEnd>S.tStart?(p-S.tStart)/(S.tEnd-S.tStart):0,C=S.pxStart+T*(S.pxEnd-S.pxStart);return wn+C-i}const x=v[v.length-1];return wn+x.pxEnd-i},totalActiveMs:m}}function mP({messages:e,onSelectSeq:t,height:n=220,controlsRef:o,onZoomChange:r}){const i=P.useMemo(()=>dP(e),[e]),s=P.useRef(null),a=P.useRef(null),[l,c]=P.useState({width:800,height:n}),[f,m]=P.useState(1),[h,y]=P.useState(0),[g,b]=P.useState(null),[v,u]=P.useState({x:0,y:0}),p=P.useRef(null);P.useEffect(()=>{const L=s.current;if(!L||typeof ResizeObserver>"u")return;const U=new ResizeObserver(D=>{const Q=D[0];if(!Q)return;const ee=Q.contentRect;c({width:Math.max(320,ee.width),height:Math.max(120,ee.height)})});return U.observe(L),()=>U.disconnect()},[]),P.useEffect(()=>{m(1),y(0),b(null)},[i.startTs,i.endTs]);const x=P.useMemo(()=>{const L=Math.max(50,l.width-wn-hs);return fP(i.events,i.startTs,i.endTs,L,f,h)},[i,l.width,f,h]),S=P.useMemo(()=>{if(i.events.length===0)return[];const L=[];for(const U of i.events){const D=x.tsToX(U.startTs),Q=x.tsToX(U.endTs),ee=Math.max(2,Q-D),q=dl.indexOf(U.lane),G=Dl+Ll+q*(oo+sf)+oo/2-9;L.push({...U,x:D,y:G,width:ee,height:18})}return L},[i,x]);P.useEffect(()=>{const L=a.current;if(!L)return;const U=window.devicePixelRatio||1;L.width=l.width*U,L.height=l.height*U,L.style.width=`${l.width}px`,L.style.height=`${l.height}px`;const D=L.getContext("2d");if(!D)return;D.setTransform(U,0,0,U,0,0);const Q=getComputedStyle(document.documentElement),ee=G=>`rgb(${Q.getPropertyValue(`--${G}`).trim()})`,q=(G,I)=>`rgba(${Q.getPropertyValue(`--${G}`).trim()} / ${I})`;D.clearRect(0,0,l.width,l.height),hP(D,l,ee),gP(D,x,l,ee,q),yP(D,l,x,ee),xP(D,S,g,ee,q)},[S,x,l,g]);const T=(L,U)=>{for(const D of S){const Q=Math.max(D.width,6);if(L>=D.x&&L<=D.x+Q&&U>=D.y&&U<=D.y+D.height)return D}return null},C=L=>{const U=L.currentTarget.getBoundingClientRect(),D=L.clientX-U.left,Q=L.clientY-U.top;if(p.current){const q=D-p.current.startX;y(Math.max(0,p.current.startPan-q));return}const ee=T(D,Q);b(ee),u({x:L.clientX,y:L.clientY})},$=L=>{const U=L.currentTarget.getBoundingClientRect(),D=L.clientX-U.left,Q=L.clientY-U.top,ee=T(D,Q);if(ee&&t){t(ee.seq);return}p.current={startX:D,startPan:h}},j=()=>{p.current=null},R=L=>{if(!L.metaKey&&!L.ctrlKey)return;L.preventDefault();const U=L.deltaY<0?1.15:1/1.15;m(D=>Math.min(50,Math.max(.3,D*U)))},M=()=>m(L=>Math.min(50,L*1.5)),F=()=>m(L=>Math.max(.3,L/1.5)),V=()=>{m(1),y(0)};return P.useEffect(()=>{if(o)return o.current={zoomIn:M,zoomOut:F,reset:V,getZoom:()=>f},()=>{o.current&&(o.current=null)}}),P.useEffect(()=>{r==null||r(f)},[f,r]),i.events.length===0?d.jsx("div",{className:"flex h-full items-center justify-center font-mono text-[11px] uppercase tracking-widest text-ink-muted",children:"no messages — capture or load a session first"}):d.jsxs("div",{ref:s,className:"relative h-full w-full",style:{minHeight:0},children:[d.jsx("canvas",{ref:a,className:K("block h-full w-full",p.current?"cursor-grabbing":g?"cursor-pointer":"cursor-grab"),onMouseMove:C,onMouseDown:$,onMouseUp:j,onMouseLeave:()=>{b(null),p.current=null},onWheel:R}),g&&d.jsxs("div",{role:"tooltip",className:"pointer-events-none fixed z-[150] rounded-sm border border-line bg-surface-base px-3 py-2 font-mono text-[11px] shadow-lg",style:{left:Math.min(window.innerWidth-280,v.x+12),top:v.y+12,maxWidth:280},children:[d.jsxs("div",{className:"text-ink-primary",children:[d.jsxs("span",{className:"text-ink-muted",children:["seq ",g.seq]})," · ",g.method??g.kind]}),d.jsx("div",{className:"text-ink-muted",children:g.endTs>g.startTs?`${Vt(g.endTs-g.startTs)}${g.erroredOut?" · error":""}`:g.lane==="notification"?"notification":"pending"}),t&&d.jsx("div",{className:"mt-1 text-[10px] text-ink-dim",children:"click to inspect"})]})]})}function hP(e,t,n){e.font="10px monospace",e.textBaseline="middle",e.textAlign="start";for(let o=0;o<dl.length;o++){const r=dl[o],i=Dl+Ll+o*(oo+sf);e.fillStyle=n("surface-elev"),e.fillRect(wn,i,t.width-wn-hs,oo),e.fillStyle=n("ink-muted"),e.fillText(uP[r],pP,i+oo/2),e.strokeStyle=n("line"),e.lineWidth=1,e.beginPath(),e.moveTo(wn,i+oo),e.lineTo(t.width-hs,i+oo),e.stroke()}}function yP(e,t,n,o){var g;const r=Dl+Ll-4;e.strokeStyle=o("line"),e.fillStyle=o("ink-muted"),e.font="10px monospace",e.textBaseline="bottom",e.textAlign="center",e.lineWidth=1;const i=n.segments.filter(b=>b.kind==="active").reduce((b,v)=>Math.max(b,v.tEnd-v.tStart),0),s=n.segments.reduce((b,v)=>b+(v.kind==="active"?v.pxEnd-v.pxStart:0),0),l=(i>0?s/n.totalActiveMs:0)*1e3,c=[.1,.25,.5,1,2,5,10,30,60,120,300],f=80;let m=c[c.length-1];for(const b of c)if(b*l>=f){m=b;break}const h=m*1e3,y=((g=n.segments[0])==null?void 0:g.tStart)??0;for(const b of n.segments){if(b.kind!=="active")continue;const v=Math.ceil((b.tStart-y)/h)*h+y;for(let u=v;u<=b.tEnd;u+=h){const p=n.tsToX(u);p<wn||p>t.width-hs||(e.beginPath(),e.moveTo(p,r),e.lineTo(p,r+4),e.stroke(),e.fillText(bP(u-y),p,r-2))}}}function gP(e,t,n,o,r){const i=Dl+Ll,s=i+dl.length*(oo+sf);for(const a of t.segments){if(a.kind!=="gap")continue;const l=t.tsToX(a.tStart),f=t.tsToX(a.tEnd)-l;if(l>n.width-hs||l+f<wn)continue;e.fillStyle=r("ink-muted",.06),e.fillRect(l,i,f,s-i),e.strokeStyle=o("line"),e.setLineDash([3,3]),e.lineWidth=1,e.beginPath(),e.moveTo(l+.5,i),e.lineTo(l+.5,s),e.moveTo(l+f-.5,i),e.lineTo(l+f-.5,s),e.stroke(),e.setLineDash([]),e.fillStyle=o("ink-muted"),e.font="10px monospace",e.textBaseline="middle",e.textAlign="center";const m=l+f/2,h=i+(s-i)/2;e.fillText(vP(a.tEnd-a.tStart),m,h)}}function vP(e){if(e<6e4)return`${Math.round(e/1e3)}s idle`;if(e<36e5)return`${Math.round(e/6e4)}m idle`;const t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return n>0?`${t}h${n}m idle`:`${t}h idle`}function bP(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(e<1e4?1:0)}s`;const t=Math.floor(e/6e4),n=Math.round(e%6e4/1e3);return`${t}m${n}s`}function xP(e,t,n,o,r){for(const i of t){const s=(n==null?void 0:n.seq)===i.seq,a=i.erroredOut?r("accent-error",.6):i.kind==="notification"?r("accent-note",.7):i.lane==="editor-req"?r("accent-out",.7):r("accent-in",.7);e.fillStyle=s?a.replace(/0\.\d+/,"0.95"):a,e.fillRect(i.x,i.y,Math.max(i.width,2),i.height),s&&(e.strokeStyle=o("ink-primary"),e.lineWidth=1,e.strokeRect(i.x-.5,i.y-.5,Math.max(i.width,2)+1,i.height+1))}}function wP({open:e,onClose:t,onNavigateToSeq:n}){const o=ne(S=>S.messages),r=ne(S=>S.session),i=ne(S=>S.select),s=P.useRef(null),[a,l]=P.useState(1),c=P.useMemo(()=>Fd(o),[o]),f=P.useMemo(()=>sP(o,c),[o,c]),m=P.useMemo(()=>c.reduce((S,T)=>Math.max(S,T.count),0),[c]),[h,y]=P.useState("count"),[g,b]=P.useState("desc"),{rendered:v,visible:u}=of(e);P.useEffect(()=>{if(!e)return;const S=T=>{T.key==="Escape"&&(T.preventDefault(),t())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[e,t]);const p=P.useMemo(()=>CP(c,h,g),[c,h,g]),x=P.useMemo(()=>NP(c),[c]);return v?d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Performance dashboard",className:K("fixed inset-0 z-[100] flex flex-col bg-surface-base/95 backdrop-blur-sm transition-opacity duration-200 ease-out",u?"opacity-100":"opacity-0"),children:d.jsxs("div",{className:K("flex h-full w-full flex-col transition-transform duration-200 ease-out",u?"translate-y-0":"-translate-y-2"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsxs("div",{className:"flex min-w-0 items-baseline gap-3",children:[d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Performance — per-method latency"}),r&&d.jsx("span",{className:"truncate font-mono text-[11px] text-ink-secondary",children:(()=>{const S=ql(r);let T=S.secondary;if(!r.clientName){const C=cl(o),$=C.client.title??C.client.name??null;if($){const j=S.secondary;T=j?`${$} · ${j}`:$}}return T?`${S.primary} · ${T}`:S.primary})()})]}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close performance panel",children:"close"})]}),f.length>0&&d.jsx(TP,{insights:f}),d.jsx("div",{className:"border-b border-line bg-surface-elev px-5 py-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:c.length===0?d.jsx("span",{children:"no messages — capture or load a session first"}):d.jsxs("span",{children:[x.methods," methods · ",x.requests," requests ·"," ",x.notifications," notifications · ",x.samples," latency samples"]})}),d.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[d.jsx("div",{className:"flex-1 overflow-y-auto",children:p.length===0?null:d.jsxs("table",{className:"w-full table-fixed text-[11px]",children:[d.jsxs("colgroup",{children:[d.jsx("col",{}),d.jsx("col",{className:"w-[64px]"}),d.jsx("col",{className:"w-[88px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[80px]"}),d.jsx("col",{className:"w-[120px]"})]}),d.jsx("thead",{className:"sticky top-0 z-10 bg-surface-base",children:d.jsxs("tr",{className:"border-b border-line text-left font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsx(cr,{sk:"method",current:h,dir:g,onSort:lr(y,b,g),className:"!pl-5",children:"method"}),d.jsx("th",{className:"px-3 py-2",children:"kind"}),d.jsx(cr,{sk:"count",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"count"}),d.jsx(cr,{sk:"p50",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"p50"}),d.jsx(cr,{sk:"p99",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"p99"}),d.jsx(cr,{sk:"max",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"max"}),d.jsx(cr,{sk:"total",current:h,dir:g,onSort:lr(y,b,g),align:"right",children:"total"}),d.jsx("th",{className:"py-2 pl-3 pr-5 text-right",children:"dist"})]})}),d.jsx("tbody",{className:"font-mono",children:p.map(S=>d.jsxs("tr",{className:"border-b border-line/40 transition-colors hover:bg-surface-rowHover/50",children:[d.jsx("td",{className:"truncate py-1.5 pl-5 pr-3 text-ink-primary",title:S.method,children:S.method}),d.jsx("td",{className:"px-3 py-1.5 text-ink-muted",children:d.jsx(jP,{kind:S.kind})}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-primary",children:d.jsx(_P,{count:S.count,max:m,kind:S.kind})}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.p50!==null?Vt(S.p50):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.p99!==null?Vt(S.p99):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.max!==null?Vt(S.max):"—"}),d.jsx("td",{className:"px-3 py-1.5 text-right text-ink-secondary",children:S.totalLatencyMs!==null?Vt(S.totalLatencyMs):"—"}),d.jsx("td",{className:"py-1.5 pl-3 pr-5 text-right",children:S.latencies.length>0?d.jsx(cP,{values:S.latencies,width:88,height:14,className:"text-accent-info",title:`${S.method} latency distribution`}):d.jsx("span",{className:"text-ink-dim",children:"—"})})]},`${S.kind}:${S.method}`))})]})}),o.length>0&&d.jsxs("div",{className:"flex h-[260px] shrink-0 flex-col border-t border-line bg-surface-elev",children:[d.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-line bg-surface-base px-5 py-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("div",{className:"flex min-w-0 items-baseline gap-2 truncate",children:[d.jsx("span",{children:"timeline — wall-clock waterfall"}),d.jsx("span",{className:"text-ink-dim",children:"· drag to pan · Cmd/Ctrl + wheel zoom · click to inspect"})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[d.jsxs("span",{className:"text-ink-secondary",children:[a.toFixed(a<1?2:1),"×"]}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.zoomOut()},className:"inline-flex h-5 w-5 items-center justify-center rounded-sm border border-line hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Zoom out",title:"Zoom out",children:"−"}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.zoomIn()},className:"inline-flex h-5 w-5 items-center justify-center rounded-sm border border-line hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Zoom in",title:"Zoom in",children:"+"}),d.jsx("button",{type:"button",onClick:()=>{var S;return(S=s.current)==null?void 0:S.reset()},className:"inline-flex h-5 items-center justify-center rounded-sm border border-line px-2 hover:bg-surface-rowHover hover:text-ink-primary","aria-label":"Reset zoom and pan",title:"Reset zoom and pan to defaults",children:"reset"})]})]}),d.jsx("div",{className:"flex-1",children:d.jsx(mP,{messages:o,controlsRef:s,onZoomChange:l,onSelectSeq:S=>{n?n(S):(i(S),t())}})})]})]})]})}):null}const SP={hotspot:"●","long-tail":"▲",outlier:"◆",busiest:"■",errors:"✗"},$P={hotspot:"text-accent-warn","long-tail":"text-accent-warn",outlier:"text-accent-warn",busiest:"text-accent-info",errors:"text-accent-error"},kP={hotspot:"hotspot","long-tail":"long tail",outlier:"outlier",busiest:"busiest",errors:"errors"};function TP({insights:e}){return d.jsxs("div",{className:"border-b border-line bg-surface-base px-5 py-2.5",children:[d.jsx("div",{className:"mb-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"insights"}),d.jsx("ul",{className:"space-y-1.5",children:e.map(t=>d.jsxs("li",{className:"flex items-start gap-2",children:[d.jsx("span",{"aria-hidden":!0,className:K("mt-[3px] inline-block text-[9px] leading-none",$P[t.kind]),children:SP[t.kind]}),d.jsx("div",{className:"min-w-[68px] font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:kP[t.kind]}),d.jsxs("div",{className:"flex-1 text-[11px] leading-snug",children:[d.jsx("div",{className:"text-ink-primary",children:t.summary}),t.detail&&d.jsx("div",{className:"text-[10px] text-ink-muted",children:t.detail})]})]},t.kind))})]})}function _P({count:e,max:t,kind:n}){const o=t>0?e/t*100:0,r=n==="request"?"bg-accent-out/15":"bg-accent-note/15";return d.jsxs("div",{className:"relative inline-block w-[44px] text-right",children:[d.jsx("div",{"aria-hidden":!0,className:K("absolute inset-y-[1px] right-0 rounded-sm",r),style:{width:`${o}%`}}),d.jsx("span",{className:"relative",children:e})]})}function lr(e,t,n){return(o,r)=>{r?t(n==="asc"?"desc":"asc"):(e(o),t(o==="method"?"asc":"desc"))}}function cr({sk:e,current:t,dir:n,onSort:o,align:r="left",className:i,children:s}){const a=t===e;return d.jsxs("th",{className:K("cursor-pointer select-none px-3 py-2 transition-colors hover:text-ink-primary",r==="right"?"text-right":"",a?"text-ink-primary":"",i),onClick:()=>o(e,a),"aria-sort":a?n==="asc"?"ascending":"descending":"none",children:[d.jsx("span",{children:s}),a&&d.jsx("span",{className:"ml-1 text-accent-warn",children:n==="asc"?"↑":"↓"})]})}function jP({kind:e}){const t=e==="request"?"text-accent-out":"text-accent-note",n=e==="request"?"req":"ntf";return d.jsx("span",{className:K("text-[10px] uppercase tracking-widest",t),title:e,children:n})}function NP(e){let t=0,n=0,o=0;for(const r of e)r.kind==="request"?t+=r.count:n+=r.count,o+=r.sampleSize;return{methods:e.length,requests:t,notifications:n,samples:o}}function CP(e,t,n){const o=n==="asc"?1:-1,r=[...e];return r.sort((i,s)=>{const a=qh(i,t),l=qh(s,t);return a===null&&l!==null?1:a!==null&&l===null?-1:t==="method"?o*i.method.localeCompare(s.method):a===null||l===null?0:o*(a-l)}),r}function qh(e,t){switch(t){case"method":return 0;case"count":return e.count;case"p50":return e.p50;case"p99":return e.p99;case"max":return e.max;case"total":return e.totalLatencyMs}}const af=["raw.githubusercontent.com","gist.githubusercontent.com"];function Gb(e){try{return{ok:!0,export:qC(e)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}function EP(e){let t;try{t=new URL(e)}catch{return!1}return t.protocol!=="https:"?!1:af.includes(t.host)}async function PP(e){if(!EP(e))return{ok:!1,error:`host not in playground allowlist (${af.join(", ")})`};let t;try{t=await fetch(e,{redirect:"follow"})}catch(o){return{ok:!1,error:`fetch failed: ${o instanceof Error?o.message:String(o)}`}}if(!t.ok)return{ok:!1,error:`HTTP ${t.status} ${t.statusText}`};const n=await t.text();return Gb(n)}function IP({initialUrl:e=null}){const[t,n]=P.useState(null),[o,r]=P.useState(e!==null),[i,s]=P.useState(!1),[a,l]=P.useState(""),c=P.useRef(null),f=(b,v)=>{b.ok?(ne.getState().loadFromExport(b.export),n(null)):n(`${v}: ${b.error}`),r(!1)},m=async b=>{r(!0),n(null);try{const v=await b.text();f(Gb(v),b.name)}catch(v){n(`${b.name}: ${v instanceof Error?v.message:String(v)}`),r(!1)}},h=async b=>{r(!0),n(null),f(await PP(b),b)},y=P.useRef(e);if(y.current!==null){const b=y.current;y.current=null,h(b)}const g=b=>{var u;b.preventDefault(),s(!1);const v=(u=b.dataTransfer.files)==null?void 0:u[0];v&&m(v)};return d.jsx("div",{className:"flex h-full w-full items-center justify-center bg-grid",children:d.jsxs("div",{className:"relative w-[min(720px,92%)] rounded-md border border-line bg-surface-elev/80 p-6 backdrop-blur-sm",children:[d.jsxs("div",{className:"mb-1 flex items-baseline gap-3",children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:"acp.devtools"}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"playground"})]}),d.jsx("h2",{className:"font-display text-2xl uppercase tracking-tight text-ink-primary",children:"Drop an exported session"}),d.jsxs("p",{className:"mt-2 font-sans text-sm leading-relaxed text-ink-secondary",children:["The playground renders ACP session exports client-side. Nothing leaves your browser. Generate exports with ",d.jsx("code",{className:"font-mono",children:"acp-devtools export <id>"})," ","— auth headers and proxy tokens are redacted by default."]}),d.jsxs("div",{role:"button",tabIndex:0,"aria-label":"Drop session export here or click to pick a file",onClick:()=>{var b;return(b=c.current)==null?void 0:b.click()},onKeyDown:b=>{var v;(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),(v=c.current)==null||v.click())},onDragOver:b=>{b.preventDefault(),s(!0)},onDragLeave:()=>s(!1),onDrop:g,className:K("mt-5 flex h-40 cursor-pointer flex-col items-center justify-center rounded-md border-2 border-dashed text-center transition-colors",i?"border-accent-out bg-accent-out/10":"border-line bg-surface-base/40 hover:border-ink-muted"),children:[d.jsx("span",{className:"font-display text-sm uppercase tracking-[0.18em] text-ink-muted",children:o?"Loading…":"Drop .json here"}),d.jsx("span",{className:"mt-1 font-mono text-[11px] text-ink-dim",children:"or click to pick a file"}),d.jsx("input",{ref:c,type:"file",accept:".json,application/json",className:"hidden",onChange:b=>{var u;const v=(u=b.target.files)==null?void 0:u[0];v&&m(v),b.target.value=""}})]}),d.jsxs("form",{className:"mt-4 flex items-center gap-2",onSubmit:b=>{b.preventDefault();const v=a.trim();v&&h(v)},children:[d.jsx("input",{type:"url",value:a,onChange:b=>l(b.target.value),placeholder:"https://raw.githubusercontent.com/…/session.json",className:"flex-1 rounded-sm border border-line bg-surface-base px-3 py-2 font-mono text-[12px] text-ink-primary outline-none focus:border-ink-muted","aria-label":"Load session from URL"}),d.jsx("button",{type:"submit",disabled:o||a.trim().length===0,className:"rounded-sm border border-line bg-surface-base px-3 py-2 font-display text-[11px] uppercase tracking-widest text-ink-secondary transition-colors hover:border-ink-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Load"})]}),d.jsxs("p",{className:"mt-2 font-mono text-[10px] leading-relaxed text-ink-dim",children:["URL allowlist: ",af.join(", "),". Gists are public — don't use this for anything you wouldn't post on Twitter."]}),t&&d.jsx("p",{className:"mt-3 font-mono text-[11px] text-accent-error",children:t})]})})}const OP=[.5,1,2,4,8];function RP(){const e=ne(h=>h.messages),t=ne(h=>h.playback),n=ne(h=>h.setPlaybackCap),o=ne(h=>h.setPlaying),r=ne(h=>h.setPlaybackSpeed),i=e.length>0?e[0].seq:0,s=e.length>0?e[e.length-1].seq:0,a=t.cap??s,l=a>=s,c=P.useRef(null);if(P.useEffect(()=>{if(!t.playing)return;if(l){o(!1);return}const h=e.findIndex(u=>u.seq===a),y=e[h+1];if(!y){o(!1);return}const g=e[h],b=g?y.timestamp-g.timestamp:0,v=Math.max(15,Math.min(1500,b/t.speed));return c.current=setTimeout(()=>{n(y.seq)},v),()=>{c.current&&(clearTimeout(c.current),c.current=null)}},[t.playing,t.speed,a,e,l,n,o]),e.length===0)return null;const f=h=>{h>=s?n(null):n(h),t.playing&&o(!1)},m=()=>{l?(n(i),o(!0)):o(!t.playing)};return d.jsxs("div",{className:"flex items-center gap-3 border-t border-line bg-surface-elev/70 px-4 py-2 font-mono text-[11px]",children:[d.jsx("button",{type:"button",onClick:m,className:K("inline-flex h-6 w-12 items-center justify-center rounded-sm border font-semibold uppercase tracking-widest transition-colors",t.playing?"border-accent-warn/50 bg-accent-warn/10 text-accent-warn":"border-accent-out/50 bg-accent-out/10 text-accent-out"),title:t.playing?"pause":l?"restart playback":"play",children:t.playing?"❚❚":l?"↺":"▶"}),d.jsxs("span",{className:"w-20 shrink-0 text-right text-ink-secondary",children:[String(a).padStart(3,"0")," / ",String(s).padStart(3,"0")]}),d.jsx("input",{type:"range",min:i,max:s,value:a,onChange:h=>f(Number(h.target.value)),className:"h-1 flex-1 cursor-pointer accent-accent-out"}),d.jsx("div",{className:"flex shrink-0 items-center gap-1",children:OP.map(h=>d.jsxs("button",{type:"button",onClick:()=>r(h),className:K("rounded-sm border px-1.5 py-0.5 text-[10px] uppercase tracking-widest transition-colors",t.speed===h?"border-accent-out/50 bg-accent-out/10 text-accent-out":"border-line text-ink-muted hover:border-line-strong hover:text-ink-secondary"),title:`${h}× speed`,children:[h,"×"]},h))}),d.jsx("button",{type:"button",onClick:()=>{n(null),o(!1)},className:"rounded-sm border border-line px-2 py-0.5 text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:border-line-strong hover:text-ink-secondary",title:"show all messages, exit playback",children:"show all"})]})}function Jb(e=5e3){const[t,n]=P.useState(()=>Date.now());return P.useEffect(()=>{const o=setInterval(()=>n(Date.now()),e);return()=>clearInterval(o)},[e]),t}function AP({open:e,onClose:t}){const n=ne(a=>a.session),o=ne(a=>a.messages),r=P.useMemo(()=>cl(o),[o]),{rendered:i,visible:s}=of(e);return P.useEffect(()=>{if(!e)return;const a=l=>{l.key==="Escape"&&(l.preventDefault(),t())};return window.addEventListener("keydown",a,!0),()=>window.removeEventListener("keydown",a,!0)},[e,t]),i?d.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"Session info",className:K("fixed inset-0 z-[100] flex items-start justify-end bg-black/60 backdrop-blur-sm transition-opacity duration-200 ease-out",s?"opacity-100":"opacity-0"),onMouseDown:a=>{a.target===a.currentTarget&&t()},children:d.jsxs("div",{className:K("flex h-full w-full max-w-[440px] flex-col border-l border-line bg-surface-base shadow-2xl transition-transform duration-200 ease-out",s?"translate-x-0":"translate-x-full"),children:[d.jsxs("header",{className:"flex items-center justify-between border-b border-line px-5 py-3",children:[d.jsx("div",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:"Session info"}),d.jsx("button",{type:"button",onClick:t,className:"font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors hover:text-ink-primary","aria-label":"Close session info panel",children:"close"})]}),d.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:n?d.jsx(MP,{session:n,meta:r,messages:o}):d.jsx("div",{className:"font-mono text-[11px] text-ink-muted",children:"No session attached."})})]})}):null}function MP({session:e,meta:t,messages:n}){const o=Jb(5e3),{primary:r}=ql(e),i=P.useMemo(()=>UP(n),[n]);return d.jsxs("div",{className:"space-y-5 text-[12px]",children:[d.jsxs(wi,{title:"Summary",children:[d.jsx(mn,{label:"Session",value:r}),d.jsx(mn,{label:"Client",value:t.client.title||t.client.name||e.clientName||"—",secondary:t.client.version?`v${t.client.version}${t.client.platform?` · ${t.client.platform}`:""}`:null}),d.jsx(mn,{label:"Agent",value:t.agent.name||qP(e.agentCommand)||"—",secondary:t.agent.version?`v${t.agent.version}`:null}),d.jsx(mn,{label:"Protocol",value:t.protocolVersion!==null?`ACP v${t.protocolVersion}`:"—"}),d.jsx(mn,{label:"Started",value:_a(e.startedAt,o)}),d.jsx(mn,{label:"Messages",value:`${n.length} (req ${i.req} · rsp ${i.rsp} · ntf ${i.note} · err ${i.err})`})]}),d.jsxs(wi,{title:"Client capabilities",children:[d.jsx(No,{label:"fs.readTextFile",enabled:t.clientCapabilities.fsReadTextFile}),d.jsx(No,{label:"fs.writeTextFile",enabled:t.clientCapabilities.fsWriteTextFile}),d.jsx(No,{label:"terminal",enabled:t.clientCapabilities.terminal}),d.jsx(No,{label:"auth.terminal",enabled:t.clientCapabilities.authTerminal}),d.jsx(No,{label:"auth.gateway",enabled:t.clientCapabilities.authGateway})]}),d.jsxs(wi,{title:"Agent capabilities",children:[d.jsx(No,{label:"prompt",enabled:t.agentCapabilities.prompt}),d.jsx(No,{label:"loadSession",enabled:t.agentCapabilities.loadSession}),d.jsx(mn,{label:"Auth methods",value:String(t.agent.authMethods)})]}),d.jsxs(wi,{title:"Runtime state",children:[d.jsx(mn,{label:"Mode",value:t.runtime.currentMode??"—",secondary:t.runtime.modeChanges>0?`changed ${t.runtime.modeChanges}× this session`:null}),d.jsx(mn,{label:"Model",value:t.runtime.currentModel??"—",secondary:t.runtime.modelChanges>0?`changed ${t.runtime.modelChanges}× this session`:null}),d.jsx(mn,{label:"Commands",value:t.runtime.availableCommands.length>0?t.runtime.availableCommands.join(", "):"—",wrap:!0})]}),t.extensions.jetbrainsProxyConfig!==null&&d.jsx(wi,{title:"JetBrains extensions",children:d.jsx("div",{className:"rounded-sm border border-line bg-surface-elev p-3 font-mono text-[11px] text-ink-secondary",children:d.jsx(al,{value:t.extensions.jetbrainsProxyConfig})})})]})}function qP(e){if(!e)return null;const t=e.trim().split(/\s+/);if(t[0]==="npx")for(let n=1;n<t.length;n++){const o=t[n];if(!o.startsWith("-"))return o}return t[0]??null}function UP(e){let t=0,n=0,o=0,r=0;for(const i of e)i.kind==="request"?t++:i.kind==="response"?n++:i.kind==="notification"?o++:i.kind==="error"&&r++;return{req:t,rsp:n,note:o,err:r}}function wi({title:e,children:t}){return d.jsxs("div",{children:[d.jsx("h3",{className:"mb-2 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("div",{className:"space-y-1.5",children:t})]})}function mn({label:e,value:t,secondary:n,wrap:o=!1}){return d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsx("span",{className:"w-[120px] shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsxs("span",{className:K("flex-1 text-ink-primary",o?"whitespace-normal break-words":"truncate"),title:o?void 0:t,children:[t,n&&d.jsx("span",{className:"ml-2 text-[10px] text-ink-muted",children:n})]})]})}function No({label:e,enabled:t}){return d.jsxs("div",{className:"flex items-baseline gap-3",children:[d.jsx("span",{className:"w-[120px] shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e}),d.jsx("span",{className:K("flex-1 font-mono text-[11px]",t?"text-accent-ok":"text-ink-dim"),children:t?"✓ enabled":"— not advertised"})]})}function LP({left:e,right:t,storageKey:n,initialLeftFraction:o=.6,minLeft:r=320,minRight:i=320}){const s=P.useRef(null),[a,l]=P.useState(null),c=P.useRef(!1);P.useEffect(()=>{if(!s.current)return;const y=s.current.clientWidth,g=n?Number(localStorage.getItem(n)):NaN;n&&Number.isFinite(g)&&g>0&&g<y?l(g):l(Math.round(y*o))},[o,n]);const f=P.useCallback(y=>{y.preventDefault(),c.current=!0,y.currentTarget.setPointerCapture(y.pointerId)},[]),m=P.useCallback(y=>{if(!c.current||!s.current)return;const g=s.current.getBoundingClientRect(),b=y.clientX-g.left,v=g.width,u=Math.min(Math.max(b,r),v-i);l(u),n&&localStorage.setItem(n,String(Math.round(u)))},[r,i,n]),h=P.useCallback(y=>{c.current=!1;try{y.currentTarget.releasePointerCapture(y.pointerId)}catch{}},[]);return d.jsxs("div",{ref:s,className:"flex h-full w-full overflow-hidden",children:[d.jsx("div",{style:{width:a??"60%"},className:"flex h-full min-w-0 flex-col",children:e}),d.jsx("div",{role:"separator","aria-orientation":"vertical",className:K("group relative w-px shrink-0 cursor-col-resize bg-line",'before:absolute before:inset-y-0 before:-left-1 before:-right-1 before:content-[""]'),onPointerDown:f,onPointerMove:m,onPointerUp:h,onPointerCancel:h,children:d.jsx("div",{className:"absolute inset-y-0 left-0 w-px bg-line transition-colors group-hover:bg-accent-out/40"})}),d.jsx("div",{className:"flex h-full min-w-0 flex-1 flex-col",children:t})]})}function DP(){const e=ne(n=>n.messages),t=P.useMemo(()=>{let n=0,o=0,r=0,i=0,s=0;const a=new Map;for(const y of e)switch(a.set(y.seq,y.timestamp),s+=y.raw.length,y.kind){case"request":n+=1;break;case"response":o+=1;break;case"notification":r+=1;break;case"error":i+=1;break}const l=Cl(e),c=[];for(const y of e){if(y.kind!=="response"&&y.kind!=="error")continue;const g=l.get(y.seq);if(g===void 0)continue;const b=a.get(g);b!==void 0&&c.push(y.timestamp-b)}c.sort((y,g)=>y-g);const f=c.length?gh(c,50):null,m=c.length?gh(c,99):null,h=HN(Zp(e));return{total:e.length,req:n,res:o,note:r,err:i,bytes:s,p50:f,p99:m,spec:h}},[e]);return d.jsxs("footer",{className:"flex items-center justify-between gap-6 border-t border-line bg-surface-elev/80 px-5 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:[d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsx(Yn,{label:"msgs",value:t.total,tone:"primary"}),d.jsx(Yn,{label:"req",value:t.req,tone:"out"}),d.jsx(Yn,{label:"rsp",value:t.res,tone:"in"}),d.jsx(Yn,{label:"ntf",value:t.note,tone:"note"}),d.jsx(Yn,{label:"err",value:t.err,tone:t.err>0?"error":"muted"})]}),d.jsxs("div",{className:"flex items-center gap-5",children:[d.jsx(Yn,{label:"p50",value:t.p50!==null?Vt(t.p50):"—",tone:"primary"}),d.jsx(Yn,{label:"p99",value:t.p99!==null?Vt(t.p99):"—",tone:"primary"}),d.jsx(Yn,{label:"bytes",value:t.total>0?Ul(t.bytes):"—",tone:"primary"}),t.spec.checked>0&&d.jsx(FP,{invalidFrames:t.spec.invalidFrames,totalErrors:t.spec.totalErrors,affectedMethods:t.spec.affectedMethods}),d.jsx(zP,{})]})]})}function zP(){return d.jsxs("a",{href:"https://github.com/maksugr/acp-devtools",target:"_blank",rel:"noreferrer noopener",title:"Enjoying acp-devtools? Star it on GitHub — thank you!","aria-label":"Star acp-devtools on GitHub",className:"inline-flex items-baseline gap-1 text-ink-muted transition-colors hover:text-accent-warn focus-visible:text-accent-warn focus-visible:outline-none",children:[d.jsx("span",{"aria-hidden":"true",className:"text-[10px]",children:"★"}),d.jsx("span",{className:"text-[9px] tracking-normal",children:"Star on GitHub"})]})}function FP({invalidFrames:e,totalErrors:t,affectedMethods:n}){if(e===0)return d.jsx(ps,{label:d.jsx("span",{className:"font-sans",children:"every frame validates against the ACP schema"}),tone:"info",children:d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:"spec"}),d.jsx("span",{className:"text-accent-ok",children:"✓"})]})});const o=`${t} schema error${t===1?"":"s"} in ${e} frame${e===1?"":"s"}`;return d.jsx(ps,{tone:"warn",label:d.jsxs("div",{className:"space-y-1.5 font-sans",children:[d.jsx("div",{children:o}),n.length>0&&d.jsxs("div",{className:"font-mono text-[10px] text-ink-muted",children:["methods: ",n.join(", ")]})]}),children:d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:"spec"}),d.jsxs("span",{className:"text-accent-error",children:["⚠ ",e]})]})})}function Yn({label:e,value:t,tone:n}){const o=n==="primary"?"text-ink-primary":n==="out"?"text-accent-out":n==="in"?"text-accent-in":n==="note"?"text-accent-note":n==="error"?"text-accent-error":"text-ink-muted";return d.jsxs("span",{className:"inline-flex items-baseline gap-1",children:[d.jsx("span",{children:e}),d.jsx("span",{className:o,children:t})]})}const zl=0,$o=1,oi=2,Qb=4;function Uh(e){return()=>e}function BP(e){e()}function Yb(e,t){return n=>e(t(n))}function Lh(e,t){return()=>e(t)}function HP(e,t){return n=>e(t,n)}function lf(e){return e!==void 0}function VP(...e){return()=>{e.map(BP)}}function ri(){}function Fl(e,t){return t(e),e}function WP(e,t){return t(e)}function Ue(...e){return e}function $e(e,t){return e($o,t)}function me(e,t){e(zl,t)}function cf(e){e(oi)}function Le(e){return e(Qb)}function oe(e,t){return $e(e,HP(t,zl))}function cn(e,t){const n=e($o,o=>{n(),t(o)});return n}function Dh(e){let t,n;return o=>r=>{t=r,n&&clearTimeout(n),n=setTimeout(()=>{o(t)},e)}}function Xb(e,t){return e===t}function Me(e=Xb){let t;return n=>o=>{e(t,o)||(t=o,n(o))}}function ae(e){return t=>n=>{e(n)&&t(n)}}function X(e){return t=>Yb(t,e)}function yn(e){return t=>()=>{t(e)}}function z(e,...t){const n=KP(...t);return(o,r)=>{switch(o){case oi:cf(e);return;case $o:return $e(e,n(r))}}}function Sn(e,t){return n=>o=>{n(t=e(t,o))}}function Qo(e){return t=>n=>{e>0?e--:t(n)}}function On(e){let t=null,n;return o=>r=>{t=r,!n&&(n=setTimeout(()=>{n=void 0,o(t)},e))}}function he(...e){const t=new Array(e.length);let n=0,o=null;const r=2**e.length-1;return e.forEach((i,s)=>{const a=2**s;$e(i,l=>{const c=n;n|=a,t[s]=l,c!==r&&n===r&&o&&(o(),o=null)})}),i=>s=>{const a=()=>{i([s].concat(t))};n===r?a():o=a}}function KP(...e){return t=>e.reduceRight(WP,t)}function GP(e){let t,n;const o=()=>t==null?void 0:t();return function(r,i){switch(r){case $o:return i?n===i?void 0:(o(),n=i,t=$e(e,i),t):(o(),ri);case oi:o(),n=null;return}}}function W(e){let t=e;const n=ve();return(o,r)=>{switch(o){case zl:t=r;break;case $o:{r(t);break}case Qb:return t}return n(o,r)}}function yt(e,t){return Fl(W(t),n=>oe(e,n))}function ve(){const e=[];return(t,n)=>{switch(t){case zl:e.slice().forEach(o=>{o(n)});return;case oi:e.splice(0,e.length);return;case $o:return e.push(n),()=>{const o=e.indexOf(n);o>-1&&e.splice(o,1)}}}}function Mt(e){return Fl(ve(),t=>oe(e,t))}function xe(e,t=[],{singleton:n}={singleton:!0}){return{constructor:e,dependencies:t,id:JP(),singleton:n}}const JP=()=>Symbol();function QP(e){const t=new Map,n=({constructor:o,dependencies:r,id:i,singleton:s})=>{if(s&&t.has(i))return t.get(i);const a=o(r.map(l=>n(l)));return s&&t.set(i,a),a};return n(e)}function Qe(...e){const t=ve(),n=new Array(e.length);let o=0;const r=2**e.length-1;return e.forEach((i,s)=>{const a=2**s;$e(i,l=>{n[s]=l,o|=a,o===r&&me(t,n)})}),function(i,s){switch(i){case oi:{cf(t);return}case $o:return o===r&&s(n),$e(t,s)}}}function se(e,t=Xb){return z(e,Me(t))}function Bd(...e){return function(t,n){switch(t){case oi:return;case $o:return VP(...e.map(o=>$e(o,n)))}}}const nt={DEBUG:0,INFO:1,WARN:2,ERROR:3},YP={[nt.DEBUG]:"debug",[nt.ERROR]:"error",[nt.INFO]:"log",[nt.WARN]:"warn"},XP=()=>typeof globalThis>"u"?window:globalThis,ko=xe(()=>{const e=W(nt.ERROR);return{log:W((t,n,o=nt.INFO)=>{const r=XP().VIRTUOSO_LOG_LEVEL??Le(e);o>=r&&console[YP[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,n)}),logLevel:e}},[],{singleton:!0}),Hd=new WeakMap;function Zb(e){return"self"in e?e.document.documentElement:e}function ZP(e){const t=Zb(e),n=Hd.get(t);if(n!==void 0)return n;const o=t.ownerDocument.defaultView.getComputedStyle(t).direction==="rtl";return Hd.set(t,o),o}function zh(e){Hd.delete(Zb(e))}function ex(e,t){return ZP(e)?-t:t}const Lo=ex;function Fh(e,t){return ex(e,t)}function Zo(e,t,n){return df(e,t,n).callbackRef}function df(e,t,n){const o=te.useRef(null);let r=s=>{};const i=te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(s=>{const a=()=>{const l=s[0].target;l.offsetParent!==null&&e(l)};n?a():requestAnimationFrame(a)}):null,[e,n]);return r=s=>{s&&t?(i==null||i.observe(s),o.current=s):(o.current&&(i==null||i.unobserve(o.current)),o.current=null)},{callbackRef:r,ref:o}}function eI(e,t,n,o,r,i,s,a,l){const c=te.useCallback(f=>{const m=tI(f.children,t,a?"offsetWidth":"offsetHeight",r);let h=f.parentElement;for(;h.dataset.virtuosoScroller===void 0;)h=h.parentElement;const y=h.lastElementChild.dataset.viewportType==="window";let g;y&&(g=h.ownerDocument.defaultView);const b=s?a?s.scrollWidth:s.scrollHeight:y?a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight:a?h.scrollWidth:h.scrollHeight,v=s?a?s.offsetWidth:s.offsetHeight:y?a?g.innerWidth:g.innerHeight:a?h.offsetWidth:h.offsetHeight,u=s?a?Lo(s,s.scrollLeft):s.scrollTop:y?a?Lo(g,g.scrollX||g.document.documentElement.scrollLeft):g.scrollY||g.document.documentElement.scrollTop:a?Lo(h,h.scrollLeft):h.scrollTop;o({scrollHeight:b,scrollTop:Math.max(u,0),viewportHeight:v}),i==null||i(a?Bh("column-gap",getComputedStyle(f).columnGap,r):Bh("row-gap",getComputedStyle(f).rowGap,r)),m!==null&&e(m)},[e,t,r,i,s,o,a]);return df(c,n,l)}function tI(e,t,n,o){const r=e.length;if(r===0)return null;const i=[];for(let s=0;s<r;s++){const a=e.item(s);if(a.dataset.index===void 0)continue;const l=parseInt(a.dataset.index),c=parseFloat(a.dataset.knownSize),f=t(a,n);if(f===0&&o("Zero-sized element, this should not happen",{child:a},nt.ERROR),f===c)continue;const m=i[i.length-1];i.length===0||m.size!==f||m.endIndex!==l-1?i.push({endIndex:l,size:f,startIndex:l}):i[i.length-1].endIndex++}return i}function Bh(e,t,n){return t!=="normal"&&(t==null?void 0:t.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function tx(e,t,n){const o=te.useRef(null),r=te.useCallback(l=>{if(!(l!=null&&l.offsetParent))return;const c=l.getBoundingClientRect(),f=c.width;let m,h;if(t){const y=t.getBoundingClientRect(),g=c.top-y.top;h=y.height-Math.max(0,g),m=g+t.scrollTop}else{const y=s.current.ownerDocument.defaultView;h=y.innerHeight-Math.max(0,c.top),m=c.top+y.scrollY}o.current={listHeight:c.height,offsetTop:m,visibleHeight:h,visibleWidth:f},e(o.current)},[e,t]),{callbackRef:i,ref:s}=df(r,!0,n),a=te.useCallback(()=>{r(s.current)},[r,s]);return te.useEffect(()=>{var c;if(t){t.addEventListener("scroll",a);const f=new ResizeObserver(()=>{requestAnimationFrame(a)});return f.observe(t),()=>{t.removeEventListener("scroll",a),f.unobserve(t)}}const l=(c=s.current)==null?void 0:c.ownerDocument.defaultView;return l==null||l.addEventListener("scroll",a),l==null||l.addEventListener("resize",a),()=>{l==null||l.removeEventListener("scroll",a),l==null||l.removeEventListener("resize",a)}},[a,t,s]),i}const kt=xe(()=>{const e=ve(),t=ve(),n=W(0),o=ve(),r=W(0),i=ve(),s=ve(),a=W(0),l=W(0),c=W(0),f=W(0),m=ve(),h=ve(),y=W(!1),g=W(!1),b=W(!1);return oe(z(e,X(({scrollTop:v})=>v)),t),oe(z(e,X(({scrollHeight:v})=>v)),s),oe(t,r),{deviation:n,fixedFooterHeight:c,fixedHeaderHeight:l,footerHeight:f,headerHeight:a,horizontalDirection:g,scrollBy:h,scrollContainerState:e,scrollHeight:s,scrollingInProgress:y,scrollTo:m,scrollTop:t,skipAnimationFrameInResizeObserver:b,smoothScrollTargetReached:o,statefulScrollTop:r,viewportHeight:i}},[],{singleton:!0}),ys={lvl:0};function nx(e,t){const n=e.length;if(n===0)return[];let{index:o,value:r}=t(e[0]);const i=[];for(let s=1;s<n;s++){const{index:a,value:l}=t(e[s]);i.push({end:a-1,start:o,value:r}),o=a,r=l}return i.push({end:1/0,start:o,value:r}),i}function Te(e){return e===ys}function gs(e,t){if(!Te(e))return t===e.k?e.v:t<e.k?gs(e.l,t):gs(e.r,t)}function un(e,t,n="k"){if(Te(e))return[-1/0,void 0];if(Number(e[n])===t)return[e.k,e.v];if(Number(e[n])<t){const o=un(e.r,t,n);return o[0]===-1/0?[e.k,e.v]:o}return un(e.l,t,n)}function It(e,t,n){return Te(e)?ix(t,n,1):t===e.k?Ze(e,{k:t,v:n}):t<e.k?Hh(Ze(e,{l:It(e.l,t,n)})):Hh(Ze(e,{r:It(e.r,t,n)}))}function Mr(){return ys}function qr(e,t,n){if(Te(e))return[];const o=un(e,t)[0];return nI(Wd(e,o,n))}function Vd(e,t){if(Te(e))return ys;const{k:n,l:o,r}=e;if(t===n){if(Te(o))return r;if(Te(r))return o;const[i,s]=rx(o);return Na(Ze(e,{k:i,l:ox(o),v:s}))}return t<n?Na(Ze(e,{l:Vd(o,t)})):Na(Ze(e,{r:Vd(r,t)}))}function Do(e){return Te(e)?[]:[...Do(e.l),{k:e.k,v:e.v},...Do(e.r)]}function Wd(e,t,n){if(Te(e))return[];const{k:o,l:r,r:i,v:s}=e;let a=[];return o>t&&(a=a.concat(Wd(r,t,n))),o>=t&&o<=n&&a.push({k:o,v:s}),o<=n&&(a=a.concat(Wd(i,t,n))),a}function Na(e){const{l:t,lvl:n,r:o}=e;if(o.lvl>=n-1&&t.lvl>=n-1)return e;if(n>o.lvl+1){if(_c(t))return sx(Ze(e,{lvl:n-1}));if(!Te(t)&&!Te(t.r))return Ze(t.r,{l:Ze(t,{r:t.r.l}),lvl:n,r:Ze(e,{l:t.r.r,lvl:n-1})});throw new Error("Unexpected empty nodes")}if(_c(e))return Kd(Ze(e,{lvl:n-1}));if(!Te(o)&&!Te(o.l)){const r=o.l,i=_c(r)?o.lvl-1:o.lvl;return Ze(r,{l:Ze(e,{lvl:n-1,r:r.l}),lvl:r.lvl+1,r:Kd(Ze(o,{l:r.r,lvl:i}))})}throw new Error("Unexpected empty nodes")}function Ze(e,t){return ix(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ox(e){return Te(e.r)?e.l:Na(Ze(e,{r:ox(e.r)}))}function _c(e){return Te(e)||e.lvl>e.r.lvl}function rx(e){return Te(e.r)?[e.k,e.v]:rx(e.r)}function ix(e,t,n,o=ys,r=ys){return{k:e,l:o,lvl:n,r,v:t}}function Hh(e){return Kd(sx(e))}function sx(e){const{l:t}=e;return!Te(t)&&t.lvl===e.lvl?Ze(t,{r:Ze(e,{l:t.r})}):e}function Kd(e){const{lvl:t,r:n}=e;return!Te(n)&&!Te(n.r)&&n.lvl===t&&n.r.lvl===t?Ze(n,{l:Ze(e,{r:n.l}),lvl:t+1}):e}function nI(e){return nx(e,({k:t,v:n})=>({index:t,value:n}))}function ax(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function vs(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const uf=xe(()=>({recalcInProgress:W(!1)}),[],{singleton:!0});function lx(e,t,n){return e[ul(e,t,n)]}function ul(e,t,n,o=0){let r=e.length-1;for(;o<=r;){const i=Math.floor((o+r)/2),s=e[i],a=n(s,t);if(a===0)return i;if(a===-1){if(r-o<2)return i-1;r=i-1}else{if(r===o)return i;o=i+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function oI(e,t,n,o){const r=ul(e,t,o),i=ul(e,n,o,r);return e.slice(r,i+1)}function bo(e,t){return Math.round(e.getBoundingClientRect()[t])}function Bl(e){return!Te(e.groupOffsetTree)}function pf({index:e},t){return t===e?0:t<e?-1:1}function rI(){return{groupIndices:[],groupOffsetTree:Mr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Mr()}}function iI(e,t){let n=Te(e)?0:1/0;for(const o of t){const{endIndex:r,size:i,startIndex:s}=o;if(n=Math.min(n,s),Te(e)){e=It(e,0,i);continue}const a=qr(e,s-1,r+1);if(a.some(pI(o)))continue;let l=!1,c=!1;for(const{end:f,start:m,value:h}of a)l?(r>=m||i===h)&&(e=Vd(e,m)):(c=h!==i,l=!0),f>r&&r>=m&&h!==i&&(e=It(e,r+1,h));c&&(e=It(e,s,i))}return[e,n]}function sI(e){return typeof e.groupIndex<"u"}function aI({offset:e},t){return t===e?0:t<e?-1:1}function bs(e,t,n){if(t.length===0)return 0;const{index:o,offset:r,size:i}=lx(t,e,pf),s=e-o,a=i*s+(s-1)*n+r;return a>0?a+n:a}function cx(e,t){if(!Bl(t))return e;let n=0;for(;t.groupIndices[n]<=e+n;)n++;return e+n}function dx(e,t,n){if(sI(e))return t.groupIndices[e.groupIndex]+1;const o=e.index==="LAST"?n:e.index;let r=cx(o,t);return r=Math.max(0,r,Math.min(n,r)),r}function lI(e,t,n,o=0){return o>0&&(t=Math.max(t,lx(e,o,pf).offset)),nx(oI(e,t,n,aI),uI)}function cI(e,[t,n,o,r]){t.length>0&&o("received item sizes",t,nt.DEBUG);const i=e.sizeTree;let s=i,a=0;if(n.length>0&&Te(i)&&t.length===2){const h=t[0].size,y=t[1].size;s=n.reduce((g,b)=>It(It(g,b,h),b+1,y),s)}else[s,a]=iI(s,t);if(s===i)return e;const{lastIndex:l,lastOffset:c,lastSize:f,offsetTree:m}=Gd(e.offsetTree,a,s,r);return{groupIndices:n,groupOffsetTree:n.reduce((h,y)=>It(h,y,bs(y,m,r)),Mr()),lastIndex:l,lastOffset:c,lastSize:f,offsetTree:m,sizeTree:s}}function dI(e){return Do(e).map(({k:t,v:n},o,r)=>{const i=r[o+1];return{endIndex:i!==void 0?i.k-1:1/0,size:n,startIndex:t}})}function Vh(e,t){let n=0,o=0;for(;n<e;)n+=t[o+1]-t[o]-1,o++;return o-(n===e?0:1)}function Gd(e,t,n,o){let r=e,i=0,s=0,a=0,l=0;if(t!==0){l=ul(r,t-1,pf),a=r[l].offset;const c=un(n,t-1);i=c[0],s=c[1],r.length&&r[l].size===un(n,t)[1]&&(l-=1),r=r.slice(0,l+1)}else r=[];for(const{start:c,value:f}of qr(n,t,1/0)){const m=c-i,h=m*s+a+m*o;r.push({index:c,offset:h,size:f}),i=c,a=h,s=f}return{lastIndex:i,lastOffset:a,lastSize:s,offsetTree:r}}function uI(e){return{index:e.index,value:e}}function pI(e){const{endIndex:t,size:n,startIndex:o}=e;return r=>r.start===o&&(r.end===t||r.end===1/0)&&r.value===n}const fI={offsetHeight:"height",offsetWidth:"width"},Tn=xe(([{log:e},{recalcInProgress:t}])=>{const n=ve(),o=ve(),r=yt(o,0),i=ve(),s=ve(),a=W(0),l=W([]),c=W(void 0),f=W(void 0),m=W(void 0),h=W(void 0),y=W(($,j)=>bo($,fI[j])),g=W(void 0),b=W(0),v=rI(),u=yt(z(n,he(l,e,b),Sn(cI,v),Me()),v),p=yt(z(l,Me(),Sn(($,j)=>({current:j,prev:$.current}),{current:[],prev:[]}),X(({prev:$})=>$)),[]);oe(z(l,ae($=>$.length>0),he(u,b),X(([$,j,R])=>{const M=$.reduce((F,V,L)=>It(F,V,bs(V,j.offsetTree,R)||L),Mr());return{...j,groupIndices:$,groupOffsetTree:M}})),u),oe(z(o,he(u),ae(([$,{lastIndex:j}])=>$<j),X(([$,{lastIndex:j,lastSize:R}])=>[{endIndex:j,size:R,startIndex:$}])),n),oe(c,f);const x=yt(z(c,X($=>$===void 0)),!0);oe(z(f,ae($=>$!==void 0&&Te(Le(u).sizeTree)),X($=>{const j=Le(m),R=Le(l).length>0;return j!==void 0&&j!==0?R?[{endIndex:0,size:j,startIndex:0},{endIndex:1,size:$,startIndex:1}]:[]:[{endIndex:0,size:$,startIndex:0}]})),n),oe(z(h,ae($=>$!==void 0&&$.length>0&&Te(Le(u).sizeTree)),X($=>{const j=[];let R=$[0],M=0;for(let F=1;F<$.length;F++){const V=$[F];V!==R&&(j.push({endIndex:F-1,size:R,startIndex:M}),R=V,M=F)}return j.push({endIndex:$.length-1,size:R,startIndex:M}),j})),n),oe(z(l,he(m,f),ae(([,$,j])=>$!==void 0&&j!==void 0),X(([$,j,R])=>{const M=[];for(let F=0;F<$.length;F++){const V=$[F],L=$[F+1];M.push({startIndex:V,endIndex:V,size:j}),L!==void 0&&M.push({startIndex:V+1,endIndex:L-1,size:R})}return M})),n);const S=Mt(z(n,he(u),Sn(({sizes:$},[j,R])=>({changed:R!==$,sizes:R}),{changed:!1,sizes:v}),X($=>$.changed)));$e(z(a,Sn(($,j)=>({diff:$.prev-j,prev:j}),{diff:0,prev:0}),X($=>$.diff)),$=>{const{groupIndices:j}=Le(u);if($>0)me(t,!0),me(i,$+Vh($,j));else if($<0){const R=Le(p);R.length>0&&($-=Vh(-$,R)),me(s,$)}}),$e(z(a,he(e)),([$,j])=>{$<0&&j("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:a},nt.ERROR)});const T=Mt(i);oe(z(i,he(u),X(([$,j])=>{const R=j.groupIndices.length>0,M=[],F=j.lastSize;if(R){const V=gs(j.sizeTree,0);let L=0,U=0;for(;L<$;){const Q=j.groupIndices[U],ee=j.groupIndices.length===U+1?1/0:j.groupIndices[U+1]-Q-1;M.push({endIndex:Q,size:V,startIndex:Q}),M.push({endIndex:Q+1+ee-1,size:F,startIndex:Q+1}),U++,L+=ee+1}const D=Do(j.sizeTree);return L!==$&&D.shift(),D.reduce((Q,{k:ee,v:q})=>{let G=Q.ranges;return Q.prevSize!==0&&(G=[...Q.ranges,{endIndex:ee+$-1,size:Q.prevSize,startIndex:Q.prevIndex}]),{prevIndex:ee+$,prevSize:q,ranges:G}},{prevIndex:$,prevSize:0,ranges:M}).ranges}return Do(j.sizeTree).reduce((V,{k:L,v:U})=>({prevIndex:L+$,prevSize:U,ranges:[...V.ranges,{endIndex:L+$-1,size:V.prevSize,startIndex:V.prevIndex}]}),{prevIndex:0,prevSize:F,ranges:[]}).ranges})),n);const C=Mt(z(s,he(u,b),X(([$,{offsetTree:j},R])=>{const M=-$;return bs(M,j,R)})));return oe(z(s,he(u,b),X(([$,j,R])=>{if(j.groupIndices.length>0){if(Te(j.sizeTree))return j;let F=Mr();const V=Le(p);let L=0,U=0,D=0;for(;L<-$;){D=V[U];const Q=V[U+1]-D-1;U++,L+=Q+1}if(F=Do(j.sizeTree).reduce((Q,{k:ee,v:q})=>It(Q,Math.max(0,ee+$),q),F),L!==-$){const Q=gs(j.sizeTree,D);F=It(F,0,Q);const ee=un(j.sizeTree,-$+1)[1];F=It(F,1,ee)}return{...j,sizeTree:F,...Gd(j.offsetTree,0,F,R)}}const M=Do(j.sizeTree).reduce((F,{k:V,v:L})=>It(F,Math.max(0,V+$),L),Mr());return{...j,sizeTree:M,...Gd(j.offsetTree,0,M,R)}})),u),{beforeUnshiftWith:T,data:g,defaultItemSize:f,firstItemIndex:a,fixedItemSize:c,fixedGroupSize:m,gap:b,groupIndices:l,heightEstimates:h,itemSize:y,listRefresh:S,shiftWith:s,shiftWithOffset:C,sizeRanges:n,sizes:u,statefulTotalCount:r,totalCount:o,trackItemSizes:x,unshiftWith:i}},Ue(ko,uf),{singleton:!0});function mI(e){return e.reduce((t,n)=>(t.groupIndices.push(t.totalCount),t.totalCount+=n+1,t),{groupIndices:[],totalCount:0})}const ux=xe(([{groupIndices:e,sizes:t,totalCount:n},{headerHeight:o,scrollTop:r}])=>{const i=ve(),s=ve(),a=Mt(z(i,X(mI)));return oe(z(a,X(l=>l.totalCount)),n),oe(z(a,X(l=>l.groupIndices)),e),oe(z(Qe(r,t,o),ae(([l,c])=>Bl(c)),X(([l,c,f])=>un(c.groupOffsetTree,Math.max(l-f,0),"v")[0]),Me(),X(l=>[l])),s),{groupCounts:i,topItemsIndexes:s}},Ue(Tn,kt)),To=xe(([{log:e}])=>{const t=W(!1),n=Mt(z(t,ae(o=>o),Me()));return $e(t,o=>{o&&Le(e)("props updated",{},nt.DEBUG)}),{didMount:n,propsReady:t}},Ue(ko),{singleton:!0}),hI=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function px(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!hI)&&(t.behavior="auto"),t.offset===void 0&&(t.offset=0),t}const Ps=xe(([{gap:e,listRefresh:t,sizes:n,totalCount:o},{fixedFooterHeight:r,fixedHeaderHeight:i,footerHeight:s,headerHeight:a,scrollingInProgress:l,scrollTo:c,smoothScrollTargetReached:f,viewportHeight:m},{log:h}])=>{const y=ve(),g=ve(),b=W(0);let v=null,u=null,p=null;function x(){v!==null&&(v(),v=null),p!==null&&(p(),p=null),u&&(clearTimeout(u),u=null),me(l,!1)}return oe(z(y,he(n,m,o,b,a,s,h),he(e,i,r),X(([[S,T,C,$,j,R,M,F],V,L,U])=>{const D=px(S),{align:Q,behavior:ee,offset:q}=D,G=$-1,I=dx(D,T,G);let _=bs(I,T.offsetTree,V)+R;Q==="end"?(_+=L+un(T.sizeTree,I)[1]-C+U,I===G&&(_+=M)):Q==="center"?_+=(L+un(T.sizeTree,I)[1]-C+U)/2:_-=j,q!==void 0&&q!==0&&(_+=q);const A=E=>{x(),E?(F("retrying to scroll to",{location:S},nt.DEBUG),me(y,S)):(me(g,!0),F("list did not change, scroll successful",{},nt.DEBUG))};if(x(),ee==="smooth"){let E=!1;p=$e(t,w=>{E=E||w}),v=cn(f,()=>{A(E)})}else v=cn(z(t,yI(150)),A);return u=setTimeout(()=>{x()},1200),me(l,!0),F("scrolling from index to",{behavior:ee,index:I,top:_},nt.DEBUG),{behavior:ee,top:_}})),c),{scrollTargetReached:g,scrollToIndex:y,topListHeight:b}},Ue(Tn,kt,ko),{singleton:!0});function yI(e){return t=>{const n=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(n))}}}function ff(e,t){e===0?t():requestAnimationFrame(()=>{ff(e-1,t)})}function mf(e,t){const n=t-1;return typeof e=="number"?e:e.index==="LAST"?n:e.index}const Is=xe(([{defaultItemSize:e,listRefresh:t,sizes:n},{scrollTop:o},{scrollTargetReached:r,scrollToIndex:i},{didMount:s}])=>{const a=W(!0),l=W(0),c=W(!0);return oe(z(s,he(l),ae(([f,m])=>m!==0),yn(!1)),a),oe(z(s,he(l),ae(([f,m])=>m!==0),yn(!1)),c),$e(z(Qe(t,s),he(a,n,e,c),ae(([[,f],m,{sizeTree:h},y,g])=>f&&(!Te(h)||lf(y))&&!m&&!g),he(l)),([,f])=>{cn(r,()=>{me(c,!0)}),ff(4,()=>{cn(o,()=>{me(a,!0)}),me(i,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:l,scrolledToInitialItem:a}},Ue(Tn,kt,Ps,To),{singleton:!0});function fx(e,t){return Math.abs(e-t)<1.01}const xs="up",Bi="down",gI="none",vI={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},bI=0,Os=xe(([{footerHeight:e,headerHeight:t,scrollBy:n,scrollContainerState:o,scrollTop:r,viewportHeight:i}])=>{const s=W(!1),a=W(!0),l=ve(),c=ve(),f=W(4),m=W(bI),h=yt(z(Bd(z(se(r),Qo(1),yn(!0)),z(se(r),Qo(1),yn(!1),Dh(100))),Me()),!1),y=yt(z(Bd(z(n,yn(!0)),z(n,yn(!1),Dh(200))),Me()),!1);oe(z(Qe(se(r),se(m)),X(([p,x])=>p<=x),Me()),a),oe(z(a,On(50)),c);const g=Mt(z(Qe(o,se(i),se(t),se(e),se(f)),Sn((p,[{scrollHeight:x,scrollTop:S},T,C,$,j])=>{const R=S+T-x>-j,M={scrollHeight:x,scrollTop:S,viewportHeight:T};if(R){let V,L;return S>p.state.scrollTop?(V="SCROLLED_DOWN",L=p.state.scrollTop-S):(V="SIZE_DECREASED",L=p.state.scrollTop-S||p.scrollTopDelta),{atBottom:!0,atBottomBecause:V,scrollTopDelta:L,state:M}}let F;return M.scrollHeight>p.state.scrollHeight?F="SIZE_INCREASED":T<p.state.viewportHeight?F="VIEWPORT_HEIGHT_DECREASING":S<p.state.scrollTop?F="SCROLLING_UPWARDS":F="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:F,state:M}},vI),Me((p,x)=>p!==void 0&&p.atBottom===x.atBottom))),b=yt(z(o,Sn((p,{scrollHeight:x,scrollTop:S,viewportHeight:T})=>{if(!fx(p.scrollHeight,x)){const C=x-(S+T)<1;return p.scrollTop!==S&&C?{changed:!0,jump:p.scrollTop-S,scrollHeight:x,scrollTop:S}:{changed:!0,jump:0,scrollHeight:x,scrollTop:S}}return{changed:!1,jump:0,scrollHeight:x,scrollTop:S}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ae(p=>p.changed),X(p=>p.jump)),0);oe(z(g,X(p=>p.atBottom)),s),oe(z(s,On(50)),l);const v=W(Bi);oe(z(o,X(({scrollTop:p})=>p),Me(),Sn((p,x)=>Le(y)?{direction:p.direction,prevScrollTop:x}:{direction:x<p.prevScrollTop?xs:Bi,prevScrollTop:x},{direction:Bi,prevScrollTop:0}),X(p=>p.direction)),v),oe(z(o,On(50),yn(gI)),v);const u=W(0);return oe(z(h,ae(p=>!p),yn(0)),u),oe(z(r,On(100),he(h),ae(([p,x])=>x),Sn(([p,x],[S])=>[x,S],[0,0]),X(([p,x])=>x-p)),u),{atBottomState:g,atBottomStateChange:l,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:m,isAtBottom:s,isAtTop:a,isScrolling:h,lastJumpDueToItemResize:b,scrollDirection:v,scrollVelocity:u}},Ue(kt)),ws="top",Ss="bottom",Wh="none";function Kh(e,t,n){return typeof e=="number"?n===xs&&t===ws||n===Bi&&t===Ss?e:0:n===xs?t===ws?e.main:e.reverse:t===Ss?e.main:e.reverse}function Gh(e,t){return typeof e=="number"?e:e[t]??0}const hf=xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:n,scrollTop:o,viewportHeight:r}])=>{const i=ve(),s=W(0),a=W(0),l=W(0),c=yt(z(Qe(se(o),se(r),se(n),se(i,vs),se(l),se(s),se(t),se(e),se(a)),X(([f,m,h,[y,g],b,v,u,p,x])=>{const S=f-p,T=v+u,C=Math.max(h-S,0);let $=Wh;const j=Gh(x,ws),R=Gh(x,Ss);return y-=p,y+=h+u,g+=h+u,g-=p,y>f+T-j&&($=xs),g<f-C+m+R&&($=Bi),$!==Wh?[Math.max(S-h-Kh(b,ws,$)-j,0),S-C-u+m+Kh(b,Ss,$)+R]:null}),ae(f=>f!==null),Me(vs)),[0,0]);return{increaseViewportBy:a,listBoundary:i,overscan:l,topListHeight:s,visibleRange:c}},Ue(kt),{singleton:!0});function xI(e,t,n){if(Bl(t)){const o=cx(e,t);return[{index:un(t.groupOffsetTree,o)[0],offset:0,size:0},{data:n==null?void 0:n[0],index:o,offset:0,size:0}]}return[{data:n==null?void 0:n[0],index:e,offset:0,size:0}]}const jc={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ca(e,t,n,o,r,i){const{lastIndex:s,lastOffset:a,lastSize:l}=r;let c=0,f=0;if(e.length>0){c=e[0].offset;const b=e[e.length-1];f=b.offset+b.size}const m=n-s,h=a+m*l+(m-1)*o,y=c,g=h-f;return{bottom:f,firstItemIndex:i,items:Jh(e,r,i),offsetBottom:g,offsetTop:c,top:y,topItems:Jh(t,r,i),topListHeight:t.reduce((b,v)=>v.size+b,0),totalCount:n}}function mx(e,t,n,o,r,i){let s=0;if(n.groupIndices.length>0)for(const f of n.groupIndices){if(f-s>=e)break;s++}const a=e+s,l=mf(t,a),c=Array.from({length:a}).map((f,m)=>({data:i[m+l],index:m+l,offset:0,size:0}));return Ca(c,[],a,r,n,o)}function Jh(e,t,n){if(e.length===0)return[];if(!Bl(t))return e.map(c=>({...c,index:c.index+n,originalIndex:c.index}));const o=e[0].index,r=e[e.length-1].index,i=[],s=qr(t.groupOffsetTree,o,r);let a,l=0;for(const c of e){(!a||a.end<c.index)&&(a=s.shift(),l=t.groupIndices.indexOf(a.start));let f;c.index===a.start?f={index:l,type:"group"}:f={groupIndex:l,index:c.index-(l+1)+n},i.push({...f,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return i}function Qh(e,t){return e===void 0?0:typeof e=="number"?e:e[t]??0}const er=xe(([{data:e,firstItemIndex:t,gap:n,sizes:o,totalCount:r},i,{listBoundary:s,topListHeight:a,visibleRange:l},{initialTopMostItemIndex:c,scrolledToInitialItem:f},{topListHeight:m},h,{didMount:y},{recalcInProgress:g}])=>{const b=W([]),v=W(0),u=ve(),p=W(0);oe(i.topItemsIndexes,b);const x=yt(z(Qe(y,g,se(l,vs),se(r),se(o),se(c),f,se(b),se(t),se(n),se(p),e),ae(([$,j,,R,,,,,,,,M])=>{const F=M!==void 0&&M.length!==R;return $&&!j&&!F}),X(([,,[$,j],R,M,F,V,L,U,D,Q,ee])=>{var Y,ie;const q=M,{offsetTree:G,sizeTree:I}=q,_=Le(v);if(R===0)return{...jc,totalCount:R};if($===0&&j===0)return _===0?{...jc,totalCount:R}:mx(_,F,M,U,D,ee||[]);if(Te(I))return _>0?null:Ca(xI(mf(F,R),q,ee),[],R,D,q,U);const A=[];if(L.length>0){const de=L[0],we=L[L.length-1];let ze=0;for(const Ee of qr(I,de,we)){const Se=Ee.value,_e=Math.max(Ee.start,de),Ye=Math.min(Ee.end,we);for(let Pe=_e;Pe<=Ye;Pe++)A.push({data:ee==null?void 0:ee[Pe],index:Pe,offset:ze,size:Se}),ze+=Se}}if(!V)return Ca([],A,R,D,q,U);const E=L.length>0?L[L.length-1]+1:0,w=lI(G,$,j,E);if(w.length===0)return null;const k=R-1,N=Fl([],de=>{for(const we of w){const ze=we.value;let Ee=ze.offset,Se=we.start;const _e=ze.size;if(ze.offset<$){Se+=Math.floor(($-ze.offset+D)/(_e+D));const Pe=Se-we.start;Ee+=Pe*_e+Pe*D}Se<E&&(Ee+=(E-Se)*_e,Se=E);const Ye=Math.min(we.end,k);for(let Pe=Se;Pe<=Ye&&!(Ee>=j);Pe++)de.push({data:ee==null?void 0:ee[Pe],index:Pe,offset:Ee,size:_e}),Ee+=_e+D}}),B=Qh(Q,ws),O=Qh(Q,Ss);if(N.length>0&&(B>0||O>0)){const de=N[0],we=N[N.length-1];if(B>0&&de.index>E){const ze=Math.min(B,de.index-E),Ee=[];let Se=de.offset;for(let _e=de.index-1;_e>=de.index-ze;_e--){const Ye=((Y=qr(I,_e,_e)[0])==null?void 0:Y.value)??de.size;Se-=Ye+D,Ee.unshift({data:ee==null?void 0:ee[_e],index:_e,offset:Se,size:Ye})}N.unshift(...Ee)}if(O>0&&we.index<k){const ze=Math.min(O,k-we.index);let Ee=we.offset+we.size+D;for(let Se=we.index+1;Se<=we.index+ze;Se++){const _e=((ie=qr(I,Se,Se)[0])==null?void 0:ie.value)??we.size;N.push({data:ee==null?void 0:ee[Se],index:Se,offset:Ee,size:_e}),Ee+=_e+D}}}return Ca(N,A,R,D,q,U)}),ae($=>$!==null),Me()),jc);oe(z(e,ae(lf),X($=>$==null?void 0:$.length)),r),oe(z(x,X($=>$.topListHeight)),m),oe(m,a),oe(z(x,X($=>[$.top,$.bottom])),s),oe(z(x,X($=>$.items)),u);const S=Mt(z(x,ae(({items:$})=>$.length>0),he(r,e),ae(([{items:$},j])=>$[$.length-1].originalIndex===j-1),X(([,$,j])=>[$-1,j]),Me(vs),X(([$])=>$))),T=Mt(z(x,On(200),ae(({items:$,topItems:j})=>$.length>0&&$[0].originalIndex===j.length),X(({items:$})=>$[0].index),Me())),C=Mt(z(x,ae(({items:$})=>$.length>0),X(({items:$})=>{let j=0,R=$.length-1;for(;$[j].type==="group"&&j<R;)j++;for(;$[R].type==="group"&&R>j;)R--;return{endIndex:$[R].index,startIndex:$[j].index}}),Me(ax)));return{endReached:S,initialItemCount:v,itemsRendered:u,listState:x,minOverscanItemCount:p,rangeChanged:C,startReached:T,topItemsIndexes:b,...h}},Ue(Tn,ux,hf,Is,Ps,Os,To,uf),{singleton:!0}),hx=xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:n,headerHeight:o},{listState:r}])=>{const i=ve(),s=yt(z(Qe(n,e,o,t,r),X(([a,l,c,f,m])=>a+l+c+f+m.offsetBottom+m.bottom)),0);return oe(se(s),i),{totalListHeight:s,totalListHeightChanged:i}},Ue(kt,er),{singleton:!0}),wI=xe(([{viewportHeight:e},{totalListHeight:t}])=>{const n=W(!1),o=yt(z(Qe(n,e,t),ae(([r])=>r),X(([,r,i])=>Math.max(0,r-i)),On(0),Me()),0);return{alignToBottom:n,paddingTopAddition:o}},Ue(kt,hx),{singleton:!0}),yx=xe(()=>({context:W(null)})),SI=({itemBottom:e,itemTop:t,locationParams:{align:n,behavior:o,...r},viewportBottom:i,viewportTop:s})=>t<s?{...r,align:n??"start",...o!==void 0?{behavior:o}:{}}:e>i?{...r,align:n??"end",...o!==void 0?{behavior:o}:{}}:null,gx=xe(([{gap:e,sizes:t,totalCount:n},{fixedFooterHeight:o,fixedHeaderHeight:r,headerHeight:i,scrollingInProgress:s,scrollTop:a,viewportHeight:l},{scrollToIndex:c}])=>{const f=ve();return oe(z(f,he(t,l,n,i,r,o,a),he(e),X(([[m,h,y,g,b,v,u,p],x])=>{const{calculateViewLocation:S=SI,done:T,...C}=m,$=dx(m,h,g-1),j=bs($,h.offsetTree,x)+b+v,R=j+un(h.sizeTree,$)[1],M=p+v,F=p+y-u,V=S({itemBottom:R,itemTop:j,locationParams:C,viewportBottom:F,viewportTop:M});return V!==null?T&&cn(z(s,ae(L=>!L),Qo(Le(s)?1:2)),T):T==null||T(),V}),ae(m=>m!==null)),c),{scrollIntoView:f}},Ue(Tn,kt,Ps,er,ko),{singleton:!0});function Yh(e){return e===!1?!1:e==="smooth"?"smooth":"auto"}const $I=(e,t)=>typeof e=="function"?Yh(e(t)):t&&Yh(e),kI=xe(([{listRefresh:e,totalCount:t,fixedItemSize:n,data:o},{atBottomState:r,isAtBottom:i},{scrollToIndex:s},{scrolledToInitialItem:a},{didMount:l,propsReady:c},{log:f},{scrollingInProgress:m},{context:h},{scrollIntoView:y}])=>{const g=W(!1),b=ve();let v=null;function u(T){me(s,{align:"end",behavior:T,index:"LAST"})}$e(z(Qe(z(se(t),Qo(1)),l),he(se(g),i,a,m),X(([[T,C],$,j,R,M])=>{let F=C&&R,V="auto";return F&&(V=$I($,j||M),F=F&&V!==!1),{followOutputBehavior:V,shouldFollow:F,totalCount:T}}),ae(({shouldFollow:T})=>T)),({followOutputBehavior:T,totalCount:C})=>{v!==null&&(v(),v=null),Le(n)!==void 0?requestAnimationFrame(()=>{Le(f)("following output to ",{totalCount:C},nt.DEBUG),u(T)}):v=cn(e,()=>{Le(f)("following output to ",{totalCount:C},nt.DEBUG),u(T),v=null})});function p(T){const C=cn(r,$=>{T&&!$.atBottom&&$.notAtBottomBecause==="SIZE_INCREASED"&&v===null&&(Le(f)("scrolling to bottom due to increased size",{},nt.DEBUG),u("auto"))});setTimeout(C,100)}$e(z(Qe(se(g),t,c),ae(([T,,C])=>T!==!1&&C),Sn(({value:T},[,C])=>({refreshed:T===C,value:C}),{refreshed:!1,value:0}),ae(({refreshed:T})=>T),he(g,t)),([,T])=>{Le(a)&&p(T!==!1)}),$e(b,()=>{p(Le(g)!==!1)}),$e(Qe(se(g),r),([T,C])=>{T!==!1&&!C.atBottom&&C.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&u("auto")});const x=W(null),S=ve();return oe(Bd(z(se(o),X(T=>(T==null?void 0:T.length)??0)),z(se(t))),S),$e(z(Qe(z(S,Qo(1)),l),he(se(x),a,m,h),X(([[T,C],$,j,R,M])=>C&&j&&($==null?void 0:$({context:M,totalCount:T,scrollingInProgress:R}))),ae(T=>!!T),On(0)),T=>{v!==null&&(v(),v=null),Le(n)!==void 0?requestAnimationFrame(()=>{Le(f)("scrolling into view",{}),me(y,T)}):v=cn(e,()=>{Le(f)("scrolling into view",{}),me(y,T),v=null})}),{autoscrollToBottom:b,followOutput:g,scrollIntoViewOnChange:x}},Ue(Tn,Os,Ps,Is,To,ko,kt,yx,gx)),TI=xe(([{data:e,firstItemIndex:t,gap:n,sizes:o},{initialTopMostItemIndex:r},{initialItemCount:i,listState:s},{didMount:a}])=>(oe(z(a,he(i),ae(([,l])=>l!==0),he(r,o,t,n,e),X(([[,l],c,f,m,h,y=[]])=>mx(l,c,f,m,h,y))),s),{}),Ue(Tn,Is,er,To),{singleton:!0}),_I=xe(([{didMount:e},{scrollTo:t},{listState:n}])=>{const o=W(0);return $e(z(e,he(o),ae(([,r])=>r!==0),X(([,r])=>({top:r}))),r=>{cn(z(n,Qo(1),ae(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{me(t,r)})})}),{initialScrollTop:o}},Ue(To,kt,er),{singleton:!0}),vx=xe(([{scrollVelocity:e}])=>{const t=W(!1),n=ve(),o=W(!1);return oe(z(e,he(o,t,n),ae(([r,i])=>i!==!1&&i!==void 0),X(([r,i,s,a])=>{const{enter:l,exit:c}=i;if(s){if(c(r,a))return!1}else if(l(r,a))return!0;return s}),Me()),t),$e(z(Qe(t,e,n),he(o)),([[r,i,s],a])=>{r&&a!==!1&&a!==void 0&&a.change&&a.change(i,s)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:n,scrollVelocity:e}},Ue(Os),{singleton:!0}),yf=xe(([{scrollContainerState:e,scrollTo:t}])=>{const n=ve(),o=ve(),r=ve(),i=W(!1),s=W(void 0);return oe(z(Qe(n,o),X(([{scrollTop:a,viewportHeight:l},{offsetTop:c,listHeight:f}])=>({scrollHeight:f,scrollTop:Math.max(0,a-c),viewportHeight:l}))),e),oe(z(t,he(o),X(([a,{offsetTop:l}])=>({...a,top:a.top+l}))),r),{customScrollParent:s,useWindowScroll:i,windowScrollContainerState:n,windowScrollTo:r,windowViewportRect:o}},Ue(kt)),jI=xe(([{sizeRanges:e,sizes:t},{headerHeight:n,scrollTop:o},{initialTopMostItemIndex:r},{didMount:i},{useWindowScroll:s,windowScrollContainerState:a,windowViewportRect:l}])=>{const c=ve(),f=W(void 0),m=W(null),h=W(null);return oe(a,m),oe(l,h),$e(z(c,he(t,o,s,m,h,n)),([y,g,b,v,u,p,x])=>{const S=dI(g.sizeTree);v&&u!==null&&p!==null&&(b=u.scrollTop-p.offsetTop),b-=x,y({ranges:S,scrollTop:b})}),oe(z(f,ae(lf),X(NI)),r),oe(z(i,he(f),ae(([,y])=>y!==void 0),Me(),X(([,y])=>y.ranges)),e),{getState:c,restoreStateFrom:f}},Ue(Tn,kt,Is,To,yf));function NI(e){return{align:"start",index:0,offset:e.scrollTop}}const CI=xe(([{topItemsIndexes:e}])=>{const t=W(0);return oe(z(t,ae(n=>n>=0),X(n=>Array.from({length:n}).map((o,r)=>r))),e),{topItemCount:t}},Ue(er));function bx(e){let t=!1,n;return()=>(t||(t=!0,n=e()),n)}const EI=bx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),PI=xe(([{deviation:e,scrollBy:t,scrollingInProgress:n,scrollTop:o},{isAtBottom:r,isScrolling:i,lastJumpDueToItemResize:s,scrollDirection:a},{listState:l},{beforeUnshiftWith:c,gap:f,shiftWithOffset:m,sizes:h},{log:y},{recalcInProgress:g}])=>{const b=Mt(z(l,he(s),Sn(([,u,p,x],[{bottom:S,items:T,offsetBottom:C,totalCount:$},j])=>{const R=S+C;let M=0;return p===$&&u.length>0&&T.length>0&&(T[0].originalIndex===0&&u[0].originalIndex===0||(M=R-x,M!==0&&(M+=j))),[M,T,$,R]},[0,[],0,0]),ae(([u])=>u!==0),he(o,a,n,r,y,g),ae(([,u,p,x,,,S])=>!S&&!x&&u!==0&&p===xs),X(([[u],,,,,p])=>(p("Upward scrolling compensation",{amount:u},nt.DEBUG),u))));function v(u){u>0?(me(t,{behavior:"auto",top:-u}),me(e,0)):(me(e,0),me(t,{behavior:"auto",top:-u}))}return $e(z(b,he(e,i)),([u,p,x])=>{x&&EI()?me(e,p-u):v(-u)}),$e(z(Qe(yt(i,!1),e,g),ae(([u,p,x])=>!u&&!x&&p!==0),X(([u,p])=>p),On(1)),v),oe(z(m,X(u=>({top:-u}))),t),$e(z(c,he(h,f),X(([u,{groupIndices:p,lastSize:x,sizeTree:S},T])=>{function C(F){return F*(x+T)}if(p.length===0)return C(u);let $=0;const j=gs(S,0);let R=0,M=0;for(;R<u;){R++,$+=j;let F=p.length===M+1?1/0:p[M+1]-p[M]-1;R+F>u&&($-=j,F=u-R+1),R+=F,$+=C(F),M++}return $})),u=>{me(e,u),requestAnimationFrame(()=>{me(t,{top:u}),requestAnimationFrame(()=>{me(e,0),me(g,!1)})})}),{deviation:e}},Ue(kt,Os,er,Tn,ko,uf)),II=xe(([e,t,n,o,r,i,s,a,l,c,f])=>({...e,...t,...n,...o,...r,...i,...s,...a,...l,...c,...f}),Ue(hf,TI,To,vx,hx,_I,wI,yf,gx,ko,yx)),xx=xe(([{data:e,defaultItemSize:t,firstItemIndex:n,fixedItemSize:o,fixedGroupSize:r,gap:i,groupIndices:s,heightEstimates:a,itemSize:l,sizeRanges:c,sizes:f,statefulTotalCount:m,totalCount:h,trackItemSizes:y},{initialItemFinalLocationReached:g,initialTopMostItemIndex:b,scrolledToInitialItem:v},u,p,x,S,{scrollToIndex:T},C,{topItemCount:$},{groupCounts:j},R])=>{const{listState:M,minOverscanItemCount:F,topItemsIndexes:V,rangeChanged:L,...U}=S;return oe(L,R.scrollSeekRangeChanged),oe(z(R.windowViewportRect,X(D=>D.visibleHeight)),u.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:n,fixedItemHeight:o,fixedGroupHeight:r,gap:i,groupCounts:j,heightEstimates:a,initialItemFinalLocationReached:g,initialTopMostItemIndex:b,scrolledToInitialItem:v,sizeRanges:c,topItemCount:$,topItemsIndexes:V,totalCount:h,...x,groupIndices:s,itemSize:l,listState:M,minOverscanItemCount:F,scrollToIndex:T,statefulTotalCount:m,trackItemSizes:y,rangeChanged:L,...U,...R,...u,sizes:f,...p}},Ue(Tn,Is,kt,jI,kI,er,Ps,PI,CI,ux,II));function OI(e,t){const n={},o={};let r=0;const i=e.length;for(;r<i;)o[e[r]]=1,r+=1;for(const s in t)Object.hasOwn(o,s)||(n[s]=t[s]);return n}const ra=typeof document<"u"?te.useLayoutEffect:te.useEffect;function wx(e,t,n){const o=Object.keys(t.required||{}),r=Object.keys(t.optional||{}),i=Object.keys(t.methods||{}),s=Object.keys(t.events||{}),a=te.createContext({});function l(v,u){v.propsReady!==void 0&&me(v.propsReady,!1);for(const p of o){const x=v[t.required[p]];me(x,u[p])}for(const p of r)if(p in u){const x=v[t.optional[p]];me(x,u[p])}v.propsReady!==void 0&&me(v.propsReady,!0)}function c(v){return i.reduce((u,p)=>(u[p]=x=>{const S=v[t.methods[p]];me(S,x)},u),{})}function f(v){return s.reduce((u,p)=>(u[p]=GP(v[t.events[p]]),u),{})}const m=te.forwardRef(function(v,u){const{children:p,...x}=v,[S]=te.useState(()=>Fl(QP(e),$=>{l($,x)})),[T]=te.useState(Lh(f,S));ra(()=>{for(const $ of s)$ in x&&$e(T[$],x[$]);return()=>{Object.values(T).map(cf)}},[x,T,S]),ra(()=>{l(S,x)}),te.useImperativeHandle(u,Uh(c(S)));const C=n;return d.jsx(a.Provider,{value:S,children:n!==void 0?d.jsx(C,{...OI([...o,...r,...s],x),children:p}):p})}),h=v=>{const u=te.useContext(a);return te.useCallback(p=>{me(u[v],p)},[u,v])},y=v=>{const u=te.useContext(a)[v],p=te.useCallback(x=>$e(u,x),[u]);return te.useSyncExternalStore(p,()=>Le(u),()=>Le(u))},g=v=>{const u=te.useContext(a)[v],[p,x]=te.useState(Lh(Le,u));return ra(()=>$e(u,S=>{S!==p&&x(Uh(S))}),[u,p]),p},b=parseInt(te.version)>=18?y:g;return{Component:m,useEmitter:(v,u)=>{const p=te.useContext(a)[v];ra(()=>$e(p,u),[u,p])},useEmitterValue:b,usePublisher:h}}const Sx=te.createContext(void 0),$x=te.createContext(void 0),Nc="-webkit-sticky",Xh="sticky",gf=bx(()=>{if(typeof document>"u")return Xh;const e=document.createElement("div");return e.style.position=Nc,e.style.position===Nc?Nc:Xh}),kx=typeof document<"u"?te.useLayoutEffect:te.useEffect;function Cc(e){return"self"in e}function RI(e){return"body"in e}function Tx(e,t,n,o=ri,r,i){const s=te.useRef(null),a=te.useRef(null),l=te.useRef(null),c=te.useCallback(h=>{let y,g,b;const v=h.target;if(RI(v)||Cc(v)){const p=Cc(v)?v:v.defaultView;b=i===!0?Lo(p,p.scrollX):p.scrollY,y=i===!0?p.document.documentElement.scrollWidth:p.document.documentElement.scrollHeight,g=i===!0?p.innerWidth:p.innerHeight}else b=i===!0?Lo(v,v.scrollLeft):v.scrollTop,y=i===!0?v.scrollWidth:v.scrollHeight,g=i===!0?v.offsetWidth:v.offsetHeight;const u=()=>{e({scrollHeight:y,scrollTop:Math.max(b,0),viewportHeight:g})};h.suppressFlushSync===!0?u():iS.flushSync(u),a.current!==null&&(b===a.current||b<=0||b===y-g)&&(a.current=null,t(!0),l.current&&(clearTimeout(l.current),l.current=null))},[e,t,i]);te.useEffect(()=>{const h=r||s.current;return zh(h),o(r||s.current),c({suppressFlushSync:!0,target:h}),h.addEventListener("scroll",c,{passive:!0}),()=>{zh(h),o(null),h.removeEventListener("scroll",c)}},[s,c,n,o,r]);function f(h){const y=s.current;if(!y||(i===!0?"offsetWidth"in y&&y.offsetWidth===0:"offsetHeight"in y&&y.offsetHeight===0))return;const g=h.behavior==="smooth";let b,v,u;Cc(y)?(v=Math.max(bo(y.document.documentElement,i===!0?"width":"height"),i===!0?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight),b=i===!0?y.innerWidth:y.innerHeight,u=i===!0?Lo(y,y.scrollX):y.scrollY):(v=y[i===!0?"scrollWidth":"scrollHeight"],b=bo(y,i===!0?"width":"height"),u=i===!0?Lo(y,y.scrollLeft):y.scrollTop);const p=v-b;if(h.top===void 0){y.scrollTo(h);return}const x=Math.ceil(Math.max(Math.min(p,h.top),0));if(h.top=x,fx(b,v)||x===u){e({scrollHeight:v,scrollTop:u,viewportHeight:b}),g&&t(!0);return}g?(a.current=x,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{l.current=null,a.current=null,t(!0)},1e3)):a.current=null,i===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},left:Fh(y,x)}),y.scrollTo(h)}function m(h){i===!0&&(h={...h.behavior!==void 0?{behavior:h.behavior}:{},...h.top!==void 0?{left:Fh(s.current,h.top)}:{}}),s.current.scrollBy(h)}return{scrollByCallback:m,scrollerRef:s,scrollToCallback:f}}function vf(e){return e}const AI=xe(()=>{const e=W(a=>`Item ${a}`),t=W(a=>`Group ${a}`),n=W({}),o=W(vf),r=W("div"),i=W(ri),s=(a,l=null)=>yt(z(n,X(c=>c[a]),Me()),l);return{components:n,computeItemKey:o,EmptyPlaceholder:s("EmptyPlaceholder"),FooterComponent:s("Footer"),GroupComponent:s("Group","div"),groupContent:t,HeaderComponent:s("Header"),HeaderFooterTag:r,ItemComponent:s("Item","div"),itemContent:e,ListComponent:s("List","div"),ScrollerComponent:s("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:s("ScrollSeekPlaceholder"),TopItemListComponent:s("TopItemList")}}),MI=xe(([e,t])=>({...e,...t}),Ue(xx,AI)),qI=({height:e})=>d.jsx("div",{style:{height:e}}),UI={overflowAnchor:"none",position:gf(),zIndex:1},_x={overflowAnchor:"none"},LI={..._x,display:"inline-block",height:"100%"},Zh=te.memo(function({showTopList:e=!1}){const t=ce("listState"),n=Wt("sizeRanges"),o=ce("useWindowScroll"),r=ce("customScrollParent"),i=Wt("windowScrollContainerState"),s=Wt("scrollContainerState"),a=r||o?i:s,l=ce("itemContent"),c=ce("context"),f=ce("groupContent"),m=ce("trackItemSizes"),h=ce("itemSize"),y=ce("log"),g=Wt("gap"),b=ce("horizontalDirection"),{callbackRef:v}=eI(n,h,m,e?ri:a,y,g,r,b,ce("skipAnimationFrameInResizeObserver")),[u,p]=te.useState(0);xf("deviation",U=>{u!==U&&p(U)});const x=ce("EmptyPlaceholder"),S=ce("ScrollSeekPlaceholder")??qI,T=ce("ListComponent"),C=ce("ItemComponent"),$=ce("GroupComponent"),j=ce("computeItemKey"),R=ce("isSeeking"),M=ce("groupIndices").length>0,F=ce("alignToBottom"),V=ce("initialItemFinalLocationReached"),L=e?{}:{boxSizing:"border-box",...b?{display:"inline-block",height:"100%",marginInlineStart:u!==0?u:F?"auto":0,paddingInlineEnd:t.offsetBottom,paddingInlineStart:t.offsetTop,whiteSpace:"nowrap"}:{marginTop:u!==0?u:F?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...V?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&x!==null&&x!==void 0?d.jsx(x,{...ht(x,c)}):d.jsx(T,{...ht(T,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:v,style:L,children:(e?t.topItems:t.items).map(U=>{const D=U.originalIndex,Q=j(D+t.firstItemIndex,U.data,c);return R?P.createElement(S,{...ht(S,c),height:U.size,index:U.index,key:Q,type:U.type||"item",...U.type==="group"?{}:{groupIndex:U.groupIndex}}):U.type==="group"?P.createElement($,{...ht($,c),"data-index":D,"data-item-index":U.index,"data-known-size":U.size,key:Q,style:UI},f(U.index,c)):P.createElement(C,{...ht(C,c),...BI(C,U.data),"data-index":D,"data-item-group-index":U.groupIndex,"data-item-index":U.index,"data-known-size":U.size,key:Q,style:b?LI:_x},M?l(U.index,U.groupIndex,U.data,c):l(U.index,U.data,c))})})}),DI={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},zI={outline:"none",overflowX:"auto",position:"relative"},bf=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:void 0}),jx=(e,t,n=0)=>({...bf(e),position:t?"relative":"absolute",top:t?-n:0}),FI={position:gf(),top:0,width:"100%",zIndex:1};function ht(e,t){if(typeof e!="string")return{context:t}}function BI(e,t){return{item:typeof e=="string"?void 0:t}}const HI=te.memo(function(){const e=ce("HeaderComponent"),t=Wt("headerHeight"),n=ce("HeaderFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,ce("skipAnimationFrameInResizeObserver")),r=ce("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),VI=te.memo(function(){const e=ce("FooterComponent"),t=Wt("footerHeight"),n=ce("HeaderFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,ce("skipAnimationFrameInResizeObserver")),r=ce("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null});function Nx({useEmitter:e,useEmitterValue:t,usePublisher:n}){return te.memo(function({children:o,style:r,context:i,...s}){const a=n("scrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),f=t("scrollerRef"),m=t("horizontalDirection")||!1,{scrollByCallback:h,scrollerRef:y,scrollToCallback:g}=Tx(a,c,l,f,void 0,m);return e("scrollTo",g),e("scrollBy",h),d.jsx(l,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:y,style:{...m?zI:DI,...r},tabIndex:0,...s,...ht(l,i),children:o})})}function Cx({useEmitter:e,useEmitterValue:t,usePublisher:n}){return te.memo(function({children:o,style:r,context:i,...s}){const a=n("windowScrollContainerState"),l=t("ScrollerComponent"),c=n("smoothScrollTargetReached"),f=t("totalListHeight"),m=t("deviation"),h=t("customScrollParent"),y=te.useRef(null),g=t("scrollerRef"),{scrollByCallback:b,scrollerRef:v,scrollToCallback:u}=Tx(a,c,l,g,h);return kx(()=>{var p;return v.current=h||((p=y.current)==null?void 0:p.ownerDocument.defaultView),()=>{v.current=null}},[v,h]),e("windowScrollTo",u),e("scrollBy",b),d.jsx(l,{ref:y,"data-virtuoso-scroller":!0,style:{position:"relative",...r,...f!==0?{height:f+m}:void 0},...s,...ht(l,i),children:o})})}const WI=({children:e})=>{const t=te.useContext(Sx),n=Wt("viewportHeight"),o=Wt("fixedItemHeight"),r=ce("alignToBottom"),i=ce("horizontalDirection"),s=te.useMemo(()=>Yb(n,l=>bo(l,i?"width":"height")),[n,i]),a=Zo(s,!0,ce("skipAnimationFrameInResizeObserver"));return te.useEffect(()=>{t&&(n(t.viewportHeight),o(t.itemHeight))},[t,n,o]),d.jsx("div",{"data-viewport-type":"element",ref:a,style:bf(r),children:e})},KI=({children:e})=>{const t=te.useContext(Sx),n=Wt("windowViewportRect"),o=Wt("fixedItemHeight"),r=ce("customScrollParent"),i=ce("useWindowScroll"),s=ce("topListHeight"),a=tx(n,r,ce("skipAnimationFrameInResizeObserver")),l=ce("alignToBottom");return te.useEffect(()=>{t&&(o(t.itemHeight),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,n,o]),d.jsx("div",{"data-viewport-type":"window",ref:a,style:jx(l,i,s),children:e})},GI=({children:e})=>{const t=ce("TopItemListComponent")??"div",n=ce("headerHeight"),o={...FI,marginTop:`${n}px`},r=ce("context");return d.jsx(t,{style:o,...ht(t,r),children:e})},JI=te.memo(function(e){const t=ce("useWindowScroll"),n=ce("topItemsIndexes").length>0,o=ce("customScrollParent"),r=ce("context");return d.jsxs(o||t?XI:YI,{...e,context:r,children:[n&&d.jsx(GI,{children:d.jsx(Zh,{showTopList:!0})}),d.jsxs(o||t?KI:WI,{children:[d.jsx(HI,{}),d.jsx(Zh,{}),d.jsx(VI,{})]})]})}),{Component:QI,useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}=wx(MI,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},JI),YI=Nx({useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}),XI=Cx({useEmitter:xf,useEmitterValue:ce,usePublisher:Wt}),ZI=QI,eO=xe(()=>{const e=W(c=>d.jsxs("td",{children:["Item $",c]})),t=W(null),n=W(c=>d.jsxs("td",{colSpan:1e3,children:["Group ",c]})),o=W(null),r=W(null),i=W({}),s=W(vf),a=W(ri),l=(c,f=null)=>yt(z(i,X(m=>m[c]),Me()),f);return{components:i,computeItemKey:s,context:t,EmptyPlaceholder:l("EmptyPlaceholder"),FillerRow:l("FillerRow"),fixedFooterContent:r,fixedHeaderContent:o,itemContent:e,groupContent:n,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder"),TableBodyComponent:l("TableBody","tbody"),TableComponent:l("Table","table"),TableFooterComponent:l("TableFoot","tfoot"),TableHeadComponent:l("TableHead","thead"),TableRowComponent:l("TableRow","tr"),GroupComponent:l("Group","tr")}});Ue(xx,eO);gf();const ey={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},tO={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:ty,floor:pl,max:Hi,min:Ec,round:ny}=Math;function oy(e,t,n){return Array.from({length:t-e+1}).map((o,r)=>({data:n===null?null:n[r+e],index:r+e}))}function nO(e){return{...tO,items:e}}function ia(e,t){return e!==void 0&&e.width===t.width&&e.height===t.height}function oO(e,t){return e!==void 0&&e.column===t.column&&e.row===t.row}const rO=xe(([{increaseViewportBy:e,listBoundary:t,overscan:n,visibleRange:o},{footerHeight:r,headerHeight:i,scrollBy:s,scrollContainerState:a,scrollTo:l,scrollTop:c,smoothScrollTargetReached:f,viewportHeight:m},h,y,{didMount:g,propsReady:b},{customScrollParent:v,useWindowScroll:u,windowScrollContainerState:p,windowScrollTo:x,windowViewportRect:S},T])=>{const C=W(0),$=W(0),j=W(ey),R=W({height:0,width:0}),M=W({height:0,width:0}),F=ve(),V=ve(),L=W(0),U=W(null),D=W({column:0,row:0}),Q=ve(),ee=ve(),q=W(!1),G=W(0),I=W(!0),_=W(!1),A=W(!1);$e(z(g,he(G),ae(([O,Y])=>Y!==0)),()=>{me(I,!1)}),$e(z(Qe(g,I,M,R,G,_),ae(([O,Y,ie,de,,we])=>O&&!Y&&ie.height!==0&&de.height!==0&&!we)),([,,,,O])=>{me(_,!0),ff(1,()=>{me(F,O)}),cn(z(c),()=>{me(t,[0,0]),me(I,!0)})}),oe(z(ee,ae(O=>O!=null&&O.scrollTop>0),yn(0)),$),$e(z(g,he(ee),ae(([,O])=>O!=null)),([,O])=>{O&&(me(R,O.viewport),me(M,O.item),me(D,O.gap),O.scrollTop>0&&(me(q,!0),cn(z(c,Qo(1)),Y=>{me(q,!1)}),me(l,{top:O.scrollTop})))}),oe(z(R,X(({height:O})=>O)),m),oe(z(Qe(se(R,ia),se(M,ia),se(D,(O,Y)=>O!==void 0&&O.column===Y.column&&O.row===Y.row),se(c)),X(([O,Y,ie,de])=>({gap:ie,item:Y,scrollTop:de,viewport:O}))),Q),oe(z(Qe(se(C),o,se(D,oO),se(M,ia),se(R,ia),se(U),se($),se(q),se(I),se(G)),ae(([,,,,,,,O])=>!O),X(([O,[Y,ie],de,we,ze,Ee,Se,,_e,Ye])=>{const{column:Pe,row:_n}=de,{height:Bn,width:_o}=we,{width:tr}=ze;if(Se===0&&(O===0||tr===0))return ey;if(_o===0){const wf=mf(Ye,O),Ox=wf+Math.max(Se-1,0);return nO(oy(wf,Ox,Ee))}const Hn=Ex(tr,_o,Pe);let pn,Yt;_e?Y===0&&ie===0&&Se>0?(pn=0,Yt=Se-1):(pn=Hn*pl((Y+_n)/(Bn+_n)),Yt=Hn*ty((ie+_n)/(Bn+_n))-1,Yt=Ec(O-1,Hi(Yt,Hn-1)),pn=Ec(Yt,Hi(0,pn))):(pn=0,Yt=-1);const Vn=oy(pn,Yt,Ee),{bottom:nr,top:ii}=ry(ze,de,we,Vn),si=ty(O/Hn),Hl=si*Bn+(si-1)*_n-nr;return{bottom:nr,itemHeight:Bn,items:Vn,itemWidth:_o,offsetBottom:Hl,offsetTop:ii,top:ii}})),j),oe(z(U,ae(O=>O!==null),X(O=>O.length)),C),oe(z(Qe(R,M,j,D),ae(([O,Y,{items:ie}])=>ie.length>0&&Y.height!==0&&O.height!==0),X(([O,Y,{items:ie},de])=>{const{bottom:we,top:ze}=ry(O,de,Y,ie);return[ze,we]}),Me(vs)),t);const E=W(!1);oe(z(c,he(E),X(([O,Y])=>Y||O!==0)),E);const w=Mt(z(Qe(j,C),ae(([{items:O}])=>O.length>0),he(E),ae(([[O,Y],ie])=>{const de=O.items[O.items.length-1].index===Y-1;return(ie||O.bottom>0&&O.itemHeight>0&&O.offsetBottom===0&&O.items.length===Y)&&de}),X(([[,O]])=>O-1),Me())),k=Mt(z(se(j),ae(({items:O})=>O.length>0&&O[0].index===0),yn(0),Me())),N=Mt(z(se(j),he(q),ae(([{items:O},Y])=>O.length>0&&!Y),X(([{items:O}])=>({endIndex:O[O.length-1].index,startIndex:O[0].index})),Me(ax),On(0)));oe(N,y.scrollSeekRangeChanged),oe(z(F,he(R,M,C,D),X(([O,Y,ie,de,we])=>{const ze=px(O),{align:Ee,behavior:Se,offset:_e}=ze;let Ye=ze.index;Ye==="LAST"&&(Ye=de-1),Ye=Hi(0,Ye,Ec(de-1,Ye));let Pe=Jd(Y,we,ie,Ye);return Ee==="end"?Pe=ny(Pe-Y.height+ie.height):Ee==="center"&&(Pe=ny(Pe-Y.height/2+ie.height/2)),_e!==void 0&&_e!==0&&(Pe+=_e),{behavior:Se,top:Pe}})),l);const B=yt(z(j,X(O=>O.offsetBottom+O.bottom)),0);return oe(z(S,X(O=>({height:O.visibleHeight,width:O.visibleWidth}))),R),{customScrollParent:v,data:U,deviation:L,footerHeight:r,gap:D,headerHeight:i,increaseViewportBy:e,initialItemCount:$,itemDimensions:M,overscan:n,restoreStateFrom:ee,scrollBy:s,scrollContainerState:a,scrollHeight:V,scrollTo:l,scrollToIndex:F,scrollTop:c,smoothScrollTargetReached:f,totalCount:C,useWindowScroll:u,viewportDimensions:R,windowScrollContainerState:p,windowScrollTo:x,windowViewportRect:S,...y,gridState:j,horizontalDirection:A,initialTopMostItemIndex:G,totalListHeight:B,...h,endReached:w,propsReady:b,rangeChanged:N,startReached:k,stateChanged:Q,stateRestoreInProgress:q,...T}},Ue(hf,kt,Os,vx,To,yf,ko));function Ex(e,t,n){return Hi(1,pl((e+n)/(pl(t)+n)))}function ry(e,t,n,o){const{height:r}=n;if(r===void 0||o.length===0)return{bottom:0,top:0};const i=Jd(e,t,n,o[0].index);return{bottom:Jd(e,t,n,o[o.length-1].index)+r,top:i}}function Jd(e,t,n,o){const r=Ex(e.width,n.width,t.column),i=pl(o/r),s=i*n.height+Hi(0,i-1)*t.row;return s>0?s+t.row:s}const iO=xe(()=>{const e=W(m=>`Item ${m}`),t=W({}),n=W(null),o=W("virtuoso-grid-item"),r=W("virtuoso-grid-list"),i=W(vf),s=W("div"),a=W(ri),l=(m,h=null)=>yt(z(t,X(y=>y[m]),Me()),h),c=W(!1),f=W(!1);return oe(se(f),c),{components:t,computeItemKey:i,context:n,FooterComponent:l("Footer"),HeaderComponent:l("Header"),headerFooterTag:s,itemClassName:o,ItemComponent:l("Item","div"),itemContent:e,listClassName:r,ListComponent:l("List","div"),readyStateChanged:c,reportReadyState:f,ScrollerComponent:l("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:l("ScrollSeekPlaceholder","div")}}),sO=xe(([e,t])=>({...e,...t}),Ue(rO,iO)),aO=te.memo(function(){const e=Re("gridState"),t=Re("listClassName"),n=Re("itemClassName"),o=Re("itemContent"),r=Re("computeItemKey"),i=Re("isSeeking"),s=Kt("scrollHeight"),a=Re("ItemComponent"),l=Re("ListComponent"),c=Re("ScrollSeekPlaceholder"),f=Re("context"),m=Kt("itemDimensions"),h=Kt("gap"),y=Re("log"),g=Re("stateRestoreInProgress"),b=Kt("reportReadyState"),v=Zo(te.useMemo(()=>u=>{const p=u.parentElement.parentElement.scrollHeight;s(p);const x=u.firstChild;if(x!==null){const{height:S,width:T}=x.getBoundingClientRect();m({height:S,width:T})}h({column:iy("column-gap",getComputedStyle(u).columnGap,y),row:iy("row-gap",getComputedStyle(u).rowGap,y)})},[s,m,h,y]),!0,!1);return kx(()=>{e.itemHeight>0&&e.itemWidth>0&&b(!0)},[e]),g?null:d.jsx(l,{className:t,ref:v,...ht(l,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(u=>{const p=r(u.index,u.data,f);return i?d.jsx(c,{...ht(c,f),height:e.itemHeight,index:u.index,width:e.itemWidth},p):P.createElement(a,{...ht(a,f),className:n,"data-index":u.index,key:p},o(u.index,u.data,f))})})}),lO=te.memo(function(){const e=Re("HeaderComponent"),t=Kt("headerHeight"),n=Re("headerFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,!1),r=Re("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),cO=te.memo(function(){const e=Re("FooterComponent"),t=Kt("footerHeight"),n=Re("headerFooterTag"),o=Zo(te.useMemo(()=>i=>{t(bo(i,"height"))},[t]),!0,!1),r=Re("context");return e!=null?d.jsx(n,{ref:o,children:d.jsx(e,{...ht(e,r)})}):null}),dO=({children:e})=>{const t=te.useContext($x),n=Kt("itemDimensions"),o=Kt("viewportDimensions"),r=Zo(te.useMemo(()=>i=>{o(i.getBoundingClientRect())},[o]),!0,!1);return te.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),n({height:t.itemHeight,width:t.itemWidth}))},[t,o,n]),d.jsx("div",{ref:r,style:bf(!1),children:e})},uO=({children:e})=>{const t=te.useContext($x),n=Kt("windowViewportRect"),o=Kt("itemDimensions"),r=Re("customScrollParent"),i=Re("useWindowScroll"),s=tx(n,r,!1);return te.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),n({listHeight:0,offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,n,o]),d.jsx("div",{ref:s,style:jx(!1,i),children:e})},pO=te.memo(function({...e}){const t=Re("useWindowScroll"),n=Re("customScrollParent"),o=n||t?mO:fO,r=n||t?uO:dO,i=Re("context");return d.jsx(o,{...e,...ht(o,i),children:d.jsxs(r,{children:[d.jsx(lO,{}),d.jsx(aO,{}),d.jsx(cO,{})]})})}),{useEmitter:Px,useEmitterValue:Re,usePublisher:Kt}=wx(sO,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},pO),fO=Nx({useEmitter:Px,useEmitterValue:Re,usePublisher:Kt}),mO=Cx({useEmitter:Px,useEmitterValue:Re,usePublisher:Kt});function iy(e,t,n){return t!=="normal"&&(t==null?void 0:t.endsWith("px"))!==!0&&n(`${e} was not resolved to pixel value correctly`,t,nt.WARN),t==="normal"?0:parseInt(t??"0",10)}function hO(e){var o,r,i;if(e.kind!=="notification"||e.method!=="session/update")return null;const t=e.payload;if(!t||typeof t!="object")return null;const n=t.params;return!n||((o=n.update)==null?void 0:o.sessionUpdate)!=="agent_message_chunk"?null:{sessionId:String(n.sessionId??""),text:((i=(r=n.update)==null?void 0:r.content)==null?void 0:i.text)??""}}function yO(e){const t=[];let n=null;const o=()=>{if(n){if(n.messages.length===1){const r=n.messages[0];t.push({type:"message",message:r})}else{const r=n.messages[0],i=n.messages[n.messages.length-1];t.push({type:"stream-cluster",sessionId:n.sessionId,messages:n.messages,firstSeq:r.seq,lastSeq:i.seq,combinedText:n.text,firstTimestamp:r.timestamp,lastTimestamp:i.timestamp})}n=null}};for(const r of e){const i=hO(r);if(i&&n&&n.sessionId===i.sessionId){n.messages.push(r),n.text+=i.text;continue}o(),i?n={sessionId:i.sessionId,messages:[r],text:i.text}:t.push({type:"message",message:r})}return o(),t}function gO(e){var n;if(!e.payload||typeof e.payload!="object")return null;const t=e.payload.params;if(!t||typeof t!="object")return null;if(e.method==="session/prompt"){const o=t.prompt;if(!Array.isArray(o))return null;const r=[];for(const s of o)(s==null?void 0:s.type)==="text"&&typeof s.text=="string"&&r.push(s.text);const i=r.join(" ").trim();return i.length>0?i:null}if(e.method==="session/update"){const o=t.update;if(!o)return null;const r=((n=o.content)==null?void 0:n.text)??o.text;return typeof r=="string"&&r.length>0?r:null}return null}function vO(e){return e.method==="session/prompt"&&e.kind==="request"}const bO={request:"REQ",response:"RSP",notification:"NTF",error:"ERR",unknown:"???"},xO={request:"request — expects a response",response:"response — answer to a previous request",notification:"notification — one-way event, no response",error:"error — response carrying an error object",unknown:"unknown — could not classify as JSON-RPC"},wO={"editor-to-agent":"editor → agent (e.g. JetBrains/Zed sending to the AI)","agent-to-editor":"agent → editor (AI replying or calling the host)"};function SO(e){switch(e){case"error":return"text-accent-error";case"notification":return"text-accent-note";case"request":return"text-accent-out";case"response":return"text-accent-in";default:return"text-ink-muted"}}function $O({message:e,selected:t,paired:n=!1,latencyMs:o,validation:r,onSelect:i}){const s=e.direction==="editor-to-agent",a=e.kind==="error",l=o!==void 0?rE(o):null,c=gO(e),f=vO(e),m=r&&!r.skipped&&!r.valid;return d.jsxs("button",{type:"button",onClick:()=>i(e.seq),className:K("relative flex w-full items-center gap-3 px-4 py-1.5 text-left font-mono text-[12px] leading-5","border-b border-line-grid/70 transition-colors","hover:bg-surface-rowHover",t?"bg-surface-rowHover ring-1 ring-inset ring-accent-out/40":"",n&&!t?"bg-accent-out/[0.04] ring-1 ring-inset ring-accent-out/15":"",a?"bg-accent-error/[0.06]":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("absolute inset-y-0 left-0 w-[3px]",s?"bg-accent-out":"bg-accent-in",a?"bg-accent-error":"")}),d.jsx("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:String(e.seq).padStart(3,"0")}),d.jsx("span",{className:"w-24 shrink-0 text-ink-secondary",children:fs(e.timestamp)}),d.jsxs("span",{className:K("flex w-16 shrink-0 items-center gap-1 font-semibold",s?"text-accent-out":"text-accent-in"),title:wO[e.direction],children:[d.jsx("span",{"aria-hidden":!0,children:Fb(e.direction)}),d.jsx("span",{className:"text-[10px] tracking-widest",children:zb(e.direction)})]}),d.jsx("span",{className:K("inline-flex w-12 shrink-0 items-center justify-center rounded-sm border px-1 text-[10px] font-semibold tracking-widest",SO(e.kind),"border-current/40"),title:xO[e.kind],children:bO[e.kind]}),d.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-3 overflow-hidden",children:[d.jsx("span",{className:K("shrink-0",f?"text-accent-out":"text-ink-primary"),children:e.method?e.method:"—"}),m&&r&&d.jsxs("span",{className:K("inline-flex shrink-0 items-center gap-0.5 rounded-sm border border-accent-error/40","bg-accent-error/10 px-1 text-[9px] font-semibold uppercase tracking-widest text-accent-error"),title:`fails ACP schema (${r.schemaName??"?"}): ${r.errors.map(h=>`${h.path==="/"?"":h.path+" "}${h.message}`).join(" · ")}`,children:["⚠ SPEC ",r.errors.length]}),c&&d.jsxs("span",{className:K("truncate",f?"text-accent-out/85":"text-ink-secondary"),title:c,children:["“",c,"”"]})]}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",title:e.rpcId!==void 0&&e.rpcId!==null?`id:${String(e.rpcId)}`:void 0,children:e.rpcId!==void 0&&e.rpcId!==null?`id:${sE(e.rpcId)}`:""}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:Ul(e.raw.length)}),d.jsx("span",{className:K("w-20 shrink-0 text-right",l==="ok"&&"text-accent-ok",l==="warn"&&"text-accent-warn",l==="error"&&"text-accent-error",!l&&"text-ink-dim"),children:o!==void 0?`+${Vt(o)}`:""})]})}const kO=P.memo($O);function TO({messages:e,combinedText:t,firstTimestamp:n,lastTimestamp:o,selectedSeq:r,onSelect:i}){const[s,a]=P.useState(!1),l=e[0],c=e[e.length-1],f=o-n,m=t.length>140?`${t.slice(0,140)}…`:t,h=r!==null&&e.some(y=>y.seq===r);return d.jsxs("div",{className:"border-b border-line-grid/70",children:[d.jsxs("button",{type:"button",onClick:()=>{a(y=>!y),i(l.seq)},className:K("relative flex w-full items-center gap-3 px-4 py-1.5 text-left font-mono text-[12px] leading-5","transition-colors hover:bg-surface-rowHover",h?"bg-surface-rowHover ring-1 ring-inset ring-accent-note/40":""),children:[d.jsx("span",{"aria-hidden":!0,className:"absolute inset-y-0 left-0 w-[3px] bg-accent-note"}),d.jsxs("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:[String(l.seq).padStart(3,"0"),"…",String(c.seq).padStart(3,"0")]}),d.jsx("span",{className:"w-24 shrink-0 text-ink-secondary",children:fs(n)}),d.jsxs("span",{className:"flex w-16 shrink-0 items-center gap-1 font-semibold text-accent-in",title:"agent → editor (AI replying or calling the host)",children:[d.jsx("span",{"aria-hidden":!0,children:"←"}),d.jsx("span",{className:"text-[10px] tracking-widest",children:"IN"})]}),d.jsx("span",{className:K("inline-flex w-12 shrink-0 items-center justify-center rounded-sm border border-accent-note/40 px-1 text-[10px] font-semibold tracking-widest text-accent-note"),title:`stream — ${e.length} consecutive agent_message_chunk notifications collapsed into one row`,children:"STR"}),d.jsxs("span",{className:"flex flex-1 items-center gap-2 truncate text-ink-primary",children:[d.jsx("span",{className:"inline-flex h-[14px] w-1 rounded-sm bg-accent-note/60","aria-hidden":!0}),d.jsx("span",{className:"truncate text-ink-secondary",children:m||d.jsx("span",{className:"text-ink-muted",children:"(empty stream)"})})]}),d.jsxs("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:[e.length," chunks"]}),d.jsx("span",{className:"w-20 shrink-0 text-right text-ink-muted",children:Vt(f)}),d.jsx("span",{"aria-hidden":!0,className:K("w-3 shrink-0 text-ink-muted transition-transform",s?"rotate-90":""),children:"▸"})]}),s&&d.jsx("div",{className:"border-l border-line-grid/70 bg-surface-base/40",children:e.map((y,g)=>d.jsxs("button",{type:"button",onClick:()=>i(y.seq),className:K("flex w-full items-center gap-3 px-8 py-1 text-left font-mono text-[11px] leading-5 text-ink-secondary","transition-colors hover:bg-surface-rowHover",r===y.seq?"bg-surface-rowHover text-ink-primary":""),children:[d.jsx("span",{className:"w-10 shrink-0 text-right text-ink-muted",children:String(y.seq).padStart(3,"0")}),d.jsx("span",{className:"w-24 shrink-0 text-ink-muted",children:fs(y.timestamp)}),d.jsxs("span",{className:"w-8 shrink-0 text-ink-muted",children:["#",g+1]}),d.jsx("span",{className:"flex-1 truncate text-ink-primary",children:_O(y)})]},y.seq))})]})}function _O(e){var o,r;const t=e.payload;if(!t||typeof t!="object")return"";const n=t.params;return((r=(o=n==null?void 0:n.update)==null?void 0:o.content)==null?void 0:r.text)??""}const jO=80;function NO(){const e=ne(u=>u.messages),t=ne(u=>u.selectedSeq),n=ne(u=>u.filters),o=ne(u=>u.playback.cap),r=ne(u=>u.select),i=P.useMemo(()=>mS(e,n,o),[e,n,o]),s=P.useMemo(()=>yO(i),[i]),a=P.useMemo(()=>Cl(e),[e]),l=P.useMemo(()=>Zp(e),[e]),c=P.useMemo(()=>{const u=new Map;for(const p of e)u.set(p.seq,p.timestamp);return u},[e]),f=P.useMemo(()=>{if(t===null)return null;const u=a.get(t);if(u!==void 0)return u;for(const[p,x]of a)if(x===t)return p;return null},[t,a]),m=P.useRef(null),h=ne(u=>{var p;return((p=u.session)==null?void 0:p.id)??null}),y=ne(u=>u.replayDone),g=P.useRef(h),b=P.useRef(!1);P.useEffect(()=>{g.current!==h&&(g.current=h,b.current=!1)},[h]),P.useEffect(()=>{if(!y||h===null||b.current||s.length===0)return;b.current=!0;const u=s.length-1,p=window.setTimeout(()=>{var x;(x=m.current)==null||x.scrollToIndex({index:u,align:"end",behavior:"smooth"})},50);return()=>window.clearTimeout(p)},[y,h,s.length]);const v=u=>{const p=s[u];return p?CO(p,{selectedSeq:t,pairedSeq:f,onSelect:r,responseToRequest:a,reqTimestampBySeq:c,validationBySeq:l}):null};return d.jsxs("div",{className:"relative flex h-full flex-col",children:[s.length===0?d.jsx("div",{className:"flex h-full items-center justify-center bg-surface-base font-mono text-xs text-ink-muted",children:"no messages match current filters"}):d.jsx(ZI,{ref:m,className:"flex-1 bg-surface-base",totalCount:s.length,itemContent:v,atBottomThreshold:jO,initialTopMostItemIndex:Math.max(0,s.length-1),followOutput:u=>u?"auto":!1,computeItemKey:u=>EO(s[u])}),d.jsx(PO,{total:e.length,shown:i.length})]})}function CO(e,t){if(e.type==="message"){const n=e.message,o=t.responseToRequest.get(n.seq),r=o!==void 0?n.timestamp-(t.reqTimestampBySeq.get(o)??n.timestamp):void 0,i=t.validationBySeq.get(n.seq);return d.jsx(kO,{message:n,selected:t.selectedSeq===n.seq,paired:t.pairedSeq===n.seq,...r!==void 0?{latencyMs:r}:{},...i!==void 0?{validation:i}:{},onSelect:t.onSelect})}return d.jsx(TO,{messages:e.messages,combinedText:e.combinedText,firstTimestamp:e.firstTimestamp,lastTimestamp:e.lastTimestamp,selectedSeq:t.selectedSeq,onSelect:t.onSelect})}function EO(e){return e.type==="message"?`m-${e.message.seq}`:`c-${e.firstSeq}-${e.lastSeq}`}function PO({total:e,shown:t}){return e===0||t===e?null:d.jsxs("div",{className:"border-t border-line bg-surface-elev/60 px-4 py-1 text-right font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:["showing ",t," of ",e]})}function IO({message:e,tone:t="info"}){if(!e)return null;const n=t==="success"?"border-accent-out/50 bg-accent-out/10 text-accent-out":t==="warn"?"border-accent-warn/50 bg-accent-warn/10 text-accent-warn":"border-accent-info/50 bg-accent-info/10 text-accent-info";return d.jsx("div",{role:"status",className:K("pointer-events-none fixed right-4 top-[60px] z-50 rounded-sm border px-3 py-2 font-mono text-[11px] uppercase tracking-widest shadow-lg backdrop-blur-sm",n),children:e})}function OO({onImportResult:e}){const[t,n]=P.useState(!1),[o,r]=P.useState(!1),i=P.useRef(null),s=P.useRef(null),a=ne(y=>y.session),l=ne(y=>y.messages.length),c=a!==null&&l>0;P.useEffect(()=>{if(!t)return;const y=b=>{i.current&&!i.current.contains(b.target)&&n(!1)},g=b=>{b.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",g)}},[t]);const f=()=>{var y;n(!1),(y=s.current)==null||y.click()},m=()=>{n(!1);const y=ne.getState();y.session&&y.messages.length>0&&Db(y.session,y.messages)},h=async y=>{var b;const g=(b=y.target.files)==null?void 0:b[0];if(y.target.value="",!!g){r(!0);try{const v=await $v(g);await Qu(),ft.getState().setSelected(tl(v.id)),e==null||e(`imported ${g.name} · #${v.id} · ${v.messageCount} message${v.messageCount===1?"":"s"}`,"success")}catch(v){const u=v instanceof Error?v.message:String(v);e==null||e(`import failed: ${u}`,"warn")}finally{r(!1)}}};return d.jsxs("div",{ref:i,className:"relative",children:[d.jsx("input",{ref:s,type:"file",accept:"application/json,.json",onChange:h,className:"hidden","aria-hidden":"true",tabIndex:-1}),d.jsx("button",{type:"button",onClick:()=>n(y=>!y),title:"Session actions — import file · export","aria-haspopup":"menu","aria-expanded":t,"aria-label":"session actions",disabled:o,className:K("inline-flex h-7 w-7 items-center justify-center rounded-sm border font-mono text-[14px] leading-none transition-colors",t?"border-line-strong bg-surface-rowHover text-ink-primary":"border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",o&&"cursor-progress opacity-60"),children:d.jsx("span",{"aria-hidden":!0,children:"⋯"})}),t&&d.jsxs("div",{role:"menu",className:"absolute right-0 top-[calc(100%+6px)] z-50 w-max overflow-hidden rounded-sm border border-line bg-surface-elev p-1 font-mono text-[11px] uppercase tracking-widest shadow-lg",children:[d.jsx(sy,{icon:"↑",label:"import",onClick:f,title:"Open a session JSON exported earlier — yours or someone else's."}),d.jsx(sy,{icon:"↓",label:"export",onClick:m,disabled:!c,title:"Download this session as JSON. Auth headers and proxy tokens (Authorization, X-Api-Key, JetBrains proxy_key) are redacted — safe to attach to a bug report. For an un-redacted copy (self-debug only), use 'acp-devtools export <id> --raw' in the CLI.",disabledTitle:"Nothing to export yet — wait for the first message."})]})]})}function sy({icon:e,label:t,onClick:n,disabled:o,title:r,disabledTitle:i}){return d.jsxs("button",{type:"button",role:"menuitem",disabled:o,onClick:n,title:o?i:r,className:K("flex w-full items-center gap-2 rounded-[2px] px-2 py-1.5 text-left transition-colors",o?"cursor-not-allowed text-ink-dim opacity-50":"text-ink-muted hover:bg-surface-rowHover hover:text-ink-secondary"),children:[d.jsx("span",{"aria-hidden":!0,className:"w-4 text-center text-[13px] leading-none",children:e}),d.jsx("span",{className:"flex-1",children:t})]})}function RO({onSelect:e,activeUrl:t,overrideUrl:n}){const o=ft(p=>p.captures),r=ft(p=>p.savedSessions),i=ft(p=>p.lastFetchAt),[s,a]=P.useState(!1),l=P.useRef(null);P.useEffect(()=>{if(!s)return;const p=x=>{l.current&&!l.current.contains(x.target)&&a(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[s]);const c=o.find(p=>p.url===t)??null,f=t!==null&&SS(t)?$S(t):null,m=P.useMemo(()=>new Set(o.map(p=>p.sessionDbId).filter(p=>p!==null)),[o]),h=P.useMemo(()=>r.filter(p=>!m.has(p.id)),[r,m]),y=P.useMemo(()=>h.filter(p=>p.imported_at===null),[h]),g=P.useMemo(()=>h.filter(p=>p.imported_at!==null),[h]),b=f!==null?h.find(p=>p.id===f)??null:null,v=o.length+h.length;let u;return n?u="?ws override":c?u=ef(c):b?u=`#${b.id} · ${b.name??(b.client_name?`${b.client_name} · ${Rt(b.agent_command??"")}`:Rt(b.agent_command??""))}`:v===0?u="no captures":u="pick capture",d.jsxs("div",{ref:l,className:"relative",children:[d.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] uppercase tracking-widest transition-colors","border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary",s?"border-line-strong text-ink-primary":""),title:"Select a live capture or saved session",children:[d.jsx("span",{className:"inline-block w-[200px] truncate text-left",children:u}),v>1&&!n&&d.jsx("span",{className:"rounded-sm border border-line-strong px-1 text-[9px] text-ink-secondary",children:v}),d.jsx("span",{"aria-hidden":!0,className:K("transition-transform",s?"rotate-180":""),children:"▾"})]}),s&&d.jsxs("div",{className:K("absolute right-0 top-[calc(100%+6px)] z-50 w-[460px] rounded-md border border-line bg-surface-elev shadow-xl"),children:[d.jsxs(Pc,{children:["live captures · last poll"," ",i?`${Math.round((Date.now()-i)/1e3)}s ago`:"—"]}),o.length===0&&d.jsxs("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:["none. start a proxy with"," ",d.jsx("span",{className:"text-ink-secondary",children:"acp-devtools proxy …"})]}),d.jsx("ul",{className:"max-h-[260px] overflow-y-auto",children:o.map(p=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>{e(p.url),a(!1)},title:`${p.agentCommand} · ${p.url}${p.saveTo?" · saved to local store":" · not persisted"}`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",p.url===t?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",p.url===t?"bg-accent-out animate-pulse-soft":"bg-accent-warn/50")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsx("span",{className:"text-accent-out",children:p.sessionDbId!==null?`#${p.sessionDbId}`:`pid ${p.pid}`}),d.jsx("span",{className:"text-ink-muted",children:" · "}),p.sessionName??(p.clientName?`${p.clientName} · ${Rt(p.agentCommand)}`:Rt(p.agentCommand))]}),d.jsx("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:Ar(p.startedAt)})]})},p.url))}),d.jsxs(Pc,{children:["saved · ",y.length," session",y.length===1?"":"s"]}),y.length===0&&d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:r.length===0?"no saved sessions yet":g.length>0?"no live-captured sessions yet":"all saved sessions are currently live"}),d.jsx("ul",{className:"max-h-[300px] overflow-y-auto",children:y.map(p=>d.jsx(ay,{s:p,activeUrl:t,onPick:x=>{e(x),a(!1)}},p.id))}),(g.length>0||r.some(p=>p.imported_at!==null))&&d.jsxs(d.Fragment,{children:[d.jsxs(Pc,{children:["imported · ",g.length," file",g.length===1?"":"s"]}),g.length===0?d.jsx("div",{className:"px-3 py-3 text-center font-mono text-[11px] text-ink-muted",children:"no imported files"}):d.jsx("ul",{className:"max-h-[200px] overflow-y-auto",children:g.map(p=>d.jsx(ay,{s:p,activeUrl:t,onPick:x=>{e(x),a(!1)}},p.id))})]}),n&&d.jsx("div",{className:"border-t border-line px-3 py-2 font-mono text-[10px] uppercase tracking-widest text-accent-warn",children:"?ws override active — discovery selection ignored"})]})]})}function Pc({children:e}){return d.jsx("div",{className:"border-b border-line bg-surface-base/50 px-3 py-1.5 font-mono text-[10px] uppercase tracking-widest text-ink-muted",children:e})}function ay({s:e,activeUrl:t,onPick:n}){const o=tl(e.id),r=o===t,i=s=>{s.stopPropagation();const a=e.name??Rt(e.agent_command??"");window.confirm(`Delete session #${e.id} ${a} forever?`)&&(async()=>{try{await wS(e.id),r&&ft.getState().setSelected(null),await Qu()}catch(l){const c=l instanceof Error?l.message:String(l);window.alert(`Delete failed: ${c}`)}})()};return d.jsxs("li",{className:"group relative",children:[d.jsxs("button",{type:"button",onClick:()=>n(o),title:`session #${e.id} · ${e.agent_command??""} · ${e.message_count} messages`,className:K("flex w-full items-baseline gap-3 border-b border-line-grid/70 px-3 py-2 text-left transition-colors hover:bg-surface-rowHover",r?"bg-surface-rowHover":""),children:[d.jsx("span",{"aria-hidden":!0,className:K("h-2 w-2 shrink-0 rounded-full",r?"bg-accent-note animate-pulse-soft":"bg-ink-dim")}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-primary",children:[d.jsxs("span",{className:"text-accent-note",children:["#",e.id]}),d.jsx("span",{className:"text-ink-muted",children:" · "}),e.name??(e.client_name?`${e.client_name} · ${Rt(e.agent_command??"")}`:Rt(e.agent_command??""))]}),d.jsxs("span",{className:"shrink-0 font-mono text-[10px] uppercase tracking-widest text-ink-muted transition-colors group-hover:text-ink-secondary",children:[e.message_count,"msg · ",Ar(e.started_at)]})]}),d.jsx("button",{type:"button",onClick:i,"aria-label":`delete session #${e.id} forever`,title:"Delete this session permanently",className:K("absolute right-2 top-1/2 hidden h-6 w-6 -translate-y-1/2 items-center justify-center rounded-sm border border-line bg-surface-elev/70 text-[12px] leading-none text-ink-muted transition-colors","group-hover:flex hover:border-accent-error/70 hover:bg-surface-rowHover hover:text-accent-error"),children:d.jsx("span",{"aria-hidden":!0,children:"×"})})]})}const Ic=[{mode:"system",label:"AUTO",title:"follow OS theme",icon:"◐"},{mode:"light",label:"LIGHT",title:"force light theme",icon:"☀"},{mode:"dark",label:"DARK",title:"force dark theme",icon:"☾"}];function AO(){const e=Pd(s=>s.mode),t=Pd(s=>s.setMode),[n,o]=P.useState(!1),r=P.useRef(null);P.useEffect(()=>{if(!n)return;const s=a=>{r.current&&!r.current.contains(a.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[n]);const i=Ic.find(s=>s.mode===e)??Ic[0];return d.jsxs("div",{ref:r,className:"relative",children:[d.jsx("button",{type:"button",onClick:()=>o(s=>!s),title:`theme · ${i.title}`,"aria-haspopup":"menu","aria-expanded":n,className:K("inline-flex h-7 w-7 items-center justify-center rounded-sm border font-mono text-[12px] transition-colors",n?"border-line-strong bg-surface-rowHover text-ink-primary":"border-line bg-surface-row text-ink-secondary hover:border-line-strong hover:text-ink-primary"),children:d.jsx("span",{"aria-hidden":!0,children:i.icon})}),n&&d.jsx("div",{role:"menu",className:"absolute right-0 top-[calc(100%+6px)] z-50 inline-flex items-center gap-px rounded-sm border border-line bg-surface-elev p-px font-mono text-[10px] uppercase tracking-widest shadow-lg",children:Ic.map(s=>{const a=s.mode===e;return d.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a,onClick:()=>{t(s.mode),o(!1)},title:s.title,className:K("inline-flex items-center gap-1 rounded-[2px] px-2 py-1 transition-colors",a?"bg-accent-out/15 text-accent-out":"text-ink-muted hover:bg-surface-rowHover hover:text-ink-secondary"),children:[d.jsx("span",{"aria-hidden":!0,children:s.icon}),d.jsx("span",{children:s.label})]},s.mode)})})]})}function MO({wsUrl:e,overrideUrl:t,activeUrl:n,isReplay:o,isImported:r=!1,onPickCapture:i,onImportResult:s,onOpenInfo:a,onOpenPerf:l,onOpenDiff:c}){const f=ne(b=>b.connection),m=ne(b=>b.session),h=ne(b=>b.lastError),y=ne(b=>b.messages.length>0?b.messages[b.messages.length-1].timestamp:null),g=Jb(5e3);return d.jsxs("header",{className:"flex items-center justify-between border-b border-line bg-surface-base px-5 py-2.5",children:[d.jsxs("div",{className:"flex items-center gap-4",children:[d.jsx("div",{className:"wordmark-rule",children:d.jsx("span",{className:"font-display text-[18px] uppercase tracking-[0.18em] text-ink-primary",children:"acp.devtools"})}),d.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-ink-dim",children:"v0.2.1"})]}),d.jsxs("div",{className:"flex items-center gap-4",children:[m&&(()=>{const{primary:b}=ql(m),v=o||r,u=m.endedAt!==null?m.endedAt:y??m.startedAt,p=v?Ar(m.startedAt,u):Ar(m.startedAt,g),x=y!==null?g-y:null,S=!v&&x!==null&&x>5e3,T=_a(m.startedAt,g),C=r?"IMPORTED":o?"REPLAY":"SESSION",$=r?"session loaded from a JSON file on disk — not connected to any proxy":o?"replay of a saved session — proxy has ended":"live capture — proxy process is still running",j=r?"text-accent-warn":o?"text-accent-note":"text-accent-out";return d.jsxs("div",{className:"flex items-center gap-3 font-mono text-[11px] text-ink-secondary",children:[d.jsx("span",{className:"text-ink-muted",title:$,children:C}),d.jsx("span",{className:j,title:m.agentCommand?`session #${m.id} · ${m.agentCommand}`:"persisted session id",children:b}),d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsx("span",{title:`session started at ${T}`,children:_a(m.startedAt,g)}),p&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsxs("span",{className:"text-ink-muted",title:v?"capture duration (start → end of recorded session)":"how long the proxy process has been alive",children:[v?"lasted":"alive"," ",p]})]}),S&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-muted",children:"·"}),d.jsxs("span",{className:"text-ink-dim",title:`time since the most recent ACP frame · last event ${_a(y,g)}`,children:["idle ",Ar(y,g)]})]})]})})(),d.jsxs("div",{className:"flex items-center gap-1.5",children:[i&&d.jsx(RO,{onSelect:i,activeUrl:n,overrideUrl:t}),d.jsx(qO,{status:f,wsUrl:e,lastError:h,isReplay:o,isImported:r,onReconnect:bS})]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[a&&m&&d.jsx("button",{type:"button",onClick:a,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Show session info — client/agent capabilities, runtime state","aria-label":"Open session info panel",children:"info"}),l&&m&&d.jsx("button",{type:"button",onClick:l,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Show performance dashboard — per-method latency stats and waterfall timeline","aria-label":"Open performance dashboard",children:"perf"}),c&&m&&d.jsx("button",{type:"button",onClick:c,className:"inline-flex h-7 items-center rounded-sm border border-line bg-surface-row px-3 font-mono text-[10px] uppercase tracking-widest text-ink-secondary transition-colors hover:bg-surface-rowHover hover:text-ink-primary",title:"Compare this session against another — metadata, per-method latency, and frame-level differences","aria-label":"Open session diff",children:"diff"}),d.jsx(OO,{...s?{onImportResult:s}:{}})]}),d.jsx("div",{className:"flex items-center gap-1.5",children:d.jsx(AO,{})})]})]})}function qO({status:e,wsUrl:t,lastError:n,isReplay:o,isImported:r,onReconnect:i}){if(r)return d.jsxs("div",{className:"inline-flex h-7 cursor-default items-center gap-2 rounded-sm border border-accent-warn/40 bg-accent-warn/10 px-3 font-mono text-[10px] font-semibold uppercase tracking-widest text-accent-warn",title:`viewing data from a JSON file · ${t}`,children:[d.jsx("span",{"aria-hidden":!0,className:"inline-block h-2 w-2 rounded-full bg-accent-warn"}),d.jsx("span",{className:"inline-block min-w-[52px] text-center",children:"FILE"})]});const a=e==="open"?o?"REPLAY":"LIVE":e==="connecting"?"WAITING":e==="idle"?"IDLE":e==="closed"?"CLOSED":"ERROR",c={idle:"text-ink-secondary bg-surface-row border-line",connecting:"text-accent-warn/80 bg-accent-warn/10 border-accent-warn/30",open:o?"text-accent-note bg-accent-note/10 border-accent-note/40":"text-accent-out bg-accent-out/10 border-accent-out/40",closed:"text-ink-secondary bg-surface-row border-line",error:"text-accent-error bg-accent-error/10 border-accent-error/40"},m=e==="open"?o?"bg-accent-note animate-pulse-soft":"bg-accent-out animate-pulse-soft":e==="connecting"?"bg-accent-warn/60 animate-pulse-soft":e==="error"?"bg-accent-error":"bg-ink-dim",h=e==="idle"||e==="closed"||e==="error",g=n||(e==="open"?`${o?"serving a recorded session from the local store":"connected to a live proxy capture"} · ${t}`:h?`click to reconnect · ${t}`:t);return d.jsxs("button",{type:"button",onClick:h?i:void 0,disabled:!h,className:K("inline-flex h-7 items-center gap-2 rounded-sm border px-3 font-mono text-[10px] font-semibold uppercase tracking-widest transition-colors",c[e],h?"cursor-pointer hover:bg-surface-rowHover":"cursor-default"),title:g,children:[d.jsx("span",{"aria-hidden":!0,className:K("inline-block h-2 w-2 rounded-full",m)}),d.jsx("span",{className:"inline-block min-w-[52px] text-center",children:a})]})}const ur=GN(),UO=ur?new URLSearchParams(typeof window<"u"?window.location.search:"").get("url"):null;function LO(){const e=ft(w=>w.captures),t=ft(w=>w.selectedUrl),n=ft(w=>w.setSelected),o=ne(w=>{var k;return((k=w.session)==null?void 0:k.importedAt)??null}),r=t,i=t!==null&&/\/replay\/\d+$/.test(t),s=o!==null;P.useEffect(()=>ur?void 0:CS(),[]),P.useEffect(()=>IS(),[]);const[a,l]=P.useState(null),c=P.useRef(new Set);P.useEffect(()=>{const w=mh(window.location.search),k=ne.getState(),N={};Object.keys(w.filters).length>0&&(N.filters={...k.filters,...w.filters}),w.selectedSeq!==null&&(N.selectedSeq=w.selectedSeq),w.detailTab!==null&&(N.detailTab=w.detailTab),w.playbackCap!==null&&(N.playback={...k.playback,cap:w.playbackCap}),Object.keys(N).length>0&&ne.setState(N),w.captureUrl&&ft.getState().setSelected(w.captureUrl)},[]);const[f,m]=P.useState(!1),[h,y]=P.useState(!1),[g,b]=P.useState(!1);P.useEffect(()=>{const w=()=>{const B=ne.getState(),O=ft.getState();tC({filters:B.filters,selectedSeq:B.selectedSeq,detailTab:B.detailTab,playbackCap:B.playback.cap,captureUrl:O.selectedUrl})},k=ne.subscribe(w),N=ft.subscribe(w);return w(),()=>{k(),N()}},[]);const v=()=>{f||(window.history.pushState({drawer:"info"},"",window.location.href),m(!0))},u=()=>{h||(window.history.pushState({drawer:"perf"},"",window.location.href),y(!0))},p=()=>{g||(window.history.pushState({drawer:"diff"},"",window.location.href),b(!0))},x=()=>{f&&window.history.back()},S=()=>{h&&window.history.back()},T=()=>{g&&window.history.back()},C=w=>{window.history.pushState({drawer:null},"",window.location.href),ne.getState().select(w),m(!1),y(!1),b(!1)};P.useEffect(()=>{const w=k=>{const N=k.state;m((N==null?void 0:N.drawer)==="info"),y((N==null?void 0:N.drawer)==="perf"),b((N==null?void 0:N.drawer)==="diff");const B=mh(window.location.search),O=ne.getState(),Y=ft.getState(),ie={};Object.keys(B.filters).length>0&&(ie.filters={...O.filters,...B.filters}),ie.selectedSeq=B.selectedSeq,ie.detailTab=B.detailTab??"tree",ie.playback={...O.playback,cap:B.playbackCap},ne.setState(ie),B.captureUrl!==Y.selectedUrl&&B.captureUrl&&Y.setSelected(B.captureUrl)};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),P.useEffect(()=>{const w=new Set(e.map(Y=>Y.url));if(c.current=c.current,i){c.current=w;return}const k=e[0]??null,N=t===null,B=t!==null&&w.has(t),O=k!==null&&!c.current.has(k.url)&&c.current.size>0;e.length===0?t!==null&&n(null):N||!B?n(k.url):O&&k.url!==t&&(n(k.url),l({message:`switched → ${ef(k)}`,tone:"success"})),c.current=w},[e,t,n,i]),P.useEffect(()=>{if(!a)return;let w=3e3,k=Date.now(),N=null;const B=()=>{N===null&&document.visibilityState==="visible"&&(k=Date.now(),N=setTimeout(()=>l(null),w))},O=()=>{N!==null&&(clearTimeout(N),N=null,w=Math.max(0,w-(Date.now()-k)))},Y=()=>{document.visibilityState==="visible"?B():O()};return document.addEventListener("visibilitychange",Y),B(),()=>{document.removeEventListener("visibilitychange",Y),N&&clearTimeout(N)}},[a]),P.useEffect(()=>{if(ur){Cd();return}if(!r){Cd();return}Gu(r)},[r]);const[$,j]=P.useState(!1);P.useEffect(()=>{const w=k=>{if((k.metaKey||k.ctrlKey)&&(k.key==="k"||k.key==="K")){k.preventDefault(),j(B=>!B);return}if($)return;const N=k.target;if(!(N&&(N.tagName==="INPUT"||N.tagName==="TEXTAREA"))){if(k.key==="Escape"){ne.getState().select(null);return}if(k.key==="j"||k.key==="J"){ly(1);return}if(k.key==="k"||k.key==="K"){ly(-1);return}}};return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[$]);const R=ne(w=>w.messages),M=ne(w=>w.session),F=ne(w=>w.selectedSeq),V=ne(w=>w.connection),L=ne(w=>w.lastError);P.useEffect(()=>{const w="ACP Devtools";if(!M){document.title=w;return}const{primary:k,secondary:N}=ql(M),B=N?`${k} · ${N}`:k;document.title=`${B} — ${w}`},[M]);const U=P.useMemo(()=>hS(R,F),[R,F]),D=P.useMemo(()=>{const w=Cl(R),k=new Map;for(const[N,B]of w.entries())k.set(B,N);return{responseToRequest:w,requestToResponse:k}},[R]),Q=P.useMemo(()=>Zp(R),[R]);let ee,q=null;if(U){if(U.kind==="response"||U.kind==="error"){const w=D.responseToRequest.get(U.seq);w!==void 0&&(q=R.find(k=>k.seq===w)??null,q&&(ee=U.timestamp-q.timestamp))}else if(U.kind==="request"){const w=D.requestToResponse.get(U.seq);w!==void 0&&(q=R.find(k=>k.seq===w)??null,q&&(ee=q.timestamp-U.timestamp))}}const G=R.length===0&&!M,I=r??"no capture selected",_=ur&&G,A=!ur&&G&&r===null&&e.length===0,E=!ur&&G&&!A;return d.jsxs("div",{className:"flex h-full flex-col bg-surface-base text-ink-primary",children:[d.jsx(IO,{message:(a==null?void 0:a.message)??null,tone:(a==null?void 0:a.tone)??"info"}),d.jsx(WC,{open:$,onClose:()=>j(!1)}),d.jsx(AP,{open:f,onClose:x}),d.jsx(wP,{open:h,onClose:S,onNavigateToSeq:C}),d.jsx(ME,{open:g,onClose:T}),d.jsx(MO,{wsUrl:I,overrideUrl:null,isReplay:i,isImported:s,onPickCapture:w=>{n(w),c.current.add(w)},onImportResult:(w,k)=>l({message:w,tone:k}),activeUrl:r,onOpenInfo:v,onOpenPerf:u,onOpenDiff:p}),d.jsx(XE,{}),d.jsx("main",{className:"flex-1 overflow-hidden",children:_?d.jsx(IP,{initialUrl:UO}):A?d.jsx(QE,{status:V,lastError:L,url:I,captureCount:e.length}):E?d.jsx(QC,{status:V,url:I,lastError:L}):d.jsx(LP,{storageKey:"acp.split.leftPx",initialLeftFraction:.62,minLeft:420,minRight:360,left:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsx("div",{className:"min-h-0 flex-1",children:d.jsx(NO,{})}),(i||s)&&d.jsx(RP,{})]}),right:d.jsx(pE,{message:U,...ee!==void 0?{latencyMs:ee}:{},...q?{pairedRequest:q}:{},...U?(()=>{const w=Q.get(U.seq);return w?{validation:w}:{}})():{},onJumpToPaired:w=>ne.getState().select(w)})})}),d.jsx(DP,{})]})}function ly(e){const t=ne.getState(),{messages:n,selectedSeq:o}=t;if(n.length===0)return;if(o===null){const s=e===1?n[0]:n[n.length-1];s&&t.select(s.seq);return}const r=n.findIndex(s=>s.seq===o);if(r===-1){const s=n[0];s&&t.select(s.seq);return}const i=n[r+e];i&&t.select(i.seq)}const Ix=document.getElementById("root");if(!Ix)throw new Error("#root not found");Oc.createRoot(Ix).render(d.jsx(te.StrictMode,{children:d.jsx(LO,{})}));
|
|
1768
|
+
//# sourceMappingURL=index-BnYwNhFF.js.map
|