import{i as B,a as p,f,s as $}from"../chunks/DoGIJDSZ.js";import{p as G,s as g,q as H,v as Q,w as U,D as V,b as a,g as s,c as o,x as j,d as c,$ as W,r as n,t as X}from"../chunks/kzeZOqU5.js";import{I as Y,B as Z,b as ee,e as se,P as te,d as ae}from"../chunks/aiM7Bbhi.js";import{h as re}from"../chunks/BQJR1fvD.js";import{g as ne}from"../chunks/Sy9X1UNl.js";import{E as oe}from"../chunks/DFa6kKPT.js";var ie=f('<p class="muted svelte-1ggfn1w">Loading…</p>'),le=f('<a class="ss-card svelte-1ggfn1w"><div class="ss-card-head svelte-1ggfn1w"><span class="ss-label svelte-1ggfn1w"> </span> <!></div> <div class="ss-meta svelte-1ggfn1w"><span> </span> <span> </span></div></a>'),ce=f('<div class="ss-grid svelte-1ggfn1w"></div>'),ve=f('<main class="main sos-list svelte-1ggfn1w"><div class="page-head svelte-1ggfn1w"><div><h1 class="svelte-1ggfn1w">Session Over Sessions</h1> <p class="subtitle svelte-1ggfn1w">Coordinate multiple running agents as one super-session.</p></div></div> <div class="create-row svelte-1ggfn1w"><!> <!></div> <!> <!></main>');function he(I,P){G(P,!0);let m=g(H([])),h=g(!0),i=g(""),v=g(""),d=g(!1);function x(){try{const e=localStorage.getItem("shooter_config");return e?JSON.parse(e):null}catch{return null}}async function T(){const e=x();if(!e){a(i,"No configuration found. Open Settings first."),a(h,!1);return}try{const t=await fetch("/api/sos",{headers:{Authorization:`Bearer ${e.apiKey}`}});if(!t.ok){a(i,`Failed to load (${t.status})`);return}const r=await t.json();a(m,r.superSessions??[],!0)}catch{a(i,"Network error — is the server running?")}finally{a(h,!1)}}async function z(){const e=x();if(!(!e||!s(v).trim())){a(d,!0);try{const t=await fetch("/api/sos",{body:JSON.stringify({label:s(v).trim()}),headers:{Authorization:`Bearer ${e.apiKey}`,"Content-Type":"application/json"},method:"POST"});if(t.ok){const r=await t.json();ne(`/sos/${r.id}`)}else{const r=await t.json().catch(()=>({}));a(i,r.error??`Failed to create (${t.status})`,!0)}}catch{a(i,"Network error — could not create super-session")}finally{a(d,!1)}}}Q(()=>{T()});var w=ve();re("1ggfn1w",e=>{V(()=>{W.title="Session Over Sessions - Shooter"})});var _=c(o(w),2),k=o(_);Y(k,{dataType:"text",placeholder:"New super-session label…",classes:"sos-create-input",get value(){return s(v)},set value(e){a(v,e,!0)}});var A=c(k,2);{let e=j(()=>s(d)?"Creating…":"Create"),t=j(()=>s(d)||!s(v).trim());Z(A,{get text(){return s(e)},get disabled(){return s(t)},onclick:z,classes:"btn-create"})}n(_);var N=c(_,2);{var E=e=>{ee(e,{get text(){return s(i)},classes:"banner-error"})};B(N,e=>{s(i)&&e(E)})}var F=c(N,2);{var J=e=>{var t=ie();p(e,t)},K=e=>{oe(e,{title:"No super-sessions yet",description:"Create one above, then add running agent sessions as members."})},L=e=>{var t=ce();se(t,21,()=>s(m),r=>r.id,(r,l)=>{var u=le(),b=o(u),y=o(b),R=o(y,!0);n(y);var q=c(y,2);te(q,{get text(){return s(l).status},classes:"pill-status-unknown"}),n(b);var C=c(b,2),S=o(C),D=o(S);n(S);var O=c(S,2),M=o(O);n(O),n(C),n(u),X(()=>{ae(u,"href",`/sos/${s(l).id}`),$(R,s(l).label),$(D,`${s(l).members.length??""} member${s(l).members.length===1?"":"s"}`),$(M,`${s(l).routingRules.length??""} rule${s(l).routingRules.length===1?"":"s"}`)}),p(r,u)}),n(t),p(e,t)};B(F,e=>{s(h)?e(J):s(m).length===0?e(K,1):e(L,-1)})}n(w),p(I,w),U()}export{he as component};
