aegis-bridge 2.3.2 → 2.3.4
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/dashboard/dist/assets/{index-QtT4j0ht.js → index-DSdepmv7.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/channels/webhook.js +2 -1
- package/dist/dashboard/assets/{index-QtT4j0ht.js → index-DSdepmv7.js} +1 -1
- package/dist/dashboard/index.html +1 -1
- package/dist/utils/redact-headers.d.ts +13 -0
- package/dist/utils/redact-headers.js +55 -0
- package/package.json +1 -1
|
@@ -250,7 +250,7 @@ Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}
|
|
|
250
250
|
|
|
251
251
|
`)}w.write("payload.value = newResult;"),w.write("return payload;");const f=w.compile();return(S,A)=>f(C,S,A)};let x;const T=el,c=!Np.jitless,h=c&&bb.value,y=r.catchall;let d;i._zod.parse=(C,w)=>{d??(d=o.value);const k=C.value;return T(k)?c&&h&&(w==null?void 0:w.async)===!1&&w.jitless!==!0?(x||(x=g(r.shape)),C=x(C,w),y?Xp([],k,C,w,d,i):C):a(C,w):(C.issues.push({expected:"object",code:"invalid_type",input:k,inst:i}),C)}});function Dm(i,r,a,o){for(const x of i)if(x.issues.length===0)return r.value=x.value,r;const g=i.filter(x=>!tn(x));return g.length===1?(r.value=g[0].value,g[0]):(r.issues.push({code:"invalid_union",input:r.value,inst:a,errors:i.map(x=>x.issues.map(T=>Ws(T,o,Gs())))}),r)}const oC=fe("$ZodUnion",(i,r)=>{ft.init(i,r),We(i._zod,"optin",()=>r.options.some(g=>g._zod.optin==="optional")?"optional":void 0),We(i._zod,"optout",()=>r.options.some(g=>g._zod.optout==="optional")?"optional":void 0),We(i._zod,"values",()=>{if(r.options.every(g=>g._zod.values))return new Set(r.options.flatMap(g=>Array.from(g._zod.values)))}),We(i._zod,"pattern",()=>{if(r.options.every(g=>g._zod.pattern)){const g=r.options.map(x=>x._zod.pattern);return new RegExp(`^(${g.map(x=>hh(x.source)).join("|")})$`)}});const a=r.options.length===1,o=r.options[0]._zod.run;i._zod.parse=(g,x)=>{if(a)return o(g,x);let T=!1;const c=[];for(const u of r.options){const h=u._zod.run({value:g.value,issues:[]},x);if(h instanceof Promise)c.push(h),T=!0;else{if(h.issues.length===0)return h;c.push(h)}}return T?Promise.all(c).then(u=>Dm(u,g,i,x)):Dm(c,g,i,x)}}),lC=fe("$ZodIntersection",(i,r)=>{ft.init(i,r),i._zod.parse=(a,o)=>{const g=a.value,x=r.left._zod.run({value:g,issues:[]},o),T=r.right._zod.run({value:g,issues:[]},o);return x instanceof Promise||T instanceof Promise?Promise.all([x,T]).then(([u,h])=>km(a,u,h)):km(a,x,T)}});function Ju(i,r){if(i===r)return{valid:!0,data:i};if(i instanceof Date&&r instanceof Date&&+i==+r)return{valid:!0,data:i};if(nn(i)&&nn(r)){const a=Object.keys(r),o=Object.keys(i).filter(x=>a.indexOf(x)!==-1),g={...i,...r};for(const x of o){const T=Ju(i[x],r[x]);if(!T.valid)return{valid:!1,mergeErrorPath:[x,...T.mergeErrorPath]};g[x]=T.data}return{valid:!0,data:g}}if(Array.isArray(i)&&Array.isArray(r)){if(i.length!==r.length)return{valid:!1,mergeErrorPath:[]};const a=[];for(let o=0;o<i.length;o++){const g=i[o],x=r[o],T=Ju(g,x);if(!T.valid)return{valid:!1,mergeErrorPath:[o,...T.mergeErrorPath]};a.push(T.data)}return{valid:!0,data:a}}return{valid:!1,mergeErrorPath:[]}}function km(i,r,a){const o=new Map;let g;for(const c of r.issues)if(c.code==="unrecognized_keys"){g??(g=c);for(const u of c.keys)o.has(u)||o.set(u,{}),o.get(u).l=!0}else i.issues.push(c);for(const c of a.issues)if(c.code==="unrecognized_keys")for(const u of c.keys)o.has(u)||o.set(u,{}),o.get(u).r=!0;else i.issues.push(c);const x=[...o].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(x.length&&g&&i.issues.push({...g,keys:x}),tn(i))return i;const T=Ju(r.value,a.value);if(!T.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(T.mergeErrorPath)}`);return i.value=T.data,i}const cC=fe("$ZodRecord",(i,r)=>{ft.init(i,r),i._zod.parse=(a,o)=>{const g=a.value;if(!nn(g))return a.issues.push({expected:"record",code:"invalid_type",input:g,inst:i}),a;const x=[],T=r.keyType._zod.values;if(T){a.value={};const c=new Set;for(const h of T)if(typeof h=="string"||typeof h=="number"||typeof h=="symbol"){c.add(typeof h=="number"?h.toString():h);const y=r.valueType._zod.run({value:g[h],issues:[]},o);y instanceof Promise?x.push(y.then(d=>{d.issues.length&&a.issues.push(...sn(h,d.issues)),a.value[h]=d.value})):(y.issues.length&&a.issues.push(...sn(h,y.issues)),a.value[h]=y.value)}let u;for(const h in g)c.has(h)||(u=u??[],u.push(h));u&&u.length>0&&a.issues.push({code:"unrecognized_keys",input:g,inst:i,keys:u})}else{a.value={};for(const c of Reflect.ownKeys(g)){if(c==="__proto__")continue;let u=r.keyType._zod.run({value:c,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&Zp.test(c)&&u.issues.length){const d=r.keyType._zod.run({value:Number(c),issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(u=d)}if(u.issues.length){r.mode==="loose"?a.value[c]=g[c]:a.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(d=>Ws(d,o,Gs())),input:c,path:[c],inst:i});continue}const y=r.valueType._zod.run({value:g[c],issues:[]},o);y instanceof Promise?x.push(y.then(d=>{d.issues.length&&a.issues.push(...sn(c,d.issues)),a.value[u.value]=d.value})):(y.issues.length&&a.issues.push(...sn(c,y.issues)),a.value[u.value]=y.value)}}return x.length?Promise.all(x).then(()=>a):a}}),uC=fe("$ZodEnum",(i,r)=>{ft.init(i,r);const a=Bp(r.entries),o=new Set(a);i._zod.values=o,i._zod.pattern=new RegExp(`^(${a.filter(g=>Cb.has(typeof g)).map(g=>typeof g=="string"?fl(g):g.toString()).join("|")})$`),i._zod.parse=(g,x)=>{const T=g.value;return o.has(T)||g.issues.push({code:"invalid_value",values:a,input:T,inst:i}),g}}),hC=fe("$ZodTransform",(i,r)=>{ft.init(i,r),i._zod.parse=(a,o)=>{if(o.direction==="backward")throw new Lp(i.constructor.name);const g=r.transform(a.value,a);if(o.async)return(g instanceof Promise?g:Promise.resolve(g)).then(T=>(a.value=T,a));if(g instanceof Promise)throw new rn;return a.value=g,a}});function Om(i,r){return i.issues.length&&r===void 0?{issues:[],value:void 0}:i}const Jp=fe("$ZodOptional",(i,r)=>{ft.init(i,r),i._zod.optin="optional",i._zod.optout="optional",We(i._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,void 0]):void 0),We(i._zod,"pattern",()=>{const a=r.innerType._zod.pattern;return a?new RegExp(`^(${hh(a.source)})?$`):void 0}),i._zod.parse=(a,o)=>{if(r.innerType._zod.optin==="optional"){const g=r.innerType._zod.run(a,o);return g instanceof Promise?g.then(x=>Om(x,a.value)):Om(g,a.value)}return a.value===void 0?a:r.innerType._zod.run(a,o)}}),fC=fe("$ZodExactOptional",(i,r)=>{Jp.init(i,r),We(i._zod,"values",()=>r.innerType._zod.values),We(i._zod,"pattern",()=>r.innerType._zod.pattern),i._zod.parse=(a,o)=>r.innerType._zod.run(a,o)}),dC=fe("$ZodNullable",(i,r)=>{ft.init(i,r),We(i._zod,"optin",()=>r.innerType._zod.optin),We(i._zod,"optout",()=>r.innerType._zod.optout),We(i._zod,"pattern",()=>{const a=r.innerType._zod.pattern;return a?new RegExp(`^(${hh(a.source)}|null)$`):void 0}),We(i._zod,"values",()=>r.innerType._zod.values?new Set([...r.innerType._zod.values,null]):void 0),i._zod.parse=(a,o)=>a.value===null?a:r.innerType._zod.run(a,o)}),_C=fe("$ZodDefault",(i,r)=>{ft.init(i,r),i._zod.optin="optional",We(i._zod,"values",()=>r.innerType._zod.values),i._zod.parse=(a,o)=>{if(o.direction==="backward")return r.innerType._zod.run(a,o);if(a.value===void 0)return a.value=r.defaultValue,a;const g=r.innerType._zod.run(a,o);return g instanceof Promise?g.then(x=>Mm(x,r)):Mm(g,r)}});function Mm(i,r){return i.value===void 0&&(i.value=r.defaultValue),i}const mC=fe("$ZodPrefault",(i,r)=>{ft.init(i,r),i._zod.optin="optional",We(i._zod,"values",()=>r.innerType._zod.values),i._zod.parse=(a,o)=>(o.direction==="backward"||a.value===void 0&&(a.value=r.defaultValue),r.innerType._zod.run(a,o))}),pC=fe("$ZodNonOptional",(i,r)=>{ft.init(i,r),We(i._zod,"values",()=>{const a=r.innerType._zod.values;return a?new Set([...a].filter(o=>o!==void 0)):void 0}),i._zod.parse=(a,o)=>{const g=r.innerType._zod.run(a,o);return g instanceof Promise?g.then(x=>Lm(x,i)):Lm(g,i)}});function Lm(i,r){return!i.issues.length&&i.value===void 0&&i.issues.push({code:"invalid_type",expected:"nonoptional",input:i.value,inst:r}),i}const vC=fe("$ZodCatch",(i,r)=>{ft.init(i,r),We(i._zod,"optin",()=>r.innerType._zod.optin),We(i._zod,"optout",()=>r.innerType._zod.optout),We(i._zod,"values",()=>r.innerType._zod.values),i._zod.parse=(a,o)=>{if(o.direction==="backward")return r.innerType._zod.run(a,o);const g=r.innerType._zod.run(a,o);return g instanceof Promise?g.then(x=>(a.value=x.value,x.issues.length&&(a.value=r.catchValue({...a,error:{issues:x.issues.map(T=>Ws(T,o,Gs()))},input:a.value}),a.issues=[]),a)):(a.value=g.value,g.issues.length&&(a.value=r.catchValue({...a,error:{issues:g.issues.map(x=>Ws(x,o,Gs()))},input:a.value}),a.issues=[]),a)}}),gC=fe("$ZodPipe",(i,r)=>{ft.init(i,r),We(i._zod,"values",()=>r.in._zod.values),We(i._zod,"optin",()=>r.in._zod.optin),We(i._zod,"optout",()=>r.out._zod.optout),We(i._zod,"propValues",()=>r.in._zod.propValues),i._zod.parse=(a,o)=>{if(o.direction==="backward"){const x=r.out._zod.run(a,o);return x instanceof Promise?x.then(T=>Fo(T,r.in,o)):Fo(x,r.in,o)}const g=r.in._zod.run(a,o);return g instanceof Promise?g.then(x=>Fo(x,r.out,o)):Fo(g,r.out,o)}});function Fo(i,r,a){return i.issues.length?(i.aborted=!0,i):r._zod.run({value:i.value,issues:i.issues},a)}const yC=fe("$ZodReadonly",(i,r)=>{ft.init(i,r),We(i._zod,"propValues",()=>r.innerType._zod.propValues),We(i._zod,"values",()=>r.innerType._zod.values),We(i._zod,"optin",()=>{var a,o;return(o=(a=r.innerType)==null?void 0:a._zod)==null?void 0:o.optin}),We(i._zod,"optout",()=>{var a,o;return(o=(a=r.innerType)==null?void 0:a._zod)==null?void 0:o.optout}),i._zod.parse=(a,o)=>{if(o.direction==="backward")return r.innerType._zod.run(a,o);const g=r.innerType._zod.run(a,o);return g instanceof Promise?g.then(Nm):Nm(g)}});function Nm(i){return i.value=Object.freeze(i.value),i}const SC=fe("$ZodCustom",(i,r)=>{ni.init(i,r),ft.init(i,r),i._zod.parse=(a,o)=>a,i._zod.check=a=>{const o=a.value,g=r.fn(o);if(g instanceof Promise)return g.then(x=>Bm(x,a,o,i));Bm(g,a,o,i)}});function Bm(i,r,a,o){if(!i){const g={code:"custom",input:a,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(g.params=o._zod.def.params),r.issues.push(ya(g))}}var zm;class bC{constructor(){this._map=new WeakMap,this._idmap=new Map}add(r,...a){const o=a[0];return this._map.set(r,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,r),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(r){const a=this._map.get(r);return a&&typeof a=="object"&&"id"in a&&this._idmap.delete(a.id),this._map.delete(r),this}get(r){const a=r._zod.parent;if(a){const o={...this.get(a)??{}};delete o.id;const g={...o,...this._map.get(r)};return Object.keys(g).length?g:void 0}return this._map.get(r)}has(r){return this._map.has(r)}}function CC(){return new bC}(zm=globalThis).__zod_globalRegistry??(zm.__zod_globalRegistry=CC());const va=globalThis.__zod_globalRegistry;function xC(i,r){return new i({type:"string",...xe(r)})}function wC(i,r){return new i({type:"string",format:"email",check:"string_format",abort:!1,...xe(r)})}function jm(i,r){return new i({type:"string",format:"guid",check:"string_format",abort:!1,...xe(r)})}function EC(i,r){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,...xe(r)})}function TC(i,r){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...xe(r)})}function AC(i,r){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...xe(r)})}function RC(i,r){return new i({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...xe(r)})}function DC(i,r){return new i({type:"string",format:"url",check:"string_format",abort:!1,...xe(r)})}function kC(i,r){return new i({type:"string",format:"emoji",check:"string_format",abort:!1,...xe(r)})}function OC(i,r){return new i({type:"string",format:"nanoid",check:"string_format",abort:!1,...xe(r)})}function MC(i,r){return new i({type:"string",format:"cuid",check:"string_format",abort:!1,...xe(r)})}function LC(i,r){return new i({type:"string",format:"cuid2",check:"string_format",abort:!1,...xe(r)})}function NC(i,r){return new i({type:"string",format:"ulid",check:"string_format",abort:!1,...xe(r)})}function BC(i,r){return new i({type:"string",format:"xid",check:"string_format",abort:!1,...xe(r)})}function zC(i,r){return new i({type:"string",format:"ksuid",check:"string_format",abort:!1,...xe(r)})}function jC(i,r){return new i({type:"string",format:"ipv4",check:"string_format",abort:!1,...xe(r)})}function HC(i,r){return new i({type:"string",format:"ipv6",check:"string_format",abort:!1,...xe(r)})}function UC(i,r){return new i({type:"string",format:"cidrv4",check:"string_format",abort:!1,...xe(r)})}function IC(i,r){return new i({type:"string",format:"cidrv6",check:"string_format",abort:!1,...xe(r)})}function PC(i,r){return new i({type:"string",format:"base64",check:"string_format",abort:!1,...xe(r)})}function $C(i,r){return new i({type:"string",format:"base64url",check:"string_format",abort:!1,...xe(r)})}function FC(i,r){return new i({type:"string",format:"e164",check:"string_format",abort:!1,...xe(r)})}function ZC(i,r){return new i({type:"string",format:"jwt",check:"string_format",abort:!1,...xe(r)})}function qC(i,r){return new i({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...xe(r)})}function GC(i,r){return new i({type:"string",format:"date",check:"string_format",...xe(r)})}function WC(i,r){return new i({type:"string",format:"time",check:"string_format",precision:null,...xe(r)})}function YC(i,r){return new i({type:"string",format:"duration",check:"string_format",...xe(r)})}function VC(i,r){return new i({type:"number",checks:[],...xe(r)})}function KC(i,r){return new i({type:"number",check:"number_format",abort:!1,format:"safeint",...xe(r)})}function XC(i,r){return new i({type:"boolean",...xe(r)})}function JC(i){return new i({type:"unknown"})}function QC(i,r){return new i({type:"never",...xe(r)})}function Hm(i,r){return new Gp({check:"less_than",...xe(r),value:i,inclusive:!1})}function Bu(i,r){return new Gp({check:"less_than",...xe(r),value:i,inclusive:!0})}function Um(i,r){return new Wp({check:"greater_than",...xe(r),value:i,inclusive:!1})}function zu(i,r){return new Wp({check:"greater_than",...xe(r),value:i,inclusive:!0})}function Im(i,r){return new m1({check:"multiple_of",...xe(r),value:i})}function Qp(i,r){return new v1({check:"max_length",...xe(r),maximum:i})}function il(i,r){return new g1({check:"min_length",...xe(r),minimum:i})}function ev(i,r){return new y1({check:"length_equals",...xe(r),length:i})}function ex(i,r){return new S1({check:"string_format",format:"regex",...xe(r),pattern:i})}function tx(i){return new b1({check:"string_format",format:"lowercase",...xe(i)})}function ix(i){return new C1({check:"string_format",format:"uppercase",...xe(i)})}function sx(i,r){return new x1({check:"string_format",format:"includes",...xe(r),includes:i})}function rx(i,r){return new w1({check:"string_format",format:"starts_with",...xe(r),prefix:i})}function nx(i,r){return new E1({check:"string_format",format:"ends_with",...xe(r),suffix:i})}function cn(i){return new T1({check:"overwrite",tx:i})}function ax(i){return cn(r=>r.normalize(i))}function ox(){return cn(i=>i.trim())}function lx(){return cn(i=>i.toLowerCase())}function cx(){return cn(i=>i.toUpperCase())}function ux(){return cn(i=>Sb(i))}function hx(i,r,a){return new i({type:"array",element:r,...xe(a)})}function fx(i,r,a){return new i({type:"custom",check:"custom",fn:r,...xe(a)})}function dx(i){const r=_x(a=>(a.addIssue=o=>{if(typeof o=="string")a.issues.push(ya(o,a.value,r._zod.def));else{const g=o;g.fatal&&(g.continue=!1),g.code??(g.code="custom"),g.input??(g.input=a.value),g.inst??(g.inst=r),g.continue??(g.continue=!r._zod.def.abort),a.issues.push(ya(g))}},i(a.value,a)));return r}function _x(i,r){const a=new ni({check:"custom",...xe(r)});return a._zod.check=i,a}function tv(i){let r=(i==null?void 0:i.target)??"draft-2020-12";return r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),{processors:i.processors??{},metadataRegistry:(i==null?void 0:i.metadata)??va,target:r,unrepresentable:(i==null?void 0:i.unrepresentable)??"throw",override:(i==null?void 0:i.override)??(()=>{}),io:(i==null?void 0:i.io)??"output",counter:0,seen:new Map,cycles:(i==null?void 0:i.cycles)??"ref",reused:(i==null?void 0:i.reused)??"inline",external:(i==null?void 0:i.external)??void 0}}function wt(i,r,a={path:[],schemaPath:[]}){var y,d;var o;const g=i._zod.def,x=r.seen.get(i);if(x)return x.count++,a.schemaPath.includes(i)&&(x.cycle=a.path),x.schema;const T={schema:{},count:1,cycle:void 0,path:a.path};r.seen.set(i,T);const c=(d=(y=i._zod).toJSONSchema)==null?void 0:d.call(y);if(c)T.schema=c;else{const C={...a,schemaPath:[...a.schemaPath,i],path:a.path};if(i._zod.processJSONSchema)i._zod.processJSONSchema(r,T.schema,C);else{const k=T.schema,b=r.processors[g.type];if(!b)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${g.type}`);b(i,r,k,C)}const w=i._zod.parent;w&&(T.ref||(T.ref=w),wt(w,r,C),r.seen.get(w).isParent=!0)}const u=r.metadataRegistry.get(i);return u&&Object.assign(T.schema,u),r.io==="input"&&Wt(i)&&(delete T.schema.examples,delete T.schema.default),r.io==="input"&&T.schema._prefault&&((o=T.schema).default??(o.default=T.schema._prefault)),delete T.schema._prefault,r.seen.get(i).schema}function iv(i,r){var T,c,u,h;const a=i.seen.get(r);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const y of i.seen.entries()){const d=(T=i.metadataRegistry.get(y[0]))==null?void 0:T.id;if(d){const C=o.get(d);if(C&&C!==y[0])throw new Error(`Duplicate schema id "${d}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(d,y[0])}}const g=y=>{var b;const d=i.target==="draft-2020-12"?"$defs":"definitions";if(i.external){const m=(b=i.external.registry.get(y[0]))==null?void 0:b.id,v=i.external.uri??(p=>p);if(m)return{ref:v(m)};const f=y[1].defId??y[1].schema.id??`schema${i.counter++}`;return y[1].defId=f,{defId:f,ref:`${v("__shared")}#/${d}/${f}`}}if(y[1]===a)return{ref:"#"};const w=`#/${d}/`,k=y[1].schema.id??`__schema${i.counter++}`;return{defId:k,ref:w+k}},x=y=>{if(y[1].schema.$ref)return;const d=y[1],{ref:C,defId:w}=g(y);d.def={...d.schema},w&&(d.defId=w);const k=d.schema;for(const b in k)delete k[b];k.$ref=C};if(i.cycles==="throw")for(const y of i.seen.entries()){const d=y[1];if(d.cycle)throw new Error(`Cycle detected: #/${(c=d.cycle)==null?void 0:c.join("/")}/<root>
|
|
252
252
|
|
|
253
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const y of i.seen.entries()){const d=y[1];if(r===y[0]){x(y);continue}if(i.external){const w=(u=i.external.registry.get(y[0]))==null?void 0:u.id;if(r!==y[0]&&w){x(y);continue}}if((h=i.metadataRegistry.get(y[0]))==null?void 0:h.id){x(y);continue}if(d.cycle){x(y);continue}if(d.count>1&&i.reused==="ref"){x(y);continue}}}function sv(i,r){var T,c,u;const a=i.seen.get(r);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=h=>{const y=i.seen.get(h);if(y.ref===null)return;const d=y.def??y.schema,C={...d},w=y.ref;if(y.ref=null,w){o(w);const b=i.seen.get(w),m=b.schema;if(m.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(m)):Object.assign(d,m),Object.assign(d,C),h._zod.parent===w)for(const f in d)f==="$ref"||f==="allOf"||f in C||delete d[f];if(m.$ref&&b.def)for(const f in d)f==="$ref"||f==="allOf"||f in b.def&&JSON.stringify(d[f])===JSON.stringify(b.def[f])&&delete d[f]}const k=h._zod.parent;if(k&&k!==w){o(k);const b=i.seen.get(k);if(b!=null&&b.schema.$ref&&(d.$ref=b.schema.$ref,b.def))for(const m in d)m==="$ref"||m==="allOf"||m in b.def&&JSON.stringify(d[m])===JSON.stringify(b.def[m])&&delete d[m]}i.override({zodSchema:h,jsonSchema:d,path:y.path??[]})};for(const h of[...i.seen.entries()].reverse())o(h[0]);const g={};if(i.target==="draft-2020-12"?g.$schema="https://json-schema.org/draft/2020-12/schema":i.target==="draft-07"?g.$schema="http://json-schema.org/draft-07/schema#":i.target==="draft-04"?g.$schema="http://json-schema.org/draft-04/schema#":i.target,(T=i.external)!=null&&T.uri){const h=(c=i.external.registry.get(r))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");g.$id=i.external.uri(h)}Object.assign(g,a.def??a.schema);const x=((u=i.external)==null?void 0:u.defs)??{};for(const h of i.seen.entries()){const y=h[1];y.def&&y.defId&&(x[y.defId]=y.def)}i.external||Object.keys(x).length>0&&(i.target==="draft-2020-12"?g.$defs=x:g.definitions=x);try{const h=JSON.parse(JSON.stringify(g));return Object.defineProperty(h,"~standard",{value:{...r["~standard"],jsonSchema:{input:sl(r,"input",i.processors),output:sl(r,"output",i.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Wt(i,r){const a=r??{seen:new Set};if(a.seen.has(i))return!1;a.seen.add(i);const o=i._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Wt(o.element,a);if(o.type==="set")return Wt(o.valueType,a);if(o.type==="lazy")return Wt(o.getter(),a);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Wt(o.innerType,a);if(o.type==="intersection")return Wt(o.left,a)||Wt(o.right,a);if(o.type==="record"||o.type==="map")return Wt(o.keyType,a)||Wt(o.valueType,a);if(o.type==="pipe")return Wt(o.in,a)||Wt(o.out,a);if(o.type==="object"){for(const g in o.shape)if(Wt(o.shape[g],a))return!0;return!1}if(o.type==="union"){for(const g of o.options)if(Wt(g,a))return!0;return!1}if(o.type==="tuple"){for(const g of o.items)if(Wt(g,a))return!0;return!!(o.rest&&Wt(o.rest,a))}return!1}const mx=(i,r={})=>a=>{const o=tv({...a,processors:r});return wt(i,o),iv(o,i),sv(o,i)},sl=(i,r,a={})=>o=>{const{libraryOptions:g,target:x}=o??{},T=tv({...g??{},target:x,io:r,processors:a});return wt(i,T),iv(T,i),sv(T,i)},px={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vx=(i,r,a,o)=>{const g=a;g.type="string";const{minimum:x,maximum:T,format:c,patterns:u,contentEncoding:h}=i._zod.bag;if(typeof x=="number"&&(g.minLength=x),typeof T=="number"&&(g.maxLength=T),c&&(g.format=px[c]??c,g.format===""&&delete g.format,c==="time"&&delete g.format),h&&(g.contentEncoding=h),u&&u.size>0){const y=[...u];y.length===1?g.pattern=y[0].source:y.length>1&&(g.allOf=[...y.map(d=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},gx=(i,r,a,o)=>{const g=a,{minimum:x,maximum:T,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:y}=i._zod.bag;typeof c=="string"&&c.includes("int")?g.type="integer":g.type="number",typeof y=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(g.minimum=y,g.exclusiveMinimum=!0):g.exclusiveMinimum=y),typeof x=="number"&&(g.minimum=x,typeof y=="number"&&r.target!=="draft-04"&&(y>=x?delete g.minimum:delete g.exclusiveMinimum)),typeof h=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(g.maximum=h,g.exclusiveMaximum=!0):g.exclusiveMaximum=h),typeof T=="number"&&(g.maximum=T,typeof h=="number"&&r.target!=="draft-04"&&(h<=T?delete g.maximum:delete g.exclusiveMaximum)),typeof u=="number"&&(g.multipleOf=u)},yx=(i,r,a,o)=>{a.type="boolean"},Sx=(i,r,a,o)=>{a.not={}},bx=(i,r,a,o)=>{},Cx=(i,r,a,o)=>{const g=i._zod.def,x=Bp(g.entries);x.every(T=>typeof T=="number")&&(a.type="number"),x.every(T=>typeof T=="string")&&(a.type="string"),a.enum=x},xx=(i,r,a,o)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wx=(i,r,a,o)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ex=(i,r,a,o)=>{const g=a,x=i._zod.def,{minimum:T,maximum:c}=i._zod.bag;typeof T=="number"&&(g.minItems=T),typeof c=="number"&&(g.maxItems=c),g.type="array",g.items=wt(x.element,r,{...o,path:[...o.path,"items"]})},Tx=(i,r,a,o)=>{var h;const g=a,x=i._zod.def;g.type="object",g.properties={};const T=x.shape;for(const y in T)g.properties[y]=wt(T[y],r,{...o,path:[...o.path,"properties",y]});const c=new Set(Object.keys(T)),u=new Set([...c].filter(y=>{const d=x.shape[y]._zod;return r.io==="input"?d.optin===void 0:d.optout===void 0}));u.size>0&&(g.required=Array.from(u)),((h=x.catchall)==null?void 0:h._zod.def.type)==="never"?g.additionalProperties=!1:x.catchall?x.catchall&&(g.additionalProperties=wt(x.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(g.additionalProperties=!1)},Ax=(i,r,a,o)=>{const g=i._zod.def,x=g.inclusive===!1,T=g.options.map((c,u)=>wt(c,r,{...o,path:[...o.path,x?"oneOf":"anyOf",u]}));x?a.oneOf=T:a.anyOf=T},Rx=(i,r,a,o)=>{const g=i._zod.def,x=wt(g.left,r,{...o,path:[...o.path,"allOf",0]}),T=wt(g.right,r,{...o,path:[...o.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(x)?x.allOf:[x],...c(T)?T.allOf:[T]];a.allOf=u},Dx=(i,r,a,o)=>{const g=a,x=i._zod.def;g.type="object";const T=x.keyType,c=T._zod.bag,u=c==null?void 0:c.patterns;if(x.mode==="loose"&&u&&u.size>0){const y=wt(x.valueType,r,{...o,path:[...o.path,"patternProperties","*"]});g.patternProperties={};for(const d of u)g.patternProperties[d.source]=y}else(r.target==="draft-07"||r.target==="draft-2020-12")&&(g.propertyNames=wt(x.keyType,r,{...o,path:[...o.path,"propertyNames"]})),g.additionalProperties=wt(x.valueType,r,{...o,path:[...o.path,"additionalProperties"]});const h=T._zod.values;if(h){const y=[...h].filter(d=>typeof d=="string"||typeof d=="number");y.length>0&&(g.required=y)}},kx=(i,r,a,o)=>{const g=i._zod.def,x=wt(g.innerType,r,o),T=r.seen.get(i);r.target==="openapi-3.0"?(T.ref=g.innerType,a.nullable=!0):a.anyOf=[x,{type:"null"}]},Ox=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType},Mx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,a.default=JSON.parse(JSON.stringify(g.defaultValue))},Lx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,r.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(g.defaultValue)))},Nx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType;let T;try{T=g.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=T},Bx=(i,r,a,o)=>{const g=i._zod.def,x=r.io==="input"?g.in._zod.def.type==="transform"?g.out:g.in:g.out;wt(x,r,o);const T=r.seen.get(i);T.ref=x},zx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,a.readOnly=!0},rv=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType},jx=fe("ZodISODateTime",(i,r)=>{I1.init(i,r),lt.init(i,r)});function Hx(i){return qC(jx,i)}const Ux=fe("ZodISODate",(i,r)=>{P1.init(i,r),lt.init(i,r)});function Ix(i){return GC(Ux,i)}const Px=fe("ZodISOTime",(i,r)=>{$1.init(i,r),lt.init(i,r)});function $x(i){return WC(Px,i)}const Fx=fe("ZodISODuration",(i,r)=>{F1.init(i,r),lt.init(i,r)});function Zx(i){return YC(Fx,i)}const qx=(i,r)=>{Up.init(i,r),i.name="ZodError",Object.defineProperties(i,{format:{value:a=>Lb(i,a)},flatten:{value:a=>Mb(i,a)},addIssue:{value:a=>{i.issues.push(a),i.message=JSON.stringify(i.issues,Xu,2)}},addIssues:{value:a=>{i.issues.push(...a),i.message=JSON.stringify(i.issues,Xu,2)}},isEmpty:{get(){return i.issues.length===0}}})},Mi=fe("ZodError",qx,{Parent:Error}),Gx=dh(Mi),Wx=_h(Mi),Yx=dl(Mi),Vx=_l(Mi),Kx=zb(Mi),Xx=jb(Mi),Jx=Hb(Mi),Qx=Ub(Mi),ew=Ib(Mi),tw=Pb(Mi),iw=$b(Mi),sw=Fb(Mi),dt=fe("ZodType",(i,r)=>(ft.init(i,r),Object.assign(i["~standard"],{jsonSchema:{input:sl(i,"input"),output:sl(i,"output")}}),i.toJSONSchema=mx(i,{}),i.def=r,i.type=r.type,Object.defineProperty(i,"_def",{value:r}),i.check=(...a)=>i.clone(Vs(r,{checks:[...r.checks??[],...a.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),i.with=i.check,i.clone=(a,o)=>Ks(i,a,o),i.brand=()=>i,i.register=((a,o)=>(a.add(i,o),i)),i.parse=(a,o)=>Gx(i,a,o,{callee:i.parse}),i.safeParse=(a,o)=>Yx(i,a,o),i.parseAsync=async(a,o)=>Wx(i,a,o,{callee:i.parseAsync}),i.safeParseAsync=async(a,o)=>Vx(i,a,o),i.spa=i.safeParseAsync,i.encode=(a,o)=>Kx(i,a,o),i.decode=(a,o)=>Xx(i,a,o),i.encodeAsync=async(a,o)=>Jx(i,a,o),i.decodeAsync=async(a,o)=>Qx(i,a,o),i.safeEncode=(a,o)=>ew(i,a,o),i.safeDecode=(a,o)=>tw(i,a,o),i.safeEncodeAsync=async(a,o)=>iw(i,a,o),i.safeDecodeAsync=async(a,o)=>sw(i,a,o),i.refine=(a,o)=>i.check(Kw(a,o)),i.superRefine=a=>i.check(Xw(a)),i.overwrite=a=>i.check(cn(a)),i.optional=()=>Fm(i),i.exactOptional=()=>jw(i),i.nullable=()=>Zm(i),i.nullish=()=>Fm(Zm(i)),i.nonoptional=a=>Fw(i,a),i.array=()=>pl(i),i.or=a=>kw([i,a]),i.and=a=>Mw(i,a),i.transform=a=>qm(i,Bw(a)),i.default=a=>Iw(i,a),i.prefault=a=>$w(i,a),i.catch=a=>qw(i,a),i.pipe=a=>qm(i,a),i.readonly=()=>Yw(i),i.describe=a=>{const o=i.clone();return va.add(o,{description:a}),o},Object.defineProperty(i,"description",{get(){var a;return(a=va.get(i))==null?void 0:a.description},configurable:!0}),i.meta=(...a)=>{if(a.length===0)return va.get(i);const o=i.clone();return va.add(o,a[0]),o},i.isOptional=()=>i.safeParse(void 0).success,i.isNullable=()=>i.safeParse(null).success,i.apply=a=>a(i),i)),nv=fe("_ZodString",(i,r)=>{mh.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>vx(i,o,g);const a=i._zod.bag;i.format=a.format??null,i.minLength=a.minimum??null,i.maxLength=a.maximum??null,i.regex=(...o)=>i.check(ex(...o)),i.includes=(...o)=>i.check(sx(...o)),i.startsWith=(...o)=>i.check(rx(...o)),i.endsWith=(...o)=>i.check(nx(...o)),i.min=(...o)=>i.check(il(...o)),i.max=(...o)=>i.check(Qp(...o)),i.length=(...o)=>i.check(ev(...o)),i.nonempty=(...o)=>i.check(il(1,...o)),i.lowercase=o=>i.check(tx(o)),i.uppercase=o=>i.check(ix(o)),i.trim=()=>i.check(ox()),i.normalize=(...o)=>i.check(ax(...o)),i.toLowerCase=()=>i.check(lx()),i.toUpperCase=()=>i.check(cx()),i.slugify=()=>i.check(ux())}),rw=fe("ZodString",(i,r)=>{mh.init(i,r),nv.init(i,r),i.email=a=>i.check(wC(nw,a)),i.url=a=>i.check(DC(aw,a)),i.jwt=a=>i.check(ZC(bw,a)),i.emoji=a=>i.check(kC(ow,a)),i.guid=a=>i.check(jm(Pm,a)),i.uuid=a=>i.check(EC(Zo,a)),i.uuidv4=a=>i.check(TC(Zo,a)),i.uuidv6=a=>i.check(AC(Zo,a)),i.uuidv7=a=>i.check(RC(Zo,a)),i.nanoid=a=>i.check(OC(lw,a)),i.guid=a=>i.check(jm(Pm,a)),i.cuid=a=>i.check(MC(cw,a)),i.cuid2=a=>i.check(LC(uw,a)),i.ulid=a=>i.check(NC(hw,a)),i.base64=a=>i.check(PC(gw,a)),i.base64url=a=>i.check($C(yw,a)),i.xid=a=>i.check(BC(fw,a)),i.ksuid=a=>i.check(zC(dw,a)),i.ipv4=a=>i.check(jC(_w,a)),i.ipv6=a=>i.check(HC(mw,a)),i.cidrv4=a=>i.check(UC(pw,a)),i.cidrv6=a=>i.check(IC(vw,a)),i.e164=a=>i.check(FC(Sw,a)),i.datetime=a=>i.check(Hx(a)),i.date=a=>i.check(Ix(a)),i.time=a=>i.check($x(a)),i.duration=a=>i.check(Zx(a))});function Ie(i){return xC(rw,i)}const lt=fe("ZodStringFormat",(i,r)=>{rt.init(i,r),nv.init(i,r)}),nw=fe("ZodEmail",(i,r)=>{O1.init(i,r),lt.init(i,r)}),Pm=fe("ZodGUID",(i,r)=>{D1.init(i,r),lt.init(i,r)}),Zo=fe("ZodUUID",(i,r)=>{k1.init(i,r),lt.init(i,r)}),aw=fe("ZodURL",(i,r)=>{M1.init(i,r),lt.init(i,r)}),ow=fe("ZodEmoji",(i,r)=>{L1.init(i,r),lt.init(i,r)}),lw=fe("ZodNanoID",(i,r)=>{N1.init(i,r),lt.init(i,r)}),cw=fe("ZodCUID",(i,r)=>{B1.init(i,r),lt.init(i,r)}),uw=fe("ZodCUID2",(i,r)=>{z1.init(i,r),lt.init(i,r)}),hw=fe("ZodULID",(i,r)=>{j1.init(i,r),lt.init(i,r)}),fw=fe("ZodXID",(i,r)=>{H1.init(i,r),lt.init(i,r)}),dw=fe("ZodKSUID",(i,r)=>{U1.init(i,r),lt.init(i,r)}),_w=fe("ZodIPv4",(i,r)=>{Z1.init(i,r),lt.init(i,r)}),mw=fe("ZodIPv6",(i,r)=>{q1.init(i,r),lt.init(i,r)}),pw=fe("ZodCIDRv4",(i,r)=>{G1.init(i,r),lt.init(i,r)}),vw=fe("ZodCIDRv6",(i,r)=>{W1.init(i,r),lt.init(i,r)}),gw=fe("ZodBase64",(i,r)=>{Y1.init(i,r),lt.init(i,r)}),yw=fe("ZodBase64URL",(i,r)=>{K1.init(i,r),lt.init(i,r)}),Sw=fe("ZodE164",(i,r)=>{X1.init(i,r),lt.init(i,r)}),bw=fe("ZodJWT",(i,r)=>{Q1.init(i,r),lt.init(i,r)}),av=fe("ZodNumber",(i,r)=>{Vp.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>gx(i,o,g),i.gt=(o,g)=>i.check(Um(o,g)),i.gte=(o,g)=>i.check(zu(o,g)),i.min=(o,g)=>i.check(zu(o,g)),i.lt=(o,g)=>i.check(Hm(o,g)),i.lte=(o,g)=>i.check(Bu(o,g)),i.max=(o,g)=>i.check(Bu(o,g)),i.int=o=>i.check($m(o)),i.safe=o=>i.check($m(o)),i.positive=o=>i.check(Um(0,o)),i.nonnegative=o=>i.check(zu(0,o)),i.negative=o=>i.check(Hm(0,o)),i.nonpositive=o=>i.check(Bu(0,o)),i.multipleOf=(o,g)=>i.check(Im(o,g)),i.step=(o,g)=>i.check(Im(o,g)),i.finite=()=>i;const a=i._zod.bag;i.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,i.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,i.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),i.isFinite=!0,i.format=a.format??null});function Oe(i){return VC(av,i)}const Cw=fe("ZodNumberFormat",(i,r)=>{eC.init(i,r),av.init(i,r)});function $m(i){return KC(Cw,i)}const xw=fe("ZodBoolean",(i,r)=>{tC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>yx(i,a,o)});function ys(i){return XC(xw,i)}const ww=fe("ZodUnknown",(i,r)=>{iC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>bx()});function rl(){return JC(ww)}const Ew=fe("ZodNever",(i,r)=>{sC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Sx(i,a,o)});function Tw(i){return QC(Ew,i)}const Aw=fe("ZodArray",(i,r)=>{rC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ex(i,a,o,g),i.element=r.element,i.min=(a,o)=>i.check(il(a,o)),i.nonempty=a=>i.check(il(1,a)),i.max=(a,o)=>i.check(Qp(a,o)),i.length=(a,o)=>i.check(ev(a,o)),i.unwrap=()=>i.element});function pl(i,r){return hx(Aw,i,r)}const Rw=fe("ZodObject",(i,r)=>{aC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Tx(i,a,o,g),We(i,"shape",()=>r.shape),i.keyof=()=>an(Object.keys(i._zod.def.shape)),i.catchall=a=>i.clone({...i._zod.def,catchall:a}),i.passthrough=()=>i.clone({...i._zod.def,catchall:rl()}),i.loose=()=>i.clone({...i._zod.def,catchall:rl()}),i.strict=()=>i.clone({...i._zod.def,catchall:Tw()}),i.strip=()=>i.clone({...i._zod.def,catchall:void 0}),i.extend=a=>Ab(i,a),i.safeExtend=a=>Rb(i,a),i.merge=a=>Db(i,a),i.pick=a=>Eb(i,a),i.omit=a=>Tb(i,a),i.partial=(...a)=>kb(ov,i,a[0]),i.required=(...a)=>Ob(lv,i,a[0])});function Lt(i,r){const a={type:"object",shape:i??{},...xe(r)};return new Rw(a)}const Dw=fe("ZodUnion",(i,r)=>{oC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ax(i,a,o,g),i.options=r.options});function kw(i,r){return new Dw({type:"union",options:i,...xe(r)})}const Ow=fe("ZodIntersection",(i,r)=>{lC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Rx(i,a,o,g)});function Mw(i,r){return new Ow({type:"intersection",left:i,right:r})}const Lw=fe("ZodRecord",(i,r)=>{cC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Dx(i,a,o,g),i.keyType=r.keyType,i.valueType=r.valueType});function vl(i,r,a){return new Lw({type:"record",keyType:i,valueType:r,...xe(a)})}const Qu=fe("ZodEnum",(i,r)=>{uC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>Cx(i,o,g),i.enum=r.entries,i.options=Object.values(r.entries);const a=new Set(Object.keys(r.entries));i.extract=(o,g)=>{const x={};for(const T of o)if(a.has(T))x[T]=r.entries[T];else throw new Error(`Key ${T} not found in enum`);return new Qu({...r,checks:[],...xe(g),entries:x})},i.exclude=(o,g)=>{const x={...r.entries};for(const T of o)if(a.has(T))delete x[T];else throw new Error(`Key ${T} not found in enum`);return new Qu({...r,checks:[],...xe(g),entries:x})}});function an(i,r){const a=Array.isArray(i)?Object.fromEntries(i.map(o=>[o,o])):i;return new Qu({type:"enum",entries:a,...xe(r)})}const Nw=fe("ZodTransform",(i,r)=>{hC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>wx(i,a),i._zod.parse=(a,o)=>{if(o.direction==="backward")throw new Lp(i.constructor.name);a.addIssue=x=>{if(typeof x=="string")a.issues.push(ya(x,a.value,r));else{const T=x;T.fatal&&(T.continue=!1),T.code??(T.code="custom"),T.input??(T.input=a.value),T.inst??(T.inst=i),a.issues.push(ya(T))}};const g=r.transform(a.value,a);return g instanceof Promise?g.then(x=>(a.value=x,a)):(a.value=g,a)}});function Bw(i){return new Nw({type:"transform",transform:i})}const ov=fe("ZodOptional",(i,r)=>{Jp.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>rv(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Fm(i){return new ov({type:"optional",innerType:i})}const zw=fe("ZodExactOptional",(i,r)=>{fC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>rv(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function jw(i){return new zw({type:"optional",innerType:i})}const Hw=fe("ZodNullable",(i,r)=>{dC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>kx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Zm(i){return new Hw({type:"nullable",innerType:i})}const Uw=fe("ZodDefault",(i,r)=>{_C.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Mx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType,i.removeDefault=i.unwrap});function Iw(i,r){return new Uw({type:"default",innerType:i,get defaultValue(){return typeof r=="function"?r():jp(r)}})}const Pw=fe("ZodPrefault",(i,r)=>{mC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Lx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function $w(i,r){return new Pw({type:"prefault",innerType:i,get defaultValue(){return typeof r=="function"?r():jp(r)}})}const lv=fe("ZodNonOptional",(i,r)=>{pC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ox(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Fw(i,r){return new lv({type:"nonoptional",innerType:i,...xe(r)})}const Zw=fe("ZodCatch",(i,r)=>{vC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Nx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType,i.removeCatch=i.unwrap});function qw(i,r){return new Zw({type:"catch",innerType:i,catchValue:typeof r=="function"?r:()=>r})}const Gw=fe("ZodPipe",(i,r)=>{gC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Bx(i,a,o,g),i.in=r.in,i.out=r.out});function qm(i,r){return new Gw({type:"pipe",in:i,out:r})}const Ww=fe("ZodReadonly",(i,r)=>{yC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>zx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Yw(i){return new Ww({type:"readonly",innerType:i})}const Vw=fe("ZodCustom",(i,r)=>{SC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>xx(i,a)});function Kw(i,r={}){return fx(Vw,i,r)}function Xw(i){return dx(i)}const ph=an(["idle","working","permission_prompt","plan_mode","ask_question","bash_approval","settings","unknown"]),cv=Lt({ok:ys()}),Jw=cv.extend({delivered:ys(),attempts:Oe()}),Qw=Lt({status:Ie(),version:Ie(),uptime:Oe(),sessions:Lt({active:Oe(),total:Oe()}),timestamp:Ie()}),uv=Lt({id:Ie(),windowId:Ie(),windowName:Ie(),workDir:Ie(),claudeSessionId:Ie().optional(),jsonlPath:Ie().optional(),byteOffset:Oe(),monitorOffset:Oe(),status:ph,createdAt:Oe(),lastActivity:Oe(),stallThresholdMs:Oe(),permissionMode:Ie(),autoApprove:ys().optional(),settingsPatched:ys().optional(),promptDelivery:Lt({delivered:ys(),attempts:Oe()}).optional(),actionHints:vl(Ie(),Lt({method:Ie(),url:Ie(),description:Ie()})).optional()}),e2=Lt({sessions:pl(uv),pagination:Lt({page:Oe(),limit:Oe(),total:Oe(),totalPages:Oe()})}),t2=Lt({alive:ys(),windowExists:ys(),claudeRunning:ys(),paneCommand:Ie().nullable(),status:ph,hasTranscript:ys(),lastActivity:Oe(),lastActivityAgo:Oe(),sessionAge:Oe(),details:Ie(),actionHints:vl(Ie(),Lt({method:Ie(),url:Ie(),description:Ie()})).optional()}),i2=Lt({durationSec:Oe(),messages:Oe(),toolCalls:Oe(),approvals:Oe(),autoApprovals:Oe(),statusChanges:pl(Ie())}),s2=Lt({role:an(["user","assistant","system"]),contentType:an(["text","thinking","tool_use","tool_result","permission_request"]),text:Ie(),toolName:Ie().optional(),toolUseId:Ie().optional(),timestamp:Ie().optional()}),r2=Lt({messages:pl(s2),status:ph,statusText:Ie().nullable(),interactiveContent:Ie().nullable()}),n2=Lt({uptime:Oe(),sessions:Lt({total_created:Oe(),currently_active:Oe(),completed:Oe(),failed:Oe(),avg_duration_sec:Oe(),avg_messages_per_session:Oe()}),auto_approvals:Oe(),webhooks_sent:Oe(),webhooks_failed:Oe(),screenshots_taken:Oe(),pipelines_created:Oe(),batches_created:Oe(),prompt_delivery:Lt({sent:Oe(),delivered:Oe(),failed:Oe(),success_rate:Oe().nullable()})}),a2=an(["status","message","approval","ended","heartbeat","stall","dead","system","hook","subagent_start","subagent_stop"]),o2=Lt({event:a2,sessionId:Ie(),timestamp:Ie(),data:vl(Ie(),rl()).optional()}),l2=an(["session_status_change","session_message","session_approval","session_ended","session_created","session_stall","session_dead","session_subagent_start","session_subagent_stop"]),c2=Lt({event:l2,sessionId:Ie(),timestamp:Ie(),data:vl(Ie(),rl())}),u2=3e4,h2=300*1e3;class nl{constructor(r,a,o={}){At(this,"eventSource",null);At(this,"consecutiveFailures",0);At(this,"failStartTime",null);At(this,"destroyed",!1);At(this,"reconnectTimer",null);At(this,"url");At(this,"callbacks");At(this,"onMessage");this.url=r,this.onMessage=a,this.callbacks=o,this.connect()}connect(){this.destroyed||(this.eventSource=new EventSource(this.url),this.eventSource.onmessage=this.onMessage,this.eventSource.onopen=()=>{var r,a;this.destroyed||(this.consecutiveFailures=0,this.failStartTime=null,(a=(r=this.callbacks).onOpen)==null||a.call(r))},this.eventSource.onerror=()=>{var a,o,g,x,T,c,u,h,y;if(this.destroyed)return;if((a=this.eventSource)==null||a.close(),this.eventSource=null,this.failStartTime===null&&(this.failStartTime=Date.now()),Date.now()-this.failStartTime>=h2){(g=(o=this.callbacks).onGiveUp)==null||g.call(o),(T=(x=this.callbacks).onClose)==null||T.call(x);return}this.consecutiveFailures++;const r=Math.min(u2,1e3*Math.pow(2,this.consecutiveFailures-1));(u=(c=this.callbacks).onReconnecting)==null||u.call(c,this.consecutiveFailures,r),(y=(h=this.callbacks).onClose)==null||y.call(h),this.reconnectTimer=setTimeout(()=>this.connect(),r)})}close(){var r;this.destroyed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(r=this.eventSource)==null||r.close(),this.eventSource=null}}const f2="";function d2(i){if(!i)return{};if(i instanceof Headers){const r={};return i.forEach((a,o)=>{r[o]=a}),r}return i}function _2(i,r,a){const o=r.safeParse(i);if(o.success)return o.data;throw console.error(`[aegis] API response validation failed (${a}):`,o.error.issues),new Error(`API response validation failed for ${a}: ${o.error.issues.map(g=>g.message).join(", ")}`)}function m2(i){return!(i.name==="AbortError"||!i.message||i.message.includes("HTTP "))}async function vt(i,r={}){const a=localStorage.getItem("aegis_token"),o={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},...d2(r.headers)},{retries:g=0,schema:x,schemaContext:T,...c}=r;let u=null;for(let h=0;h<=g;h++)try{const y=await fetch(`${f2}${i}`,{...c,headers:o});if(!y.ok){const C=await y.json().catch(()=>({error:y.statusText})),w=new Error(C.error??`HTTP ${y.status}`);throw w.statusCode=y.status,w}const d=await y.json();return x?_2(d,x,T??i):d}catch(y){if(u=y,h<g&&m2(u))await new Promise(d=>setTimeout(d,1e3*Math.pow(2,h)));else throw u}throw u}function p2(){return vt("/v1/health",{schema:Qw,schemaContext:"getHealth"})}function v2(){return vt("/v1/metrics",{schema:n2,schemaContext:"getMetrics"})}function g2(){return vt("/v1/sessions",{schema:e2,schemaContext:"getSessions"})}function y2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}`,{schema:uv,schemaContext:"getSession"})}function S2(i){const{signal:r,...a}=i;return vt("/v1/sessions",{method:"POST",body:JSON.stringify(a),signal:r})}function hv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}`,{method:"DELETE",schema:cv,schemaContext:"killSession"})}function b2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/health`,{schema:t2,schemaContext:"getSessionHealth"})}function C2(){return vt("/v1/sessions/health")}function x2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/read`,{schema:r2,schemaContext:"getSessionMessages"})}function w2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/metrics`,{schema:i2,schemaContext:"getSessionMetrics"})}function E2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/pane`)}function T2(i,r){return vt(`/v1/sessions/${encodeURIComponent(i)}/send`,{method:"POST",body:JSON.stringify({text:r}),schema:Jw,schemaContext:"sendMessage"})}function fv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/approve`,{method:"POST"})}function A2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/reject`,{method:"POST"})}function dv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/interrupt`,{method:"POST"})}function R2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/escape`,{method:"POST"})}const Gm=3,D2=1e3;async function _v(i,r){for(let a=0;a<Gm;a++){if(r!=null&&r.aborted)throw new DOMException("Aborted","AbortError");try{return await B2(r)}catch{if(r!=null&&r.aborted)throw new DOMException("Aborted","AbortError");if(a<Gm-1){const o=D2*Math.pow(2,a);await new Promise(g=>{const x=setTimeout(g,o);r==null||r.addEventListener("abort",()=>{clearTimeout(x),g(void 0)},{once:!0})})}}}throw i==null||i(),new Error("Real-time updates unavailable")}function mv(i,r,a,o){const g=`/v1/sessions/${encodeURIComponent(i)}/events`;let x=null,T=!1;const c=new AbortController;return a?_v(o==null?void 0:o.onGiveUp,c.signal).then(u=>{if(T)return;const h=`${g}?token=${encodeURIComponent(u.token)}`;x=new nl(h,r,o)}).catch(()=>{}):x=new nl(g,r,o),()=>{T=!0,c.abort(),x==null||x.close()}}function k2(i,r,a){const o="/v1/events";let g=null,x=!1;const T=new AbortController,c=u=>{try{const h=c2.safeParse(JSON.parse(u.data));if(!h.success){console.warn("Global SSE event failed validation",h.error.message);return}i(h.data)}catch{}};return r?_v(a==null?void 0:a.onGiveUp,T.signal).then(u=>{if(x)return;const h=`${o}?token=${encodeURIComponent(u.token)}`;g=new nl(h,c,a)}).catch(()=>{}):g=new nl(o,c,a),()=>{var u;x=!0,T.abort(),(u=a==null?void 0:a.onClose)==null||u.call(a),g==null||g.close()}}function O2(i){return vt("/v1/sessions/batch",{method:"POST",signal:i.signal,body:JSON.stringify(i)})}function M2(i){return vt("/v1/pipelines",{method:"POST",body:JSON.stringify(i)})}function L2(){return vt("/v1/pipelines")}function N2(i){return vt(`/v1/pipelines/${encodeURIComponent(i)}`)}function B2(i){return vt("/v1/auth/sse-token",{method:"POST",signal:i})}const qo=new Map;let z2=0;const Xs=Mp(i=>({toasts:[],addToast:(r,a,o)=>{const g=`toast-${++z2}`,x=setTimeout(()=>{qo.delete(g),i(T=>({toasts:T.toasts.filter(c=>c.id!==g)}))},4e3);return qo.set(g,x),i(T=>({toasts:[...T.toasts,{id:g,type:r,title:a,description:o}]})),g},removeToast:r=>{const a=qo.get(r);a&&(clearTimeout(a),qo.delete(r)),i(o=>({toasts:o.toasts.filter(g=>g.id!==r)}))}})),j2={error:"border-red-500/50 bg-red-950/80 text-red-200",success:"border-green-500/50 bg-green-950/80 text-green-200",info:"border-cyan-500/50 bg-cyan-950/80 text-cyan-200",warning:"border-yellow-500/50 bg-yellow-950/80 text-yellow-200"};function H2({id:i,type:r,title:a,description:o}){const g=Xs(x=>x.removeToast);return O.jsxs("div",{role:"alert",className:`flex items-start gap-3 rounded-lg border px-4 py-3 shadow-lg backdrop-blur-sm animate-slide-in ${j2[r]}`,children:[O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsx("p",{className:"text-sm font-medium",children:a}),o&&O.jsx("p",{className:"mt-0.5 text-xs opacity-80",children:o})]}),O.jsx("button",{onClick:()=>g(i),className:"shrink-0 rounded p-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:O.jsx(hl,{className:"h-3.5 w-3.5"})})]})}function U2(){const i=Xs(r=>r.toasts);return i.length===0?null:O.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:i.map(r=>O.jsx("div",{className:"pointer-events-auto",children:O.jsx(H2,{id:r.id,type:r.type,title:r.title,description:r.description})},r.id))})}const I2=[{to:"/",label:"Overview",icon:HS},{to:"/pipelines",label:"Pipelines",icon:kp}];function P2(){const i=Mt(x=>x.sseConnected),r=Mt(x=>x.setSseConnected),a=Mt(x=>x.addActivity),o=Mt(x=>x.token),g=F.useRef(null);return F.useEffect(()=>{const x=k2(T=>{T.sessionId&&a(T)},o,{onOpen:()=>{g.current&&(clearTimeout(g.current),g.current=null),r(!0)},onClose:()=>{g.current=setTimeout(()=>{r(!1)},2e3)}});return()=>{g.current&&clearTimeout(g.current),x()}},[r,a,o]),O.jsxs("div",{className:"flex h-screen overflow-hidden bg-void",children:[O.jsxs("aside",{className:"flex w-56 flex-col border-r border-void-lighter bg-void-light shrink-0",children:[O.jsxs("div",{className:"flex items-center gap-2 px-4 py-5 border-b border-void-lighter",children:[O.jsx(tb,{className:"h-6 w-6 text-cyan glow-text-cyan"}),O.jsx("span",{className:"text-lg font-semibold tracking-tight text-gray-100",children:"Aegis"})]}),O.jsxs("nav",{className:"flex flex-col gap-1 px-2 py-4 flex-1",children:[I2.map(({to:x,label:T,icon:c})=>O.jsxs(Ap,{to:x,end:x==="/",className:({isActive:u})=>`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${u?"bg-cyan/10 text-cyan":"text-gray-400 hover:bg-void-lighter hover:text-gray-200"}`,children:[O.jsx(c,{className:"h-4 w-4"}),T]},x)),O.jsx("div",{className:"mt-4 border-t border-void-lighter pt-4 opacity-40",children:O.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 text-sm text-gray-500",children:[O.jsx(nb,{className:"h-4 w-4"}),"Sessions"]})})]})]}),O.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[O.jsxs("header",{className:"flex items-center justify-between border-b border-void-lighter bg-void-light px-6 py-3 shrink-0",children:[O.jsx("h1",{className:"text-sm font-medium text-gray-300",children:"Aegis Dashboard"}),O.jsx("div",{className:"flex items-center gap-3",children:O.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[O.jsx("span",{className:`status-dot ${i?"status-dot--idle":""}`,style:i?void 0:{backgroundColor:"#666"}}),i?"SSE Live":"SSE Off"]})})]}),O.jsx("main",{className:"flex-1 overflow-auto p-6",children:O.jsx(Iy,{})})]}),O.jsx(U2,{})]})}function $2(i){if(i<0)return"0s";const r=Math.floor(i/3600),a=Math.floor(i%3600/60);return r>0&&a>0?`${r}h ${a}m`:r>0?`${r}h`:a>0?`${a}m`:`${Math.floor(i)}s`}function pr(i){const r=Date.now()-i;if(r<0)return"just now";const a=Math.floor(r/1e3);if(a<60)return`${a}s ago`;const o=Math.floor(a/60);if(o<60)return`${o}m ago`;const g=Math.floor(o/60);return g<24?`${g}h ago`:`${Math.floor(g/24)}d ago`}function F2(i){if(i<0)return"0s";const r=Math.floor(i/1e3);if(r<60)return`${r}s`;const a=Math.floor(r/60),o=r%60;if(a<60)return`${a}m ${o.toString().padStart(2,"0")}s`;const g=Math.floor(a/60),x=a%60;return`${g}h ${x.toString().padStart(2,"0")}m`}function qs({label:i,value:r,icon:a,suffix:o}){return O.jsxs("div",{className:"rounded-lg border border-void-lighter bg-[#111118] p-4",children:[O.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[#888]",children:[a,i]}),O.jsxs("div",{className:"font-mono text-2xl text-[#00e5ff]",children:[r,o&&O.jsx("span",{className:"ml-1 text-base text-[#666]",children:o})]})]})}function Z2(){const i=Mt(y=>y.metrics),r=Mt(y=>y.setMetrics),[a,o]=F.useState(null),g=Xs(y=>y.addToast),x=F.useCallback(async()=>{try{const[y,d]=await Promise.all([v2(),p2()]);r(y),o(d)}catch(y){g("error","Failed to load metrics",y instanceof Error?y.message:void 0)}},[r,o,g]);F.useEffect(()=>{x();const y=setInterval(x,1e4);return()=>clearInterval(y)},[x]);const T=(i==null?void 0:i.sessions.currently_active)??(a==null?void 0:a.sessions.active)??0,c=(i==null?void 0:i.sessions.total_created)??(a==null?void 0:a.sessions.total)??0,u=i==null?void 0:i.prompt_delivery.success_rate,h=(a==null?void 0:a.uptime)??(i==null?void 0:i.uptime)??0;return O.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[O.jsx(qs,{label:"Active Sessions",value:T,icon:O.jsx(kp,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Total Created",value:c,icon:O.jsx(zS,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Delivery Rate",value:u!=null?u.toFixed(1):"—",suffix:"%",icon:O.jsx(mb,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Uptime",value:$2(h),icon:O.jsx(MS,{className:"h-4 w-4"})})]})}const Wm={idle:"#00ff88",working:"#00e5ff",permission_prompt:"#ffaa00",bash_approval:"#ffaa00",plan_mode:"#ff8800",ask_question:"#ff3366",settings:"#00e5ff",unknown:"#666666"},q2=new Set(["working","permission_prompt","bash_approval","ask_question"]);function al({status:i}){const r=Wm[i]??Wm.unknown,a=q2.has(i);return O.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:r,boxShadow:`0 0 6px ${r}66`,animation:a?"pulse 1.5s ease-in-out infinite":void 0}})}function G2(){const i=Mt(y=>y.sessions),r=Mt(y=>y.healthMap),a=Mt(y=>y.setSessionsAndHealth),o=Xs(y=>y.addToast),g=F.useCallback(async()=>{try{const y=await g2();let d={};try{const C=await C2(),w=new Set(y.sessions.map(k=>k.id));for(const[k,b]of Object.entries(C))w.has(k)&&(d[k]={alive:b.alive,loading:!1})}catch{}a(y.sessions,d)}catch(y){o("error","Failed to fetch sessions",y instanceof Error?y.message:void 0)}},[o,a]);F.useEffect(()=>{g();const y=setInterval(g,5e3);return()=>clearInterval(y)},[g]);const x=async(y,d)=>{y.preventDefault();try{await fv(d)}catch(C){o("error","Approve failed",C instanceof Error?C.message:void 0)}},T=async(y,d)=>{y.preventDefault();try{await dv(d)}catch(C){o("error","Interrupt failed",C instanceof Error?C.message:void 0)}},c=async(y,d)=>{if(y.preventDefault(),!!confirm("Kill this session?"))try{await hv(d)}catch(C){o("error","Failed to kill session",C instanceof Error?C.message:void 0)}};if(i.length===0)return O.jsx("div",{className:"rounded-lg border border-void-lighter bg-[#111118] p-12 text-center",children:O.jsx("p",{className:"text-gray-500",children:"No active sessions"})});const u=y=>y.status==="permission_prompt"||y.status==="bash_approval",h=(y,d=40)=>y.length>d?`…${y.slice(y.length-d+1)}`:y;return O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"md:hidden space-y-3",children:i.map(y=>{const d=r[y.id],C=d?d.alive:!0;return O.jsxs(Wi,{to:`/sessions/${encodeURIComponent(y.id)}`,className:"block rounded-lg border border-[#1a1a2e] bg-[#111118] p-4 active:bg-[#1a1a2e]/50 transition-colors",children:[O.jsxs("div",{className:"flex items-center justify-between mb-2",children:[O.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[O.jsx(al,{status:y.status}),O.jsx("span",{className:"font-medium text-gray-200 truncate",children:y.windowName||y.id}),!C&&O.jsx(Po,{className:"h-3.5 w-3.5 text-red-400 shrink-0"})]}),O.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[u(y)&&O.jsx("button",{onClick:w=>x(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-green-900/30 p-2 text-green-400 transition-colors hover:bg-green-900/50",title:"Approve",children:O.jsx(Cm,{className:"h-4 w-4"})}),O.jsx("button",{onClick:w=>T(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-yellow-900/30 p-2 text-yellow-400 transition-colors hover:bg-yellow-900/50",title:"Interrupt",children:O.jsx(Sm,{className:"h-4 w-4"})}),O.jsx("button",{onClick:w=>c(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-red-900/30 p-2 text-red-400 transition-colors hover:bg-red-900/50",title:"Kill",children:O.jsx(Po,{className:"h-4 w-4"})})]})]}),O.jsx("div",{className:"font-mono text-xs text-gray-500 truncate mb-1.5",children:h(y.workDir,50)}),O.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500",children:[O.jsxs("span",{children:["Age: ",pr(y.createdAt)]}),O.jsxs("span",{children:["Active: ",pr(y.lastActivity)]}),y.permissionMode&&y.permissionMode!=="default"?O.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-900/30 px-2 py-0.5 text-green-400",children:[O.jsx(bm,{className:"h-3 w-3"})," ",y.permissionMode]}):null]})]},y.id)})}),O.jsx("div",{className:"hidden md:block overflow-x-auto rounded-lg border border-void-lighter bg-[#111118]",children:O.jsxs("table",{className:"w-full text-left text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"border-b border-void-lighter text-[#666]",children:[O.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Name"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"WorkDir"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Age"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Last Activity"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Permission"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Actions"})]})}),O.jsx("tbody",{children:i.map(y=>{const d=r[y.id],C=d?d.alive:!0;return O.jsxs("tr",{className:"border-b border-void-lighter/50 transition-colors hover:border-l-2 hover:border-l-cyan",children:[O.jsx("td",{className:"px-4 py-3",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(al,{status:y.status}),!C&&O.jsx(Po,{className:"h-3.5 w-3.5 text-red-400"})]})}),O.jsx("td",{className:"px-4 py-3",children:O.jsx(Wi,{to:`/sessions/${encodeURIComponent(y.id)}`,className:"font-medium text-gray-200 hover:text-cyan transition-colors",children:y.windowName||y.id})}),O.jsx("td",{className:"px-4 py-3 max-w-[200px] truncate font-mono text-xs text-gray-400",title:y.workDir,children:h(y.workDir)}),O.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-gray-400",children:pr(y.createdAt)}),O.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-gray-400",children:pr(y.lastActivity)}),O.jsx("td",{className:"px-4 py-3",children:y.permissionMode&&y.permissionMode!=="default"?O.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-900/30 px-2 py-0.5 text-xs text-green-400",children:[O.jsx(bm,{className:"h-3 w-3"}),y.permissionMode]}):O.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-void-lighter px-2 py-0.5 text-xs text-gray-500",children:"default"})}),O.jsx("td",{className:"px-4 py-3",children:O.jsxs("div",{className:"flex items-center gap-1.5",children:[u(y)&&O.jsx("button",{onClick:w=>x(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-green-900/30 text-xs font-medium text-green-400 transition-colors hover:bg-green-900/50",title:"Approve",children:O.jsx(Cm,{className:"h-3 w-3"})}),O.jsx("button",{onClick:w=>T(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-yellow-900/30 text-xs font-medium text-yellow-400 transition-colors hover:bg-yellow-900/50",title:"Interrupt",children:O.jsx(Sm,{className:"h-3 w-3"})}),O.jsx("button",{onClick:w=>c(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-red-900/30 text-xs font-medium text-red-400 transition-colors hover:bg-red-900/50",title:"Kill",children:O.jsx(Po,{className:"h-3 w-3"})})]})})]},y.id)})})]})})]})}const ju={session_status_change:{icon:VS,label:"Status",color:"#00e5ff"},session_message:{icon:PS,label:"Message",color:"#00ff88"},session_approval:{icon:QS,label:"Approval",color:"#ffaa00"},session_ended:{icon:WS,label:"Ended",color:"#ff3366"},session_created:{icon:DS,label:"Created",color:"#a78bfa"},session_stall:{icon:lb,label:"Stall",color:"#ff6600"},session_dead:{icon:sb,label:"Dead",color:"#ff0044"},session_subagent_start:{icon:fb,label:"Subagent",color:"#38bdf8"},session_subagent_stop:{icon:ub,label:"Subagent Done",color:"#34d399"}};function mr(i,r="unknown"){return typeof i=="string"?i:r}function W2(i){const r=i.data;switch(i.event){case"session_status_change":{const a=mr(r.status),o=typeof r.detail=="string"?`: ${r.detail}`:"";return`Status → ${a}${o}`}case"session_message":{const a=r.role==="user"?"User":r.role==="assistant"?"Claude":"System",o=typeof r.text=="string"?r.text:JSON.stringify(r.text??"");return`${a}: ${Ym(o,80)}`}case"session_approval":{const a=typeof r.prompt=="string"?r.prompt:JSON.stringify(r.prompt??"");return`Approval needed: ${Ym(a,80)}`}case"session_ended":return`Session ended: ${mr(r.reason)}`;case"session_created":return`Created in ${mr(r.workDir,"unknown dir")}`;case"session_stall":return`Session stalled: ${mr(r.stallType)}`;case"session_dead":return`Session dead: ${mr(r.stallType)}`;case"session_subagent_start":return`Subagent started: ${mr(r.name)}`;case"session_subagent_stop":return`Subagent finished: ${mr(r.name)}`;default:return JSON.stringify(r)}}function Ym(i,r){return i.length>r?i.slice(0,r)+"...":i}function Y2(i){try{return new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function V2(){const i=Mt(h=>h.activities),r=Mt(h=>h.activityFilterSession),a=Mt(h=>h.activityFilterType),o=Mt(h=>h.setActivityFilterSession),g=Mt(h=>h.setActivityFilterType),x=Mt(h=>h.sessions),T=F.useMemo(()=>i.filter(h=>!(r&&h.sessionId!==r||a&&h.event!==a)),[i,r,a]),c=F.useMemo(()=>{const h=new Map;for(const y of x)h.set(y.id,y.windowName??y.id.slice(0,8));return h},[x]),u=h=>c.get(h)??(h??"unknown").slice(0,8);return O.jsxs("div",{className:"bg-[#111118] border border-[#1a1a2e] rounded-lg w-full",children:[O.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 px-3 sm:px-4 py-3 border-b border-[#1a1a2e]",children:[O.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Activity Stream"}),O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsxs("select",{value:r??"",onChange:h=>o(h.target.value||null),className:"min-h-[44px] text-xs bg-[#0a0a0f] border border-[#1a1a2e] rounded px-2 py-2 text-gray-400 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"",children:"All sessions"}),x.map(h=>O.jsx("option",{value:h.id,children:h.windowName||h.id.slice(0,8)},h.id))]}),O.jsxs("select",{value:a??"",onChange:h=>g(h.target.value||null),className:"min-h-[44px] text-xs bg-[#0a0a0f] border border-[#1a1a2e] rounded px-2 py-2 text-gray-400 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"",children:"All types"}),Object.entries(ju).map(([h,y])=>O.jsx("option",{value:h,children:y.label},h))]}),(r||a)&&O.jsx("button",{onClick:()=>{o(null),g(null)},className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-gray-300",children:O.jsx(hl,{className:"h-4 w-4"})})]})]}),O.jsxs("div",{className:"max-h-[360px] overflow-y-auto divide-y divide-[#1a1a2e]/50",children:[T.length===0&&O.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#555]",children:"No activity yet"}),T.map((h,y)=>{const d=ju[h.event]??ju.session_status_change,C=d.icon;return O.jsxs("div",{className:"flex items-start gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-2.5 hover:bg-[#1a1a2e]/30 transition-colors",children:[O.jsx(C,{className:"h-4 w-4 mt-0.5 shrink-0",style:{color:d.color}}),O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[O.jsx("span",{className:"text-xs font-medium text-gray-300 truncate",children:u(h.sessionId)}),O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded hidden sm:inline-block",style:{backgroundColor:`${d.color}15`,color:d.color},children:d.label})]}),O.jsx("p",{className:"text-xs text-gray-500 mt-0.5 font-mono truncate",children:W2(h)})]}),O.jsx("span",{className:"text-[10px] text-[#444] shrink-0 tabular-nums mt-0.5",children:Y2(h.timestamp)})]},`${h.sessionId}-${h.timestamp}-${y}`)})]})]})}function K2({open:i,onClose:r}){const a=ll(),o=F.useRef(null),g=F.useRef(null),x=F.useCallback(()=>{P(),r()},[r]),T=F.useRef(null);F.useEffect(()=>{if(!i)return;const N=U=>{var L;U.key==="Escape"&&((L=g.current)==null||L.abort(),x())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[i,x]),F.useEffect(()=>{if(!i)return;const N=T.current;if(!N)return;const U='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',L=H=>{if(H.key!=="Tab")return;const V=Array.from(N.querySelectorAll(U));if(V.length===0)return;const re=V[0],ue=V[V.length-1];H.shiftKey?document.activeElement===re&&(H.preventDefault(),ue.focus()):document.activeElement===ue&&(H.preventDefault(),re.focus())};return N.addEventListener("keydown",L),()=>N.removeEventListener("keydown",L)},[i]),F.useEffect(()=>{if(i){const N=setTimeout(()=>{var U;return(U=o.current)==null?void 0:U.focus()},50);return()=>clearTimeout(N)}},[i]);const[c,u]=F.useState(""),[h,y]=F.useState(""),[d,C]=F.useState(""),[w,k]=F.useState("default"),[b,m]=F.useState(!1),[v,f]=F.useState(null);let p=0;function S(){return{workDir:"",name:"",prompt:"",_key:p++}}const[A,R]=F.useState("single"),[M,E]=F.useState([S(),S()]),[B,$]=F.useState(""),[I,q]=F.useState(null);function P(){u(""),y(""),C(""),k("default"),m(!1),f(null),E([S(),S()]),$(""),q(null),R("single")}function J(){M.length>=10||E([...M,S()])}function te(N){M.length<=1||E(M.filter((U,L)=>L!==N))}function G(N,U,L){E(M.map((H,V)=>V===N?{...H,[U]:L}:H))}async function se(N){var H;N.preventDefault(),f(null),q(null);const U=M.filter(V=>V.workDir.trim());if(U.length===0){f("At least one working directory is required");return}m(!0),(H=g.current)==null||H.abort();const L=new AbortController;g.current=L;try{const V=await O2({sessions:U.map(re=>({workDir:re.workDir.trim(),name:re.name.trim()||void 0,prompt:re.prompt.trim()||B.trim()||void 0,permissionMode:w})),signal:L.signal});q(V)}catch(V){if(L.signal.aborted)return;f(V instanceof Error?V.message:"Failed to create sessions")}finally{g.current===L&&(g.current=null,m(!1))}}if(!i)return null;async function ae(N){var L;if(N.preventDefault(),f(null),!c.trim()){f("Working directory is required");return}m(!0),(L=g.current)==null||L.abort();const U=new AbortController;g.current=U;try{const H=await S2({workDir:c.trim(),name:h.trim()||void 0,prompt:d.trim()||void 0,permissionMode:w,signal:U.signal});P(),r(),a(`/sessions/${H.id}`)}catch(H){if(U.signal.aborted)return;f(H instanceof Error?H.message:"Failed to create session")}finally{g.current===U&&(g.current=null,m(!1))}}return O.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[O.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:x}),O.jsxs("div",{ref:T,role:"dialog","aria-modal":"true","aria-label":"Create new session",className:`relative w-full ${A==="batch"?"max-w-2xl":"max-w-md"} mx-4 bg-[#111118] border border-[#1a1a2e] rounded-lg shadow-2xl max-h-[90vh] overflow-y-auto`,children:[O.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-4 border-b border-[#1a1a2e]",children:[O.jsxs("div",{className:"flex items-center gap-4",children:[O.jsx("h2",{className:"text-sm font-semibold text-gray-100",children:"New Session"}),O.jsxs("div",{className:"flex rounded bg-[#0a0a0f] p-0.5",children:[O.jsx("button",{type:"button",onClick:()=>R("single"),className:`px-3 py-1 text-xs rounded transition-colors ${A==="single"?"bg-[#00e5ff]/10 text-[#00e5ff]":"text-gray-500 hover:text-gray-300"}`,children:"Single"}),O.jsx("button",{type:"button",onClick:()=>R("batch"),className:`px-3 py-1 text-xs rounded transition-colors ${A==="batch"?"bg-[#00e5ff]/10 text-[#00e5ff]":"text-gray-500 hover:text-gray-300"}`,children:"Batch"})]})]}),O.jsx("button",{onClick:x,className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-gray-300 transition-colors",children:O.jsx(hl,{className:"h-4 w-4"})})]}),A==="single"&&O.jsxs("form",{onSubmit:ae,className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{children:[O.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:["Working Directory ",O.jsx("span",{className:"text-[#ff3366]",children:"*"})]}),O.jsx("input",{type:"text",ref:o,value:c,onChange:N=>u(N.target.value),placeholder:"/home/user/project",className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] font-mono"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Session Name"}),O.jsx("input",{type:"text",value:h,onChange:N=>y(N.target.value),placeholder:"my-session",className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Initial Prompt"}),O.jsx("textarea",{value:d,onChange:N=>C(N.target.value),placeholder:"Fix the login bug...",rows:3,className:"w-full min-h-[88px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] resize-none"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Permission Mode"}),O.jsxs("select",{value:w,onChange:N=>k(N.target.value),className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"default",children:"default — asks for everything"}),O.jsx("option",{value:"plan",children:"plan — auto-reads, asks for writes"}),O.jsx("option",{value:"acceptEdits",children:"acceptEdits — auto-edits, asks for bash"}),O.jsx("option",{value:"bypassPermissions",children:"bypassPermissions — never asks"}),O.jsx("option",{value:"auto",children:"auto — auto-approve in sandbox"})]})]}),v&&O.jsx("div",{className:"text-xs text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-2",children:v}),O.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Cancel"}),O.jsxs("button",{type:"submit",disabled:b||!c.trim(),className:"min-h-[44px] flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[b&&O.jsx(Ku,{className:"h-3 w-3 animate-spin"}),"Create Session"]})]})]}),A==="batch"&&!I&&O.jsxs("form",{onSubmit:se,className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Shared Prompt"}),O.jsx("textarea",{value:B,onChange:N=>$(N.target.value),placeholder:"Apply to all sessions without a per-row prompt...",rows:2,className:"w-full min-h-[88px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] resize-none"})]}),O.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_44px] gap-2 text-xs font-medium text-gray-500 px-1",children:[O.jsxs("span",{children:["Working Directory ",O.jsx("span",{className:"text-[#ff3366]",children:"*"})]}),O.jsx("span",{children:"Name"}),O.jsx("span",{children:"Prompt (override)"}),O.jsx("span",{})]}),O.jsx("div",{className:"space-y-2",children:M.map((N,U)=>O.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_44px] gap-2 items-start",children:[O.jsx("input",{type:"text",value:N.workDir,onChange:L=>G(U,"workDir",L.target.value),placeholder:"/home/user/project",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] font-mono"}),O.jsx("input",{type:"text",value:N.name,onChange:L=>G(U,"name",L.target.value),placeholder:"name",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"}),O.jsx("input",{type:"text",value:N.prompt,onChange:L=>G(U,"prompt",L.target.value),placeholder:"Override prompt...",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"}),O.jsx("button",{type:"button",onClick:()=>te(U),disabled:M.length<=1,className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-[#ff3366] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:O.jsx(Op,{className:"h-3.5 w-3.5"})})]},N._key))}),M.length<10&&O.jsxs("button",{type:"button",onClick:J,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-gray-300 transition-colors",children:[O.jsx(ul,{className:"h-3.5 w-3.5"}),"Add session"]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Permission Mode"}),O.jsxs("select",{value:w,onChange:N=>k(N.target.value),className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"default",children:"default — asks for everything"}),O.jsx("option",{value:"plan",children:"plan — auto-reads, asks for writes"}),O.jsx("option",{value:"acceptEdits",children:"acceptEdits — auto-edits, asks for bash"}),O.jsx("option",{value:"bypassPermissions",children:"bypassPermissions — never asks"}),O.jsx("option",{value:"auto",children:"auto — auto-approve in sandbox"})]})]}),v&&O.jsx("div",{className:"text-xs text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-2",children:v}),O.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Cancel"}),O.jsxs("button",{type:"submit",disabled:b||!M.some(N=>N.workDir.trim()),className:"min-h-[44px] flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[b&&O.jsx(Ku,{className:"h-3 w-3 animate-spin"}),"Create ",M.filter(N=>N.workDir.trim()).length," Session(s)"]})]})]}),I&&O.jsxs("div",{className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[I.created>0&&O.jsxs("span",{className:"text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/20 rounded px-3 py-1.5",children:[I.created," created"]}),I.failed>0&&O.jsxs("span",{className:"text-xs font-medium text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-1.5",children:[I.failed," failed"]})]}),I.sessions.length>0&&O.jsxs("div",{className:"space-y-1",children:[O.jsx("p",{className:"text-xs font-medium text-gray-400",children:"Created sessions"}),O.jsx("ul",{className:"space-y-1",children:I.sessions.map(N=>O.jsx("li",{children:O.jsxs("button",{type:"button",onClick:()=>{x(),a(`/sessions/${N.id}`)},className:"text-xs text-[#00e5ff] hover:underline font-mono",children:[N.id.slice(0,8),"...",N.name?` — ${N.name}`:""]})},N.id))})]}),I.errors.length>0&&O.jsxs("div",{className:"space-y-1",children:[O.jsx("p",{className:"text-xs font-medium text-gray-400",children:"Errors"}),O.jsx("ul",{className:"space-y-1",children:I.errors.map((N,U)=>O.jsx("li",{className:"text-xs text-[#ff3366]",children:N},U))})]}),O.jsx("div",{className:"flex justify-end pt-2",children:O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Close"})})]})]})]})}function X2(){const[i,r]=F.useState(!1);return O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"flex items-center justify-between",children:[O.jsxs("div",{children:[O.jsx("h2",{className:"text-2xl font-bold text-gray-100",children:"Overview"}),O.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Aegis session monitoring and metrics"})]}),O.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors",children:[O.jsx(ul,{className:"h-3.5 w-3.5"}),"New Session"]})]}),O.jsx(Z2,{}),O.jsxs("div",{children:[O.jsx("h3",{className:"mb-3 text-lg font-semibold text-gray-200",children:"Sessions"}),O.jsx(G2,{})]}),O.jsx(V2,{}),O.jsx(K2,{open:i,onClose:()=>r(!1)})]})}function Vm(i){return i instanceof Error&&"statusCode"in i}function J2(i){const r=Mt(J=>J.token),a=Xs(J=>J.addToast),[o,g]=F.useState(null),[x,T]=F.useState(null),[c,u]=F.useState(!1),[h,y]=F.useState(!0),[d,C]=F.useState(""),[w,k]=F.useState(!0),[b,m]=F.useState(null),[v,f]=F.useState(!0),p=F.useRef(i);p.current=i;const S=F.useRef(!1),A=F.useRef(0),R=F.useRef(void 0),M=F.useRef(void 0),E=F.useCallback(async()=>{try{const[J,te]=await Promise.allSettled([y2(p.current),b2(p.current)]);if(J.status==="rejected"&&Vm(J.reason)&&J.reason.statusCode===404||te.status==="rejected"&&Vm(te.reason)&&te.reason.statusCode===404){u(!0);return}J.status==="fulfilled"&&g(J.value),te.status==="fulfilled"&&T(te.value)}catch(J){a("error","Failed to load session",J instanceof Error?J.message:void 0)}finally{y(!1)}},[a]);R.current=E;const B=F.useCallback(async()=>{if(S.current)return;const J=p.current;try{const te=await E2(J);S.current||C(te.pane??"")}catch(te){a("warning","Failed to load terminal pane",te instanceof Error?te.message:void 0)}finally{S.current||k(!1)}try{const te=await w2(J);S.current||m(te)}catch(te){a("warning","Failed to load session metrics",te instanceof Error?te.message:void 0)}finally{S.current||f(!1)}},[a]);M.current=B,F.useEffect(()=>(S.current=!1,A.current++,y(!0),k(!0),f(!0),E(),B(),()=>{S.current=!0,$.current&&clearTimeout($.current),I.current&&clearTimeout(I.current)}),[i,E,B]);const $=F.useRef(void 0),I=F.useRef(void 0),q=F.useCallback(()=>{$.current&&clearTimeout($.current);const J=A.current;$.current=setTimeout(()=>{var te;A.current===J&&((te=M.current)==null||te.call(M))},1e3)},[]),P=F.useCallback(()=>{I.current&&clearTimeout(I.current);const J=A.current;I.current=setTimeout(()=>{var te;A.current===J&&((te=R.current)==null||te.call(R))},1e3)},[]);return F.useEffect(()=>{if(!i)return;const J=mv(i,te=>{var G,se;try{const ae=o2.safeParse(JSON.parse(te.data));if(!ae.success){console.warn("SSE event failed validation",ae.error.message);return}switch(ae.data.event){case"status":case"approval":case"stall":case"dead":P(),q();break;case"message":q();break;case"ended":(G=R.current)==null||G.call(R),(se=M.current)==null||se.call(M);break}}catch{}},r);return()=>J()},[i,r,P,q]),{session:o,health:x,notFound:c,loading:h,paneContent:d,paneLoading:w,metrics:b,metricsLoading:v,refetchPaneAndMetrics:B}}const Q2={idle:"Idle",working:"Working",permission_prompt:"Permission",plan_mode:"Planning",ask_question:"Question",bash_approval:"Bash Approval",settings:"Settings",unknown:"Unknown"};function Km(i,r){if(i.length<=r)return i;const a=i.slice(0,Math.ceil(r/2)-1),o=i.slice(-(Math.floor(r/2)-2));return`${a}…${o}`}function Xm(i){return new Date(i).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function eE({session:i,health:r,onApprove:a,onReject:o,onInterrupt:g,onKill:x}){const[T,c]=F.useState(!1),u=r.status==="permission_prompt"||r.status==="bash_approval";return O.jsxs("div",{className:"bg-[#111118] border border-[#1a1a2e] rounded-lg p-3 sm:p-4",children:[O.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[O.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[O.jsx(al,{status:r.status}),O.jsx("span",{className:"text-sm font-medium text-[#e0e0e0]",children:Q2[r.status]})]}),O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsx("h1",{className:"text-base sm:text-lg font-semibold text-[#e0e0e0] truncate",children:i.windowName||"Untitled Session"}),O.jsx("div",{className:"text-xs text-[#555] font-mono truncate mt-0.5",children:Km(i.workDir,40)})]}),O.jsxs("div",{className:"hidden sm:flex items-center gap-2 shrink-0",children:[i.permissionMode&&i.permissionMode!=="default"&&O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#003322] text-[#00ff88] border border-[#00ff88]/30",children:i.permissionMode}),r.alive?O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#111118] text-[#888] border border-[#1a1a2e]",children:"Alive"}):O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#331111] text-[#ff3366] border border-[#ff3366]/30",children:"Dead"})]})]}),O.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 text-[11px] text-[#555] mb-3 flex-wrap",children:[O.jsxs("span",{children:["Created: ",Xm(i.createdAt)]}),O.jsxs("span",{className:"hidden sm:inline",children:["Last activity: ",Xm(i.lastActivity)]}),O.jsxs("span",{className:"font-mono hidden sm:inline",children:["ID: ",Km(i.id,16)]}),r.details&&O.jsx("span",{className:"text-[#888] italic",children:r.details})]}),O.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&O.jsxs(O.Fragment,{children:[O.jsx("button",{onClick:a,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#003322] hover:bg-[#004433] text-[#00ff88] border border-[#00ff88]/30 transition-colors",children:"Approve"}),O.jsx("button",{onClick:o,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#331111] hover:bg-[#442222] text-[#ff3366] border border-[#ff3366]/30 transition-colors",children:"Reject"})]}),O.jsx("button",{onClick:g,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors",children:"Interrupt"}),T?O.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[O.jsx("span",{className:"text-xs text-[#ff3366]",children:"Confirm kill?"}),O.jsx("button",{onClick:()=>{x==null||x(),c(!1)},className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#331111] text-[#ff3366] border border-[#ff3366]/30 transition-colors",children:"Yes, Kill"}),O.jsx("button",{onClick:()=>c(!1),className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors",children:"Cancel"})]}):O.jsx("button",{onClick:()=>c(!0),className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors ml-auto",children:"Kill"})]})]})}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:pv,setPrototypeOf:Jm,isFrozen:tE,getPrototypeOf:iE,getOwnPropertyDescriptor:sE}=Object;let{freeze:Yt,seal:ki,create:Xo}=Object,{apply:eh,construct:th}=typeof Reflect<"u"&&Reflect;Yt||(Yt=function(r){return r});ki||(ki=function(r){return r});eh||(eh=function(r,a){for(var o=arguments.length,g=new Array(o>2?o-2:0),x=2;x<o;x++)g[x-2]=arguments[x];return r.apply(a,g)});th||(th=function(r){for(var a=arguments.length,o=new Array(a>1?a-1:0),g=1;g<a;g++)o[g-1]=arguments[g];return new r(...o)});const Go=Vt(Array.prototype.forEach),rE=Vt(Array.prototype.lastIndexOf),Qm=Vt(Array.prototype.pop),ua=Vt(Array.prototype.push),nE=Vt(Array.prototype.splice),Jo=Vt(String.prototype.toLowerCase),Hu=Vt(String.prototype.toString),Uu=Vt(String.prototype.match),ha=Vt(String.prototype.replace),aE=Vt(String.prototype.indexOf),oE=Vt(String.prototype.trim),_i=Vt(Object.prototype.hasOwnProperty),Gt=Vt(RegExp.prototype.test),fa=lE(TypeError);function Vt(i){return function(r){r instanceof RegExp&&(r.lastIndex=0);for(var a=arguments.length,o=new Array(a>1?a-1:0),g=1;g<a;g++)o[g-1]=arguments[g];return eh(i,r,o)}}function lE(i){return function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return th(i,a)}}function Me(i,r){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jo;Jm&&Jm(i,null);let o=r.length;for(;o--;){let g=r[o];if(typeof g=="string"){const x=a(g);x!==g&&(tE(r)||(r[o]=x),g=x)}i[g]=!0}return i}function cE(i){for(let r=0;r<i.length;r++)_i(i,r)||(i[r]=null);return i}function qi(i){const r=Xo(null);for(const[a,o]of pv(i))_i(i,a)&&(Array.isArray(o)?r[a]=cE(o):o&&typeof o=="object"&&o.constructor===Object?r[a]=qi(o):r[a]=o);return r}function da(i,r){for(;i!==null;){const o=sE(i,r);if(o){if(o.get)return Vt(o.get);if(typeof o.value=="function")return Vt(o.value)}i=iE(i)}function a(){return null}return a}const ep=Yt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Iu=Yt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Pu=Yt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),uE=Yt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),$u=Yt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hE=Yt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),tp=Yt(["#text"]),ip=Yt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Fu=Yt(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),sp=Yt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wo=Yt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fE=ki(/\{\{[\w\W]*|[\w\W]*\}\}/gm),dE=ki(/<%[\w\W]*|[\w\W]*%>/gm),_E=ki(/\$\{[\w\W]*/gm),mE=ki(/^data-[\-\w.\u00B7-\uFFFF]+$/),pE=ki(/^aria-[\-\w]+$/),vv=ki(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vE=ki(/^(?:\w+script|data):/i),gE=ki(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gv=ki(/^html$/i),yE=ki(/^[a-z][.\w]*(-[.\w]+)+$/i);var rp=Object.freeze({__proto__:null,ARIA_ATTR:pE,ATTR_WHITESPACE:gE,CUSTOM_ELEMENT:yE,DATA_ATTR:mE,DOCTYPE_NAME:gv,ERB_EXPR:dE,IS_ALLOWED_URI:vv,IS_SCRIPT_OR_DATA:vE,MUSTACHE_EXPR:fE,TMPLIT_EXPR:_E});const _a={element:1,text:3,progressingInstruction:7,comment:8,document:9},SE=function(){return typeof window>"u"?null:window},bE=function(r,a){if(typeof r!="object"||typeof r.createPolicy!="function")return null;let o=null;const g="data-tt-policy-suffix";a&&a.hasAttribute(g)&&(o=a.getAttribute(g));const x="dompurify"+(o?"#"+o:"");try{return r.createPolicy(x,{createHTML(T){return T},createScriptURL(T){return T}})}catch{return console.warn("TrustedTypes policy "+x+" could not be created."),null}},np=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function yv(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:SE();const r=Se=>yv(Se);if(r.version="3.3.3",r.removed=[],!i||!i.document||i.document.nodeType!==_a.document||!i.Element)return r.isSupported=!1,r;let{document:a}=i;const o=a,g=o.currentScript,{DocumentFragment:x,HTMLTemplateElement:T,Node:c,Element:u,NodeFilter:h,NamedNodeMap:y=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:C,trustedTypes:w}=i,k=u.prototype,b=da(k,"cloneNode"),m=da(k,"remove"),v=da(k,"nextSibling"),f=da(k,"childNodes"),p=da(k,"parentNode");if(typeof T=="function"){const Se=a.createElement("template");Se.content&&Se.content.ownerDocument&&(a=Se.content.ownerDocument)}let S,A="";const{implementation:R,createNodeIterator:M,createDocumentFragment:E,getElementsByTagName:B}=a,{importNode:$}=o;let I=np();r.isSupported=typeof pv=="function"&&typeof p=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:P,TMPLIT_EXPR:J,DATA_ATTR:te,ARIA_ATTR:G,IS_SCRIPT_OR_DATA:se,ATTR_WHITESPACE:ae,CUSTOM_ELEMENT:N}=rp;let{IS_ALLOWED_URI:U}=rp,L=null;const H=Me({},[...ep,...Iu,...Pu,...$u,...tp]);let V=null;const re=Me({},[...ip,...Fu,...sp,...Wo]);let ue=Object.seal(Xo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),me=null,Y=null;const j=Object.seal(Xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ce=!0,oe=!0,ve=!1,pe=!0,Te=!1,je=!0,Ue=!1,ct=!1,Ee=!1,Ft=!1,mi=!1,pi=!1,Ui=!0,Vi=!1;const Pt="user-content-";let nt=!0,Rt=!1,Zt={},Nt=null;const Bt=Me({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ki=null;const Kt=Me({},["audio","video","img","source","image","track"]);let Li=null;const Ye=Me({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vi="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",kt="http://www.w3.org/1999/xhtml";let gt=kt,un=!1,hn=null;const gl=Me({},[vi,Dt,kt],Hu);let Xi=Me({},["mi","mo","mn","ms","mtext"]),Ji=Me({},["annotation-xml"]);const gr=Me({},["title","style","font","a","script"]);let ai=null;const yr=["application/xhtml+xml","text/html"],Js="text/html";let _t=null,Qi=null;const fn=a.createElement("form"),bs=function(W){return W instanceof RegExp||W instanceof Function},dn=function(){let W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qi&&Qi===W)){if((!W||typeof W!="object")&&(W={}),W=qi(W),ai=yr.indexOf(W.PARSER_MEDIA_TYPE)===-1?Js:W.PARSER_MEDIA_TYPE,_t=ai==="application/xhtml+xml"?Hu:Jo,L=_i(W,"ALLOWED_TAGS")?Me({},W.ALLOWED_TAGS,_t):H,V=_i(W,"ALLOWED_ATTR")?Me({},W.ALLOWED_ATTR,_t):re,hn=_i(W,"ALLOWED_NAMESPACES")?Me({},W.ALLOWED_NAMESPACES,Hu):gl,Li=_i(W,"ADD_URI_SAFE_ATTR")?Me(qi(Ye),W.ADD_URI_SAFE_ATTR,_t):Ye,Ki=_i(W,"ADD_DATA_URI_TAGS")?Me(qi(Kt),W.ADD_DATA_URI_TAGS,_t):Kt,Nt=_i(W,"FORBID_CONTENTS")?Me({},W.FORBID_CONTENTS,_t):Bt,me=_i(W,"FORBID_TAGS")?Me({},W.FORBID_TAGS,_t):qi({}),Y=_i(W,"FORBID_ATTR")?Me({},W.FORBID_ATTR,_t):qi({}),Zt=_i(W,"USE_PROFILES")?W.USE_PROFILES:!1,ce=W.ALLOW_ARIA_ATTR!==!1,oe=W.ALLOW_DATA_ATTR!==!1,ve=W.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=W.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=W.SAFE_FOR_TEMPLATES||!1,je=W.SAFE_FOR_XML!==!1,Ue=W.WHOLE_DOCUMENT||!1,Ft=W.RETURN_DOM||!1,mi=W.RETURN_DOM_FRAGMENT||!1,pi=W.RETURN_TRUSTED_TYPE||!1,Ee=W.FORCE_BODY||!1,Ui=W.SANITIZE_DOM!==!1,Vi=W.SANITIZE_NAMED_PROPS||!1,nt=W.KEEP_CONTENT!==!1,Rt=W.IN_PLACE||!1,U=W.ALLOWED_URI_REGEXP||vv,gt=W.NAMESPACE||kt,Xi=W.MATHML_TEXT_INTEGRATION_POINTS||Xi,Ji=W.HTML_INTEGRATION_POINTS||Ji,ue=W.CUSTOM_ELEMENT_HANDLING||{},W.CUSTOM_ELEMENT_HANDLING&&bs(W.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ue.tagNameCheck=W.CUSTOM_ELEMENT_HANDLING.tagNameCheck),W.CUSTOM_ELEMENT_HANDLING&&bs(W.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ue.attributeNameCheck=W.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),W.CUSTOM_ELEMENT_HANDLING&&typeof W.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=W.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Te&&(oe=!1),mi&&(Ft=!0),Zt&&(L=Me({},tp),V=Xo(null),Zt.html===!0&&(Me(L,ep),Me(V,ip)),Zt.svg===!0&&(Me(L,Iu),Me(V,Fu),Me(V,Wo)),Zt.svgFilters===!0&&(Me(L,Pu),Me(V,Fu),Me(V,Wo)),Zt.mathMl===!0&&(Me(L,$u),Me(V,sp),Me(V,Wo))),_i(W,"ADD_TAGS")||(j.tagCheck=null),_i(W,"ADD_ATTR")||(j.attributeCheck=null),W.ADD_TAGS&&(typeof W.ADD_TAGS=="function"?j.tagCheck=W.ADD_TAGS:(L===H&&(L=qi(L)),Me(L,W.ADD_TAGS,_t))),W.ADD_ATTR&&(typeof W.ADD_ATTR=="function"?j.attributeCheck=W.ADD_ATTR:(V===re&&(V=qi(V)),Me(V,W.ADD_ATTR,_t))),W.ADD_URI_SAFE_ATTR&&Me(Li,W.ADD_URI_SAFE_ATTR,_t),W.FORBID_CONTENTS&&(Nt===Bt&&(Nt=qi(Nt)),Me(Nt,W.FORBID_CONTENTS,_t)),W.ADD_FORBID_CONTENTS&&(Nt===Bt&&(Nt=qi(Nt)),Me(Nt,W.ADD_FORBID_CONTENTS,_t)),nt&&(L["#text"]=!0),Ue&&Me(L,["html","head","body"]),L.table&&(Me(L,["tbody"]),delete me.tbody),W.TRUSTED_TYPES_POLICY){if(typeof W.TRUSTED_TYPES_POLICY.createHTML!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof W.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=W.TRUSTED_TYPES_POLICY,A=S.createHTML("")}else S===void 0&&(S=bE(w,g)),S!==null&&typeof A=="string"&&(A=S.createHTML(""));Yt&&Yt(W),Qi=W}},_n=Me({},[...Iu,...Pu,...uE]),mn=Me({},[...$u,...hE]),xa=function(W){let _e=p(W);(!_e||!_e.tagName)&&(_e={namespaceURI:gt,tagName:"template"});const ge=Jo(W.tagName),Ze=Jo(_e.tagName);return hn[W.namespaceURI]?W.namespaceURI===Dt?_e.namespaceURI===kt?ge==="svg":_e.namespaceURI===vi?ge==="svg"&&(Ze==="annotation-xml"||Xi[Ze]):!!_n[ge]:W.namespaceURI===vi?_e.namespaceURI===kt?ge==="math":_e.namespaceURI===Dt?ge==="math"&&Ji[Ze]:!!mn[ge]:W.namespaceURI===kt?_e.namespaceURI===Dt&&!Ji[Ze]||_e.namespaceURI===vi&&!Xi[Ze]?!1:!mn[ge]&&(gr[ge]||!_n[ge]):!!(ai==="application/xhtml+xml"&&hn[W.namespaceURI]):!1},Xt=function(W){ua(r.removed,{element:W});try{p(W).removeChild(W)}catch{m(W)}},Ni=function(W,_e){try{ua(r.removed,{attribute:_e.getAttributeNode(W),from:_e})}catch{ua(r.removed,{attribute:null,from:_e})}if(_e.removeAttribute(W),W==="is")if(Ft||mi)try{Xt(_e)}catch{}else try{_e.setAttribute(W,"")}catch{}},pn=function(W){let _e=null,ge=null;if(Ee)W="<remove></remove>"+W;else{const ke=Uu(W,/^[\r\n\t ]+/);ge=ke&&ke[0]}ai==="application/xhtml+xml"&>===kt&&(W='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+W+"</body></html>");const Ze=S?S.createHTML(W):W;if(gt===kt)try{_e=new C().parseFromString(Ze,ai)}catch{}if(!_e||!_e.documentElement){_e=R.createDocument(gt,"template",null);try{_e.documentElement.innerHTML=un?A:Ze}catch{}}const at=_e.body||_e.documentElement;return W&&ge&&at.insertBefore(a.createTextNode(ge),at.childNodes[0]||null),gt===kt?B.call(_e,Ue?"html":"body")[0]:Ue?_e.documentElement:at},vn=function(W){return M.call(W.ownerDocument||W,W,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},gi=function(W){return W instanceof d&&(typeof W.nodeName!="string"||typeof W.textContent!="string"||typeof W.removeChild!="function"||!(W.attributes instanceof y)||typeof W.removeAttribute!="function"||typeof W.setAttribute!="function"||typeof W.namespaceURI!="string"||typeof W.insertBefore!="function"||typeof W.hasChildNodes!="function")},yt=function(W){return typeof c=="function"&&W instanceof c};function it(Se,W,_e){Go(Se,ge=>{ge.call(r,W,_e,Qi)})}const es=function(W){let _e=null;if(it(I.beforeSanitizeElements,W,null),gi(W))return Xt(W),!0;const ge=_t(W.nodeName);if(it(I.uponSanitizeElement,W,{tagName:ge,allowedTags:L}),je&&W.hasChildNodes()&&!yt(W.firstElementChild)&&Gt(/<[/\w!]/g,W.innerHTML)&&Gt(/<[/\w!]/g,W.textContent)||W.nodeType===_a.progressingInstruction||je&&W.nodeType===_a.comment&&Gt(/<[/\w]/g,W.data))return Xt(W),!0;if(!(j.tagCheck instanceof Function&&j.tagCheck(ge))&&(!L[ge]||me[ge])){if(!me[ge]&&wa(ge)&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,ge)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(ge)))return!1;if(nt&&!Nt[ge]){const Ze=p(W)||W.parentNode,at=f(W)||W.childNodes;if(at&&Ze){const ke=at.length;for(let zt=ke-1;zt>=0;--zt){const yi=b(at[zt],!0);yi.__removalCount=(W.__removalCount||0)+1,Ze.insertBefore(yi,v(W))}}}return Xt(W),!0}return W instanceof u&&!xa(W)||(ge==="noscript"||ge==="noembed"||ge==="noframes")&&Gt(/<\/no(script|embed|frames)/i,W.innerHTML)?(Xt(W),!0):(Te&&W.nodeType===_a.text&&(_e=W.textContent,Go([q,P,J],Ze=>{_e=ha(_e,Ze," ")}),W.textContent!==_e&&(ua(r.removed,{element:W.cloneNode()}),W.textContent=_e)),it(I.afterSanitizeElements,W,null),!1)},Sr=function(W,_e,ge){if(Y[_e]||Ui&&(_e==="id"||_e==="name")&&(ge in a||ge in fn))return!1;if(!(oe&&!Y[_e]&&Gt(te,_e))){if(!(ce&&Gt(G,_e))){if(!(j.attributeCheck instanceof Function&&j.attributeCheck(_e,W))){if(!V[_e]||Y[_e]){if(!(wa(W)&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,W)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(W))&&(ue.attributeNameCheck instanceof RegExp&&Gt(ue.attributeNameCheck,_e)||ue.attributeNameCheck instanceof Function&&ue.attributeNameCheck(_e,W))||_e==="is"&&ue.allowCustomizedBuiltInElements&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,ge)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(ge))))return!1}else if(!Li[_e]){if(!Gt(U,ha(ge,ae,""))){if(!((_e==="src"||_e==="xlink:href"||_e==="href")&&W!=="script"&&aE(ge,"data:")===0&&Ki[W])){if(!(ve&&!Gt(se,ha(ge,ae,"")))){if(ge)return!1}}}}}}}return!0},wa=function(W){return W!=="annotation-xml"&&Uu(W,N)},Ea=function(W){it(I.beforeSanitizeAttributes,W,null);const{attributes:_e}=W;if(!_e||gi(W))return;const ge={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let Ze=_e.length;for(;Ze--;){const at=_e[Ze],{name:ke,namespaceURI:zt,value:yi}=at,Jt=_t(ke),Ii=yi;let Et=ke==="value"?Ii:oE(Ii);if(ge.attrName=Jt,ge.attrValue=Et,ge.keepAttr=!0,ge.forceKeepAttr=void 0,it(I.uponSanitizeAttribute,W,ge),Et=ge.attrValue,Vi&&(Jt==="id"||Jt==="name")&&(Ni(ke,W),Et=Pt+Et),je&&Gt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Et)){Ni(ke,W);continue}if(Jt==="attributename"&&Uu(Et,"href")){Ni(ke,W);continue}if(ge.forceKeepAttr)continue;if(!ge.keepAttr){Ni(ke,W);continue}if(!pe&&Gt(/\/>/i,Et)){Ni(ke,W);continue}Te&&Go([q,P,J],yn=>{Et=ha(Et,yn," ")});const gn=_t(W.nodeName);if(!Sr(gn,Jt,Et)){Ni(ke,W);continue}if(S&&typeof w=="object"&&typeof w.getAttributeType=="function"&&!zt)switch(w.getAttributeType(gn,Jt)){case"TrustedHTML":{Et=S.createHTML(Et);break}case"TrustedScriptURL":{Et=S.createScriptURL(Et);break}}if(Et!==Ii)try{zt?W.setAttributeNS(zt,ke,Et):W.setAttribute(ke,Et),gi(W)?Xt(W):Qm(r.removed)}catch{Ni(ke,W)}}it(I.afterSanitizeAttributes,W,null)},Ta=function Se(W){let _e=null;const ge=vn(W);for(it(I.beforeSanitizeShadowDOM,W,null);_e=ge.nextNode();)it(I.uponSanitizeShadowNode,_e,null),es(_e),Ea(_e),_e.content instanceof x&&Se(_e.content);it(I.afterSanitizeShadowDOM,W,null)};return r.sanitize=function(Se){let W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_e=null,ge=null,Ze=null,at=null;if(un=!Se,un&&(Se="<!-->"),typeof Se!="string"&&!yt(Se))if(typeof Se.toString=="function"){if(Se=Se.toString(),typeof Se!="string")throw fa("dirty is not a string, aborting")}else throw fa("toString is not a function");if(!r.isSupported)return Se;if(ct||dn(W),r.removed=[],typeof Se=="string"&&(Rt=!1),Rt){if(Se.nodeName){const yi=_t(Se.nodeName);if(!L[yi]||me[yi])throw fa("root node is forbidden and cannot be sanitized in-place")}}else if(Se instanceof c)_e=pn("<!---->"),ge=_e.ownerDocument.importNode(Se,!0),ge.nodeType===_a.element&&ge.nodeName==="BODY"||ge.nodeName==="HTML"?_e=ge:_e.appendChild(ge);else{if(!Ft&&!Te&&!Ue&&Se.indexOf("<")===-1)return S&&pi?S.createHTML(Se):Se;if(_e=pn(Se),!_e)return Ft?null:pi?A:""}_e&&Ee&&Xt(_e.firstChild);const ke=vn(Rt?Se:_e);for(;Ze=ke.nextNode();)es(Ze),Ea(Ze),Ze.content instanceof x&&Ta(Ze.content);if(Rt)return Se;if(Ft){if(mi)for(at=E.call(_e.ownerDocument);_e.firstChild;)at.appendChild(_e.firstChild);else at=_e;return(V.shadowroot||V.shadowrootmode)&&(at=$.call(o,at,!0)),at}let zt=Ue?_e.outerHTML:_e.innerHTML;return Ue&&L["!doctype"]&&_e.ownerDocument&&_e.ownerDocument.doctype&&_e.ownerDocument.doctype.name&&Gt(gv,_e.ownerDocument.doctype.name)&&(zt="<!DOCTYPE "+_e.ownerDocument.doctype.name+`>
|
|
253
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const y of i.seen.entries()){const d=y[1];if(r===y[0]){x(y);continue}if(i.external){const w=(u=i.external.registry.get(y[0]))==null?void 0:u.id;if(r!==y[0]&&w){x(y);continue}}if((h=i.metadataRegistry.get(y[0]))==null?void 0:h.id){x(y);continue}if(d.cycle){x(y);continue}if(d.count>1&&i.reused==="ref"){x(y);continue}}}function sv(i,r){var T,c,u;const a=i.seen.get(r);if(!a)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=h=>{const y=i.seen.get(h);if(y.ref===null)return;const d=y.def??y.schema,C={...d},w=y.ref;if(y.ref=null,w){o(w);const b=i.seen.get(w),m=b.schema;if(m.$ref&&(i.target==="draft-07"||i.target==="draft-04"||i.target==="openapi-3.0")?(d.allOf=d.allOf??[],d.allOf.push(m)):Object.assign(d,m),Object.assign(d,C),h._zod.parent===w)for(const f in d)f==="$ref"||f==="allOf"||f in C||delete d[f];if(m.$ref&&b.def)for(const f in d)f==="$ref"||f==="allOf"||f in b.def&&JSON.stringify(d[f])===JSON.stringify(b.def[f])&&delete d[f]}const k=h._zod.parent;if(k&&k!==w){o(k);const b=i.seen.get(k);if(b!=null&&b.schema.$ref&&(d.$ref=b.schema.$ref,b.def))for(const m in d)m==="$ref"||m==="allOf"||m in b.def&&JSON.stringify(d[m])===JSON.stringify(b.def[m])&&delete d[m]}i.override({zodSchema:h,jsonSchema:d,path:y.path??[]})};for(const h of[...i.seen.entries()].reverse())o(h[0]);const g={};if(i.target==="draft-2020-12"?g.$schema="https://json-schema.org/draft/2020-12/schema":i.target==="draft-07"?g.$schema="http://json-schema.org/draft-07/schema#":i.target==="draft-04"?g.$schema="http://json-schema.org/draft-04/schema#":i.target,(T=i.external)!=null&&T.uri){const h=(c=i.external.registry.get(r))==null?void 0:c.id;if(!h)throw new Error("Schema is missing an `id` property");g.$id=i.external.uri(h)}Object.assign(g,a.def??a.schema);const x=((u=i.external)==null?void 0:u.defs)??{};for(const h of i.seen.entries()){const y=h[1];y.def&&y.defId&&(x[y.defId]=y.def)}i.external||Object.keys(x).length>0&&(i.target==="draft-2020-12"?g.$defs=x:g.definitions=x);try{const h=JSON.parse(JSON.stringify(g));return Object.defineProperty(h,"~standard",{value:{...r["~standard"],jsonSchema:{input:sl(r,"input",i.processors),output:sl(r,"output",i.processors)}},enumerable:!1,writable:!1}),h}catch{throw new Error("Error converting schema to JSON.")}}function Wt(i,r){const a=r??{seen:new Set};if(a.seen.has(i))return!1;a.seen.add(i);const o=i._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Wt(o.element,a);if(o.type==="set")return Wt(o.valueType,a);if(o.type==="lazy")return Wt(o.getter(),a);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Wt(o.innerType,a);if(o.type==="intersection")return Wt(o.left,a)||Wt(o.right,a);if(o.type==="record"||o.type==="map")return Wt(o.keyType,a)||Wt(o.valueType,a);if(o.type==="pipe")return Wt(o.in,a)||Wt(o.out,a);if(o.type==="object"){for(const g in o.shape)if(Wt(o.shape[g],a))return!0;return!1}if(o.type==="union"){for(const g of o.options)if(Wt(g,a))return!0;return!1}if(o.type==="tuple"){for(const g of o.items)if(Wt(g,a))return!0;return!!(o.rest&&Wt(o.rest,a))}return!1}const mx=(i,r={})=>a=>{const o=tv({...a,processors:r});return wt(i,o),iv(o,i),sv(o,i)},sl=(i,r,a={})=>o=>{const{libraryOptions:g,target:x}=o??{},T=tv({...g??{},target:x,io:r,processors:a});return wt(i,T),iv(T,i),sv(T,i)},px={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vx=(i,r,a,o)=>{const g=a;g.type="string";const{minimum:x,maximum:T,format:c,patterns:u,contentEncoding:h}=i._zod.bag;if(typeof x=="number"&&(g.minLength=x),typeof T=="number"&&(g.maxLength=T),c&&(g.format=px[c]??c,g.format===""&&delete g.format,c==="time"&&delete g.format),h&&(g.contentEncoding=h),u&&u.size>0){const y=[...u];y.length===1?g.pattern=y[0].source:y.length>1&&(g.allOf=[...y.map(d=>({...r.target==="draft-07"||r.target==="draft-04"||r.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},gx=(i,r,a,o)=>{const g=a,{minimum:x,maximum:T,format:c,multipleOf:u,exclusiveMaximum:h,exclusiveMinimum:y}=i._zod.bag;typeof c=="string"&&c.includes("int")?g.type="integer":g.type="number",typeof y=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(g.minimum=y,g.exclusiveMinimum=!0):g.exclusiveMinimum=y),typeof x=="number"&&(g.minimum=x,typeof y=="number"&&r.target!=="draft-04"&&(y>=x?delete g.minimum:delete g.exclusiveMinimum)),typeof h=="number"&&(r.target==="draft-04"||r.target==="openapi-3.0"?(g.maximum=h,g.exclusiveMaximum=!0):g.exclusiveMaximum=h),typeof T=="number"&&(g.maximum=T,typeof h=="number"&&r.target!=="draft-04"&&(h<=T?delete g.maximum:delete g.exclusiveMaximum)),typeof u=="number"&&(g.multipleOf=u)},yx=(i,r,a,o)=>{a.type="boolean"},Sx=(i,r,a,o)=>{a.not={}},bx=(i,r,a,o)=>{},Cx=(i,r,a,o)=>{const g=i._zod.def,x=Bp(g.entries);x.every(T=>typeof T=="number")&&(a.type="number"),x.every(T=>typeof T=="string")&&(a.type="string"),a.enum=x},xx=(i,r,a,o)=>{if(r.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},wx=(i,r,a,o)=>{if(r.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ex=(i,r,a,o)=>{const g=a,x=i._zod.def,{minimum:T,maximum:c}=i._zod.bag;typeof T=="number"&&(g.minItems=T),typeof c=="number"&&(g.maxItems=c),g.type="array",g.items=wt(x.element,r,{...o,path:[...o.path,"items"]})},Tx=(i,r,a,o)=>{var h;const g=a,x=i._zod.def;g.type="object",g.properties={};const T=x.shape;for(const y in T)g.properties[y]=wt(T[y],r,{...o,path:[...o.path,"properties",y]});const c=new Set(Object.keys(T)),u=new Set([...c].filter(y=>{const d=x.shape[y]._zod;return r.io==="input"?d.optin===void 0:d.optout===void 0}));u.size>0&&(g.required=Array.from(u)),((h=x.catchall)==null?void 0:h._zod.def.type)==="never"?g.additionalProperties=!1:x.catchall?x.catchall&&(g.additionalProperties=wt(x.catchall,r,{...o,path:[...o.path,"additionalProperties"]})):r.io==="output"&&(g.additionalProperties=!1)},Ax=(i,r,a,o)=>{const g=i._zod.def,x=g.inclusive===!1,T=g.options.map((c,u)=>wt(c,r,{...o,path:[...o.path,x?"oneOf":"anyOf",u]}));x?a.oneOf=T:a.anyOf=T},Rx=(i,r,a,o)=>{const g=i._zod.def,x=wt(g.left,r,{...o,path:[...o.path,"allOf",0]}),T=wt(g.right,r,{...o,path:[...o.path,"allOf",1]}),c=h=>"allOf"in h&&Object.keys(h).length===1,u=[...c(x)?x.allOf:[x],...c(T)?T.allOf:[T]];a.allOf=u},Dx=(i,r,a,o)=>{const g=a,x=i._zod.def;g.type="object";const T=x.keyType,c=T._zod.bag,u=c==null?void 0:c.patterns;if(x.mode==="loose"&&u&&u.size>0){const y=wt(x.valueType,r,{...o,path:[...o.path,"patternProperties","*"]});g.patternProperties={};for(const d of u)g.patternProperties[d.source]=y}else(r.target==="draft-07"||r.target==="draft-2020-12")&&(g.propertyNames=wt(x.keyType,r,{...o,path:[...o.path,"propertyNames"]})),g.additionalProperties=wt(x.valueType,r,{...o,path:[...o.path,"additionalProperties"]});const h=T._zod.values;if(h){const y=[...h].filter(d=>typeof d=="string"||typeof d=="number");y.length>0&&(g.required=y)}},kx=(i,r,a,o)=>{const g=i._zod.def,x=wt(g.innerType,r,o),T=r.seen.get(i);r.target==="openapi-3.0"?(T.ref=g.innerType,a.nullable=!0):a.anyOf=[x,{type:"null"}]},Ox=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType},Mx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,a.default=JSON.parse(JSON.stringify(g.defaultValue))},Lx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,r.io==="input"&&(a._prefault=JSON.parse(JSON.stringify(g.defaultValue)))},Nx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType;let T;try{T=g.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}a.default=T},Bx=(i,r,a,o)=>{const g=i._zod.def,x=r.io==="input"?g.in._zod.def.type==="transform"?g.out:g.in:g.out;wt(x,r,o);const T=r.seen.get(i);T.ref=x},zx=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType,a.readOnly=!0},rv=(i,r,a,o)=>{const g=i._zod.def;wt(g.innerType,r,o);const x=r.seen.get(i);x.ref=g.innerType},jx=fe("ZodISODateTime",(i,r)=>{I1.init(i,r),lt.init(i,r)});function Hx(i){return qC(jx,i)}const Ux=fe("ZodISODate",(i,r)=>{P1.init(i,r),lt.init(i,r)});function Ix(i){return GC(Ux,i)}const Px=fe("ZodISOTime",(i,r)=>{$1.init(i,r),lt.init(i,r)});function $x(i){return WC(Px,i)}const Fx=fe("ZodISODuration",(i,r)=>{F1.init(i,r),lt.init(i,r)});function Zx(i){return YC(Fx,i)}const qx=(i,r)=>{Up.init(i,r),i.name="ZodError",Object.defineProperties(i,{format:{value:a=>Lb(i,a)},flatten:{value:a=>Mb(i,a)},addIssue:{value:a=>{i.issues.push(a),i.message=JSON.stringify(i.issues,Xu,2)}},addIssues:{value:a=>{i.issues.push(...a),i.message=JSON.stringify(i.issues,Xu,2)}},isEmpty:{get(){return i.issues.length===0}}})},Mi=fe("ZodError",qx,{Parent:Error}),Gx=dh(Mi),Wx=_h(Mi),Yx=dl(Mi),Vx=_l(Mi),Kx=zb(Mi),Xx=jb(Mi),Jx=Hb(Mi),Qx=Ub(Mi),ew=Ib(Mi),tw=Pb(Mi),iw=$b(Mi),sw=Fb(Mi),dt=fe("ZodType",(i,r)=>(ft.init(i,r),Object.assign(i["~standard"],{jsonSchema:{input:sl(i,"input"),output:sl(i,"output")}}),i.toJSONSchema=mx(i,{}),i.def=r,i.type=r.type,Object.defineProperty(i,"_def",{value:r}),i.check=(...a)=>i.clone(Vs(r,{checks:[...r.checks??[],...a.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0}),i.with=i.check,i.clone=(a,o)=>Ks(i,a,o),i.brand=()=>i,i.register=((a,o)=>(a.add(i,o),i)),i.parse=(a,o)=>Gx(i,a,o,{callee:i.parse}),i.safeParse=(a,o)=>Yx(i,a,o),i.parseAsync=async(a,o)=>Wx(i,a,o,{callee:i.parseAsync}),i.safeParseAsync=async(a,o)=>Vx(i,a,o),i.spa=i.safeParseAsync,i.encode=(a,o)=>Kx(i,a,o),i.decode=(a,o)=>Xx(i,a,o),i.encodeAsync=async(a,o)=>Jx(i,a,o),i.decodeAsync=async(a,o)=>Qx(i,a,o),i.safeEncode=(a,o)=>ew(i,a,o),i.safeDecode=(a,o)=>tw(i,a,o),i.safeEncodeAsync=async(a,o)=>iw(i,a,o),i.safeDecodeAsync=async(a,o)=>sw(i,a,o),i.refine=(a,o)=>i.check(Kw(a,o)),i.superRefine=a=>i.check(Xw(a)),i.overwrite=a=>i.check(cn(a)),i.optional=()=>Fm(i),i.exactOptional=()=>jw(i),i.nullable=()=>Zm(i),i.nullish=()=>Fm(Zm(i)),i.nonoptional=a=>Fw(i,a),i.array=()=>pl(i),i.or=a=>kw([i,a]),i.and=a=>Mw(i,a),i.transform=a=>qm(i,Bw(a)),i.default=a=>Iw(i,a),i.prefault=a=>$w(i,a),i.catch=a=>qw(i,a),i.pipe=a=>qm(i,a),i.readonly=()=>Yw(i),i.describe=a=>{const o=i.clone();return va.add(o,{description:a}),o},Object.defineProperty(i,"description",{get(){var a;return(a=va.get(i))==null?void 0:a.description},configurable:!0}),i.meta=(...a)=>{if(a.length===0)return va.get(i);const o=i.clone();return va.add(o,a[0]),o},i.isOptional=()=>i.safeParse(void 0).success,i.isNullable=()=>i.safeParse(null).success,i.apply=a=>a(i),i)),nv=fe("_ZodString",(i,r)=>{mh.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>vx(i,o,g);const a=i._zod.bag;i.format=a.format??null,i.minLength=a.minimum??null,i.maxLength=a.maximum??null,i.regex=(...o)=>i.check(ex(...o)),i.includes=(...o)=>i.check(sx(...o)),i.startsWith=(...o)=>i.check(rx(...o)),i.endsWith=(...o)=>i.check(nx(...o)),i.min=(...o)=>i.check(il(...o)),i.max=(...o)=>i.check(Qp(...o)),i.length=(...o)=>i.check(ev(...o)),i.nonempty=(...o)=>i.check(il(1,...o)),i.lowercase=o=>i.check(tx(o)),i.uppercase=o=>i.check(ix(o)),i.trim=()=>i.check(ox()),i.normalize=(...o)=>i.check(ax(...o)),i.toLowerCase=()=>i.check(lx()),i.toUpperCase=()=>i.check(cx()),i.slugify=()=>i.check(ux())}),rw=fe("ZodString",(i,r)=>{mh.init(i,r),nv.init(i,r),i.email=a=>i.check(wC(nw,a)),i.url=a=>i.check(DC(aw,a)),i.jwt=a=>i.check(ZC(bw,a)),i.emoji=a=>i.check(kC(ow,a)),i.guid=a=>i.check(jm(Pm,a)),i.uuid=a=>i.check(EC(Zo,a)),i.uuidv4=a=>i.check(TC(Zo,a)),i.uuidv6=a=>i.check(AC(Zo,a)),i.uuidv7=a=>i.check(RC(Zo,a)),i.nanoid=a=>i.check(OC(lw,a)),i.guid=a=>i.check(jm(Pm,a)),i.cuid=a=>i.check(MC(cw,a)),i.cuid2=a=>i.check(LC(uw,a)),i.ulid=a=>i.check(NC(hw,a)),i.base64=a=>i.check(PC(gw,a)),i.base64url=a=>i.check($C(yw,a)),i.xid=a=>i.check(BC(fw,a)),i.ksuid=a=>i.check(zC(dw,a)),i.ipv4=a=>i.check(jC(_w,a)),i.ipv6=a=>i.check(HC(mw,a)),i.cidrv4=a=>i.check(UC(pw,a)),i.cidrv6=a=>i.check(IC(vw,a)),i.e164=a=>i.check(FC(Sw,a)),i.datetime=a=>i.check(Hx(a)),i.date=a=>i.check(Ix(a)),i.time=a=>i.check($x(a)),i.duration=a=>i.check(Zx(a))});function Ie(i){return xC(rw,i)}const lt=fe("ZodStringFormat",(i,r)=>{rt.init(i,r),nv.init(i,r)}),nw=fe("ZodEmail",(i,r)=>{O1.init(i,r),lt.init(i,r)}),Pm=fe("ZodGUID",(i,r)=>{D1.init(i,r),lt.init(i,r)}),Zo=fe("ZodUUID",(i,r)=>{k1.init(i,r),lt.init(i,r)}),aw=fe("ZodURL",(i,r)=>{M1.init(i,r),lt.init(i,r)}),ow=fe("ZodEmoji",(i,r)=>{L1.init(i,r),lt.init(i,r)}),lw=fe("ZodNanoID",(i,r)=>{N1.init(i,r),lt.init(i,r)}),cw=fe("ZodCUID",(i,r)=>{B1.init(i,r),lt.init(i,r)}),uw=fe("ZodCUID2",(i,r)=>{z1.init(i,r),lt.init(i,r)}),hw=fe("ZodULID",(i,r)=>{j1.init(i,r),lt.init(i,r)}),fw=fe("ZodXID",(i,r)=>{H1.init(i,r),lt.init(i,r)}),dw=fe("ZodKSUID",(i,r)=>{U1.init(i,r),lt.init(i,r)}),_w=fe("ZodIPv4",(i,r)=>{Z1.init(i,r),lt.init(i,r)}),mw=fe("ZodIPv6",(i,r)=>{q1.init(i,r),lt.init(i,r)}),pw=fe("ZodCIDRv4",(i,r)=>{G1.init(i,r),lt.init(i,r)}),vw=fe("ZodCIDRv6",(i,r)=>{W1.init(i,r),lt.init(i,r)}),gw=fe("ZodBase64",(i,r)=>{Y1.init(i,r),lt.init(i,r)}),yw=fe("ZodBase64URL",(i,r)=>{K1.init(i,r),lt.init(i,r)}),Sw=fe("ZodE164",(i,r)=>{X1.init(i,r),lt.init(i,r)}),bw=fe("ZodJWT",(i,r)=>{Q1.init(i,r),lt.init(i,r)}),av=fe("ZodNumber",(i,r)=>{Vp.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>gx(i,o,g),i.gt=(o,g)=>i.check(Um(o,g)),i.gte=(o,g)=>i.check(zu(o,g)),i.min=(o,g)=>i.check(zu(o,g)),i.lt=(o,g)=>i.check(Hm(o,g)),i.lte=(o,g)=>i.check(Bu(o,g)),i.max=(o,g)=>i.check(Bu(o,g)),i.int=o=>i.check($m(o)),i.safe=o=>i.check($m(o)),i.positive=o=>i.check(Um(0,o)),i.nonnegative=o=>i.check(zu(0,o)),i.negative=o=>i.check(Hm(0,o)),i.nonpositive=o=>i.check(Bu(0,o)),i.multipleOf=(o,g)=>i.check(Im(o,g)),i.step=(o,g)=>i.check(Im(o,g)),i.finite=()=>i;const a=i._zod.bag;i.minValue=Math.max(a.minimum??Number.NEGATIVE_INFINITY,a.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,i.maxValue=Math.min(a.maximum??Number.POSITIVE_INFINITY,a.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,i.isInt=(a.format??"").includes("int")||Number.isSafeInteger(a.multipleOf??.5),i.isFinite=!0,i.format=a.format??null});function Oe(i){return VC(av,i)}const Cw=fe("ZodNumberFormat",(i,r)=>{eC.init(i,r),av.init(i,r)});function $m(i){return KC(Cw,i)}const xw=fe("ZodBoolean",(i,r)=>{tC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>yx(i,a,o)});function ys(i){return XC(xw,i)}const ww=fe("ZodUnknown",(i,r)=>{iC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>bx()});function rl(){return JC(ww)}const Ew=fe("ZodNever",(i,r)=>{sC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Sx(i,a,o)});function Tw(i){return QC(Ew,i)}const Aw=fe("ZodArray",(i,r)=>{rC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ex(i,a,o,g),i.element=r.element,i.min=(a,o)=>i.check(il(a,o)),i.nonempty=a=>i.check(il(1,a)),i.max=(a,o)=>i.check(Qp(a,o)),i.length=(a,o)=>i.check(ev(a,o)),i.unwrap=()=>i.element});function pl(i,r){return hx(Aw,i,r)}const Rw=fe("ZodObject",(i,r)=>{aC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Tx(i,a,o,g),We(i,"shape",()=>r.shape),i.keyof=()=>an(Object.keys(i._zod.def.shape)),i.catchall=a=>i.clone({...i._zod.def,catchall:a}),i.passthrough=()=>i.clone({...i._zod.def,catchall:rl()}),i.loose=()=>i.clone({...i._zod.def,catchall:rl()}),i.strict=()=>i.clone({...i._zod.def,catchall:Tw()}),i.strip=()=>i.clone({...i._zod.def,catchall:void 0}),i.extend=a=>Ab(i,a),i.safeExtend=a=>Rb(i,a),i.merge=a=>Db(i,a),i.pick=a=>Eb(i,a),i.omit=a=>Tb(i,a),i.partial=(...a)=>kb(ov,i,a[0]),i.required=(...a)=>Ob(lv,i,a[0])});function Lt(i,r){const a={type:"object",shape:i??{},...xe(r)};return new Rw(a)}const Dw=fe("ZodUnion",(i,r)=>{oC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ax(i,a,o,g),i.options=r.options});function kw(i,r){return new Dw({type:"union",options:i,...xe(r)})}const Ow=fe("ZodIntersection",(i,r)=>{lC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Rx(i,a,o,g)});function Mw(i,r){return new Ow({type:"intersection",left:i,right:r})}const Lw=fe("ZodRecord",(i,r)=>{cC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Dx(i,a,o,g),i.keyType=r.keyType,i.valueType=r.valueType});function vl(i,r,a){return new Lw({type:"record",keyType:i,valueType:r,...xe(a)})}const Qu=fe("ZodEnum",(i,r)=>{uC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(o,g,x)=>Cx(i,o,g),i.enum=r.entries,i.options=Object.values(r.entries);const a=new Set(Object.keys(r.entries));i.extract=(o,g)=>{const x={};for(const T of o)if(a.has(T))x[T]=r.entries[T];else throw new Error(`Key ${T} not found in enum`);return new Qu({...r,checks:[],...xe(g),entries:x})},i.exclude=(o,g)=>{const x={...r.entries};for(const T of o)if(a.has(T))delete x[T];else throw new Error(`Key ${T} not found in enum`);return new Qu({...r,checks:[],...xe(g),entries:x})}});function an(i,r){const a=Array.isArray(i)?Object.fromEntries(i.map(o=>[o,o])):i;return new Qu({type:"enum",entries:a,...xe(r)})}const Nw=fe("ZodTransform",(i,r)=>{hC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>wx(i,a),i._zod.parse=(a,o)=>{if(o.direction==="backward")throw new Lp(i.constructor.name);a.addIssue=x=>{if(typeof x=="string")a.issues.push(ya(x,a.value,r));else{const T=x;T.fatal&&(T.continue=!1),T.code??(T.code="custom"),T.input??(T.input=a.value),T.inst??(T.inst=i),a.issues.push(ya(T))}};const g=r.transform(a.value,a);return g instanceof Promise?g.then(x=>(a.value=x,a)):(a.value=g,a)}});function Bw(i){return new Nw({type:"transform",transform:i})}const ov=fe("ZodOptional",(i,r)=>{Jp.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>rv(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Fm(i){return new ov({type:"optional",innerType:i})}const zw=fe("ZodExactOptional",(i,r)=>{fC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>rv(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function jw(i){return new zw({type:"optional",innerType:i})}const Hw=fe("ZodNullable",(i,r)=>{dC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>kx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Zm(i){return new Hw({type:"nullable",innerType:i})}const Uw=fe("ZodDefault",(i,r)=>{_C.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Mx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType,i.removeDefault=i.unwrap});function Iw(i,r){return new Uw({type:"default",innerType:i,get defaultValue(){return typeof r=="function"?r():jp(r)}})}const Pw=fe("ZodPrefault",(i,r)=>{mC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Lx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function $w(i,r){return new Pw({type:"prefault",innerType:i,get defaultValue(){return typeof r=="function"?r():jp(r)}})}const lv=fe("ZodNonOptional",(i,r)=>{pC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Ox(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Fw(i,r){return new lv({type:"nonoptional",innerType:i,...xe(r)})}const Zw=fe("ZodCatch",(i,r)=>{vC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Nx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType,i.removeCatch=i.unwrap});function qw(i,r){return new Zw({type:"catch",innerType:i,catchValue:typeof r=="function"?r:()=>r})}const Gw=fe("ZodPipe",(i,r)=>{gC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>Bx(i,a,o,g),i.in=r.in,i.out=r.out});function qm(i,r){return new Gw({type:"pipe",in:i,out:r})}const Ww=fe("ZodReadonly",(i,r)=>{yC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>zx(i,a,o,g),i.unwrap=()=>i._zod.def.innerType});function Yw(i){return new Ww({type:"readonly",innerType:i})}const Vw=fe("ZodCustom",(i,r)=>{SC.init(i,r),dt.init(i,r),i._zod.processJSONSchema=(a,o,g)=>xx(i,a)});function Kw(i,r={}){return fx(Vw,i,r)}function Xw(i){return dx(i)}const ph=an(["idle","working","permission_prompt","plan_mode","ask_question","bash_approval","settings","unknown"]),cv=Lt({ok:ys()}),Jw=cv.extend({delivered:ys(),attempts:Oe()}),Qw=Lt({status:Ie(),version:Ie(),uptime:Oe(),sessions:Lt({active:Oe(),total:Oe()}),timestamp:Ie()}),uv=Lt({id:Ie(),windowId:Ie(),windowName:Ie(),workDir:Ie(),claudeSessionId:Ie().optional(),jsonlPath:Ie().optional(),byteOffset:Oe(),monitorOffset:Oe(),status:ph,createdAt:Oe(),lastActivity:Oe(),stallThresholdMs:Oe(),permissionMode:Ie(),autoApprove:ys().optional(),settingsPatched:ys().optional(),promptDelivery:Lt({delivered:ys(),attempts:Oe()}).optional(),actionHints:vl(Ie(),Lt({method:Ie(),url:Ie(),description:Ie()})).optional()}),e2=Lt({sessions:pl(uv),pagination:Lt({page:Oe(),limit:Oe(),total:Oe(),totalPages:Oe()})}),t2=Lt({alive:ys(),windowExists:ys(),claudeRunning:ys(),paneCommand:Ie().nullable(),status:ph,hasTranscript:ys(),lastActivity:Oe(),lastActivityAgo:Oe(),sessionAge:Oe(),details:Ie(),actionHints:vl(Ie(),Lt({method:Ie(),url:Ie(),description:Ie()})).optional()}),i2=Lt({durationSec:Oe(),messages:Oe(),toolCalls:Oe(),approvals:Oe(),autoApprovals:Oe(),statusChanges:pl(Ie())}),s2=Lt({role:an(["user","assistant","system"]),contentType:an(["text","thinking","tool_use","tool_result","permission_request"]),text:Ie(),toolName:Ie().optional(),toolUseId:Ie().optional(),timestamp:Ie().optional()}),r2=Lt({messages:pl(s2),status:ph,statusText:Ie().nullable(),interactiveContent:Ie().nullable()}),n2=Lt({uptime:Oe(),sessions:Lt({total_created:Oe(),currently_active:Oe(),completed:Oe(),failed:Oe(),avg_duration_sec:Oe(),avg_messages_per_session:Oe()}),auto_approvals:Oe(),webhooks_sent:Oe(),webhooks_failed:Oe(),screenshots_taken:Oe(),pipelines_created:Oe(),batches_created:Oe(),prompt_delivery:Lt({sent:Oe(),delivered:Oe(),failed:Oe(),success_rate:Oe().nullable()})}),a2=an(["status","message","approval","ended","heartbeat","stall","dead","system","hook","subagent_start","subagent_stop"]),o2=Lt({event:a2,sessionId:Ie(),timestamp:Ie(),data:vl(Ie(),rl()).optional()}),l2=an(["session_status_change","session_message","session_approval","session_ended","session_created","session_stall","session_dead","session_subagent_start","session_subagent_stop"]),c2=Lt({event:l2,sessionId:Ie(),timestamp:Ie(),data:vl(Ie(),rl())}),u2=3e4,h2=300*1e3;class nl{constructor(r,a,o={}){At(this,"eventSource",null);At(this,"consecutiveFailures",0);At(this,"failStartTime",null);At(this,"destroyed",!1);At(this,"reconnectTimer",null);At(this,"url");At(this,"callbacks");At(this,"onMessage");this.url=r,this.onMessage=a,this.callbacks=o,this.connect()}connect(){this.destroyed||(this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.eventSource&&(this.eventSource.close(),this.eventSource=null),this.eventSource=new EventSource(this.url),this.eventSource.onmessage=this.onMessage,this.eventSource.onopen=()=>{var r,a;this.destroyed||(this.consecutiveFailures=0,this.failStartTime=null,(a=(r=this.callbacks).onOpen)==null||a.call(r))},this.eventSource.onerror=()=>{var a,o,g,x,T,c,u,h,y;if(this.destroyed)return;if((a=this.eventSource)==null||a.close(),this.eventSource=null,this.failStartTime===null&&(this.failStartTime=Date.now()),Date.now()-this.failStartTime>=h2){(g=(o=this.callbacks).onGiveUp)==null||g.call(o),(T=(x=this.callbacks).onClose)==null||T.call(x);return}this.consecutiveFailures++;const r=Math.min(u2,1e3*Math.pow(2,this.consecutiveFailures-1));(u=(c=this.callbacks).onReconnecting)==null||u.call(c,this.consecutiveFailures,r),(y=(h=this.callbacks).onClose)==null||y.call(h),this.reconnectTimer=setTimeout(()=>this.connect(),r)})}close(){var r;this.destroyed=!0,this.reconnectTimer&&clearTimeout(this.reconnectTimer),(r=this.eventSource)==null||r.close(),this.eventSource=null}}const f2="";function d2(i){if(!i)return{};if(i instanceof Headers){const r={};return i.forEach((a,o)=>{r[o]=a}),r}return i}function _2(i,r,a){const o=r.safeParse(i);if(o.success)return o.data;throw console.error(`[aegis] API response validation failed (${a}):`,o.error.issues),new Error(`API response validation failed for ${a}: ${o.error.issues.map(g=>g.message).join(", ")}`)}function m2(i){return!(i.name==="AbortError"||!i.message||i.message.includes("HTTP "))}async function vt(i,r={}){const a=localStorage.getItem("aegis_token"),o={"Content-Type":"application/json",...a?{Authorization:`Bearer ${a}`}:{},...d2(r.headers)},{retries:g=0,schema:x,schemaContext:T,...c}=r;let u=null;for(let h=0;h<=g;h++)try{const y=await fetch(`${f2}${i}`,{...c,headers:o});if(!y.ok){const C=await y.json().catch(()=>({error:y.statusText})),w=new Error(C.error??`HTTP ${y.status}`);throw w.statusCode=y.status,w}const d=await y.json();return x?_2(d,x,T??i):d}catch(y){if(u=y,h<g&&m2(u))await new Promise(d=>setTimeout(d,1e3*Math.pow(2,h)));else throw u}throw u}function p2(){return vt("/v1/health",{schema:Qw,schemaContext:"getHealth"})}function v2(){return vt("/v1/metrics",{schema:n2,schemaContext:"getMetrics"})}function g2(){return vt("/v1/sessions",{schema:e2,schemaContext:"getSessions"})}function y2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}`,{schema:uv,schemaContext:"getSession"})}function S2(i){const{signal:r,...a}=i;return vt("/v1/sessions",{method:"POST",body:JSON.stringify(a),signal:r})}function hv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}`,{method:"DELETE",schema:cv,schemaContext:"killSession"})}function b2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/health`,{schema:t2,schemaContext:"getSessionHealth"})}function C2(){return vt("/v1/sessions/health")}function x2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/read`,{schema:r2,schemaContext:"getSessionMessages"})}function w2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/metrics`,{schema:i2,schemaContext:"getSessionMetrics"})}function E2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/pane`)}function T2(i,r){return vt(`/v1/sessions/${encodeURIComponent(i)}/send`,{method:"POST",body:JSON.stringify({text:r}),schema:Jw,schemaContext:"sendMessage"})}function fv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/approve`,{method:"POST"})}function A2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/reject`,{method:"POST"})}function dv(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/interrupt`,{method:"POST"})}function R2(i){return vt(`/v1/sessions/${encodeURIComponent(i)}/escape`,{method:"POST"})}const Gm=3,D2=1e3;async function _v(i,r){for(let a=0;a<Gm;a++){if(r!=null&&r.aborted)throw new DOMException("Aborted","AbortError");try{return await B2(r)}catch{if(r!=null&&r.aborted)throw new DOMException("Aborted","AbortError");if(a<Gm-1){const o=D2*Math.pow(2,a);await new Promise(g=>{const x=setTimeout(g,o);r==null||r.addEventListener("abort",()=>{clearTimeout(x),g(void 0)},{once:!0})})}}}throw i==null||i(),new Error("Real-time updates unavailable")}function mv(i,r,a,o){const g=`/v1/sessions/${encodeURIComponent(i)}/events`;let x=null,T=!1;const c=new AbortController;return a?_v(o==null?void 0:o.onGiveUp,c.signal).then(u=>{if(T)return;const h=`${g}?token=${encodeURIComponent(u.token)}`;x=new nl(h,r,o)}).catch(()=>{}):x=new nl(g,r,o),()=>{T=!0,c.abort(),x==null||x.close()}}function k2(i,r,a){const o="/v1/events";let g=null,x=!1;const T=new AbortController,c=u=>{try{const h=c2.safeParse(JSON.parse(u.data));if(!h.success){console.warn("Global SSE event failed validation",h.error.message);return}i(h.data)}catch{}};return r?_v(a==null?void 0:a.onGiveUp,T.signal).then(u=>{if(x)return;const h=`${o}?token=${encodeURIComponent(u.token)}`;g=new nl(h,c,a)}).catch(()=>{}):g=new nl(o,c,a),()=>{var u;x=!0,T.abort(),(u=a==null?void 0:a.onClose)==null||u.call(a),g==null||g.close()}}function O2(i){return vt("/v1/sessions/batch",{method:"POST",signal:i.signal,body:JSON.stringify(i)})}function M2(i){return vt("/v1/pipelines",{method:"POST",body:JSON.stringify(i)})}function L2(){return vt("/v1/pipelines")}function N2(i){return vt(`/v1/pipelines/${encodeURIComponent(i)}`)}function B2(i){return vt("/v1/auth/sse-token",{method:"POST",signal:i})}const qo=new Map;let z2=0;const Xs=Mp(i=>({toasts:[],addToast:(r,a,o)=>{const g=`toast-${++z2}`,x=setTimeout(()=>{qo.delete(g),i(T=>({toasts:T.toasts.filter(c=>c.id!==g)}))},4e3);return qo.set(g,x),i(T=>({toasts:[...T.toasts,{id:g,type:r,title:a,description:o}]})),g},removeToast:r=>{const a=qo.get(r);a&&(clearTimeout(a),qo.delete(r)),i(o=>({toasts:o.toasts.filter(g=>g.id!==r)}))}})),j2={error:"border-red-500/50 bg-red-950/80 text-red-200",success:"border-green-500/50 bg-green-950/80 text-green-200",info:"border-cyan-500/50 bg-cyan-950/80 text-cyan-200",warning:"border-yellow-500/50 bg-yellow-950/80 text-yellow-200"};function H2({id:i,type:r,title:a,description:o}){const g=Xs(x=>x.removeToast);return O.jsxs("div",{role:"alert",className:`flex items-start gap-3 rounded-lg border px-4 py-3 shadow-lg backdrop-blur-sm animate-slide-in ${j2[r]}`,children:[O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsx("p",{className:"text-sm font-medium",children:a}),o&&O.jsx("p",{className:"mt-0.5 text-xs opacity-80",children:o})]}),O.jsx("button",{onClick:()=>g(i),className:"shrink-0 rounded p-0.5 opacity-60 hover:opacity-100 transition-opacity","aria-label":"Dismiss",children:O.jsx(hl,{className:"h-3.5 w-3.5"})})]})}function U2(){const i=Xs(r=>r.toasts);return i.length===0?null:O.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm w-full pointer-events-none",children:i.map(r=>O.jsx("div",{className:"pointer-events-auto",children:O.jsx(H2,{id:r.id,type:r.type,title:r.title,description:r.description})},r.id))})}const I2=[{to:"/",label:"Overview",icon:HS},{to:"/pipelines",label:"Pipelines",icon:kp}];function P2(){const i=Mt(x=>x.sseConnected),r=Mt(x=>x.setSseConnected),a=Mt(x=>x.addActivity),o=Mt(x=>x.token),g=F.useRef(null);return F.useEffect(()=>{let x;try{x=k2(T=>{T.sessionId&&a(T)},o,{onOpen:()=>{g.current&&(clearTimeout(g.current),g.current=null),r(!0)},onClose:()=>{g.current=setTimeout(()=>{r(!1)},2e3)}})}catch(T){console.error("Failed to subscribe to global SSE:",T)}return()=>{g.current&&clearTimeout(g.current),x==null||x()}},[r,a,o]),O.jsxs("div",{className:"flex h-screen overflow-hidden bg-void",children:[O.jsxs("aside",{className:"flex w-56 flex-col border-r border-void-lighter bg-void-light shrink-0",children:[O.jsxs("div",{className:"flex items-center gap-2 px-4 py-5 border-b border-void-lighter",children:[O.jsx(tb,{className:"h-6 w-6 text-cyan glow-text-cyan"}),O.jsx("span",{className:"text-lg font-semibold tracking-tight text-gray-100",children:"Aegis"})]}),O.jsxs("nav",{className:"flex flex-col gap-1 px-2 py-4 flex-1",children:[I2.map(({to:x,label:T,icon:c})=>O.jsxs(Ap,{to:x,end:x==="/",className:({isActive:u})=>`flex items-center gap-2.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors ${u?"bg-cyan/10 text-cyan":"text-gray-400 hover:bg-void-lighter hover:text-gray-200"}`,children:[O.jsx(c,{className:"h-4 w-4"}),T]},x)),O.jsx("div",{className:"mt-4 border-t border-void-lighter pt-4 opacity-40",children:O.jsxs("div",{className:"flex items-center gap-2.5 px-3 py-2 text-sm text-gray-500",children:[O.jsx(nb,{className:"h-4 w-4"}),"Sessions"]})})]})]}),O.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[O.jsxs("header",{className:"flex items-center justify-between border-b border-void-lighter bg-void-light px-6 py-3 shrink-0",children:[O.jsx("h1",{className:"text-sm font-medium text-gray-300",children:"Aegis Dashboard"}),O.jsx("div",{className:"flex items-center gap-3",children:O.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-gray-500",children:[O.jsx("span",{className:`status-dot ${i?"status-dot--idle":""}`,style:i?void 0:{backgroundColor:"#666"}}),i?"SSE Live":"SSE Off"]})})]}),O.jsx("main",{className:"flex-1 overflow-auto p-6",children:O.jsx(Iy,{})})]}),O.jsx(U2,{})]})}function $2(i){if(i<0)return"0s";const r=Math.floor(i/3600),a=Math.floor(i%3600/60);return r>0&&a>0?`${r}h ${a}m`:r>0?`${r}h`:a>0?`${a}m`:`${Math.floor(i)}s`}function pr(i){const r=Date.now()-i;if(r<0)return"just now";const a=Math.floor(r/1e3);if(a<60)return`${a}s ago`;const o=Math.floor(a/60);if(o<60)return`${o}m ago`;const g=Math.floor(o/60);return g<24?`${g}h ago`:`${Math.floor(g/24)}d ago`}function F2(i){if(i<0)return"0s";const r=Math.floor(i/1e3);if(r<60)return`${r}s`;const a=Math.floor(r/60),o=r%60;if(a<60)return`${a}m ${o.toString().padStart(2,"0")}s`;const g=Math.floor(a/60),x=a%60;return`${g}h ${x.toString().padStart(2,"0")}m`}function qs({label:i,value:r,icon:a,suffix:o}){return O.jsxs("div",{className:"rounded-lg border border-void-lighter bg-[#111118] p-4",children:[O.jsxs("div",{className:"mb-2 flex items-center gap-2 text-sm text-[#888]",children:[a,i]}),O.jsxs("div",{className:"font-mono text-2xl text-[#00e5ff]",children:[r,o&&O.jsx("span",{className:"ml-1 text-base text-[#666]",children:o})]})]})}function Z2(){const i=Mt(y=>y.metrics),r=Mt(y=>y.setMetrics),[a,o]=F.useState(null),g=Xs(y=>y.addToast),x=F.useCallback(async()=>{try{const[y,d]=await Promise.all([v2(),p2()]);r(y),o(d)}catch(y){g("error","Failed to load metrics",y instanceof Error?y.message:void 0)}},[r,o,g]);F.useEffect(()=>{x();const y=setInterval(x,1e4);return()=>clearInterval(y)},[x]);const T=(i==null?void 0:i.sessions.currently_active)??(a==null?void 0:a.sessions.active)??0,c=(i==null?void 0:i.sessions.total_created)??(a==null?void 0:a.sessions.total)??0,u=i==null?void 0:i.prompt_delivery.success_rate,h=(a==null?void 0:a.uptime)??(i==null?void 0:i.uptime)??0;return O.jsxs("div",{className:"grid grid-cols-2 gap-4 lg:grid-cols-4",children:[O.jsx(qs,{label:"Active Sessions",value:T,icon:O.jsx(kp,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Total Created",value:c,icon:O.jsx(zS,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Delivery Rate",value:u!=null?u.toFixed(1):"—",suffix:"%",icon:O.jsx(mb,{className:"h-4 w-4"})}),O.jsx(qs,{label:"Uptime",value:$2(h),icon:O.jsx(MS,{className:"h-4 w-4"})})]})}const Wm={idle:"#00ff88",working:"#00e5ff",permission_prompt:"#ffaa00",bash_approval:"#ffaa00",plan_mode:"#ff8800",ask_question:"#ff3366",settings:"#00e5ff",unknown:"#666666"},q2=new Set(["working","permission_prompt","bash_approval","ask_question"]);function al({status:i}){const r=Wm[i]??Wm.unknown,a=q2.has(i);return O.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",backgroundColor:r,boxShadow:`0 0 6px ${r}66`,animation:a?"pulse 1.5s ease-in-out infinite":void 0}})}function G2(){const i=Mt(y=>y.sessions),r=Mt(y=>y.healthMap),a=Mt(y=>y.setSessionsAndHealth),o=Xs(y=>y.addToast),g=F.useCallback(async()=>{try{const y=await g2();let d={};try{const C=await C2(),w=new Set(y.sessions.map(k=>k.id));for(const[k,b]of Object.entries(C))w.has(k)&&(d[k]={alive:b.alive,loading:!1})}catch{}a(y.sessions,d)}catch(y){o("error","Failed to fetch sessions",y instanceof Error?y.message:void 0)}},[o,a]);F.useEffect(()=>{g();const y=setInterval(g,5e3);return()=>clearInterval(y)},[g]);const x=async(y,d)=>{y.preventDefault();try{await fv(d)}catch(C){o("error","Approve failed",C instanceof Error?C.message:void 0)}},T=async(y,d)=>{y.preventDefault();try{await dv(d)}catch(C){o("error","Interrupt failed",C instanceof Error?C.message:void 0)}},c=async(y,d)=>{if(y.preventDefault(),!!confirm("Kill this session?"))try{await hv(d)}catch(C){o("error","Failed to kill session",C instanceof Error?C.message:void 0)}};if(i.length===0)return O.jsx("div",{className:"rounded-lg border border-void-lighter bg-[#111118] p-12 text-center",children:O.jsx("p",{className:"text-gray-500",children:"No active sessions"})});const u=y=>y.status==="permission_prompt"||y.status==="bash_approval",h=(y,d=40)=>y.length>d?`…${y.slice(y.length-d+1)}`:y;return O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"md:hidden space-y-3",children:i.map(y=>{const d=r[y.id],C=d?d.alive:!0;return O.jsxs(Wi,{to:`/sessions/${encodeURIComponent(y.id)}`,className:"block rounded-lg border border-[#1a1a2e] bg-[#111118] p-4 active:bg-[#1a1a2e]/50 transition-colors",children:[O.jsxs("div",{className:"flex items-center justify-between mb-2",children:[O.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[O.jsx(al,{status:y.status}),O.jsx("span",{className:"font-medium text-gray-200 truncate",children:y.windowName||y.id}),!C&&O.jsx(Po,{className:"h-3.5 w-3.5 text-red-400 shrink-0"})]}),O.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[u(y)&&O.jsx("button",{onClick:w=>x(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-green-900/30 p-2 text-green-400 transition-colors hover:bg-green-900/50",title:"Approve",children:O.jsx(Cm,{className:"h-4 w-4"})}),O.jsx("button",{onClick:w=>T(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-yellow-900/30 p-2 text-yellow-400 transition-colors hover:bg-yellow-900/50",title:"Interrupt",children:O.jsx(Sm,{className:"h-4 w-4"})}),O.jsx("button",{onClick:w=>c(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-red-900/30 p-2 text-red-400 transition-colors hover:bg-red-900/50",title:"Kill",children:O.jsx(Po,{className:"h-4 w-4"})})]})]}),O.jsx("div",{className:"font-mono text-xs text-gray-500 truncate mb-1.5",children:h(y.workDir,50)}),O.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500",children:[O.jsxs("span",{children:["Age: ",pr(y.createdAt)]}),O.jsxs("span",{children:["Active: ",pr(y.lastActivity)]}),y.permissionMode&&y.permissionMode!=="default"?O.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-900/30 px-2 py-0.5 text-green-400",children:[O.jsx(bm,{className:"h-3 w-3"})," ",y.permissionMode]}):null]})]},y.id)})}),O.jsx("div",{className:"hidden md:block overflow-x-auto rounded-lg border border-void-lighter bg-[#111118]",children:O.jsxs("table",{className:"w-full text-left text-sm",children:[O.jsx("thead",{children:O.jsxs("tr",{className:"border-b border-void-lighter text-[#666]",children:[O.jsx("th",{className:"px-4 py-3 font-medium",children:"Status"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Name"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"WorkDir"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Age"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Last Activity"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Permission"}),O.jsx("th",{className:"px-4 py-3 font-medium",children:"Actions"})]})}),O.jsx("tbody",{children:i.map(y=>{const d=r[y.id],C=d?d.alive:!0;return O.jsxs("tr",{className:"border-b border-void-lighter/50 transition-colors hover:border-l-2 hover:border-l-cyan",children:[O.jsx("td",{className:"px-4 py-3",children:O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsx(al,{status:y.status}),!C&&O.jsx(Po,{className:"h-3.5 w-3.5 text-red-400"})]})}),O.jsx("td",{className:"px-4 py-3",children:O.jsx(Wi,{to:`/sessions/${encodeURIComponent(y.id)}`,className:"font-medium text-gray-200 hover:text-cyan transition-colors",children:y.windowName||y.id})}),O.jsx("td",{className:"px-4 py-3 max-w-[200px] truncate font-mono text-xs text-gray-400",title:y.workDir,children:h(y.workDir)}),O.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-gray-400",children:pr(y.createdAt)}),O.jsx("td",{className:"px-4 py-3 whitespace-nowrap text-gray-400",children:pr(y.lastActivity)}),O.jsx("td",{className:"px-4 py-3",children:y.permissionMode&&y.permissionMode!=="default"?O.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-green-900/30 px-2 py-0.5 text-xs text-green-400",children:[O.jsx(bm,{className:"h-3 w-3"}),y.permissionMode]}):O.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-void-lighter px-2 py-0.5 text-xs text-gray-500",children:"default"})}),O.jsx("td",{className:"px-4 py-3",children:O.jsxs("div",{className:"flex items-center gap-1.5",children:[u(y)&&O.jsx("button",{onClick:w=>x(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-green-900/30 text-xs font-medium text-green-400 transition-colors hover:bg-green-900/50",title:"Approve",children:O.jsx(Cm,{className:"h-3 w-3"})}),O.jsx("button",{onClick:w=>T(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-yellow-900/30 text-xs font-medium text-yellow-400 transition-colors hover:bg-yellow-900/50",title:"Interrupt",children:O.jsx(Sm,{className:"h-3 w-3"})}),O.jsx("button",{onClick:w=>c(w,y.id),className:"min-h-[44px] min-w-[44px] flex items-center justify-center rounded-md bg-red-900/30 text-xs font-medium text-red-400 transition-colors hover:bg-red-900/50",title:"Kill",children:O.jsx(Po,{className:"h-3 w-3"})})]})})]},y.id)})})]})})]})}const ju={session_status_change:{icon:VS,label:"Status",color:"#00e5ff"},session_message:{icon:PS,label:"Message",color:"#00ff88"},session_approval:{icon:QS,label:"Approval",color:"#ffaa00"},session_ended:{icon:WS,label:"Ended",color:"#ff3366"},session_created:{icon:DS,label:"Created",color:"#a78bfa"},session_stall:{icon:lb,label:"Stall",color:"#ff6600"},session_dead:{icon:sb,label:"Dead",color:"#ff0044"},session_subagent_start:{icon:fb,label:"Subagent",color:"#38bdf8"},session_subagent_stop:{icon:ub,label:"Subagent Done",color:"#34d399"}};function mr(i,r="unknown"){return typeof i=="string"?i:r}function W2(i){const r=i.data;switch(i.event){case"session_status_change":{const a=mr(r.status),o=typeof r.detail=="string"?`: ${r.detail}`:"";return`Status → ${a}${o}`}case"session_message":{const a=r.role==="user"?"User":r.role==="assistant"?"Claude":"System",o=typeof r.text=="string"?r.text:JSON.stringify(r.text??"");return`${a}: ${Ym(o,80)}`}case"session_approval":{const a=typeof r.prompt=="string"?r.prompt:JSON.stringify(r.prompt??"");return`Approval needed: ${Ym(a,80)}`}case"session_ended":return`Session ended: ${mr(r.reason)}`;case"session_created":return`Created in ${mr(r.workDir,"unknown dir")}`;case"session_stall":return`Session stalled: ${mr(r.stallType)}`;case"session_dead":return`Session dead: ${mr(r.stallType)}`;case"session_subagent_start":return`Subagent started: ${mr(r.name)}`;case"session_subagent_stop":return`Subagent finished: ${mr(r.name)}`;default:return JSON.stringify(r)}}function Ym(i,r){return i.length>r?i.slice(0,r)+"...":i}function Y2(i){try{return new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function V2(){const i=Mt(h=>h.activities),r=Mt(h=>h.activityFilterSession),a=Mt(h=>h.activityFilterType),o=Mt(h=>h.setActivityFilterSession),g=Mt(h=>h.setActivityFilterType),x=Mt(h=>h.sessions),T=F.useMemo(()=>i.filter(h=>!(r&&h.sessionId!==r||a&&h.event!==a)),[i,r,a]),c=F.useMemo(()=>{const h=new Map;for(const y of x)h.set(y.id,y.windowName??y.id.slice(0,8));return h},[x]),u=h=>c.get(h)??(h??"unknown").slice(0,8);return O.jsxs("div",{className:"bg-[#111118] border border-[#1a1a2e] rounded-lg w-full",children:[O.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2 px-3 sm:px-4 py-3 border-b border-[#1a1a2e]",children:[O.jsx("h3",{className:"text-sm font-semibold text-gray-200",children:"Activity Stream"}),O.jsxs("div",{className:"flex items-center gap-2",children:[O.jsxs("select",{value:r??"",onChange:h=>o(h.target.value||null),className:"min-h-[44px] text-xs bg-[#0a0a0f] border border-[#1a1a2e] rounded px-2 py-2 text-gray-400 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"",children:"All sessions"}),x.map(h=>O.jsx("option",{value:h.id,children:h.windowName||h.id.slice(0,8)},h.id))]}),O.jsxs("select",{value:a??"",onChange:h=>g(h.target.value||null),className:"min-h-[44px] text-xs bg-[#0a0a0f] border border-[#1a1a2e] rounded px-2 py-2 text-gray-400 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"",children:"All types"}),Object.entries(ju).map(([h,y])=>O.jsx("option",{value:h,children:y.label},h))]}),(r||a)&&O.jsx("button",{onClick:()=>{o(null),g(null)},className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-gray-300",children:O.jsx(hl,{className:"h-4 w-4"})})]})]}),O.jsxs("div",{className:"max-h-[360px] overflow-y-auto divide-y divide-[#1a1a2e]/50",children:[T.length===0&&O.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#555]",children:"No activity yet"}),T.map((h,y)=>{const d=ju[h.event]??ju.session_status_change,C=d.icon;return O.jsxs("div",{className:"flex items-start gap-2 sm:gap-3 px-3 sm:px-4 py-2 sm:py-2.5 hover:bg-[#1a1a2e]/30 transition-colors",children:[O.jsx(C,{className:"h-4 w-4 mt-0.5 shrink-0",style:{color:d.color}}),O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[O.jsx("span",{className:"text-xs font-medium text-gray-300 truncate",children:u(h.sessionId)}),O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded hidden sm:inline-block",style:{backgroundColor:`${d.color}15`,color:d.color},children:d.label})]}),O.jsx("p",{className:"text-xs text-gray-500 mt-0.5 font-mono truncate",children:W2(h)})]}),O.jsx("span",{className:"text-[10px] text-[#444] shrink-0 tabular-nums mt-0.5",children:Y2(h.timestamp)})]},`${h.sessionId}-${h.timestamp}-${y}`)})]})]})}function K2({open:i,onClose:r}){const a=ll(),o=F.useRef(null),g=F.useRef(null),x=F.useCallback(()=>{P(),r()},[r]),T=F.useRef(null);F.useEffect(()=>{if(!i)return;const N=U=>{var L;U.key==="Escape"&&((L=g.current)==null||L.abort(),x())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[i,x]),F.useEffect(()=>{if(!i)return;const N=T.current;if(!N)return;const U='input, textarea, select, button, [tabindex]:not([tabindex="-1"])',L=H=>{if(H.key!=="Tab")return;const V=Array.from(N.querySelectorAll(U));if(V.length===0)return;const re=V[0],ue=V[V.length-1];H.shiftKey?document.activeElement===re&&(H.preventDefault(),ue.focus()):document.activeElement===ue&&(H.preventDefault(),re.focus())};return N.addEventListener("keydown",L),()=>N.removeEventListener("keydown",L)},[i]),F.useEffect(()=>{if(i){const N=setTimeout(()=>{var U;return(U=o.current)==null?void 0:U.focus()},50);return()=>clearTimeout(N)}},[i]);const[c,u]=F.useState(""),[h,y]=F.useState(""),[d,C]=F.useState(""),[w,k]=F.useState("default"),[b,m]=F.useState(!1),[v,f]=F.useState(null);let p=0;function S(){return{workDir:"",name:"",prompt:"",_key:p++}}const[A,R]=F.useState("single"),[M,E]=F.useState([S(),S()]),[B,$]=F.useState(""),[I,q]=F.useState(null);function P(){u(""),y(""),C(""),k("default"),m(!1),f(null),E([S(),S()]),$(""),q(null),R("single")}function J(){M.length>=10||E([...M,S()])}function te(N){M.length<=1||E(M.filter((U,L)=>L!==N))}function G(N,U,L){E(M.map((H,V)=>V===N?{...H,[U]:L}:H))}async function se(N){var H;N.preventDefault(),f(null),q(null);const U=M.filter(V=>V.workDir.trim());if(U.length===0){f("At least one working directory is required");return}m(!0),(H=g.current)==null||H.abort();const L=new AbortController;g.current=L;try{const V=await O2({sessions:U.map(re=>({workDir:re.workDir.trim(),name:re.name.trim()||void 0,prompt:re.prompt.trim()||B.trim()||void 0,permissionMode:w})),signal:L.signal});q(V)}catch(V){if(L.signal.aborted)return;f(V instanceof Error?V.message:"Failed to create sessions")}finally{g.current===L&&(g.current=null,m(!1))}}if(!i)return null;async function ae(N){var L;if(N.preventDefault(),f(null),!c.trim()){f("Working directory is required");return}m(!0),(L=g.current)==null||L.abort();const U=new AbortController;g.current=U;try{const H=await S2({workDir:c.trim(),name:h.trim()||void 0,prompt:d.trim()||void 0,permissionMode:w,signal:U.signal});P(),r(),a(`/sessions/${H.id}`)}catch(H){if(U.signal.aborted)return;f(H instanceof Error?H.message:"Failed to create session")}finally{g.current===U&&(g.current=null,m(!1))}}return O.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[O.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:x}),O.jsxs("div",{ref:T,role:"dialog","aria-modal":"true","aria-label":"Create new session",className:`relative w-full ${A==="batch"?"max-w-2xl":"max-w-md"} mx-4 bg-[#111118] border border-[#1a1a2e] rounded-lg shadow-2xl max-h-[90vh] overflow-y-auto`,children:[O.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-5 py-4 border-b border-[#1a1a2e]",children:[O.jsxs("div",{className:"flex items-center gap-4",children:[O.jsx("h2",{className:"text-sm font-semibold text-gray-100",children:"New Session"}),O.jsxs("div",{className:"flex rounded bg-[#0a0a0f] p-0.5",children:[O.jsx("button",{type:"button",onClick:()=>R("single"),className:`px-3 py-1 text-xs rounded transition-colors ${A==="single"?"bg-[#00e5ff]/10 text-[#00e5ff]":"text-gray-500 hover:text-gray-300"}`,children:"Single"}),O.jsx("button",{type:"button",onClick:()=>R("batch"),className:`px-3 py-1 text-xs rounded transition-colors ${A==="batch"?"bg-[#00e5ff]/10 text-[#00e5ff]":"text-gray-500 hover:text-gray-300"}`,children:"Batch"})]})]}),O.jsx("button",{onClick:x,className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-gray-300 transition-colors",children:O.jsx(hl,{className:"h-4 w-4"})})]}),A==="single"&&O.jsxs("form",{onSubmit:ae,className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{children:[O.jsxs("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:["Working Directory ",O.jsx("span",{className:"text-[#ff3366]",children:"*"})]}),O.jsx("input",{type:"text",ref:o,value:c,onChange:N=>u(N.target.value),placeholder:"/home/user/project",className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] font-mono"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Session Name"}),O.jsx("input",{type:"text",value:h,onChange:N=>y(N.target.value),placeholder:"my-session",className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Initial Prompt"}),O.jsx("textarea",{value:d,onChange:N=>C(N.target.value),placeholder:"Fix the login bug...",rows:3,className:"w-full min-h-[88px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] resize-none"})]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Permission Mode"}),O.jsxs("select",{value:w,onChange:N=>k(N.target.value),className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"default",children:"default — asks for everything"}),O.jsx("option",{value:"plan",children:"plan — auto-reads, asks for writes"}),O.jsx("option",{value:"acceptEdits",children:"acceptEdits — auto-edits, asks for bash"}),O.jsx("option",{value:"bypassPermissions",children:"bypassPermissions — never asks"}),O.jsx("option",{value:"auto",children:"auto — auto-approve in sandbox"})]})]}),v&&O.jsx("div",{className:"text-xs text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-2",children:v}),O.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Cancel"}),O.jsxs("button",{type:"submit",disabled:b||!c.trim(),className:"min-h-[44px] flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[b&&O.jsx(Ku,{className:"h-3 w-3 animate-spin"}),"Create Session"]})]})]}),A==="batch"&&!I&&O.jsxs("form",{onSubmit:se,className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Shared Prompt"}),O.jsx("textarea",{value:B,onChange:N=>$(N.target.value),placeholder:"Apply to all sessions without a per-row prompt...",rows:2,className:"w-full min-h-[88px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] resize-none"})]}),O.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_44px] gap-2 text-xs font-medium text-gray-500 px-1",children:[O.jsxs("span",{children:["Working Directory ",O.jsx("span",{className:"text-[#ff3366]",children:"*"})]}),O.jsx("span",{children:"Name"}),O.jsx("span",{children:"Prompt (override)"}),O.jsx("span",{})]}),O.jsx("div",{className:"space-y-2",children:M.map((N,U)=>O.jsxs("div",{className:"grid grid-cols-[1fr_120px_1fr_44px] gap-2 items-start",children:[O.jsx("input",{type:"text",value:N.workDir,onChange:L=>G(U,"workDir",L.target.value),placeholder:"/home/user/project",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff] font-mono"}),O.jsx("input",{type:"text",value:N.name,onChange:L=>G(U,"name",L.target.value),placeholder:"name",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"}),O.jsx("input",{type:"text",value:N.prompt,onChange:L=>G(U,"prompt",L.target.value),placeholder:"Override prompt...",className:"min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 placeholder-gray-600 focus:outline-none focus:border-[#00e5ff]"}),O.jsx("button",{type:"button",onClick:()=>te(U),disabled:M.length<=1,className:"min-h-[44px] min-w-[44px] flex items-center justify-center text-gray-500 hover:text-[#ff3366] transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:O.jsx(Op,{className:"h-3.5 w-3.5"})})]},N._key))}),M.length<10&&O.jsxs("button",{type:"button",onClick:J,className:"flex items-center gap-1.5 text-xs text-gray-500 hover:text-gray-300 transition-colors",children:[O.jsx(ul,{className:"h-3.5 w-3.5"}),"Add session"]}),O.jsxs("div",{children:[O.jsx("label",{className:"block text-xs font-medium text-gray-400 mb-1.5",children:"Permission Mode"}),O.jsxs("select",{value:w,onChange:N=>k(N.target.value),className:"w-full min-h-[44px] px-3 py-2.5 text-sm bg-[#0a0a0f] border border-[#1a1a2e] rounded text-gray-200 focus:outline-none focus:border-[#00e5ff]",children:[O.jsx("option",{value:"default",children:"default — asks for everything"}),O.jsx("option",{value:"plan",children:"plan — auto-reads, asks for writes"}),O.jsx("option",{value:"acceptEdits",children:"acceptEdits — auto-edits, asks for bash"}),O.jsx("option",{value:"bypassPermissions",children:"bypassPermissions — never asks"}),O.jsx("option",{value:"auto",children:"auto — auto-approve in sandbox"})]})]}),v&&O.jsx("div",{className:"text-xs text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-2",children:v}),O.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2",children:[O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Cancel"}),O.jsxs("button",{type:"submit",disabled:b||!M.some(N=>N.workDir.trim()),className:"min-h-[44px] flex items-center gap-1.5 px-4 py-2.5 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[b&&O.jsx(Ku,{className:"h-3 w-3 animate-spin"}),"Create ",M.filter(N=>N.workDir.trim()).length," Session(s)"]})]})]}),I&&O.jsxs("div",{className:"p-4 sm:p-5 space-y-4",children:[O.jsxs("div",{className:"flex items-center gap-3",children:[I.created>0&&O.jsxs("span",{className:"text-xs font-medium text-emerald-400 bg-emerald-400/10 border border-emerald-400/20 rounded px-3 py-1.5",children:[I.created," created"]}),I.failed>0&&O.jsxs("span",{className:"text-xs font-medium text-[#ff3366] bg-[#ff3366]/10 border border-[#ff3366]/20 rounded px-3 py-1.5",children:[I.failed," failed"]})]}),I.sessions.length>0&&O.jsxs("div",{className:"space-y-1",children:[O.jsx("p",{className:"text-xs font-medium text-gray-400",children:"Created sessions"}),O.jsx("ul",{className:"space-y-1",children:I.sessions.map(N=>O.jsx("li",{children:O.jsxs("button",{type:"button",onClick:()=>{x(),a(`/sessions/${N.id}`)},className:"text-xs text-[#00e5ff] hover:underline font-mono",children:[N.id.slice(0,8),"...",N.name?` — ${N.name}`:""]})},N.id))})]}),I.errors.length>0&&O.jsxs("div",{className:"space-y-1",children:[O.jsx("p",{className:"text-xs font-medium text-gray-400",children:"Errors"}),O.jsx("ul",{className:"space-y-1",children:I.errors.map((N,U)=>O.jsx("li",{className:"text-xs text-[#ff3366]",children:N},U))})]}),O.jsx("div",{className:"flex justify-end pt-2",children:O.jsx("button",{type:"button",onClick:x,className:"min-h-[44px] px-4 py-2.5 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-gray-300 transition-colors",children:"Close"})})]})]})]})}function X2(){const[i,r]=F.useState(!1);return O.jsxs("div",{className:"flex flex-col gap-6",children:[O.jsxs("div",{className:"flex items-center justify-between",children:[O.jsxs("div",{children:[O.jsx("h2",{className:"text-2xl font-bold text-gray-100",children:"Overview"}),O.jsx("p",{className:"mt-1 text-sm text-gray-500",children:"Aegis session monitoring and metrics"})]}),O.jsxs("button",{onClick:()=>r(!0),className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded bg-[#00e5ff]/10 hover:bg-[#00e5ff]/20 text-[#00e5ff] border border-[#00e5ff]/30 transition-colors",children:[O.jsx(ul,{className:"h-3.5 w-3.5"}),"New Session"]})]}),O.jsx(Z2,{}),O.jsxs("div",{children:[O.jsx("h3",{className:"mb-3 text-lg font-semibold text-gray-200",children:"Sessions"}),O.jsx(G2,{})]}),O.jsx(V2,{}),O.jsx(K2,{open:i,onClose:()=>r(!1)})]})}function Vm(i){return i instanceof Error&&"statusCode"in i}function J2(i){const r=Mt(J=>J.token),a=Xs(J=>J.addToast),[o,g]=F.useState(null),[x,T]=F.useState(null),[c,u]=F.useState(!1),[h,y]=F.useState(!0),[d,C]=F.useState(""),[w,k]=F.useState(!0),[b,m]=F.useState(null),[v,f]=F.useState(!0),p=F.useRef(i);p.current=i;const S=F.useRef(!1),A=F.useRef(0),R=F.useRef(void 0),M=F.useRef(void 0),E=F.useCallback(async()=>{try{const[J,te]=await Promise.allSettled([y2(p.current),b2(p.current)]);if(J.status==="rejected"&&Vm(J.reason)&&J.reason.statusCode===404||te.status==="rejected"&&Vm(te.reason)&&te.reason.statusCode===404){u(!0);return}J.status==="fulfilled"&&g(J.value),te.status==="fulfilled"&&T(te.value)}catch(J){a("error","Failed to load session",J instanceof Error?J.message:void 0)}finally{y(!1)}},[a]);R.current=E;const B=F.useCallback(async()=>{if(S.current)return;const J=p.current;try{const te=await E2(J);S.current||C(te.pane??"")}catch(te){a("warning","Failed to load terminal pane",te instanceof Error?te.message:void 0)}finally{S.current||k(!1)}try{const te=await w2(J);S.current||m(te)}catch(te){a("warning","Failed to load session metrics",te instanceof Error?te.message:void 0)}finally{S.current||f(!1)}},[a]);M.current=B,F.useEffect(()=>(S.current=!1,A.current++,y(!0),k(!0),f(!0),E(),B(),()=>{S.current=!0,$.current&&clearTimeout($.current),I.current&&clearTimeout(I.current)}),[i,E,B]);const $=F.useRef(void 0),I=F.useRef(void 0),q=F.useCallback(()=>{$.current&&clearTimeout($.current);const J=A.current;$.current=setTimeout(()=>{var te;A.current===J&&((te=M.current)==null||te.call(M))},1e3)},[]),P=F.useCallback(()=>{I.current&&clearTimeout(I.current);const J=A.current;I.current=setTimeout(()=>{var te;A.current===J&&((te=R.current)==null||te.call(R))},1e3)},[]);return F.useEffect(()=>{if(!i)return;const J=mv(i,te=>{var G,se;try{const ae=o2.safeParse(JSON.parse(te.data));if(!ae.success){console.warn("SSE event failed validation",ae.error.message);return}switch(ae.data.event){case"status":case"approval":case"stall":case"dead":P(),q();break;case"message":q();break;case"ended":(G=R.current)==null||G.call(R),(se=M.current)==null||se.call(M);break}}catch{}},r);return()=>J()},[i,r,P,q]),{session:o,health:x,notFound:c,loading:h,paneContent:d,paneLoading:w,metrics:b,metricsLoading:v,refetchPaneAndMetrics:B}}const Q2={idle:"Idle",working:"Working",permission_prompt:"Permission",plan_mode:"Planning",ask_question:"Question",bash_approval:"Bash Approval",settings:"Settings",unknown:"Unknown"};function Km(i,r){if(i.length<=r)return i;const a=i.slice(0,Math.ceil(r/2)-1),o=i.slice(-(Math.floor(r/2)-2));return`${a}…${o}`}function Xm(i){return new Date(i).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function eE({session:i,health:r,onApprove:a,onReject:o,onInterrupt:g,onKill:x}){const[T,c]=F.useState(!1),u=r.status==="permission_prompt"||r.status==="bash_approval";return O.jsxs("div",{className:"bg-[#111118] border border-[#1a1a2e] rounded-lg p-3 sm:p-4",children:[O.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[O.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[O.jsx(al,{status:r.status}),O.jsx("span",{className:"text-sm font-medium text-[#e0e0e0]",children:Q2[r.status]})]}),O.jsxs("div",{className:"flex-1 min-w-0",children:[O.jsx("h1",{className:"text-base sm:text-lg font-semibold text-[#e0e0e0] truncate",children:i.windowName||"Untitled Session"}),O.jsx("div",{className:"text-xs text-[#555] font-mono truncate mt-0.5",children:Km(i.workDir,40)})]}),O.jsxs("div",{className:"hidden sm:flex items-center gap-2 shrink-0",children:[i.permissionMode&&i.permissionMode!=="default"&&O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#003322] text-[#00ff88] border border-[#00ff88]/30",children:i.permissionMode}),r.alive?O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#111118] text-[#888] border border-[#1a1a2e]",children:"Alive"}):O.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider px-2 py-0.5 rounded bg-[#331111] text-[#ff3366] border border-[#ff3366]/30",children:"Dead"})]})]}),O.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 text-[11px] text-[#555] mb-3 flex-wrap",children:[O.jsxs("span",{children:["Created: ",Xm(i.createdAt)]}),O.jsxs("span",{className:"hidden sm:inline",children:["Last activity: ",Xm(i.lastActivity)]}),O.jsxs("span",{className:"font-mono hidden sm:inline",children:["ID: ",Km(i.id,16)]}),r.details&&O.jsx("span",{className:"text-[#888] italic",children:r.details})]}),O.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&O.jsxs(O.Fragment,{children:[O.jsx("button",{onClick:a,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#003322] hover:bg-[#004433] text-[#00ff88] border border-[#00ff88]/30 transition-colors",children:"Approve"}),O.jsx("button",{onClick:o,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#331111] hover:bg-[#442222] text-[#ff3366] border border-[#ff3366]/30 transition-colors",children:"Reject"})]}),O.jsx("button",{onClick:g,className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors",children:"Interrupt"}),T?O.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[O.jsx("span",{className:"text-xs text-[#ff3366]",children:"Confirm kill?"}),O.jsx("button",{onClick:()=>{x==null||x(),c(!1)},className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#331111] text-[#ff3366] border border-[#ff3366]/30 transition-colors",children:"Yes, Kill"}),O.jsx("button",{onClick:()=>c(!1),className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors",children:"Cancel"})]}):O.jsx("button",{onClick:()=>c(!0),className:"min-h-[44px] px-3 py-2 text-xs font-medium rounded bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#e0e0e0] border border-[#1a1a2e] transition-colors ml-auto",children:"Kill"})]})]})}/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */const{entries:pv,setPrototypeOf:Jm,isFrozen:tE,getPrototypeOf:iE,getOwnPropertyDescriptor:sE}=Object;let{freeze:Yt,seal:ki,create:Xo}=Object,{apply:eh,construct:th}=typeof Reflect<"u"&&Reflect;Yt||(Yt=function(r){return r});ki||(ki=function(r){return r});eh||(eh=function(r,a){for(var o=arguments.length,g=new Array(o>2?o-2:0),x=2;x<o;x++)g[x-2]=arguments[x];return r.apply(a,g)});th||(th=function(r){for(var a=arguments.length,o=new Array(a>1?a-1:0),g=1;g<a;g++)o[g-1]=arguments[g];return new r(...o)});const Go=Vt(Array.prototype.forEach),rE=Vt(Array.prototype.lastIndexOf),Qm=Vt(Array.prototype.pop),ua=Vt(Array.prototype.push),nE=Vt(Array.prototype.splice),Jo=Vt(String.prototype.toLowerCase),Hu=Vt(String.prototype.toString),Uu=Vt(String.prototype.match),ha=Vt(String.prototype.replace),aE=Vt(String.prototype.indexOf),oE=Vt(String.prototype.trim),_i=Vt(Object.prototype.hasOwnProperty),Gt=Vt(RegExp.prototype.test),fa=lE(TypeError);function Vt(i){return function(r){r instanceof RegExp&&(r.lastIndex=0);for(var a=arguments.length,o=new Array(a>1?a-1:0),g=1;g<a;g++)o[g-1]=arguments[g];return eh(i,r,o)}}function lE(i){return function(){for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];return th(i,a)}}function Me(i,r){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jo;Jm&&Jm(i,null);let o=r.length;for(;o--;){let g=r[o];if(typeof g=="string"){const x=a(g);x!==g&&(tE(r)||(r[o]=x),g=x)}i[g]=!0}return i}function cE(i){for(let r=0;r<i.length;r++)_i(i,r)||(i[r]=null);return i}function qi(i){const r=Xo(null);for(const[a,o]of pv(i))_i(i,a)&&(Array.isArray(o)?r[a]=cE(o):o&&typeof o=="object"&&o.constructor===Object?r[a]=qi(o):r[a]=o);return r}function da(i,r){for(;i!==null;){const o=sE(i,r);if(o){if(o.get)return Vt(o.get);if(typeof o.value=="function")return Vt(o.value)}i=iE(i)}function a(){return null}return a}const ep=Yt(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Iu=Yt(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Pu=Yt(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),uE=Yt(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),$u=Yt(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),hE=Yt(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),tp=Yt(["#text"]),ip=Yt(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Fu=Yt(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),sp=Yt(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Wo=Yt(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),fE=ki(/\{\{[\w\W]*|[\w\W]*\}\}/gm),dE=ki(/<%[\w\W]*|[\w\W]*%>/gm),_E=ki(/\$\{[\w\W]*/gm),mE=ki(/^data-[\-\w.\u00B7-\uFFFF]+$/),pE=ki(/^aria-[\-\w]+$/),vv=ki(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vE=ki(/^(?:\w+script|data):/i),gE=ki(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gv=ki(/^html$/i),yE=ki(/^[a-z][.\w]*(-[.\w]+)+$/i);var rp=Object.freeze({__proto__:null,ARIA_ATTR:pE,ATTR_WHITESPACE:gE,CUSTOM_ELEMENT:yE,DATA_ATTR:mE,DOCTYPE_NAME:gv,ERB_EXPR:dE,IS_ALLOWED_URI:vv,IS_SCRIPT_OR_DATA:vE,MUSTACHE_EXPR:fE,TMPLIT_EXPR:_E});const _a={element:1,text:3,progressingInstruction:7,comment:8,document:9},SE=function(){return typeof window>"u"?null:window},bE=function(r,a){if(typeof r!="object"||typeof r.createPolicy!="function")return null;let o=null;const g="data-tt-policy-suffix";a&&a.hasAttribute(g)&&(o=a.getAttribute(g));const x="dompurify"+(o?"#"+o:"");try{return r.createPolicy(x,{createHTML(T){return T},createScriptURL(T){return T}})}catch{return console.warn("TrustedTypes policy "+x+" could not be created."),null}},np=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function yv(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:SE();const r=Se=>yv(Se);if(r.version="3.3.3",r.removed=[],!i||!i.document||i.document.nodeType!==_a.document||!i.Element)return r.isSupported=!1,r;let{document:a}=i;const o=a,g=o.currentScript,{DocumentFragment:x,HTMLTemplateElement:T,Node:c,Element:u,NodeFilter:h,NamedNodeMap:y=i.NamedNodeMap||i.MozNamedAttrMap,HTMLFormElement:d,DOMParser:C,trustedTypes:w}=i,k=u.prototype,b=da(k,"cloneNode"),m=da(k,"remove"),v=da(k,"nextSibling"),f=da(k,"childNodes"),p=da(k,"parentNode");if(typeof T=="function"){const Se=a.createElement("template");Se.content&&Se.content.ownerDocument&&(a=Se.content.ownerDocument)}let S,A="";const{implementation:R,createNodeIterator:M,createDocumentFragment:E,getElementsByTagName:B}=a,{importNode:$}=o;let I=np();r.isSupported=typeof pv=="function"&&typeof p=="function"&&R&&R.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:q,ERB_EXPR:P,TMPLIT_EXPR:J,DATA_ATTR:te,ARIA_ATTR:G,IS_SCRIPT_OR_DATA:se,ATTR_WHITESPACE:ae,CUSTOM_ELEMENT:N}=rp;let{IS_ALLOWED_URI:U}=rp,L=null;const H=Me({},[...ep,...Iu,...Pu,...$u,...tp]);let V=null;const re=Me({},[...ip,...Fu,...sp,...Wo]);let ue=Object.seal(Xo(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),me=null,Y=null;const j=Object.seal(Xo(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ce=!0,oe=!0,ve=!1,pe=!0,Te=!1,je=!0,Ue=!1,ct=!1,Ee=!1,Ft=!1,mi=!1,pi=!1,Ui=!0,Vi=!1;const Pt="user-content-";let nt=!0,Rt=!1,Zt={},Nt=null;const Bt=Me({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ki=null;const Kt=Me({},["audio","video","img","source","image","track"]);let Li=null;const Ye=Me({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),vi="http://www.w3.org/1998/Math/MathML",Dt="http://www.w3.org/2000/svg",kt="http://www.w3.org/1999/xhtml";let gt=kt,un=!1,hn=null;const gl=Me({},[vi,Dt,kt],Hu);let Xi=Me({},["mi","mo","mn","ms","mtext"]),Ji=Me({},["annotation-xml"]);const gr=Me({},["title","style","font","a","script"]);let ai=null;const yr=["application/xhtml+xml","text/html"],Js="text/html";let _t=null,Qi=null;const fn=a.createElement("form"),bs=function(W){return W instanceof RegExp||W instanceof Function},dn=function(){let W=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qi&&Qi===W)){if((!W||typeof W!="object")&&(W={}),W=qi(W),ai=yr.indexOf(W.PARSER_MEDIA_TYPE)===-1?Js:W.PARSER_MEDIA_TYPE,_t=ai==="application/xhtml+xml"?Hu:Jo,L=_i(W,"ALLOWED_TAGS")?Me({},W.ALLOWED_TAGS,_t):H,V=_i(W,"ALLOWED_ATTR")?Me({},W.ALLOWED_ATTR,_t):re,hn=_i(W,"ALLOWED_NAMESPACES")?Me({},W.ALLOWED_NAMESPACES,Hu):gl,Li=_i(W,"ADD_URI_SAFE_ATTR")?Me(qi(Ye),W.ADD_URI_SAFE_ATTR,_t):Ye,Ki=_i(W,"ADD_DATA_URI_TAGS")?Me(qi(Kt),W.ADD_DATA_URI_TAGS,_t):Kt,Nt=_i(W,"FORBID_CONTENTS")?Me({},W.FORBID_CONTENTS,_t):Bt,me=_i(W,"FORBID_TAGS")?Me({},W.FORBID_TAGS,_t):qi({}),Y=_i(W,"FORBID_ATTR")?Me({},W.FORBID_ATTR,_t):qi({}),Zt=_i(W,"USE_PROFILES")?W.USE_PROFILES:!1,ce=W.ALLOW_ARIA_ATTR!==!1,oe=W.ALLOW_DATA_ATTR!==!1,ve=W.ALLOW_UNKNOWN_PROTOCOLS||!1,pe=W.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=W.SAFE_FOR_TEMPLATES||!1,je=W.SAFE_FOR_XML!==!1,Ue=W.WHOLE_DOCUMENT||!1,Ft=W.RETURN_DOM||!1,mi=W.RETURN_DOM_FRAGMENT||!1,pi=W.RETURN_TRUSTED_TYPE||!1,Ee=W.FORCE_BODY||!1,Ui=W.SANITIZE_DOM!==!1,Vi=W.SANITIZE_NAMED_PROPS||!1,nt=W.KEEP_CONTENT!==!1,Rt=W.IN_PLACE||!1,U=W.ALLOWED_URI_REGEXP||vv,gt=W.NAMESPACE||kt,Xi=W.MATHML_TEXT_INTEGRATION_POINTS||Xi,Ji=W.HTML_INTEGRATION_POINTS||Ji,ue=W.CUSTOM_ELEMENT_HANDLING||{},W.CUSTOM_ELEMENT_HANDLING&&bs(W.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ue.tagNameCheck=W.CUSTOM_ELEMENT_HANDLING.tagNameCheck),W.CUSTOM_ELEMENT_HANDLING&&bs(W.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ue.attributeNameCheck=W.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),W.CUSTOM_ELEMENT_HANDLING&&typeof W.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ue.allowCustomizedBuiltInElements=W.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Te&&(oe=!1),mi&&(Ft=!0),Zt&&(L=Me({},tp),V=Xo(null),Zt.html===!0&&(Me(L,ep),Me(V,ip)),Zt.svg===!0&&(Me(L,Iu),Me(V,Fu),Me(V,Wo)),Zt.svgFilters===!0&&(Me(L,Pu),Me(V,Fu),Me(V,Wo)),Zt.mathMl===!0&&(Me(L,$u),Me(V,sp),Me(V,Wo))),_i(W,"ADD_TAGS")||(j.tagCheck=null),_i(W,"ADD_ATTR")||(j.attributeCheck=null),W.ADD_TAGS&&(typeof W.ADD_TAGS=="function"?j.tagCheck=W.ADD_TAGS:(L===H&&(L=qi(L)),Me(L,W.ADD_TAGS,_t))),W.ADD_ATTR&&(typeof W.ADD_ATTR=="function"?j.attributeCheck=W.ADD_ATTR:(V===re&&(V=qi(V)),Me(V,W.ADD_ATTR,_t))),W.ADD_URI_SAFE_ATTR&&Me(Li,W.ADD_URI_SAFE_ATTR,_t),W.FORBID_CONTENTS&&(Nt===Bt&&(Nt=qi(Nt)),Me(Nt,W.FORBID_CONTENTS,_t)),W.ADD_FORBID_CONTENTS&&(Nt===Bt&&(Nt=qi(Nt)),Me(Nt,W.ADD_FORBID_CONTENTS,_t)),nt&&(L["#text"]=!0),Ue&&Me(L,["html","head","body"]),L.table&&(Me(L,["tbody"]),delete me.tbody),W.TRUSTED_TYPES_POLICY){if(typeof W.TRUSTED_TYPES_POLICY.createHTML!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof W.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw fa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=W.TRUSTED_TYPES_POLICY,A=S.createHTML("")}else S===void 0&&(S=bE(w,g)),S!==null&&typeof A=="string"&&(A=S.createHTML(""));Yt&&Yt(W),Qi=W}},_n=Me({},[...Iu,...Pu,...uE]),mn=Me({},[...$u,...hE]),xa=function(W){let _e=p(W);(!_e||!_e.tagName)&&(_e={namespaceURI:gt,tagName:"template"});const ge=Jo(W.tagName),Ze=Jo(_e.tagName);return hn[W.namespaceURI]?W.namespaceURI===Dt?_e.namespaceURI===kt?ge==="svg":_e.namespaceURI===vi?ge==="svg"&&(Ze==="annotation-xml"||Xi[Ze]):!!_n[ge]:W.namespaceURI===vi?_e.namespaceURI===kt?ge==="math":_e.namespaceURI===Dt?ge==="math"&&Ji[Ze]:!!mn[ge]:W.namespaceURI===kt?_e.namespaceURI===Dt&&!Ji[Ze]||_e.namespaceURI===vi&&!Xi[Ze]?!1:!mn[ge]&&(gr[ge]||!_n[ge]):!!(ai==="application/xhtml+xml"&&hn[W.namespaceURI]):!1},Xt=function(W){ua(r.removed,{element:W});try{p(W).removeChild(W)}catch{m(W)}},Ni=function(W,_e){try{ua(r.removed,{attribute:_e.getAttributeNode(W),from:_e})}catch{ua(r.removed,{attribute:null,from:_e})}if(_e.removeAttribute(W),W==="is")if(Ft||mi)try{Xt(_e)}catch{}else try{_e.setAttribute(W,"")}catch{}},pn=function(W){let _e=null,ge=null;if(Ee)W="<remove></remove>"+W;else{const ke=Uu(W,/^[\r\n\t ]+/);ge=ke&&ke[0]}ai==="application/xhtml+xml"&>===kt&&(W='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+W+"</body></html>");const Ze=S?S.createHTML(W):W;if(gt===kt)try{_e=new C().parseFromString(Ze,ai)}catch{}if(!_e||!_e.documentElement){_e=R.createDocument(gt,"template",null);try{_e.documentElement.innerHTML=un?A:Ze}catch{}}const at=_e.body||_e.documentElement;return W&&ge&&at.insertBefore(a.createTextNode(ge),at.childNodes[0]||null),gt===kt?B.call(_e,Ue?"html":"body")[0]:Ue?_e.documentElement:at},vn=function(W){return M.call(W.ownerDocument||W,W,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},gi=function(W){return W instanceof d&&(typeof W.nodeName!="string"||typeof W.textContent!="string"||typeof W.removeChild!="function"||!(W.attributes instanceof y)||typeof W.removeAttribute!="function"||typeof W.setAttribute!="function"||typeof W.namespaceURI!="string"||typeof W.insertBefore!="function"||typeof W.hasChildNodes!="function")},yt=function(W){return typeof c=="function"&&W instanceof c};function it(Se,W,_e){Go(Se,ge=>{ge.call(r,W,_e,Qi)})}const es=function(W){let _e=null;if(it(I.beforeSanitizeElements,W,null),gi(W))return Xt(W),!0;const ge=_t(W.nodeName);if(it(I.uponSanitizeElement,W,{tagName:ge,allowedTags:L}),je&&W.hasChildNodes()&&!yt(W.firstElementChild)&&Gt(/<[/\w!]/g,W.innerHTML)&&Gt(/<[/\w!]/g,W.textContent)||W.nodeType===_a.progressingInstruction||je&&W.nodeType===_a.comment&&Gt(/<[/\w]/g,W.data))return Xt(W),!0;if(!(j.tagCheck instanceof Function&&j.tagCheck(ge))&&(!L[ge]||me[ge])){if(!me[ge]&&wa(ge)&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,ge)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(ge)))return!1;if(nt&&!Nt[ge]){const Ze=p(W)||W.parentNode,at=f(W)||W.childNodes;if(at&&Ze){const ke=at.length;for(let zt=ke-1;zt>=0;--zt){const yi=b(at[zt],!0);yi.__removalCount=(W.__removalCount||0)+1,Ze.insertBefore(yi,v(W))}}}return Xt(W),!0}return W instanceof u&&!xa(W)||(ge==="noscript"||ge==="noembed"||ge==="noframes")&&Gt(/<\/no(script|embed|frames)/i,W.innerHTML)?(Xt(W),!0):(Te&&W.nodeType===_a.text&&(_e=W.textContent,Go([q,P,J],Ze=>{_e=ha(_e,Ze," ")}),W.textContent!==_e&&(ua(r.removed,{element:W.cloneNode()}),W.textContent=_e)),it(I.afterSanitizeElements,W,null),!1)},Sr=function(W,_e,ge){if(Y[_e]||Ui&&(_e==="id"||_e==="name")&&(ge in a||ge in fn))return!1;if(!(oe&&!Y[_e]&&Gt(te,_e))){if(!(ce&&Gt(G,_e))){if(!(j.attributeCheck instanceof Function&&j.attributeCheck(_e,W))){if(!V[_e]||Y[_e]){if(!(wa(W)&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,W)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(W))&&(ue.attributeNameCheck instanceof RegExp&&Gt(ue.attributeNameCheck,_e)||ue.attributeNameCheck instanceof Function&&ue.attributeNameCheck(_e,W))||_e==="is"&&ue.allowCustomizedBuiltInElements&&(ue.tagNameCheck instanceof RegExp&&Gt(ue.tagNameCheck,ge)||ue.tagNameCheck instanceof Function&&ue.tagNameCheck(ge))))return!1}else if(!Li[_e]){if(!Gt(U,ha(ge,ae,""))){if(!((_e==="src"||_e==="xlink:href"||_e==="href")&&W!=="script"&&aE(ge,"data:")===0&&Ki[W])){if(!(ve&&!Gt(se,ha(ge,ae,"")))){if(ge)return!1}}}}}}}return!0},wa=function(W){return W!=="annotation-xml"&&Uu(W,N)},Ea=function(W){it(I.beforeSanitizeAttributes,W,null);const{attributes:_e}=W;if(!_e||gi(W))return;const ge={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:V,forceKeepAttr:void 0};let Ze=_e.length;for(;Ze--;){const at=_e[Ze],{name:ke,namespaceURI:zt,value:yi}=at,Jt=_t(ke),Ii=yi;let Et=ke==="value"?Ii:oE(Ii);if(ge.attrName=Jt,ge.attrValue=Et,ge.keepAttr=!0,ge.forceKeepAttr=void 0,it(I.uponSanitizeAttribute,W,ge),Et=ge.attrValue,Vi&&(Jt==="id"||Jt==="name")&&(Ni(ke,W),Et=Pt+Et),je&&Gt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,Et)){Ni(ke,W);continue}if(Jt==="attributename"&&Uu(Et,"href")){Ni(ke,W);continue}if(ge.forceKeepAttr)continue;if(!ge.keepAttr){Ni(ke,W);continue}if(!pe&&Gt(/\/>/i,Et)){Ni(ke,W);continue}Te&&Go([q,P,J],yn=>{Et=ha(Et,yn," ")});const gn=_t(W.nodeName);if(!Sr(gn,Jt,Et)){Ni(ke,W);continue}if(S&&typeof w=="object"&&typeof w.getAttributeType=="function"&&!zt)switch(w.getAttributeType(gn,Jt)){case"TrustedHTML":{Et=S.createHTML(Et);break}case"TrustedScriptURL":{Et=S.createScriptURL(Et);break}}if(Et!==Ii)try{zt?W.setAttributeNS(zt,ke,Et):W.setAttribute(ke,Et),gi(W)?Xt(W):Qm(r.removed)}catch{Ni(ke,W)}}it(I.afterSanitizeAttributes,W,null)},Ta=function Se(W){let _e=null;const ge=vn(W);for(it(I.beforeSanitizeShadowDOM,W,null);_e=ge.nextNode();)it(I.uponSanitizeShadowNode,_e,null),es(_e),Ea(_e),_e.content instanceof x&&Se(_e.content);it(I.afterSanitizeShadowDOM,W,null)};return r.sanitize=function(Se){let W=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},_e=null,ge=null,Ze=null,at=null;if(un=!Se,un&&(Se="<!-->"),typeof Se!="string"&&!yt(Se))if(typeof Se.toString=="function"){if(Se=Se.toString(),typeof Se!="string")throw fa("dirty is not a string, aborting")}else throw fa("toString is not a function");if(!r.isSupported)return Se;if(ct||dn(W),r.removed=[],typeof Se=="string"&&(Rt=!1),Rt){if(Se.nodeName){const yi=_t(Se.nodeName);if(!L[yi]||me[yi])throw fa("root node is forbidden and cannot be sanitized in-place")}}else if(Se instanceof c)_e=pn("<!---->"),ge=_e.ownerDocument.importNode(Se,!0),ge.nodeType===_a.element&&ge.nodeName==="BODY"||ge.nodeName==="HTML"?_e=ge:_e.appendChild(ge);else{if(!Ft&&!Te&&!Ue&&Se.indexOf("<")===-1)return S&&pi?S.createHTML(Se):Se;if(_e=pn(Se),!_e)return Ft?null:pi?A:""}_e&&Ee&&Xt(_e.firstChild);const ke=vn(Rt?Se:_e);for(;Ze=ke.nextNode();)es(Ze),Ea(Ze),Ze.content instanceof x&&Ta(Ze.content);if(Rt)return Se;if(Ft){if(mi)for(at=E.call(_e.ownerDocument);_e.firstChild;)at.appendChild(_e.firstChild);else at=_e;return(V.shadowroot||V.shadowrootmode)&&(at=$.call(o,at,!0)),at}let zt=Ue?_e.outerHTML:_e.innerHTML;return Ue&&L["!doctype"]&&_e.ownerDocument&&_e.ownerDocument.doctype&&_e.ownerDocument.doctype.name&&Gt(gv,_e.ownerDocument.doctype.name)&&(zt="<!DOCTYPE "+_e.ownerDocument.doctype.name+`>
|
|
254
254
|
`+zt),Te&&Go([q,P,J],yi=>{zt=ha(zt,yi," ")}),S&&pi?S.createHTML(zt):zt},r.setConfig=function(){let Se=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dn(Se),ct=!0},r.clearConfig=function(){Qi=null,ct=!1},r.isValidAttribute=function(Se,W,_e){Qi||dn({});const ge=_t(Se),Ze=_t(W);return Sr(ge,Ze,_e)},r.addHook=function(Se,W){typeof W=="function"&&ua(I[Se],W)},r.removeHook=function(Se,W){if(W!==void 0){const _e=rE(I[Se],W);return _e===-1?void 0:nE(I[Se],_e,1)[0]}return Qm(I[Se])},r.removeHooks=function(Se){I[Se]=[]},r.removeAllHooks=function(){I=np()},r}var CE=yv();function xE(i){return CE.sanitize(i,{ALLOWED_TAGS:[]})}const wE={Read:"📖",Edit:"✏️",Write:"📝",Bash:"💻",Search:"🔍"};function EE(i){return i?wE[i]??"❓":"❓"}function TE(i){if(!i)return"";try{return new Date(i).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Zu({entry:i}){const r=i.role==="user";return O.jsx("div",{className:`flex ${r?"justify-end":"justify-start"} mb-3`,children:O.jsxs("div",{className:`max-w-[80%] rounded-lg px-4 py-2.5 text-sm leading-relaxed ${r?"bg-[#1a1a3e] text-[#e0e0e0] rounded-br-sm":"bg-[#111118] text-[#e0e0e0] rounded-bl-sm border border-[#1a1a2e]"}`,children:[O.jsx("div",{className:"whitespace-pre-wrap break-words",children:i.text}),i.timestamp&&O.jsx("div",{className:`text-[10px] mt-1 ${r?"text-[#555]":"text-[#444]"}`,children:TE(i.timestamp)})]})})}function AE({entry:i}){const[r,a]=F.useState(!1);return O.jsx("div",{className:"flex justify-start mb-3",children:O.jsxs("div",{className:"max-w-[80%] w-full",children:[O.jsxs("button",{onClick:()=>a(o=>!o),className:"flex items-center gap-2 text-xs text-[#555] hover:text-[#777] transition-colors py-1 group",children:[O.jsx("span",{className:"inline-block transition-transform duration-200",style:{transform:r?"rotate(90deg)":"rotate(0deg)"},children:"▶"}),O.jsx("span",{className:"italic",children:"Thinking…"})]}),r&&O.jsx("div",{className:"bg-[#0d0d12] border border-[#1a1a2e] rounded-lg px-4 py-3 mt-1 text-sm text-[#555] italic leading-relaxed whitespace-pre-wrap break-words max-h-64 overflow-y-auto",children:i.text})]})})}function RE({entry:i}){const r=i.text.length>100?i.text.slice(0,100)+"…":i.text;return O.jsx("div",{className:"flex justify-start mb-3",children:O.jsxs("div",{className:"max-w-[80%] w-full bg-[#0d0d12] border border-[#1a1a2e] rounded-lg overflow-hidden",children:[O.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-[#1a1a2e]",children:[O.jsx("span",{className:"text-base",children:EE(i.toolName)}),O.jsx("span",{className:"text-xs font-semibold text-[#00e5ff] font-mono",children:i.toolName??"Tool"}),O.jsx("span",{className:"text-[10px] text-[#555] ml-auto",children:"tool_use"})]}),O.jsx("div",{className:"px-3 py-2 text-xs text-[#888] font-mono whitespace-pre-wrap break-all max-h-32 overflow-y-auto",children:r})]})})}function DE({entry:i}){const r=i.text.toLowerCase().startsWith("error")||i.text.length===0;return O.jsx("div",{className:"flex justify-start mb-3",children:O.jsxs("div",{className:`max-w-[80%] w-full bg-[#0d0d12] rounded-lg overflow-hidden ${r?"border border-[#ff3366]/40":"border border-[#00ff88]/30"}`,children:[O.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 border-b border-[#1a1a2e]",children:[O.jsx("span",{className:"text-xs font-semibold text-[#888]",children:r?"✗ Result":"✓ Result"}),i.toolName&&O.jsx("span",{className:"text-[10px] text-[#555] font-mono",children:i.toolName})]}),O.jsx("div",{className:"px-3 py-2 text-xs text-[#666] font-mono whitespace-pre-wrap break-all max-h-32 overflow-y-auto",children:i.text||"(empty)"})]})})}function kE({entry:i}){if(i.role==="user")return O.jsx(Zu,{entry:i});switch(i.contentType){case"text":return O.jsx(Zu,{entry:i});case"thinking":return O.jsx(AE,{entry:i});case"tool_use":return O.jsx(RE,{entry:i});case"tool_result":return O.jsx(DE,{entry:i});case"permission_request":return O.jsxs("div",{className:"text-red-400 text-sm font-semibold px-3 py-2",children:["Permission Request: ",xE(i.text)]});default:return O.jsx(Zu,{entry:i})}}const Yo=1e3;function qu(i){return`${i.timestamp??""}:${i.role}:${i.contentType}:${i.text.length}:${i.text.slice(0,80)}`}function OE({sessionId:i}){const[r,a]=F.useState([]),[o,g]=F.useState(!0),[x,T]=F.useState(null),c=Mt(S=>S.token),[u,h]=F.useState({thinking:!1,tool_use:!0,tool_result:!0}),[y,d]=F.useState(!1),C=F.useRef(null),w=F.useRef(null),k=F.useRef(!1),b=F.useRef(new Set);F.useEffect(()=>{let S=!1;return x2(i).then(A=>{if(!S){const R=A.messages??[],M=R.length>Yo?R.slice(R.length-Yo):R;a(M),b.current=new Set(M.map(qu))}}).catch(A=>{S||T(A instanceof Error?A.message:"Failed to load")}).finally(()=>{S||g(!1)}),()=>{S=!0}},[i]),F.useEffect(()=>{const S=mv(i,A=>{try{const R=JSON.parse(A.data);if(R.event!=="message")return;const M=R.data;a(E=>{const B=qu(M);if(b.current.has(B))return E;b.current.add(B);const $=[...E,M];if($.length>Yo){const I=$.slice($.length-Yo),q=new Set(I.map(qu));return b.current=q,I}return $})}catch{}},c);return()=>S()},[i,c]),F.useEffect(()=>{var S;k.current||(S=C.current)==null||S.scrollIntoView({behavior:"smooth"})},[r]);const m=F.useCallback(()=>{const S=w.current;if(!S)return;const A=S.scrollHeight-S.scrollTop-S.clientHeight<60;k.current=!A,d(!A)},[]),v=F.useCallback(()=>{var S;k.current=!1,(S=C.current)==null||S.scrollIntoView({behavior:"smooth"})},[]),f=F.useCallback(S=>{h(A=>({...A,[S]:!A[S]}))},[]),p=F.useMemo(()=>r.filter(S=>S.role==="user"?!0:!(S.contentType==="thinking"&&!u.thinking||S.contentType==="tool_use"&&!u.tool_use||S.contentType==="tool_result"&&!u.tool_result)),[r,u]);return o?O.jsx("div",{className:"flex items-center justify-center h-full text-[#555] text-sm",children:O.jsx("div",{className:"animate-pulse",children:"Loading transcript…"})}):x?O.jsxs("div",{className:"flex items-center justify-center h-full text-[#ff3366] text-sm",children:["⚠ ",x]}):O.jsxs("div",{className:"flex flex-col h-full relative",children:[O.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[#1a1a2e] bg-[#0a0a0f] shrink-0",children:[O.jsx("span",{className:"text-[10px] text-[#555] uppercase tracking-wider",children:"Filter:"}),["thinking","tool_use","tool_result"].map(S=>O.jsx("button",{onClick:()=>f(S),"aria-pressed":u[S],className:`text-xs px-2 py-0.5 rounded border transition-colors ${u[S]?"border-[#00e5ff]/40 text-[#00e5ff] bg-[#00e5ff]/10":"border-[#1a1a2e] text-[#555] hover:text-[#888]"}`,children:S==="tool_use"?"Tools":S==="tool_result"?"Results":S},S)),O.jsxs("span",{className:"text-[10px] text-[#444] ml-auto",children:[p.length," / ",r.length]})]}),O.jsxs("div",{ref:w,onScroll:m,className:"flex-1 overflow-y-auto px-4 py-3",children:[p.length===0&&O.jsx("div",{className:"flex items-center justify-center h-full text-[#555] text-sm",children:"No messages yet"}),p.map((S,A)=>O.jsx(kE,{entry:S},S.toolUseId??`${S.role}-${S.timestamp??A}`)),O.jsx("div",{ref:C})]}),y&&O.jsx("button",{onClick:v,className:"absolute bottom-4 right-4 bg-[#1a1a2e] hover:bg-[#2a2a3e] text-[#00e5ff] rounded-full w-10 h-10 flex items-center justify-center shadow-lg border border-[#1a1a2e] transition-colors z-10",title:"Scroll to bottom",children:"↓"})]})}var Gu={exports:{}},ap;function ME(){return ap||(ap=1,(function(i,r){(function(a,o){i.exports=o()})(globalThis,(()=>(()=>{var a={4567:function(T,c,u){var h=this&&this.__decorate||function(f,p,S,A){var R,M=arguments.length,E=M<3?p:A===null?A=Object.getOwnPropertyDescriptor(p,S):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,p,S,A);else for(var B=f.length-1;B>=0;B--)(R=f[B])&&(E=(M<3?R(E):M>3?R(p,S,E):R(p,S))||E);return M>3&&E&&Object.defineProperty(p,S,E),E},y=this&&this.__param||function(f,p){return function(S,A){p(S,A,f)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const d=u(9042),C=u(9924),w=u(844),k=u(4725),b=u(2585),m=u(3656);let v=c.AccessibilityManager=class extends w.Disposable{constructor(f,p,S,A){super(),this._terminal=f,this._coreBrowserService=S,this._renderService=A,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let R=0;R<this._terminal.rows;R++)this._rowElements[R]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[R]);if(this._topBoundaryFocusListener=R=>this._handleBoundaryFocus(R,0),this._bottomBoundaryFocusListener=R=>this._handleBoundaryFocus(R,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new C.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((R=>this._handleResize(R.rows)))),this.register(this._terminal.onRender((R=>this._refreshRows(R.start,R.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((R=>this._handleChar(R)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
255
255
|
`)))),this.register(this._terminal.onA11yTab((R=>this._handleTab(R)))),this.register(this._terminal.onKey((R=>this._handleKey(R.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,m.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,w.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let p=0;p<f;p++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
|
|
256
256
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=d.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,p){this._liveRegionDebouncer.refresh(f,p,this._terminal.rows)}_renderRows(f,p){const S=this._terminal.buffer,A=S.lines.length.toString();for(let R=f;R<=p;R++){const M=S.lines.get(S.ydisp+R),E=[],B=(M==null?void 0:M.translateToString(!0,void 0,void 0,E))||"",$=(S.ydisp+R+1).toString(),I=this._rowElements[R];I&&(B.length===0?(I.innerText=" ",this._rowColumns.set(I,[0,1])):(I.textContent=B,this._rowColumns.set(I,E)),I.setAttribute("aria-posinset",$),I.setAttribute("aria-setsize",A))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,p){const S=f.target,A=this._rowElements[p===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(p===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==A)return;let R,M;if(p===0?(R=S,M=this._rowElements.pop(),this._rowContainer.removeChild(M)):(R=this._rowElements.shift(),M=S,this._rowContainer.removeChild(R)),R.removeEventListener("focus",this._topBoundaryFocusListener),M.removeEventListener("focus",this._bottomBoundaryFocusListener),p===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(p===0?-1:1),this._rowElements[p===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleSelectionChange(){var B;if(this._rowElements.length===0)return;const f=document.getSelection();if(!f)return;if(f.isCollapsed)return void(this._rowContainer.contains(f.anchorNode)&&this._terminal.clearSelection());if(!f.anchorNode||!f.focusNode)return void console.error("anchorNode and/or focusNode are null");let p={node:f.anchorNode,offset:f.anchorOffset},S={node:f.focusNode,offset:f.focusOffset};if((p.node.compareDocumentPosition(S.node)&Node.DOCUMENT_POSITION_PRECEDING||p.node===S.node&&p.offset>S.offset)&&([p,S]=[S,p]),p.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(p={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(p.node))return;const A=this._rowElements.slice(-1)[0];if(S.node.compareDocumentPosition(A)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(S={node:A,offset:((B=A.textContent)==null?void 0:B.length)??0}),!this._rowContainer.contains(S.node))return;const R=({node:$,offset:I})=>{const q=$ instanceof Text?$.parentNode:$;let P=parseInt(q==null?void 0:q.getAttribute("aria-posinset"),10)-1;if(isNaN(P))return console.warn("row is invalid. Race condition?"),null;const J=this._rowColumns.get(q);if(!J)return console.warn("columns is null. Race condition?"),null;let te=I<J.length?J[I]:J.slice(-1)[0]+1;return te>=this._terminal.cols&&(++P,te=0),{row:P,column:te}},M=R(p),E=R(S);if(M&&E){if(M.row>E.row||M.row===E.row&&M.column>=E.column)throw new Error("invalid range");this._terminal.select(M.column,M.row,(E.row-M.row)*this._terminal.cols-M.column+E.column)}}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let p=this._rowContainer.children.length;p<this._terminal.rows;p++)this._rowElements[p]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[p]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=this._coreBrowserService.mainDocument.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=v=h([y(1,b.IInstantiationService),y(2,k.ICoreBrowserService),y(3,k.IRenderService)],v)},3614:(T,c)=>{function u(C){return C.replace(/\r?\n/g,"\r")}function h(C,w){return w?"\x1B[200~"+C+"\x1B[201~":C}function y(C,w,k,b){C=h(C=u(C),k.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),k.triggerDataEvent(C,!0),w.value=""}function d(C,w,k){const b=k.getBoundingClientRect(),m=C.clientX-b.left-10,v=C.clientY-b.top-10;w.style.width="20px",w.style.height="20px",w.style.left=`${m}px`,w.style.top=`${v}px`,w.style.zIndex="1000",w.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=u,c.bracketTextForPaste=h,c.copyHandler=function(C,w){C.clipboardData&&C.clipboardData.setData("text/plain",w.selectionText),C.preventDefault()},c.handlePasteEvent=function(C,w,k,b){C.stopPropagation(),C.clipboardData&&y(C.clipboardData.getData("text/plain"),w,k,b)},c.paste=y,c.moveTextAreaUnderMouseCursor=d,c.rightClickHandler=function(C,w,k,b,m){d(C,w,k),m&&b.rightClickSelect(C),w.value=b.selectionText,w.select()}},7239:(T,c,u)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const h=u(1505);c.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(y,d,C){this._css.set(y,d,C)}getCss(y,d){return this._css.get(y,d)}setColor(y,d,C){this._color.set(y,d,C)}getColor(y,d){return this._color.get(y,d)}clear(){this._color.clear(),this._css.clear()}}},3656:(T,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(u,h,y,d){u.addEventListener(h,y,d);let C=!1;return{dispose:()=>{C||(C=!0,u.removeEventListener(h,y,d))}}}},3551:function(T,c,u){var h=this&&this.__decorate||function(v,f,p,S){var A,R=arguments.length,M=R<3?f:S===null?S=Object.getOwnPropertyDescriptor(f,p):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(v,f,p,S);else for(var E=v.length-1;E>=0;E--)(A=v[E])&&(M=(R<3?A(M):R>3?A(f,p,M):A(f,p))||M);return R>3&&M&&Object.defineProperty(f,p,M),M},y=this&&this.__param||function(v,f){return function(p,S){f(p,S,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const d=u(3656),C=u(8460),w=u(844),k=u(2585),b=u(4725);let m=c.Linkifier=class extends w.Disposable{get currentLink(){return this._currentLink}constructor(v,f,p,S,A){super(),this._element=v,this._mouseService=f,this._renderService=p,this._bufferService=S,this._linkProviderService=A,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new C.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new C.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,w.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,w.toDisposable)((()=>{var R;this._lastMouseEvent=void 0,(R=this._activeProviderReplies)==null||R.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,d.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,d.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(v){this._lastMouseEvent=v;const f=this._positionFromMouseEvent(v,this._element,this._mouseService);if(!f)return;this._isMouseOut=!1;const p=v.composedPath();for(let S=0;S<p.length;S++){const A=p[S];if(A.classList.contains("xterm"))break;if(A.classList.contains("xterm-hover"))return}this._lastBufferCell&&f.x===this._lastBufferCell.x&&f.y===this._lastBufferCell.y||(this._handleHover(f),this._lastBufferCell=f)}_handleHover(v){if(this._activeLine!==v.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(v,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,v)||(this._clearCurrentLink(),this._askForLink(v,!0))}_askForLink(v,f){var S,A;this._activeProviderReplies&&f||((S=this._activeProviderReplies)==null||S.forEach((R=>{R==null||R.forEach((M=>{M.link.dispose&&M.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=v.y);let p=!1;for(const[R,M]of this._linkProviderService.linkProviders.entries())f?(A=this._activeProviderReplies)!=null&&A.get(R)&&(p=this._checkLinkProviderResult(R,v,p)):M.provideLinks(v.y,(E=>{var $,I;if(this._isMouseOut)return;const B=E==null?void 0:E.map((q=>({link:q})));($=this._activeProviderReplies)==null||$.set(R,B),p=this._checkLinkProviderResult(R,v,p),((I=this._activeProviderReplies)==null?void 0:I.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(v.y,this._activeProviderReplies)}))}_removeIntersectingLinks(v,f){const p=new Set;for(let S=0;S<f.size;S++){const A=f.get(S);if(A)for(let R=0;R<A.length;R++){const M=A[R],E=M.link.range.start.y<v?0:M.link.range.start.x,B=M.link.range.end.y>v?this._bufferService.cols:M.link.range.end.x;for(let $=E;$<=B;$++){if(p.has($)){A.splice(R--,1);break}p.add($)}}}}_checkLinkProviderResult(v,f,p){var R;if(!this._activeProviderReplies)return p;const S=this._activeProviderReplies.get(v);let A=!1;for(let M=0;M<v;M++)this._activeProviderReplies.has(M)&&!this._activeProviderReplies.get(M)||(A=!0);if(!A&&S){const M=S.find((E=>this._linkAtPosition(E.link,f)));M&&(p=!0,this._handleNewLink(M))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!p)for(let M=0;M<this._activeProviderReplies.size;M++){const E=(R=this._activeProviderReplies.get(M))==null?void 0:R.find((B=>this._linkAtPosition(B.link,f)));if(E){p=!0,this._handleNewLink(E);break}}return p}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(v){if(!this._currentLink)return;const f=this._positionFromMouseEvent(v,this._element,this._mouseService);f&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,f)&&this._currentLink.link.activate(v,this._currentLink.link.text)}_clearCurrentLink(v,f){this._currentLink&&this._lastMouseEvent&&(!v||!f||this._currentLink.link.range.start.y>=v&&this._currentLink.link.range.end.y<=f)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,w.disposeArray)(this._linkCacheDisposables))}_handleNewLink(v){if(!this._lastMouseEvent)return;const f=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);f&&this._linkAtPosition(v.link,f)&&(this._currentLink=v,this._currentLink.state={decorations:{underline:v.link.decorations===void 0||v.link.decorations.underline,pointerCursor:v.link.decorations===void 0||v.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,v.link,this._lastMouseEvent),v.link.decorations={},Object.defineProperties(v.link.decorations,{pointerCursor:{get:()=>{var p,S;return(S=(p=this._currentLink)==null?void 0:p.state)==null?void 0:S.decorations.pointerCursor},set:p=>{var S;(S=this._currentLink)!=null&&S.state&&this._currentLink.state.decorations.pointerCursor!==p&&(this._currentLink.state.decorations.pointerCursor=p,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",p))}},underline:{get:()=>{var p,S;return(S=(p=this._currentLink)==null?void 0:p.state)==null?void 0:S.decorations.underline},set:p=>{var S,A,R;(S=this._currentLink)!=null&&S.state&&((R=(A=this._currentLink)==null?void 0:A.state)==null?void 0:R.decorations.underline)!==p&&(this._currentLink.state.decorations.underline=p,this._currentLink.state.isHovered&&this._fireUnderlineEvent(v.link,p))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((p=>{if(!this._currentLink)return;const S=p.start===0?0:p.start+1+this._bufferService.buffer.ydisp,A=this._bufferService.buffer.ydisp+1+p.end;if(this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=A&&(this._clearCurrentLink(S,A),this._lastMouseEvent)){const R=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);R&&this._askForLink(R,!1)}}))))}_linkHover(v,f,p){var S;(S=this._currentLink)!=null&&S.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!0),this._currentLink.state.decorations.pointerCursor&&v.classList.add("xterm-cursor-pointer")),f.hover&&f.hover(p,f.text)}_fireUnderlineEvent(v,f){const p=v.range,S=this._bufferService.buffer.ydisp,A=this._createLinkUnderlineEvent(p.start.x-1,p.start.y-S-1,p.end.x,p.end.y-S-1,void 0);(f?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(A)}_linkLeave(v,f,p){var S;(S=this._currentLink)!=null&&S.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(f,!1),this._currentLink.state.decorations.pointerCursor&&v.classList.remove("xterm-cursor-pointer")),f.leave&&f.leave(p,f.text)}_linkAtPosition(v,f){const p=v.range.start.y*this._bufferService.cols+v.range.start.x,S=v.range.end.y*this._bufferService.cols+v.range.end.x,A=f.y*this._bufferService.cols+f.x;return p<=A&&A<=S}_positionFromMouseEvent(v,f,p){const S=p.getCoords(v,f,this._bufferService.cols,this._bufferService.rows);if(S)return{x:S[0],y:S[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(v,f,p,S,A){return{x1:v,y1:f,x2:p,y2:S,cols:this._bufferService.cols,fg:A}}};c.Linkifier=m=h([y(1,b.IMouseService),y(2,b.IRenderService),y(3,k.IBufferService),y(4,b.ILinkProviderService)],m)},9042:(T,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(T,c,u){var h=this&&this.__decorate||function(b,m,v,f){var p,S=arguments.length,A=S<3?m:f===null?f=Object.getOwnPropertyDescriptor(m,v):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,m,v,f);else for(var R=b.length-1;R>=0;R--)(p=b[R])&&(A=(S<3?p(A):S>3?p(m,v,A):p(m,v))||A);return S>3&&A&&Object.defineProperty(m,v,A),A},y=this&&this.__param||function(b,m){return function(v,f){m(v,f,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const d=u(511),C=u(2585);let w=c.OscLinkProvider=class{constructor(b,m,v){this._bufferService=b,this._optionsService=m,this._oscLinkService=v}provideLinks(b,m){var B;const v=this._bufferService.buffer.lines.get(b-1);if(!v)return void m(void 0);const f=[],p=this._optionsService.rawOptions.linkHandler,S=new d.CellData,A=v.getTrimmedLength();let R=-1,M=-1,E=!1;for(let $=0;$<A;$++)if(M!==-1||v.hasContent($)){if(v.loadCell($,S),S.hasExtendedAttrs()&&S.extended.urlId){if(M===-1){M=$,R=S.extended.urlId;continue}E=S.extended.urlId!==R}else M!==-1&&(E=!0);if(E||M!==-1&&$===A-1){const I=(B=this._oscLinkService.getLinkData(R))==null?void 0:B.uri;if(I){const q={start:{x:M+1,y:b},end:{x:$+(E||$!==A-1?0:1),y:b}};let P=!1;if(!(p!=null&&p.allowNonHttpProtocols))try{const J=new URL(I);["http:","https:"].includes(J.protocol)||(P=!0)}catch{P=!0}P||f.push({text:I,range:q,activate:(J,te)=>p?p.activate(J,te,q):k(0,te),hover:(J,te)=>{var G;return(G=p==null?void 0:p.hover)==null?void 0:G.call(p,J,te,q)},leave:(J,te)=>{var G;return(G=p==null?void 0:p.leave)==null?void 0:G.call(p,J,te,q)}})}E=!1,S.hasExtendedAttrs()&&S.extended.urlId?(M=$,R=S.extended.urlId):(M=-1,R=-1)}}m(f)}};function k(b,m){if(confirm(`Do you want to navigate to ${m}?
|