@useorgx/openclaw-plugin 0.7.15 → 0.7.16
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/8pbG6uLK.js +1 -0
- package/dashboard/dist/assets/8pbG6uLK.js.br +0 -0
- package/dashboard/dist/assets/8pbG6uLK.js.gz +0 -0
- package/dashboard/dist/assets/B1LENRC8.js +212 -0
- package/dashboard/dist/assets/B1LENRC8.js.br +0 -0
- package/dashboard/dist/assets/B1LENRC8.js.gz +0 -0
- package/dashboard/dist/assets/{gZr_xKlA.js → BM75sh1f.js} +1 -1
- package/dashboard/dist/assets/BM75sh1f.js.br +0 -0
- package/dashboard/dist/assets/BM75sh1f.js.gz +0 -0
- package/dashboard/dist/assets/{CJjEAGFN.js → BYVYH9CH.js} +1 -1
- package/dashboard/dist/assets/BYVYH9CH.js.br +0 -0
- package/dashboard/dist/assets/BYVYH9CH.js.gz +0 -0
- package/dashboard/dist/assets/BkMrrjAv.js +1 -0
- package/dashboard/dist/assets/BkMrrjAv.js.br +0 -0
- package/dashboard/dist/assets/BkMrrjAv.js.gz +0 -0
- package/dashboard/dist/assets/BpF7v1Dk.js +1 -0
- package/dashboard/dist/assets/BpF7v1Dk.js.br +0 -0
- package/dashboard/dist/assets/BpF7v1Dk.js.gz +0 -0
- package/dashboard/dist/assets/{C9fvfXmS.js → Bv_86bUY.js} +1 -1
- package/dashboard/dist/assets/Bv_86bUY.js.br +0 -0
- package/dashboard/dist/assets/Bv_86bUY.js.gz +0 -0
- package/dashboard/dist/assets/{CFZ4Swr5.js → C3PrI8L7.js} +1 -1
- package/dashboard/dist/assets/C3PrI8L7.js.br +0 -0
- package/dashboard/dist/assets/C3PrI8L7.js.gz +0 -0
- package/dashboard/dist/assets/{C91KLKit.js → C6AqbA9J.js} +1 -1
- package/dashboard/dist/assets/C6AqbA9J.js.br +0 -0
- package/dashboard/dist/assets/C6AqbA9J.js.gz +0 -0
- package/dashboard/dist/assets/{7DhYqBrM.js → CUXb_4F3.js} +1 -1
- package/dashboard/dist/assets/CUXb_4F3.js.br +0 -0
- package/dashboard/dist/assets/CUXb_4F3.js.gz +0 -0
- package/dashboard/dist/assets/{3TtV4moZ.js → Cn8sRTkO.js} +1 -1
- package/dashboard/dist/assets/Cn8sRTkO.js.br +0 -0
- package/dashboard/dist/assets/Cn8sRTkO.js.gz +0 -0
- package/dashboard/dist/assets/{CnPC783_.js → D5IgXoTj.js} +1 -1
- package/dashboard/dist/assets/D5IgXoTj.js.br +0 -0
- package/dashboard/dist/assets/D5IgXoTj.js.gz +0 -0
- package/dashboard/dist/assets/DMKyYAtD.js +1 -0
- package/dashboard/dist/assets/DMKyYAtD.js.br +0 -0
- package/dashboard/dist/assets/DMKyYAtD.js.gz +0 -0
- package/dashboard/dist/assets/{CGj8kRhg.js → DXzpQUC0.js} +1 -1
- package/dashboard/dist/assets/DXzpQUC0.js.br +0 -0
- package/dashboard/dist/assets/DXzpQUC0.js.gz +0 -0
- package/dashboard/dist/assets/JDPvhd68.js +1 -0
- package/dashboard/dist/assets/JDPvhd68.js.br +0 -0
- package/dashboard/dist/assets/JDPvhd68.js.gz +0 -0
- package/dashboard/dist/assets/{3VwNyxUf.js → R6N_VVqm.js} +1 -1
- package/dashboard/dist/assets/R6N_VVqm.js.br +0 -0
- package/dashboard/dist/assets/R6N_VVqm.js.gz +0 -0
- package/dashboard/dist/assets/{CKrH5fYO.js → cEP7N1dn.js} +1 -1
- package/dashboard/dist/assets/cEP7N1dn.js.br +0 -0
- package/dashboard/dist/assets/cEP7N1dn.js.gz +0 -0
- package/dashboard/dist/assets/iLnvdWmW.css +1 -0
- package/dashboard/dist/assets/iLnvdWmW.css.br +0 -0
- package/dashboard/dist/assets/iLnvdWmW.css.gz +0 -0
- package/dashboard/dist/assets/{Ctw95IkC.js → konqMbVI.js} +1 -1
- package/dashboard/dist/assets/konqMbVI.js.br +0 -0
- package/dashboard/dist/assets/konqMbVI.js.gz +0 -0
- package/dashboard/dist/assets/{T2NFtzAv.js → wc6cgXzV.js} +1 -1
- package/dashboard/dist/assets/wc6cgXzV.js.br +0 -0
- package/dashboard/dist/assets/wc6cgXzV.js.gz +0 -0
- package/dashboard/dist/index.html +3 -3
- package/dashboard/dist/index.html.br +0 -0
- package/dashboard/dist/index.html.gz +0 -0
- package/dist/http/helpers/auto-continue-engine.d.ts +15 -0
- package/dist/http/helpers/auto-continue-engine.js +165 -0
- package/dist/http/helpers/mission-control.d.ts +3 -0
- package/dist/http/helpers/mission-control.js +38 -7
- package/dist/http/helpers/value-utils.d.ts +1 -1
- package/dist/http/helpers/value-utils.js +5 -2
- package/dist/http/index.js +3 -1
- package/dist/http/routes/chat.d.ts +1 -1
- package/dist/http/routes/chat.js +2 -2
- package/dist/http/routes/entities.js +60 -2
- package/dist/http/routes/entity-dynamic.js +49 -9
- package/dist/http/routes/live-snapshot.d.ts +10 -1
- package/dist/http/routes/live-snapshot.js +11 -3
- package/dist/http/routes/mission-control-actions.d.ts +6 -0
- package/dist/http/routes/mission-control-actions.js +33 -0
- package/package.json +1 -1
- package/dashboard/dist/assets/0RUEVzJa.js +0 -1
- package/dashboard/dist/assets/0RUEVzJa.js.br +0 -0
- package/dashboard/dist/assets/0RUEVzJa.js.gz +0 -0
- package/dashboard/dist/assets/3TtV4moZ.js.br +0 -0
- package/dashboard/dist/assets/3TtV4moZ.js.gz +0 -0
- package/dashboard/dist/assets/3VwNyxUf.js.br +0 -0
- package/dashboard/dist/assets/3VwNyxUf.js.gz +0 -0
- package/dashboard/dist/assets/7DhYqBrM.js.br +0 -0
- package/dashboard/dist/assets/7DhYqBrM.js.gz +0 -0
- package/dashboard/dist/assets/BVvffj0x.js +0 -1
- package/dashboard/dist/assets/BVvffj0x.js.br +0 -0
- package/dashboard/dist/assets/BVvffj0x.js.gz +0 -0
- package/dashboard/dist/assets/BiOgVMED.js +0 -1
- package/dashboard/dist/assets/BiOgVMED.js.br +0 -0
- package/dashboard/dist/assets/BiOgVMED.js.gz +0 -0
- package/dashboard/dist/assets/C91KLKit.js.br +0 -0
- package/dashboard/dist/assets/C91KLKit.js.gz +0 -0
- package/dashboard/dist/assets/C9fvfXmS.js.br +0 -0
- package/dashboard/dist/assets/C9fvfXmS.js.gz +0 -0
- package/dashboard/dist/assets/CFZ4Swr5.js.br +0 -0
- package/dashboard/dist/assets/CFZ4Swr5.js.gz +0 -0
- package/dashboard/dist/assets/CGj8kRhg.js.br +0 -0
- package/dashboard/dist/assets/CGj8kRhg.js.gz +0 -0
- package/dashboard/dist/assets/CJjEAGFN.js.br +0 -0
- package/dashboard/dist/assets/CJjEAGFN.js.gz +0 -0
- package/dashboard/dist/assets/CKrH5fYO.js.br +0 -0
- package/dashboard/dist/assets/CKrH5fYO.js.gz +0 -0
- package/dashboard/dist/assets/CMTTPXch.js +0 -1
- package/dashboard/dist/assets/CMTTPXch.js.br +0 -0
- package/dashboard/dist/assets/CMTTPXch.js.gz +0 -0
- package/dashboard/dist/assets/CnPC783_.js.br +0 -0
- package/dashboard/dist/assets/CnPC783_.js.gz +0 -0
- package/dashboard/dist/assets/Ctw95IkC.js.br +0 -0
- package/dashboard/dist/assets/Ctw95IkC.js.gz +0 -0
- package/dashboard/dist/assets/DHz-aQPw.js +0 -1
- package/dashboard/dist/assets/DHz-aQPw.js.br +0 -0
- package/dashboard/dist/assets/DHz-aQPw.js.gz +0 -0
- package/dashboard/dist/assets/DNX2foSJ.css +0 -1
- package/dashboard/dist/assets/DNX2foSJ.css.br +0 -0
- package/dashboard/dist/assets/DNX2foSJ.css.gz +0 -0
- package/dashboard/dist/assets/DxUw4FMR.js +0 -212
- package/dashboard/dist/assets/DxUw4FMR.js.br +0 -0
- package/dashboard/dist/assets/DxUw4FMR.js.gz +0 -0
- package/dashboard/dist/assets/T2NFtzAv.js.br +0 -0
- package/dashboard/dist/assets/T2NFtzAv.js.gz +0 -0
- package/dashboard/dist/assets/gZr_xKlA.js.br +0 -0
- package/dashboard/dist/assets/gZr_xKlA.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as j,j as e}from"./Dj2k1r16.js";import{D as B,F as N,N as ke,e as x,B as M,O as Ve,Q as Ge,R as Ne,r as O,j as Ie,A as Xe,C as Ke,S as Qe,M as He,m as Je}from"./DxUw4FMR.js";import{u as Ye}from"./C9fvfXmS.js";import{A as Ze,m as I}from"./eeHXe_OQ.js";import"./BiOgVMED.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const De=/^[0-9a-f-]{20,}$/i,et=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(i){return typeof i=="string"&&i.trim().length>0}function ce(i){return(i??"").trim().toLowerCase()}function rt(i){return(i??"").trim().replace(/\s+/g," ").toLowerCase()}function st(i){return tt.has(rt(i))}function V(i,t=3){return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} +${i.length-t} more`}function G(i,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(W=>W.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(i))for(const h of i)c(h);return c(t??null),f}function it(i){if(i.runId&&i.runId.trim().length>0)return i.runId.trim();const t=i.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function at(i){const t=ce(i.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(i.phase);if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(i.state);return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":et.has(t)?t:i.blockers.length>0?"blocked":t||"unknown"}function nt(i,t,f){var h;const c=[((h=i.blockerDiagnostics)==null?void 0:h.reason)??null,i.blockerReason??null,...i.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(W=>!st(W))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(i){return i==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":i==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":i==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":i==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:i=>({opacity:1,y:0,transition:{duration:.28,delay:i*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:i=>({opacity:1,y:0,transition:{duration:.22,delay:i*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(i){return i==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:i==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:i==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:i==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:W,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[L,T]=j.useState(null),[U,he]=j.useState(!1),[re,z]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ye();j.useEffect(()=>{if(!t){z("");return}if(C!=null&&C.text){z(C.text);return}z("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const q=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?q.size===0?[]:f.filter(r=>{const l=it(r);return!!(l&&q.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,q]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",E=((we=m.runId)==null?void 0:we.trim())??"";if(A&&q.has(A)||E&&q.has(E))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const E=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(E)?E:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,q,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(E=>E.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!De.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),S=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,S,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,S]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:M("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",W),disabled:!W||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),L&&e.jsx("p",{className:"text-caption text-secondary",children:L})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=at(t),p=$[0]??null,ie=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ie),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ie>0,blockingDecisionCount:ie,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ae=nt(t,k,S),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Se=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Me=!["archived","cancelled"].includes(k),Le=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Ee=o.status!=="in_progress"&&!ne,We=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",qe=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,n=(a==null?void 0:a.context)??null,le=[v(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,v(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,v(a==null?void 0:a.errorCategory)?`Category: ${a.errorCategory.trim()}`:null,(a==null?void 0:a.retryable)===!0?"Retryable: yes":(a==null?void 0:a.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(a&&(v(a.reason)||le.length>0||b.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),Z=v(ae)?ae:null,ze=Z!==null&&!(S&&(Z===S||S.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=L?L.toLowerCase().includes("fail")||L.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:M("inline-flex items-center gap-1.5 rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-widest",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),Le]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsxs("div",{className:M("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(Ze,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-[28px] font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),S&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:S,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:M("rounded-xl border px-4 py-3",qe),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),ze&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??ae??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(a==null?void 0:a.suggestedActions)&&a.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:a.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(a==null?void 0:a.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(a.eventTimestamp).toLocaleString()," ·"," ",O(a.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:M("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:We},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[L&&e.jsx("p",{className:M("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:L}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>z(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Se&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Me&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),z("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Ee,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
|
|
1
|
+
import{r as j,j as e}from"./Dj2k1r16.js";import{D as B,F as N,N as ke,e as x,B as M,O as Ve,Q as Ge,R as Ne,v as O,j as Ie,A as Xe,C as Ke,S as Qe,M as He,m as Je}from"./B1LENRC8.js";import{u as Ye}from"./Bv_86bUY.js";import{A as Ze,m as I}from"./eeHXe_OQ.js";import"./DMKyYAtD.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";const De=/^[0-9a-f-]{20,}$/i,et=new Set(["running","active","queued","pending","in_progress","working","planning","handoff","review"]),tt=new Set(["agent execution failed","execution failed","run failed","failed"]);function v(i){return typeof i=="string"&&i.trim().length>0}function ce(i){return(i??"").trim().toLowerCase()}function rt(i){return(i??"").trim().replace(/\s+/g," ").toLowerCase()}function st(i){return tt.has(rt(i))}function V(i,t=3){return i.length<=t?i.join(", "):`${i.slice(0,t).join(", ")} +${i.length-t} more`}function G(i,t){const f=[],c=h=>{if(typeof h!="string")return;const w=h.trim();w&&(f.some(W=>W.toLowerCase()===w.toLowerCase())||f.push(w))};if(Array.isArray(i))for(const h of i)c(h);return c(t??null),f}function it(i){if(i.runId&&i.runId.trim().length>0)return i.runId.trim();const t=i.metadata;if(!t)return null;const f=["slice_run_id","sliceRunId","runId","run_id","correlation_id","correlationId","sessionId","session_id","agentRunId"];for(const c of f){const h=t[c];if(typeof h=="string"&&h.trim().length>0)return h.trim()}return null}function at(i){const t=ce(i.status);if(t==="blocked"||t==="failed"||t==="completed"||t==="cancelled")return t;const f=ce(i.phase);if(f==="blocked")return"blocked";if(f==="handoff")return"handoff";if(f==="completed")return"completed";if(f==="review")return"review";const c=ce(i.state);return c==="error"?"failed":c==="stopped"?"paused":c==="stale"?"queued":et.has(t)?t:i.blockers.length>0?"blocked":t||"unknown"}function nt(i,t,f){var h;const c=[((h=i.blockerDiagnostics)==null?void 0:h.reason)??null,i.blockerReason??null,...i.blockers,t==="blocked"||t==="failed"||t==="handoff"?f:null].map(w=>typeof w=="string"?w.trim():"").filter(w=>w.length>0);return c.length>0?c.find(W=>!st(W))??c[0]:t==="handoff"?"Waiting for handoff acceptance by the next agent.":t==="blocked"?"Blocked without an explicit reason from runtime.":t==="failed"?"Run failed without explicit error details.":null}function lt(i){return i==="completed"?"border-lime/25 bg-lime/[0.08] text-lime":i==="needs_attention"?"border-amber-400/30 bg-amber-400/10 text-amber-200":i==="failed"?"border-red-400/30 bg-red-500/10 text-red-200":i==="in_progress"?"border-teal-400/30 bg-teal-400/10 text-teal-200":"border-strong bg-white/[0.04] text-secondary"}const dt={hidden:{opacity:0,y:-4},visible:i=>({opacity:1,y:0,transition:{duration:.28,delay:i*.04,ease:[.16,1,.3,1]}}),exit:{opacity:0,transition:{duration:.18}}},R={hidden:{opacity:0,y:8},visible:i=>({opacity:1,y:0,transition:{duration:.22,delay:i*.04,ease:[.22,1,.36,1]}}),exit:{opacity:0,transition:{duration:.18}}};function ue(){return e.jsx("div",{className:"h-px bg-gradient-to-r from-transparent via-white/[0.06] to-transparent"})}function ot(i){return i==="in_progress"?{background:`linear-gradient(90deg, ${x.lime}, ${x.teal})`}:i==="needs_attention"?{background:`linear-gradient(90deg, ${x.red}, ${x.amber})`}:i==="completed"?{background:`linear-gradient(90deg, ${x.teal}, ${x.cyan})`}:i==="failed"?{background:`linear-gradient(90deg, ${x.red}, ${x.red}80)`}:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}const vt=j.memo(function({session:t,activity:f,initiatives:c=[],sliceRuns:h=[],onOpenActivityItem:w,onContinueHighestPriority:W,onDispatchSession:X,onPauseSession:K,onResumeSession:Q,onCancelSession:H,onCreateCheckpoint:J,onRollbackSession:Y,onStartInitiative:ct,onStartWorkstream:ut,initialInterventionDraft:C=null,onSubmitIntervention:te,onClose:me}){var ye,ve,je;const[u,xe]=j.useState(null),[L,T]=j.useState(null),[U,he]=j.useState(!1),[re,z]=j.useState(""),{enqueue:pe,ToastRenderer:Ce}=Ye();j.useEffect(()=>{if(!t){z("");return}if(C!=null&&C.text){z(C.text);return}z("")},[C==null?void 0:C.text,t==null?void 0:t.id]);const q=j.useMemo(()=>{var l,g,y,d,m;if(!t)return new Set;const r=new Set;return(l=t.runId)!=null&&l.trim()&&r.add(t.runId.trim()),(g=t.id)!=null&&g.trim()&&r.add(t.id.trim()),(m=(d=(y=t.blockerDiagnostics)==null?void 0:y.context)==null?void 0:d.sliceRunId)!=null&&m.trim()&&r.add(t.blockerDiagnostics.context.sliceRunId.trim()),r},[t]),$=j.useMemo(()=>t?q.size===0?[]:f.filter(r=>{const l=it(r);return!!(l&&q.has(l))}).sort((r,l)=>Date.parse(l.timestamp)-Date.parse(r.timestamp)).slice(0,12):[],[f,t,q]),s=j.useMemo(()=>{var y,d;if(!t||!Array.isArray(h)||h.length===0)return null;const r=((y=t.initiativeId)==null?void 0:y.trim())??"",l=((d=t.workstreamId)==null?void 0:d.trim())??"",g=h.filter(m=>{var oe,we;const A=((oe=m.sliceRunId)==null?void 0:oe.trim())??"",E=((we=m.runId)==null?void 0:we.trim())??"";if(A&&q.has(A)||E&&q.has(E))return!0;if(!l||!G(m.workstreamIds,m.workstreamId).includes(l))return!1;if(!r)return!0;const ee=G(m.initiativeIds,m.initiativeId);return!(ee.length>0&&!ee.includes(r))});return g.length===0?null:[...g].sort((m,A)=>{const E=Date.parse(m.updatedAt??m.lastEventAt??m.startedAt??""),de=Date.parse(A.updatedAt??A.lastEventAt??A.startedAt??""),ee=Number.isFinite(E)?E:0;return(Number.isFinite(de)?de:0)-ee})[0]},[t,q,h]),se=j.useMemo(()=>{var y;if(!t)return[];const r=[],l=t.initiativeId??t.groupId;if(l){const d=c.find(m=>m.id===l);d?r.push({label:"Initiative",value:d.name}):t.groupLabel&&t.groupLabel.trim().length>0?r.push({label:"Initiative",value:t.groupLabel}):B(l)&&r.push({label:"Initiative",value:N(l)})}if(t.workstreamId){let d=null;for(const m of c){const A=(y=m.workstreams)==null?void 0:y.find(E=>E.id===t.workstreamId);if(A){d=A.name;break}}!d&&B(t.workstreamId)?d=N(t.workstreamId):!d&&!De.test(t.workstreamId)&&(d=t.workstreamId),d&&r.push({label:"Workstream",value:d})}const g=t.phase??null;if(g){const d=String(g);r.push({label:"Milestone",value:B(d)?N(d):d})}return t.title&&r.push({label:"Task",value:t.title}),r},[c,t]),S=j.useMemo(()=>{var y,d;if(!t)return null;const r=((y=$[0])==null?void 0:y.summary)??((d=$[0])==null?void 0:d.description)??null,g=t.lastEventSummary??r??null;return g&&g.trim().length>0?g.trim():null},[$,t]),Ae=j.useMemo(()=>{var r;return t?ke(t.agentName,t.title,t.lastEventSummary,S,(r=$[0])==null?void 0:r.metadata):ke()},[$,t,S]),_=async(r,l,g)=>{if(!(!g||u)){xe(r),T(null);try{await g(),T(`${l} requested.`)}catch(y){T(y instanceof Error?y.message:`${l} failed.`)}finally{xe(null)}}};if(!t)return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:{background:`linear-gradient(90deg, ${x.iris}, ${x.iris}80)`}}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsx("div",{className:M("transition-all",U?"max-h-0 overflow-hidden":"min-h-0 flex-1"),children:e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center gap-4 px-5 py-8",children:[e.jsx("div",{className:"flex h-14 w-14 items-center justify-center rounded-2xl border border-white/[0.08] bg-white/[0.03]",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-muted",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("path",{d:"M8 21h8M12 17v4"})]})}),e.jsx("p",{className:"text-body text-secondary text-center",children:"No session selected"}),e.jsx("p",{className:"text-caption text-muted text-center max-w-[240px]",children:"Select a session to inspect summary, breadcrumbs, blockers, and recent messages."}),e.jsx("button",{onClick:()=>_("continue-priority","Continue highest priority",W),disabled:!W||!!u,className:"mt-2 h-8 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:u==="continue-priority"?"Dispatching...":"Continue highest priority"}),L&&e.jsx("p",{className:"text-caption text-secondary",children:L})]})})]});const P=t.progress===null?null:Math.round(t.progress),k=at(t),p=$[0]??null,ie=(s==null?void 0:s.blockingDecisionCount)??0,Re=Math.max(0,((s==null?void 0:s.decisionCount)??0)-ie),o=Ve({sessionStatus:t.status,sessionPhase:t.phase??null,sessionState:t.state??null,sliceStatus:(s==null?void 0:s.status)??null,activityType:(p==null?void 0:p.type)??null,activityStatus:(typeof(p==null?void 0:p.state)=="string"&&p.state.trim().length>0?p.state:null)??(typeof(p==null?void 0:p.phase)=="string"&&p.phase.trim().length>0?p.phase:null)??(s==null?void 0:s.runtimeState)??null,stopReason:t.blockerReason??((ye=t.blockerDiagnostics)==null?void 0:ye.reason)??((s==null?void 0:s.status)==="failed"?"error":null),decisionRequired:((p==null?void 0:p.decisionRequired)??!1)||ie>0,blockingDecisionCount:ie,nonBlockingDecisionCount:Re,blockerCount:t.blockers.length,blockerReason:t.blockerReason??((ve=t.blockerDiagnostics)==null?void 0:ve.reason)??null}),ae=nt(t,k,S),Te=k==="handoff"?"Handoff":k==="blocked"?"Blocker reason":k==="failed"?"Failure reason":"Status note",$e=o.status==="in_progress"&&["running","active","queued","pending","working","in_progress","planning","review"].includes(k),Se=o.status==="needs_attention"&&["paused","blocked","queued","pending"].includes(k),Be=!["completed","archived","cancelled"].includes(k),Me=!["archived","cancelled"].includes(k),Le=o.label,_e=lt(o.status),ne=["running","active","working","in_progress","planning","review"].includes(k),Ee=o.status!=="in_progress"&&!ne,We=o.tone==="critical"?x.red:o.tone==="warning"?x.amber:o.tone==="positive"?x.lime:x.teal,Ue=P!==null&&P>=100&&o.status!=="completed"?"Terminal state":"Progress",qe=o.tone==="critical"?"border-red-400/25 bg-red-500/10":o.tone==="warning"?"border-amber-400/25 bg-amber-500/10":o.tone==="positive"?"border-lime/22 bg-lime/[0.08]":"border-subtle bg-white/[0.02]",a=t.blockerDiagnostics??null,n=(a==null?void 0:a.context)??null,le=[v(a==null?void 0:a.source)?`Source: ${a.source.trim()}`:null,v(a==null?void 0:a.errorCode)?`Code: ${a.errorCode.trim()}`:null,v(a==null?void 0:a.errorCategory)?`Category: ${a.errorCategory.trim()}`:null,(a==null?void 0:a.retryable)===!0?"Retryable: yes":(a==null?void 0:a.retryable)===!1?"Retryable: no":null].filter(r=>!!r),b=[];n&&(Array.isArray(n.initiativeIds)&&n.initiativeIds.length>0?b.push({label:"Initiatives",value:V(n.initiativeIds.map(r=>B(r)?N(r):r),4)}):v(n.initiativeId)&&b.push({label:"Initiative",value:Ge("Initiative",n.initiativeId.trim())}),v(n.workstreamTitle)?b.push({label:"Workstream",value:n.workstreamTitle.trim()}):Array.isArray(n.workstreamIds)&&n.workstreamIds.length>0?b.push({label:"Workstreams",value:V(n.workstreamIds,4)}):v(n.workstreamId)&&b.push({label:"Workstream",value:n.workstreamId.trim()}),v(n.sliceRunId)&&b.push({label:"Slice run",value:N(n.sliceRunId.trim())}),v(n.parallelMode)&&b.push({label:"Mode",value:n.parallelMode.trim().toUpperCase()}),Array.isArray(n.taskIds)&&n.taskIds.length>0&&b.push({label:"Tasks",value:V(n.taskIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.milestoneIds)&&n.milestoneIds.length>0&&b.push({label:"Milestones",value:V(n.milestoneIds.map(r=>B(r)?N(r):r))}),Array.isArray(n.iwmtIds)&&n.iwmtIds.length>0?b.push({label:"Scope IDs",value:V(n.iwmtIds.map(r=>B(r)?N(r):r),4)}):v(n.iwmtId)&&b.push({label:"Scope ID",value:B(n.iwmtId.trim())?N(n.iwmtId.trim()):n.iwmtId.trim()}),v(n.logPath)&&b.push({label:"Log path",value:Ne(n.logPath.trim())}),v(n.outputPath)&&b.push({label:"Output path",value:Ne(n.outputPath.trim())}));const be=(k==="blocked"||k==="failed")&&!!(a&&(v(a.reason)||le.length>0||b.length>0||Array.isArray(a.suggestedActions)&&a.suggestedActions.length>0)),Z=v(ae)?ae:null,ze=Z!==null&&!(S&&(Z===S||S.includes(Z)))&&!be,Pe=j.useCallback(()=>{!H||!t||(T("Session will be cancelled..."),pe({message:`Cancelled "${t.title}"`,onCommit:async()=>{try{await H(t),T("Session cancelled.")}catch(r){T(r instanceof Error?r.message:"Cancel failed.")}},onUndo:()=>{T(null)}}))},[H,t,pe]),Fe=[{label:"Started",value:t.startedAt?O(t.startedAt):"—"},{label:"Updated",value:t.updatedAt?O(t.updatedAt):"—"},...t.eta?[{label:"ETA",value:t.eta}]:[],...t.checkpointCount?[{label:"Checkpoints",value:String(t.checkpointCount)}]:[]],fe=s?s.status.replace(/_/g," "):null,F=G(s==null?void 0:s.initiativeIds,(s==null?void 0:s.initiativeId)??null),D=G(s==null?void 0:s.workstreamIds,(s==null?void 0:s.workstreamId)??null);G(s==null?void 0:s.iwmtIds,(s==null?void 0:s.iwmtId)??null);const Oe=F[0]?((je=c.find(r=>r.id===F[0]))==null?void 0:je.name)??F[0]:null,ge=L?L.toLowerCase().includes("fail")||L.toLowerCase().includes("error")?"error":u?"pending":"success":null;return e.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsx("div",{className:"h-[2px] flex-shrink-0",style:ot(o.status)}),e.jsxs("div",{className:"flex items-center justify-between px-5 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("p",{className:"section-kicker",children:"Session Detail"}),e.jsxs("span",{className:M("inline-flex items-center gap-1.5 rounded-full border px-2 py-[1px] text-micro font-semibold uppercase tracking-widest",_e),children:[ne&&e.jsx("span",{className:"h-1.5 w-1.5 rounded-full pulse-soft",style:{backgroundColor:Ie(k)}}),Le]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{onClick:()=>he(r=>!r),className:"text-muted transition-colors hover:text-primary","aria-label":U?"Expand session detail":"Collapse session detail",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:M("transition-transform",U?"-rotate-90":"rotate-0"),children:e.jsx("path",{d:"m6 9 6 6 6-6"})})}),me&&e.jsx("button",{type:"button",onClick:me,"aria-label":"Close session inspector",className:"inline-flex h-8 w-8 items-center justify-center rounded-full border border-strong bg-white/[0.03] text-primary transition-colors hover:bg-white/[0.08] hover:text-white",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsxs("div",{className:M("transition-all flex flex-col min-h-0",U?"max-h-0 overflow-hidden":"flex-1"),children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-5 py-5 space-y-5",children:[e.jsx(Ze,{mode:"wait",children:e.jsxs(I.div,{variants:dt,initial:"hidden",animate:"visible",exit:"exit",custom:0,children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx(Xe,{name:t.agentName??"OrgX",size:"md",hint:t.agentName}),e.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[e.jsx("h2",{className:"text-[28px] font-medium leading-tight text-white truncate",children:Ke(t.title)}),e.jsxs("p",{className:"mt-1 text-micro uppercase tracking-[0.12em] text-muted",children:[t.agentName??"OrgX"," · ",Ae.label]})]})]}),se.length>0&&e.jsx("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:se.map((r,l)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(Qe,{tone:"muted",children:r.value}),l<se.length-1&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"flex-shrink-0 text-faint",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})]},`${r.label}-${r.value}`))})]},t.id)}),e.jsx(ue,{}),S&&e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:1,children:[e.jsx("p",{className:"section-kicker mb-2",children:"Summary"}),e.jsx(He,{text:S,mode:"block"})]}),e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:2,children:e.jsxs("div",{className:M("rounded-xl border px-4 py-3",qe),children:[e.jsx("p",{className:"section-kicker mb-1.5",children:o.label}),e.jsx("p",{className:"text-body text-secondary",children:o.sentence}),o.nextAction&&e.jsxs("p",{className:"mt-1.5 flex items-center gap-1 text-caption text-secondary",children:[e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:x.lime,strokeWidth:"2.5",className:"flex-shrink-0",children:e.jsx("path",{d:"m9 18 6-6-6-6"})}),"Next: ",o.nextAction]})]})}),ze&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5",children:Te}),e.jsx("p",{className:"text-body text-secondary",children:Z})]})}),be&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:3,children:e.jsxs("div",{className:"rounded-xl border border-red-500/25 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-1.5 text-red-200/75",children:"Why blocked"}),e.jsx("p",{className:"text-body text-red-100/90",children:(a==null?void 0:a.reason)??ae??"Runtime marked this run as blocked without details."}),le.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:le.map(r=>e.jsx("span",{className:"rounded-full border border-red-300/25 bg-red-500/10 px-2 py-0.5 text-micro text-red-100/85",children:r},r))}),b.length>0&&e.jsxs("div",{className:"mt-2 rounded-md border border-red-300/20 bg-black/15 p-2.5",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Associated context"}),e.jsx("dl",{className:"grid grid-cols-1 gap-1.5 text-caption text-red-100/85",children:b.map(r=>e.jsxs("div",{className:"grid grid-cols-[86px_1fr] gap-2",children:[e.jsx("dt",{className:"text-red-200/70",children:r.label}),e.jsx("dd",{className:"break-all text-red-50/95",children:r.value})]},r.label))})]}),Array.isArray(a==null?void 0:a.suggestedActions)&&a.suggestedActions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"mb-1 text-micro uppercase tracking-[0.14em] text-red-200/65",children:"Suggested actions"}),e.jsx("ul",{className:"space-y-1 text-caption text-red-100/85",children:a.suggestedActions.map(r=>e.jsxs("li",{children:["• ",r]},r))})]}),v(a==null?void 0:a.eventTimestamp)&&e.jsxs("p",{className:"mt-2 text-micro text-red-200/60",children:["Last blocker event: ",new Date(a.eventTimestamp).toLocaleString()," ·"," ",O(a.eventTimestamp)]})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:4,children:[P!==null&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 flex items-center justify-between text-caption text-secondary",children:[e.jsx("span",{children:Ue}),e.jsxs("span",{className:"text-primary",children:[P,"%"]})]}),e.jsx("div",{className:"h-[3px] rounded-full bg-white/[0.08]",children:e.jsx(I.div,{className:M("h-[3px] rounded-full",ne&&"live-pulse"),style:{background:We},initial:{width:0},animate:{width:`${P}%`},transition:{duration:.5,ease:Je.easingStandard}})})]}),e.jsx("dl",{className:"grid grid-cols-2 gap-3 text-caption text-secondary",children:Fe.map(r=>e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:r.label}),e.jsx("dd",{className:"text-body font-semibold text-white",children:r.value})]},r.label))})]}),s&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:5,children:e.jsxs("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"section-kicker",children:"Slice scope"}),fe?e.jsx("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-micro font-semibold uppercase tracking-[0.08em] text-secondary",children:fe}):null]}),s.statusExplainer?e.jsx("p",{className:"mt-2 text-caption text-secondary",children:s.statusExplainer}):null,e.jsxs("dl",{className:"mt-2 grid grid-cols-2 gap-2 text-caption text-secondary",children:[e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Initiative"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:Oe??"—"})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Workstream"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.workstreamTitle??(D[0]?N(D[0]):"—")})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Run"}),e.jsx("dd",{className:"break-all text-body font-semibold text-white",children:N(s.runId??s.sliceRunId)})]}),e.jsxs("div",{children:[e.jsx("dt",{className:"text-muted",children:"Updated"}),e.jsx("dd",{className:"text-body font-semibold text-white",children:s.updatedAt?O(s.updatedAt):"—"})]})]}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5 text-micro",children:[e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Tasks ",s.taskIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Milestones ",s.milestoneIds.length]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Artifacts ",s.artifactCount]}),e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["Needs input ",s.blockingDecisionCount]}),F.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",F.length-1," initiatives"]}):null,D.length>1?e.jsxs("span",{className:"rounded-full border border-white/[0.12] bg-white/[0.03] px-2 py-0.5 text-secondary",children:["+",D.length-1," workstreams"]}):null]}),s.taskIds.length>0?e.jsxs("p",{className:"mt-2 text-micro text-secondary",children:["Tasks: ",s.taskIds.length]}):null]})}),t.blockers.length>0&&e.jsx(I.div,{variants:R,initial:"hidden",animate:"visible",custom:6,children:e.jsxs("div",{className:"rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3",children:[e.jsx("p",{className:"section-kicker mb-2 text-red-200/70",children:"Blockers"}),e.jsx("ul",{className:"space-y-1 text-body text-red-100/90",children:t.blockers.map(r=>e.jsxs("li",{children:["• ",r]},r))})]})}),e.jsx(ue,{}),e.jsxs(I.div,{variants:R,initial:"hidden",animate:"visible",custom:7,children:[e.jsx("p",{className:"section-kicker mb-4",children:"Recent Messages"}),$.length===0&&e.jsx("p",{className:"text-body text-secondary",children:"No recent messages for this run."}),e.jsx("div",{className:"relative border-l border-white/[0.06] pl-6 ml-1 space-y-3",children:$.map((r,l)=>e.jsxs(I.div,{className:"relative group",variants:R,initial:"hidden",animate:"visible",custom:l,children:[e.jsx("div",{className:"absolute -left-[27px] top-1.5 h-2 w-2 rounded-full border border-black ring-4 ring-black",style:{backgroundColor:Ie(r.type??r.state??"unknown")}}),e.jsxs("article",{className:"rounded-lg border border-subtle bg-white/[0.02] px-3 py-2.5 transition-colors hover:bg-white/[0.04]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 text-caption text-bright",children:r.title}),w&&e.jsx("button",{type:"button",onClick:()=>w(r),className:"flex-shrink-0 rounded-full border border-strong bg-white/[0.03] px-2.5 py-0.5 text-micro font-semibold text-secondary opacity-0 transition-all group-hover:opacity-100 hover:bg-white/[0.08] hover:text-primary",children:"Open"})]}),(r.summary||r.description)&&e.jsx("p",{className:"mt-0.5 line-clamp-2 text-caption text-secondary",children:r.summary??r.description}),e.jsxs("p",{className:"mt-1 text-micro text-muted",children:[new Date(r.timestamp).toLocaleString()," · ",O(r.timestamp)]})]})]},r.id))})]})]}),e.jsxs("div",{className:"flex-shrink-0 border-t border-subtle px-5 py-3 space-y-3",children:[L&&e.jsx("p",{className:M("rounded-md border px-2.5 py-1.5 text-caption",ge==="error"?"border-red-400/30 bg-red-500/10 text-red-200":ge==="pending"?"border-white/[0.08] bg-white/[0.02] text-secondary pulse-soft":"border-lime/25 bg-lime/[0.08] text-lime"),children:L}),te&&e.jsx("div",{children:e.jsx("textarea",{value:re,onChange:r=>z(r.target.value),placeholder:"Share guidance for this run...",rows:2,className:"w-full resize-none rounded-lg border border-white/[0.10] bg-white/[0.03] px-3 py-2 text-body text-bright outline-none placeholder:text-faint focus:border-white/20"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[$e&&e.jsx("button",{onClick:()=>_("pause-session","Session paused",()=>K==null?void 0:K(t)),disabled:!K||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="pause-session"?"Pausing...":"Pause"}),Se&&e.jsx("button",{onClick:()=>_("resume-session","Session resumed",()=>Q==null?void 0:Q(t)),disabled:!Q||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="resume-session"?"Resuming...":"Resume"}),e.jsx("button",{onClick:()=>_("checkpoint-session","Progress saved",()=>J==null?void 0:J(t)),disabled:!J||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="checkpoint-session"?"Saving...":"Save"}),Me&&e.jsx("button",{onClick:()=>_("rollback-session","Undo requested",()=>Y==null?void 0:Y(t)),disabled:!Y||!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-secondary hover:bg-white/[0.04] hover:text-white disabled:opacity-45 transition-colors",children:u==="rollback-session"?"Undoing...":"Undo"}),Be&&H&&e.jsx("button",{onClick:Pe,disabled:!!u,className:"rounded-md px-2.5 py-1.5 text-caption font-medium text-red-400/70 hover:bg-red-500/[0.08] hover:text-red-300 disabled:opacity-45 transition-colors",children:"Cancel"})]}),e.jsx("div",{className:"flex-1"}),te&&e.jsx("button",{type:"button",onClick:()=>{const r=re.trim();if(!r){T("Intervention note cannot be empty.");return}_("intervene-note","Intervention sent",async()=>{await te({session:t,workstreamId:(C==null?void 0:C.workstreamId)??t.workstreamId??null,text:r}),z("")})},disabled:!!u||re.trim().length===0,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption font-semibold text-primary transition-colors hover:bg-white/[0.08] disabled:opacity-45",children:u==="intervene-note"?"Sending...":"Intervene"}),e.jsxs("button",{onClick:()=>_("dispatch-session","Session started",()=>X==null?void 0:X(t)),disabled:!X||!!u||!Ee,className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-lime/25 bg-lime/10 px-4 text-caption font-semibold text-lime transition-colors hover:bg-lime/20 disabled:opacity-45",children:[e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",className:"flex-shrink-0",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),u==="dispatch-session"?"Starting...":o.status==="completed"?"Restart":"Start"]})]})]})]}),e.jsx(Ce,{})]})});export{vt as SessionInspector};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as l,j as e}from"./Dj2k1r16.js";import{e as r,y as u,E as j,
|
|
1
|
+
import{r as l,j as e}from"./Dj2k1r16.js";import{e as r,y as u,E as j,v as f}from"./B1LENRC8.js";import"./DMKyYAtD.js";import"./eeHXe_OQ.js";import"./cX2e-TLi.js";import"./BjK42gtU.js";import"./BV0BcV1u.js";function c(a){if(!a)return"unknown";try{return f(a)}catch{return"unknown"}}function E({open:a,onClose:o,outbox:t,onOpenSettings:p,onRefresh:m}){const[x,d]=l.useState(!1),h=l.useMemo(()=>Object.entries(t.pendingByQueue??{}).filter(([,s])=>typeof s=="number"&&s>0).sort((s,b)=>b[1]-s[1]),[t.pendingByQueue]),i=l.useMemo(()=>t.replayStatus==="error"?r.red:t.pendingTotal>0?r.amber:r.textMuted,[t.pendingTotal,t.replayStatus]),y=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),d(!0),setTimeout(()=>d(!1),1200)}catch{}};return e.jsx(u,{open:a,onClose:o,maxWidth:"max-w-3xl",fitContent:!0,children:e.jsxs("div",{className:"flex w-full flex-col",children:[e.jsxs("div",{className:"border-b border-subtle px-5 pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"inline-flex items-center gap-2 text-heading font-semibold text-white",children:[e.jsx(j,{type:"outbox",size:14}),e.jsx("span",{className:"truncate",children:"Outbox"}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${i}30`,backgroundColor:`${i}14`,color:i},children:t.pendingTotal})]}),e.jsx("p",{className:"mt-1 text-body leading-relaxed text-secondary",children:"Buffered updates queued for replay to OrgX when connectivity is healthy."})]}),e.jsx("button",{type:"button",onClick:o,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]","aria-label":"Close outbox modal",children:"Close"})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-1 gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Replay status"}),e.jsx("p",{className:"mt-1 text-body font-semibold",style:{color:i},children:t.replayStatus}),t.lastReplayError&&t.replayStatus==="error"&&e.jsx("p",{className:"mt-1 line-clamp-2 text-caption text-red-200/75",children:t.lastReplayError})]}),e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsx("p",{className:"text-micro uppercase tracking-[0.12em] text-secondary",children:"Window"}),e.jsxs("p",{className:"mt-1 text-caption text-primary",children:["Oldest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.oldestEventAt)})]}),e.jsxs("p",{className:"mt-0.5 text-caption text-primary",children:["Newest: ",e.jsx("span",{className:"font-semibold text-white",children:c(t.newestEventAt)})]})]})]})]}),e.jsx("div",{className:"px-5 py-4",children:t.pendingTotal===0?e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] p-4 text-body text-secondary",children:"Outbox is empty."}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-caption font-semibold uppercase tracking-[0.12em] text-secondary",children:"Queues"}),e.jsx("button",{type:"button",onClick:y,className:"rounded-md border border-strong bg-white/[0.03] px-2.5 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08]",children:x?"Copied":"Copy JSON"})]}),e.jsx("div",{className:"space-y-1.5",children:h.map(([n,s])=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-white/[0.08] bg-white/[0.02] px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-body font-medium text-white",children:n}),e.jsxs("p",{className:"mt-0.5 text-micro text-secondary",children:[s," event",s===1?"":"s"]})]}),e.jsx("span",{className:"rounded-full border px-2 py-0.5 text-caption font-semibold",style:{borderColor:`${r.amber}30`,backgroundColor:`${r.amber}14`,color:r.amber},children:s})]},n))}),e.jsx("div",{className:"rounded-xl border border-subtle bg-white/[0.02] px-3 py-2 text-caption text-secondary",children:"Replay is handled automatically by the OrgX sync service. If events stay queued, check Settings for API key and last replay errors."})]})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-subtle px-5 py-3",children:[e.jsx("button",{type:"button",onClick:m,className:"rounded-md border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-primary transition-colors hover:bg-white/[0.08]",children:"Refresh"}),e.jsx("button",{type:"button",onClick:p,className:"rounded-md border border-lime/25 bg-lime/10 px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/20",children:"Open settings"})]})]})})}export{E as BulkOutboxModal};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Oe=e=>{throw TypeError(e)};var te=(e,t,s)=>t.has(e)||Oe("Cannot "+s);var r=(e,t,s)=>(te(e,t,"read from private field"),s?s.call(e):t.get(e)),c=(e,t,s)=>t.has(e)?Oe("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),o=(e,t,s,i)=>(te(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),p=(e,t,s)=>(te(e,t,"access private method"),s);var Wt=(e,t,s,i)=>({set _(n){o(e,t,n,s)},get _(){return r(e,t,i)}});import{r as D,j as ns}from"./Dj2k1r16.js";var qt=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},as={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},it,me,De,os=(De=class{constructor(){c(this,it,as);c(this,me,!1)}setTimeoutProvider(e){o(this,it,e)}setTimeout(e,t){return r(this,it).setTimeout(e,t)}clearTimeout(e){r(this,it).clearTimeout(e)}setInterval(e,t){return r(this,it).setInterval(e,t)}clearInterval(e){r(this,it).clearInterval(e)}},it=new WeakMap,me=new WeakMap,De),ft=new os;function us(e){setTimeout(e,0)}var Ot=typeof window>"u"||"Deno"in globalThis;function q(){}function hs(e,t){return typeof e=="function"?e(t):e}function ee(e){return typeof e=="number"&&e>=0&&e!==1/0}function Ge(e,t){return Math.max(e+(t||0)-Date.now(),0)}function dt(e,t){return typeof e=="function"?e(t):e}function _(e,t){return typeof e=="function"?e(t):e}function Se(e,t){const{type:s="all",exact:i,fetchStatus:n,predicate:a,queryKey:h,stale:u}=e;if(h){if(i){if(t.queryHash!==ve(h,t.options))return!1}else if(!Kt(t.queryKey,h))return!1}if(s!=="all"){const y=t.isActive();if(s==="active"&&!y||s==="inactive"&&y)return!1}return!(typeof u=="boolean"&&t.isStale()!==u||n&&n!==t.state.fetchStatus||a&&!a(t))}function Re(e,t){const{exact:s,status:i,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(s){if(St(t.options.mutationKey)!==St(a))return!1}else if(!Kt(t.options.mutationKey,a))return!1}return!(i&&t.state.status!==i||n&&!n(t))}function ve(e,t){return((t==null?void 0:t.queryKeyHashFn)||St)(e)}function St(e){return JSON.stringify(e,(t,s)=>se(s)?Object.keys(s).sort().reduce((i,n)=>(i[n]=s[n],i),{}):s)}function Kt(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>Kt(e[s],t[s])):!1}var cs=Object.prototype.hasOwnProperty;function Be(e,t,s=0){if(e===t)return e;if(s>500)return t;const i=Ee(e)&&Ee(t);if(!i&&!(se(e)&&se(t)))return t;const a=(i?e:Object.keys(e)).length,h=i?t:Object.keys(t),u=h.length,y=i?new Array(u):{};let m=0;for(let v=0;v<u;v++){const d=i?v:h[v],g=e[d],f=t[d];if(g===f){y[d]=g,(i?v<a:cs.call(e,d))&&m++;continue}if(g===null||f===null||typeof g!="object"||typeof f!="object"){y[d]=f;continue}const O=Be(g,f,s+1);y[d]=O,O===g&&m++}return a===u&&m===a?e:y}function Zt(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Ee(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function se(e){if(!Fe(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!Fe(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Fe(e){return Object.prototype.toString.call(e)==="[object Object]"}function ls(e){return new Promise(t=>{ft.setTimeout(t,e)})}function ie(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Be(e,t):t}function ds(e,t,s=0){const i=[...e,t];return s&&i.length>s?i.slice(1):i}function fs(e,t,s=0){const i=[t,...e];return s&&i.length>s?i.slice(0,-1):i}var ge=Symbol();function ze(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===ge?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function be(e,t){return typeof e=="function"?e(...t):!!e}function ys(e,t,s){let i=!1,n;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(n??(n=t()),i||(i=!0,n.aborted?s():n.addEventListener("abort",s,{once:!0})),n)}),e}var yt,rt,Rt,Ae,ps=(Ae=class extends qt{constructor(){super();c(this,yt);c(this,rt);c(this,Rt);o(this,Rt,t=>{if(!Ot&&window.addEventListener){const s=()=>t();return window.addEventListener("visibilitychange",s,!1),()=>{window.removeEventListener("visibilitychange",s)}}})}onSubscribe(){r(this,rt)||this.setEventListener(r(this,Rt))}onUnsubscribe(){var t;this.hasListeners()||((t=r(this,rt))==null||t.call(this),o(this,rt,void 0))}setEventListener(t){var s;o(this,Rt,t),(s=r(this,rt))==null||s.call(this),o(this,rt,t(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(t){r(this,yt)!==t&&(o(this,yt,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(s=>{s(t)})}isFocused(){var t;return typeof r(this,yt)=="boolean"?r(this,yt):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},yt=new WeakMap,rt=new WeakMap,Rt=new WeakMap,Ae),Pe=new ps;function re(){let e,t;const s=new Promise((n,a)=>{e=n,t=a});s.status="pending",s.catch(()=>{});function i(n){Object.assign(s,n),delete s.resolve,delete s.reject}return s.resolve=n=>{i({status:"fulfilled",value:n}),e(n)},s.reject=n=>{i({status:"rejected",reason:n}),t(n)},s}var ms=us;function vs(){let e=[],t=0,s=u=>{u()},i=u=>{u()},n=ms;const a=u=>{t?e.push(u):n(()=>{s(u)})},h=()=>{const u=e;e=[],u.length&&n(()=>{i(()=>{u.forEach(y=>{s(y)})})})};return{batch:u=>{let y;t++;try{y=u()}finally{t--,t||h()}return y},batchCalls:u=>(...y)=>{a(()=>{u(...y)})},schedule:a,setNotifyFunction:u=>{s=u},setBatchNotifyFunction:u=>{i=u},setScheduler:u=>{n=u}}}var M=vs(),Et,nt,Ft,je,gs=(je=class extends qt{constructor(){super();c(this,Et,!0);c(this,nt);c(this,Ft);o(this,Ft,t=>{if(!Ot&&window.addEventListener){const s=()=>t(!0),i=()=>t(!1);return window.addEventListener("online",s,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",s),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,nt)||this.setEventListener(r(this,Ft))}onUnsubscribe(){var t;this.hasListeners()||((t=r(this,nt))==null||t.call(this),o(this,nt,void 0))}setEventListener(t){var s;o(this,Ft,t),(s=r(this,nt))==null||s.call(this),o(this,nt,t(this.setOnline.bind(this)))}setOnline(t){r(this,Et)!==t&&(o(this,Et,t),this.listeners.forEach(i=>{i(t)}))}isOnline(){return r(this,Et)}},Et=new WeakMap,nt=new WeakMap,Ft=new WeakMap,je),Xt=new gs;function bs(e){return Math.min(1e3*2**e,3e4)}function Ve(e){return(e??"online")==="online"?Xt.isOnline():!0}var ne=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function We(e){let t=!1,s=0,i;const n=re(),a=()=>n.status!=="pending",h=b=>{var w;if(!a()){const R=new ne(b);g(R),(w=e.onCancel)==null||w.call(e,R)}},u=()=>{t=!0},y=()=>{t=!1},m=()=>Pe.isFocused()&&(e.networkMode==="always"||Xt.isOnline())&&e.canRun(),v=()=>Ve(e.networkMode)&&e.canRun(),d=b=>{a()||(i==null||i(),n.resolve(b))},g=b=>{a()||(i==null||i(),n.reject(b))},f=()=>new Promise(b=>{var w;i=R=>{(a()||m())&&b(R)},(w=e.onPause)==null||w.call(e)}).then(()=>{var b;i=void 0,a()||(b=e.onContinue)==null||b.call(e)}),O=()=>{if(a())return;let b;const w=s===0?e.initialPromise:void 0;try{b=w??e.fn()}catch(R){b=Promise.reject(R)}Promise.resolve(b).then(d).catch(R=>{var k;if(a())return;const Q=e.retry??(Ot?0:3),E=e.retryDelay??bs,l=typeof E=="function"?E(s,R):E,x=Q===!0||typeof Q=="number"&&s<Q||typeof Q=="function"&&Q(s,R);if(t||!x){g(R);return}s++,(k=e.onFail)==null||k.call(e,s,R),ls(l).then(()=>m()?void 0:f()).then(()=>{t?g(R):O()})})};return{promise:n,status:()=>n.status,cancel:h,continue:()=>(i==null||i(),n),cancelRetry:u,continueRetry:y,canStart:v,start:()=>(v()?O():f().then(O),n)}}var pt,Ue,$e=(Ue=class{constructor(){c(this,pt)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ee(this.gcTime)&&o(this,pt,ft.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ot?1/0:300*1e3))}clearGcTimeout(){r(this,pt)&&(ft.clearTimeout(r(this,pt)),o(this,pt,void 0))}},pt=new WeakMap,Ue),mt,Mt,N,vt,T,Lt,gt,H,W,qe,Ps=(qe=class extends $e{constructor(t){super();c(this,H);c(this,mt);c(this,Mt);c(this,N);c(this,vt);c(this,T);c(this,Lt);c(this,gt);o(this,gt,!1),o(this,Lt,t.defaultOptions),this.setOptions(t.options),this.observers=[],o(this,vt,t.client),o(this,N,r(this,vt).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,o(this,mt,Qe(this.options)),this.state=t.state??r(this,mt),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=r(this,T))==null?void 0:t.promise}setOptions(t){if(this.options={...r(this,Lt),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const s=Qe(this.options);s.data!==void 0&&(this.setState(Me(s.data,s.dataUpdatedAt)),o(this,mt,s))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&r(this,N).remove(this)}setData(t,s){const i=ie(this.state.data,t,this.options);return p(this,H,W).call(this,{data:i,type:"success",dataUpdatedAt:s==null?void 0:s.updatedAt,manual:s==null?void 0:s.manual}),i}setState(t,s){p(this,H,W).call(this,{type:"setState",state:t,setStateOptions:s})}cancel(t){var i,n;const s=(i=r(this,T))==null?void 0:i.promise;return(n=r(this,T))==null||n.cancel(t),s?s.then(q).catch(q):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(r(this,mt))}isActive(){return this.observers.some(t=>_(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===ge||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>dt(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Ge(this.state.dataUpdatedAt,t)}onFocus(){var s;const t=this.observers.find(i=>i.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(s=r(this,T))==null||s.continue()}onOnline(){var s;const t=this.observers.find(i=>i.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(s=r(this,T))==null||s.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),r(this,N).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(s=>s!==t),this.observers.length||(r(this,T)&&(r(this,gt)?r(this,T).cancel({revert:!0}):r(this,T).cancelRetry()),this.scheduleGc()),r(this,N).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||p(this,H,W).call(this,{type:"invalidate"})}async fetch(t,s){var y,m,v,d,g,f,O,b,w,R,Q,E;if(this.state.fetchStatus!=="idle"&&((y=r(this,T))==null?void 0:y.status())!=="rejected"){if(this.state.data!==void 0&&(s!=null&&s.cancelRefetch))this.cancel({silent:!0});else if(r(this,T))return r(this,T).continueRetry(),r(this,T).promise}if(t&&this.setOptions(t),!this.options.queryFn){const l=this.observers.find(x=>x.options.queryFn);l&&this.setOptions(l.options)}const i=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:!0,get:()=>(o(this,gt,!0),i.signal)})},a=()=>{const l=ze(this.options,s),k=(()=>{const tt={client:r(this,vt),queryKey:this.queryKey,meta:this.meta};return n(tt),tt})();return o(this,gt,!1),this.options.persister?this.options.persister(l,k,this):l(k)},u=(()=>{const l={fetchOptions:s,options:this.options,queryKey:this.queryKey,client:r(this,vt),state:this.state,fetchFn:a};return n(l),l})();(m=this.options.behavior)==null||m.onFetch(u,this),o(this,Mt,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((v=u.fetchOptions)==null?void 0:v.meta))&&p(this,H,W).call(this,{type:"fetch",meta:(d=u.fetchOptions)==null?void 0:d.meta}),o(this,T,We({initialPromise:s==null?void 0:s.initialPromise,fn:u.fetchFn,onCancel:l=>{l instanceof ne&&l.revert&&this.setState({...r(this,Mt),fetchStatus:"idle"}),i.abort()},onFail:(l,x)=>{p(this,H,W).call(this,{type:"failed",failureCount:l,error:x})},onPause:()=>{p(this,H,W).call(this,{type:"pause"})},onContinue:()=>{p(this,H,W).call(this,{type:"continue"})},retry:u.options.retry,retryDelay:u.options.retryDelay,networkMode:u.options.networkMode,canRun:()=>!0}));try{const l=await r(this,T).start();if(l===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(l),(f=(g=r(this,N).config).onSuccess)==null||f.call(g,l,this),(b=(O=r(this,N).config).onSettled)==null||b.call(O,l,this.state.error,this),l}catch(l){if(l instanceof ne){if(l.silent)return r(this,T).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw p(this,H,W).call(this,{type:"error",error:l}),(R=(w=r(this,N).config).onError)==null||R.call(w,l,this),(E=(Q=r(this,N).config).onSettled)==null||E.call(Q,this.state.data,l,this),l}finally{this.scheduleGc()}}},mt=new WeakMap,Mt=new WeakMap,N=new WeakMap,vt=new WeakMap,T=new WeakMap,Lt=new WeakMap,gt=new WeakMap,H=new WeakSet,W=function(t){const s=i=>{switch(t.type){case"failed":return{...i,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...Je(i.data,this.options),fetchMeta:t.meta??null};case"success":const n={...i,...Me(t.data,t.dataUpdatedAt),dataUpdateCount:i.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return o(this,Mt,t.manual?n:void 0),n;case"error":const a=t.error;return{...i,error:a,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...t.state}}};this.state=s(this.state),M.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),r(this,N).notify({query:this,type:"updated",action:t})})},qe);function Je(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Me(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Qe(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,i=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var K,P,Nt,U,bt,Qt,$,at,_t,xt,It,Pt,wt,ot,Tt,C,kt,ae,oe,ue,he,ce,le,de,Xe,ke,Ze=(ke=class extends qt{constructor(t,s){super();c(this,C);c(this,K);c(this,P);c(this,Nt);c(this,U);c(this,bt);c(this,Qt);c(this,$);c(this,at);c(this,_t);c(this,xt);c(this,It);c(this,Pt);c(this,wt);c(this,ot);c(this,Tt,new Set);this.options=s,o(this,K,t),o(this,at,null),o(this,$,re()),this.bindMethods(),this.setOptions(s)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(r(this,P).addObserver(this),xe(r(this,P),this.options)?p(this,C,kt).call(this):this.updateResult(),p(this,C,he).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return fe(r(this,P),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return fe(r(this,P),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,p(this,C,ce).call(this),p(this,C,le).call(this),r(this,P).removeObserver(this)}setOptions(t){const s=this.options,i=r(this,P);if(this.options=r(this,K).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof _(this.options.enabled,r(this,P))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");p(this,C,de).call(this),r(this,P).setOptions(this.options),s._defaulted&&!Zt(this.options,s)&&r(this,K).getQueryCache().notify({type:"observerOptionsUpdated",query:r(this,P),observer:this});const n=this.hasListeners();n&&Ie(r(this,P),i,this.options,s)&&p(this,C,kt).call(this),this.updateResult(),n&&(r(this,P)!==i||_(this.options.enabled,r(this,P))!==_(s.enabled,r(this,P))||dt(this.options.staleTime,r(this,P))!==dt(s.staleTime,r(this,P)))&&p(this,C,ae).call(this);const a=p(this,C,oe).call(this);n&&(r(this,P)!==i||_(this.options.enabled,r(this,P))!==_(s.enabled,r(this,P))||a!==r(this,ot))&&p(this,C,ue).call(this,a)}getOptimisticResult(t){const s=r(this,K).getQueryCache().build(r(this,K),t),i=this.createResult(s,t);return Cs(this,i)&&(o(this,U,i),o(this,Qt,this.options),o(this,bt,r(this,P).state)),i}getCurrentResult(){return r(this,U)}trackResult(t,s){return new Proxy(t,{get:(i,n)=>(this.trackProp(n),s==null||s(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&r(this,$).status==="pending"&&r(this,$).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(i,n))})}trackProp(t){r(this,Tt).add(t)}getCurrentQuery(){return r(this,P)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const s=r(this,K).defaultQueryOptions(t),i=r(this,K).getQueryCache().build(r(this,K),s);return i.fetch().then(()=>this.createResult(i,s))}fetch(t){return p(this,C,kt).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),r(this,U)))}createResult(t,s){var I;const i=r(this,P),n=this.options,a=r(this,U),h=r(this,bt),u=r(this,Qt),m=t!==i?t.state:r(this,Nt),{state:v}=t;let d={...v},g=!1,f;if(s._optimisticResults){const j=this.hasListeners(),et=!j&&xe(t,s),Bt=j&&Ie(t,i,s,n);(et||Bt)&&(d={...d,...Je(v.data,t.options)}),s._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:O,errorUpdatedAt:b,status:w}=d;f=d.data;let R=!1;if(s.placeholderData!==void 0&&f===void 0&&w==="pending"){let j;a!=null&&a.isPlaceholderData&&s.placeholderData===(u==null?void 0:u.placeholderData)?(j=a.data,R=!0):j=typeof s.placeholderData=="function"?s.placeholderData((I=r(this,It))==null?void 0:I.state.data,r(this,It)):s.placeholderData,j!==void 0&&(w="success",f=ie(a==null?void 0:a.data,j,s),g=!0)}if(s.select&&f!==void 0&&!R)if(a&&f===(h==null?void 0:h.data)&&s.select===r(this,_t))f=r(this,xt);else try{o(this,_t,s.select),f=s.select(f),f=ie(a==null?void 0:a.data,f,s),o(this,xt,f),o(this,at,null)}catch(j){o(this,at,j)}r(this,at)&&(O=r(this,at),f=r(this,xt),b=Date.now(),w="error");const Q=d.fetchStatus==="fetching",E=w==="pending",l=w==="error",x=E&&Q,k=f!==void 0,S={status:w,fetchStatus:d.fetchStatus,isPending:E,isSuccess:w==="success",isError:l,isInitialLoading:x,isLoading:x,data:f,dataUpdatedAt:d.dataUpdatedAt,error:O,errorUpdatedAt:b,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>m.dataUpdateCount||d.errorUpdateCount>m.errorUpdateCount,isFetching:Q,isRefetching:Q&&!E,isLoadingError:l&&!k,isPaused:d.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:l&&k,isStale:we(t,s),refetch:this.refetch,promise:r(this,$),isEnabled:_(s.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=S.data!==void 0,et=S.status==="error"&&!j,Bt=Vt=>{et?Vt.reject(S.error):j&&Vt.resolve(S.data)},Ce=()=>{const Vt=o(this,$,S.promise=re());Bt(Vt)},zt=r(this,$);switch(zt.status){case"pending":t.queryHash===i.queryHash&&Bt(zt);break;case"fulfilled":(et||S.data!==zt.value)&&Ce();break;case"rejected":(!et||S.error!==zt.reason)&&Ce();break}}return S}updateResult(){const t=r(this,U),s=this.createResult(r(this,P),this.options);if(o(this,bt,r(this,P).state),o(this,Qt,this.options),r(this,bt).data!==void 0&&o(this,It,r(this,P)),Zt(s,t))return;o(this,U,s);const i=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!r(this,Tt).size)return!0;const h=new Set(a??r(this,Tt));return this.options.throwOnError&&h.add("error"),Object.keys(r(this,U)).some(u=>{const y=u;return r(this,U)[y]!==t[y]&&h.has(y)})};p(this,C,Xe).call(this,{listeners:i()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&p(this,C,he).call(this)}},K=new WeakMap,P=new WeakMap,Nt=new WeakMap,U=new WeakMap,bt=new WeakMap,Qt=new WeakMap,$=new WeakMap,at=new WeakMap,_t=new WeakMap,xt=new WeakMap,It=new WeakMap,Pt=new WeakMap,wt=new WeakMap,ot=new WeakMap,Tt=new WeakMap,C=new WeakSet,kt=function(t){p(this,C,de).call(this);let s=r(this,P).fetch(this.options,t);return t!=null&&t.throwOnError||(s=s.catch(q)),s},ae=function(){p(this,C,ce).call(this);const t=dt(this.options.staleTime,r(this,P));if(Ot||r(this,U).isStale||!ee(t))return;const i=Ge(r(this,U).dataUpdatedAt,t)+1;o(this,Pt,ft.setTimeout(()=>{r(this,U).isStale||this.updateResult()},i))},oe=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(r(this,P)):this.options.refetchInterval)??!1},ue=function(t){p(this,C,le).call(this),o(this,ot,t),!(Ot||_(this.options.enabled,r(this,P))===!1||!ee(r(this,ot))||r(this,ot)===0)&&o(this,wt,ft.setInterval(()=>{(this.options.refetchIntervalInBackground||Pe.isFocused())&&p(this,C,kt).call(this)},r(this,ot)))},he=function(){p(this,C,ae).call(this),p(this,C,ue).call(this,p(this,C,oe).call(this))},ce=function(){r(this,Pt)&&(ft.clearTimeout(r(this,Pt)),o(this,Pt,void 0))},le=function(){r(this,wt)&&(ft.clearInterval(r(this,wt)),o(this,wt,void 0))},de=function(){const t=r(this,K).getQueryCache().build(r(this,K),this.options);if(t===r(this,P))return;const s=r(this,P);o(this,P,t),o(this,Nt,t.state),this.hasListeners()&&(s==null||s.removeObserver(this),t.addObserver(this))},Xe=function(t){M.batch(()=>{t.listeners&&this.listeners.forEach(s=>{s(r(this,U))}),r(this,K).getQueryCache().notify({query:r(this,P),type:"observerResultsUpdated"})})},ke);function ws(e,t){return _(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function xe(e,t){return ws(e,t)||e.state.data!==void 0&&fe(e,t,t.refetchOnMount)}function fe(e,t,s){if(_(t.enabled,e)!==!1&&dt(t.staleTime,e)!=="static"){const i=typeof s=="function"?s(e):s;return i==="always"||i!==!1&&we(e,t)}return!1}function Ie(e,t,s,i){return(e!==t||_(i.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&we(e,s)}function we(e,t){return _(t.enabled,e)!==!1&&e.isStaleByTime(dt(t.staleTime,e))}function Cs(e,t){return!Zt(e.getCurrentResult(),t)}function Yt(e){return{onFetch:(t,s)=>{var v,d,g,f,O;const i=t.options,n=(g=(d=(v=t.fetchOptions)==null?void 0:v.meta)==null?void 0:d.fetchMore)==null?void 0:g.direction,a=((f=t.state.data)==null?void 0:f.pages)||[],h=((O=t.state.data)==null?void 0:O.pageParams)||[];let u={pages:[],pageParams:[]},y=0;const m=async()=>{let b=!1;const w=E=>{ys(E,()=>t.signal,()=>b=!0)},R=ze(t.options,t.fetchOptions),Q=async(E,l,x)=>{if(b)return Promise.reject();if(l==null&&E.pages.length)return Promise.resolve(E);const tt=(()=>{const et={client:t.client,queryKey:t.queryKey,pageParam:l,direction:x?"backward":"forward",meta:t.options.meta};return w(et),et})(),S=await R(tt),{maxPages:I}=t.options,j=x?fs:ds;return{pages:j(E.pages,S,I),pageParams:j(E.pageParams,l,I)}};if(n&&a.length){const E=n==="backward",l=E?Ye:ye,x={pages:a,pageParams:h},k=l(i,x);u=await Q(x,k,E)}else{const E=e??a.length;do{const l=y===0?h[0]??i.initialPageParam:ye(i,u);if(y>0&&l==null)break;u=await Q(u,l),y++}while(y<E)}return u};t.options.persister?t.fetchFn=()=>{var b,w;return(w=(b=t.options).persister)==null?void 0:w.call(b,m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s)}:t.fetchFn=m}}}function ye(e,{pages:t,pageParams:s}){const i=t.length-1;return t.length>0?e.getNextPageParam(t[i],t,s[i],s):void 0}function Ye(e,{pages:t,pageParams:s}){var i;return t.length>0?(i=e.getPreviousPageParam)==null?void 0:i.call(e,t[0],t,s[0],s):void 0}function Os(e,t){return t?ye(e,t)!=null:!1}function Ss(e,t){return!t||!e.getPreviousPageParam?!1:Ye(e,t)!=null}var Rs=class extends Ze{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Yt()})}getOptimisticResult(e){return e.behavior=Yt(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var O,b;const{state:s}=e,i=super.createResult(e,t),{isFetching:n,isRefetching:a,isError:h,isRefetchError:u}=i,y=(b=(O=s.fetchMeta)==null?void 0:O.fetchMore)==null?void 0:b.direction,m=h&&y==="forward",v=n&&y==="forward",d=h&&y==="backward",g=n&&y==="backward";return{...i,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Os(t,s.data),hasPreviousPage:Ss(t,s.data),isFetchNextPageError:m,isFetchingNextPage:v,isFetchPreviousPageError:d,isFetchingPreviousPage:g,isRefetchError:u&&!m&&!d,isRefetching:a&&!v&&!g}}},Ht,B,A,Ct,z,st,Ke,Es=(Ke=class extends $e{constructor(t){super();c(this,z);c(this,Ht);c(this,B);c(this,A);c(this,Ct);o(this,Ht,t.client),this.mutationId=t.mutationId,o(this,A,t.mutationCache),o(this,B,[]),this.state=t.state||ts(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){r(this,B).includes(t)||(r(this,B).push(t),this.clearGcTimeout(),r(this,A).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){o(this,B,r(this,B).filter(s=>s!==t)),this.scheduleGc(),r(this,A).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){r(this,B).length||(this.state.status==="pending"?this.scheduleGc():r(this,A).remove(this))}continue(){var t;return((t=r(this,Ct))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var h,u,y,m,v,d,g,f,O,b,w,R,Q,E,l,x,k,tt;const s=()=>{p(this,z,st).call(this,{type:"continue"})},i={client:r(this,Ht),meta:this.options.meta,mutationKey:this.options.mutationKey};o(this,Ct,We({fn:()=>this.options.mutationFn?this.options.mutationFn(t,i):Promise.reject(new Error("No mutationFn found")),onFail:(S,I)=>{p(this,z,st).call(this,{type:"failed",failureCount:S,error:I})},onPause:()=>{p(this,z,st).call(this,{type:"pause"})},onContinue:s,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>r(this,A).canRun(this)}));const n=this.state.status==="pending",a=!r(this,Ct).canStart();try{if(n)s();else{p(this,z,st).call(this,{type:"pending",variables:t,isPaused:a}),r(this,A).config.onMutate&&await r(this,A).config.onMutate(t,this,i);const I=await((u=(h=this.options).onMutate)==null?void 0:u.call(h,t,i));I!==this.state.context&&p(this,z,st).call(this,{type:"pending",context:I,variables:t,isPaused:a})}const S=await r(this,Ct).start();return await((m=(y=r(this,A).config).onSuccess)==null?void 0:m.call(y,S,t,this.state.context,this,i)),await((d=(v=this.options).onSuccess)==null?void 0:d.call(v,S,t,this.state.context,i)),await((f=(g=r(this,A).config).onSettled)==null?void 0:f.call(g,S,null,this.state.variables,this.state.context,this,i)),await((b=(O=this.options).onSettled)==null?void 0:b.call(O,S,null,t,this.state.context,i)),p(this,z,st).call(this,{type:"success",data:S}),S}catch(S){try{await((R=(w=r(this,A).config).onError)==null?void 0:R.call(w,S,t,this.state.context,this,i))}catch(I){Promise.reject(I)}try{await((E=(Q=this.options).onError)==null?void 0:E.call(Q,S,t,this.state.context,i))}catch(I){Promise.reject(I)}try{await((x=(l=r(this,A).config).onSettled)==null?void 0:x.call(l,void 0,S,this.state.variables,this.state.context,this,i))}catch(I){Promise.reject(I)}try{await((tt=(k=this.options).onSettled)==null?void 0:tt.call(k,void 0,S,t,this.state.context,i))}catch(I){Promise.reject(I)}throw p(this,z,st).call(this,{type:"error",error:S}),S}finally{r(this,A).runNext(this)}}},Ht=new WeakMap,B=new WeakMap,A=new WeakMap,Ct=new WeakMap,z=new WeakSet,st=function(t){const s=i=>{switch(t.type){case"failed":return{...i,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...i,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:t.error,failureCount:i.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=s(this.state),M.batch(()=>{r(this,B).forEach(i=>{i.onMutationUpdate(t)}),r(this,A).notify({mutation:this,type:"updated",action:t})})},Ke);function ts(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var J,G,Gt,Le,Fs=(Le=class extends qt{constructor(t={}){super();c(this,J);c(this,G);c(this,Gt);this.config=t,o(this,J,new Set),o(this,G,new Map),o(this,Gt,0)}build(t,s,i){const n=new Es({client:t,mutationCache:this,mutationId:++Wt(this,Gt)._,options:t.defaultMutationOptions(s),state:i});return this.add(n),n}add(t){r(this,J).add(t);const s=$t(t);if(typeof s=="string"){const i=r(this,G).get(s);i?i.push(t):r(this,G).set(s,[t])}this.notify({type:"added",mutation:t})}remove(t){if(r(this,J).delete(t)){const s=$t(t);if(typeof s=="string"){const i=r(this,G).get(s);if(i)if(i.length>1){const n=i.indexOf(t);n!==-1&&i.splice(n,1)}else i[0]===t&&r(this,G).delete(s)}}this.notify({type:"removed",mutation:t})}canRun(t){const s=$t(t);if(typeof s=="string"){const i=r(this,G).get(s),n=i==null?void 0:i.find(a=>a.state.status==="pending");return!n||n===t}else return!0}runNext(t){var i;const s=$t(t);if(typeof s=="string"){const n=(i=r(this,G).get(s))==null?void 0:i.find(a=>a!==t&&a.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){M.batch(()=>{r(this,J).forEach(t=>{this.notify({type:"removed",mutation:t})}),r(this,J).clear(),r(this,G).clear()})}getAll(){return Array.from(r(this,J))}find(t){const s={exact:!0,...t};return this.getAll().find(i=>Re(s,i))}findAll(t={}){return this.getAll().filter(s=>Re(t,s))}notify(t){M.batch(()=>{this.listeners.forEach(s=>{s(t)})})}resumePausedMutations(){const t=this.getAll().filter(s=>s.state.isPaused);return M.batch(()=>Promise.all(t.map(s=>s.continue().catch(q))))}},J=new WeakMap,G=new WeakMap,Gt=new WeakMap,Le);function $t(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Z,ut,L,X,Y,Jt,pe,Ne,Ms=(Ne=class extends qt{constructor(t,s){super();c(this,Y);c(this,Z);c(this,ut);c(this,L);c(this,X);o(this,Z,t),this.setOptions(s),this.bindMethods(),p(this,Y,Jt).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var i;const s=this.options;this.options=r(this,Z).defaultMutationOptions(t),Zt(this.options,s)||r(this,Z).getMutationCache().notify({type:"observerOptionsUpdated",mutation:r(this,L),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&St(s.mutationKey)!==St(this.options.mutationKey)?this.reset():((i=r(this,L))==null?void 0:i.state.status)==="pending"&&r(this,L).setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=r(this,L))==null||t.removeObserver(this)}onMutationUpdate(t){p(this,Y,Jt).call(this),p(this,Y,pe).call(this,t)}getCurrentResult(){return r(this,ut)}reset(){var t;(t=r(this,L))==null||t.removeObserver(this),o(this,L,void 0),p(this,Y,Jt).call(this),p(this,Y,pe).call(this)}mutate(t,s){var i;return o(this,X,s),(i=r(this,L))==null||i.removeObserver(this),o(this,L,r(this,Z).getMutationCache().build(r(this,Z),this.options)),r(this,L).addObserver(this),r(this,L).execute(t)}},Z=new WeakMap,ut=new WeakMap,L=new WeakMap,X=new WeakMap,Y=new WeakSet,Jt=function(){var s;const t=((s=r(this,L))==null?void 0:s.state)??ts();o(this,ut,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},pe=function(t){M.batch(()=>{var s,i,n,a,h,u,y,m;if(r(this,X)&&this.hasListeners()){const v=r(this,ut).variables,d=r(this,ut).context,g={client:r(this,Z),meta:this.options.meta,mutationKey:this.options.mutationKey};if((t==null?void 0:t.type)==="success"){try{(i=(s=r(this,X)).onSuccess)==null||i.call(s,t.data,v,d,g)}catch(f){Promise.reject(f)}try{(a=(n=r(this,X)).onSettled)==null||a.call(n,t.data,null,v,d,g)}catch(f){Promise.reject(f)}}else if((t==null?void 0:t.type)==="error"){try{(u=(h=r(this,X)).onError)==null||u.call(h,t.error,v,d,g)}catch(f){Promise.reject(f)}try{(m=(y=r(this,X)).onSettled)==null||m.call(y,void 0,t.error,v,d,g)}catch(f){Promise.reject(f)}}}this.listeners.forEach(v=>{v(r(this,ut))})})},Ne),V,_e,Qs=(_e=class extends qt{constructor(t={}){super();c(this,V);this.config=t,o(this,V,new Map)}build(t,s,i){const n=s.queryKey,a=s.queryHash??ve(n,s);let h=this.get(a);return h||(h=new Ps({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(s),state:i,defaultOptions:t.getQueryDefaults(n)}),this.add(h)),h}add(t){r(this,V).has(t.queryHash)||(r(this,V).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const s=r(this,V).get(t.queryHash);s&&(t.destroy(),s===t&&r(this,V).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){M.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return r(this,V).get(t)}getAll(){return[...r(this,V).values()]}find(t){const s={exact:!0,...t};return this.getAll().find(i=>Se(s,i))}findAll(t={}){const s=this.getAll();return Object.keys(t).length>0?s.filter(i=>Se(t,i)):s}notify(t){M.batch(()=>{this.listeners.forEach(s=>{s(t)})})}onFocus(){M.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){M.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},V=new WeakMap,_e),F,ht,ct,Dt,At,lt,jt,Ut,He,_s=(He=class{constructor(e={}){c(this,F);c(this,ht);c(this,ct);c(this,Dt);c(this,At);c(this,lt);c(this,jt);c(this,Ut);o(this,F,e.queryCache||new Qs),o(this,ht,e.mutationCache||new Fs),o(this,ct,e.defaultOptions||{}),o(this,Dt,new Map),o(this,At,new Map),o(this,lt,0)}mount(){Wt(this,lt)._++,r(this,lt)===1&&(o(this,jt,Pe.subscribe(async e=>{e&&(await this.resumePausedMutations(),r(this,F).onFocus())})),o(this,Ut,Xt.subscribe(async e=>{e&&(await this.resumePausedMutations(),r(this,F).onOnline())})))}unmount(){var e,t;Wt(this,lt)._--,r(this,lt)===0&&((e=r(this,jt))==null||e.call(this),o(this,jt,void 0),(t=r(this,Ut))==null||t.call(this),o(this,Ut,void 0))}isFetching(e){return r(this,F).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return r(this,ht).findAll({...e,status:"pending"}).length}getQueryData(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=r(this,F).get(t.queryHash))==null?void 0:s.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=r(this,F).build(this,t),i=s.state.data;return i===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(dt(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(i))}getQueriesData(e){return r(this,F).findAll(e).map(({queryKey:t,state:s})=>{const i=s.data;return[t,i]})}setQueryData(e,t,s){const i=this.defaultQueryOptions({queryKey:e}),n=r(this,F).get(i.queryHash),a=n==null?void 0:n.state.data,h=hs(t,a);if(h!==void 0)return r(this,F).build(this,i).setData(h,{...s,manual:!0})}setQueriesData(e,t,s){return M.batch(()=>r(this,F).findAll(e).map(({queryKey:i})=>[i,this.setQueryData(i,t,s)]))}getQueryState(e){var s;const t=this.defaultQueryOptions({queryKey:e});return(s=r(this,F).get(t.queryHash))==null?void 0:s.state}removeQueries(e){const t=r(this,F);M.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=r(this,F);return M.batch(()=>(s.findAll(e).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},i=M.batch(()=>r(this,F).findAll(e).map(n=>n.cancel(s)));return Promise.all(i).then(q).catch(q)}invalidateQueries(e,t={}){return M.batch(()=>(r(this,F).findAll(e).forEach(s=>{s.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},i=M.batch(()=>r(this,F).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,s);return s.throwOnError||(a=a.catch(q)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(i).then(q)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=r(this,F).build(this,t);return s.isStaleByTime(dt(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(q).catch(q)}fetchInfiniteQuery(e){return e.behavior=Yt(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(q).catch(q)}ensureInfiniteQueryData(e){return e.behavior=Yt(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Xt.isOnline()?r(this,ht).resumePausedMutations():Promise.resolve()}getQueryCache(){return r(this,F)}getMutationCache(){return r(this,ht)}getDefaultOptions(){return r(this,ct)}setDefaultOptions(e){o(this,ct,e)}setQueryDefaults(e,t){r(this,Dt).set(St(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...r(this,Dt).values()],s={};return t.forEach(i=>{Kt(e,i.queryKey)&&Object.assign(s,i.defaultOptions)}),s}setMutationDefaults(e,t){r(this,At).set(St(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...r(this,At).values()],s={};return t.forEach(i=>{Kt(e,i.mutationKey)&&Object.assign(s,i.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...r(this,ct).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=ve(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===ge&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...r(this,ct).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){r(this,F).clear(),r(this,ht).clear()}},F=new WeakMap,ht=new WeakMap,ct=new WeakMap,Dt=new WeakMap,At=new WeakMap,lt=new WeakMap,jt=new WeakMap,Ut=new WeakMap,He),es=D.createContext(void 0),ss=e=>{const t=D.useContext(es);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Hs=({client:e,children:t})=>(D.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),ns.jsx(es.Provider,{value:e,children:t})),is=D.createContext(!1),xs=()=>D.useContext(is);is.Provider;function Is(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Ts=D.createContext(Is()),Ds=()=>D.useContext(Ts),As=(e,t,s)=>{const i=s!=null&&s.state.error&&typeof e.throwOnError=="function"?be(e.throwOnError,[s.state.error,s]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||i)&&(t.isReset()||(e.retryOnMount=!1))},js=e=>{D.useEffect(()=>{e.clearReset()},[e])},Us=({result:e,errorResetBoundary:t,throwOnError:s,query:i,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&i&&(n&&e.data===void 0||be(s,[e.error,i])),qs=e=>{if(e.suspense){const s=n=>n==="static"?n:Math.max(n??1e3,1e3),i=e.staleTime;e.staleTime=typeof i=="function"?(...n)=>s(i(...n)):s(i),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ks=(e,t)=>e.isLoading&&e.isFetching&&!t,Ks=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Te=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function rs(e,t,s){var g,f,O,b;const i=xs(),n=Ds(),a=ss(),h=a.defaultQueryOptions(e);(f=(g=a.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||f.call(g,h);const u=a.getQueryCache().get(h.queryHash);h._optimisticResults=i?"isRestoring":"optimistic",qs(h),As(h,n,u),js(n);const y=!a.getQueryCache().get(h.queryHash),[m]=D.useState(()=>new t(a,h)),v=m.getOptimisticResult(h),d=!i&&e.subscribed!==!1;if(D.useSyncExternalStore(D.useCallback(w=>{const R=d?m.subscribe(M.batchCalls(w)):q;return m.updateResult(),R},[m,d]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),D.useEffect(()=>{m.setOptions(h)},[h,m]),Ks(h,v))throw Te(h,m,n);if(Us({result:v,errorResetBoundary:n,throwOnError:h.throwOnError,query:u,suspense:h.suspense}))throw v.error;if((b=(O=a.getDefaultOptions().queries)==null?void 0:O._experimental_afterQuery)==null||b.call(O,h,v),h.experimental_prefetchInRender&&!Ot&&ks(v,i)){const w=y?Te(h,m,n):u==null?void 0:u.promise;w==null||w.catch(q).finally(()=>{m.updateResult()})}return h.notifyOnChangeProps?v:m.trackResult(v)}function Gs(e,t){return rs(e,Ze)}function Bs(e,t){const s=ss(),[i]=D.useState(()=>new Ms(s,e));D.useEffect(()=>{i.setOptions(e)},[i,e]);const n=D.useSyncExternalStore(D.useCallback(h=>i.subscribe(M.batchCalls(h)),[i]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),a=D.useCallback((h,u)=>{i.mutate(h,u).catch(q)},[i]);if(n.error&&be(i.options.throwOnError,[n.error]))throw n.error;return{...n,mutate:a,mutateAsync:n.mutate}}function zs(e,t){return rs(e,Rs)}export{_s as Q,zs as a,Bs as b,Gs as c,Hs as d,ss as u};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r}from"./Dj2k1r16.js";import{B as s}from"./
|
|
1
|
+
import{j as r}from"./Dj2k1r16.js";import{B as s}from"./B1LENRC8.js";function i({className:e=""}){return r.jsx("div",{className:s("shimmer-skeleton",e),"aria-hidden":"true"})}export{i as S};
|
|
Binary file
|
|
Binary file
|