agent-nuvira 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +13 -13
  2. package/dist/agent-sdk/src/scaffold.d.ts +1 -1
  3. package/dist/agent-sdk/src/scaffold.js +1 -1
  4. package/dist/cli/chat.d.ts +117 -6
  5. package/dist/cli/chat.d.ts.map +1 -1
  6. package/dist/cli/chat.js +344 -20
  7. package/dist/cli/chat.js.map +1 -1
  8. package/dist/cli/duties.d.ts +11 -0
  9. package/dist/cli/duties.d.ts.map +1 -1
  10. package/dist/cli/duties.js +31 -0
  11. package/dist/cli/duties.js.map +1 -1
  12. package/dist/cli/models.d.ts.map +1 -1
  13. package/dist/cli/models.js +55 -0
  14. package/dist/cli/models.js.map +1 -1
  15. package/dist/learning/auto-router.d.ts +28 -0
  16. package/dist/learning/auto-router.d.ts.map +1 -1
  17. package/dist/learning/auto-router.js +84 -5
  18. package/dist/learning/auto-router.js.map +1 -1
  19. package/dist/learning/duty-lease.d.ts +163 -0
  20. package/dist/learning/duty-lease.d.ts.map +1 -0
  21. package/dist/learning/duty-lease.js +301 -0
  22. package/dist/learning/duty-lease.js.map +1 -0
  23. package/dist/learning/model-first-router.d.ts +14 -0
  24. package/dist/learning/model-first-router.d.ts.map +1 -1
  25. package/dist/learning/model-first-router.js +54 -17
  26. package/dist/learning/model-first-router.js.map +1 -1
  27. package/dist/learning/model-warmup.d.ts +92 -0
  28. package/dist/learning/model-warmup.d.ts.map +1 -1
  29. package/dist/learning/model-warmup.js +137 -2
  30. package/dist/learning/model-warmup.js.map +1 -1
  31. package/dist/learning/retry-patience.d.ts +139 -0
  32. package/dist/learning/retry-patience.d.ts.map +1 -0
  33. package/dist/learning/retry-patience.js +169 -0
  34. package/dist/learning/retry-patience.js.map +1 -0
  35. package/dist/tools/tool-loop.d.ts +41 -3
  36. package/dist/tools/tool-loop.d.ts.map +1 -1
  37. package/dist/tools/tool-loop.js +260 -4
  38. package/dist/tools/tool-loop.js.map +1 -1
  39. package/package.json +4 -1
  40. package/src/web-dashboard/public/assets/{index-yky0dw5e.js → index-Bik91KJh.js} +2 -2
  41. package/src/web-dashboard/public/assets/{index-yky0dw5e.js.map → index-Bik91KJh.js.map} +1 -1
  42. package/src/web-dashboard/public/index.html +1 -1
@@ -161,7 +161,7 @@ ${s}
161
161
  </body>
162
162
  </html>`}function xle(){var yd,bd,xd,Ul,Wl,L,J,te,je,Cn,mn,ct,Hl,Gl,ql;const[e,t]=x.useState("tools"),[n,r]=x.useState(null),[a,s]=x.useState(!0),[o,l]=x.useState(null),[c,u]=x.useState(!1),[d,f]=x.useState(null),[h,p]=x.useState(!1),[m,g]=x.useState(null),[y,v]=x.useState(null),[S,w]=x.useState(""),N=Kr(),[k,b]=x.useState(""),[j,E]=x.useState(null),[P,_]=x.useState(!1),[A,O]=x.useState(null),[B,$]=x.useState(null),[M,D]=x.useState({}),[U,R]=x.useState(""),[z,T]=x.useState(""),[Z,F]=x.useState(!1),[I,se]=x.useState(null),[he,ge]=x.useState(!1),[Te,X]=x.useState({}),[Y,ie]=x.useState(!1),[de,W]=x.useState(null),[xe,we]=x.useState({}),[_e,ve]=x.useState({}),[Le,pe]=x.useState({}),[et,Be]=x.useState(!1),[Me,at]=x.useState(null),[Ge,wt]=x.useState(""),[fn,G]=x.useState(null),[Q,ce]=x.useState(!1),[me,Ne]=x.useState(new Map),[Oe,It]=x.useState(new Set),[De,rn]=x.useState(!1),[Vn,it]=x.useState([]),[Dt,hn]=x.useState(""),[Vr,Yn]=x.useState(null),[_n,ur]=x.useState(""),[At,$n]=x.useState([]),[Tr,ma]=x.useState(0),[pn,Yr]=x.useState(0),[an,ga]=x.useState(!0),[ze,Wi]=x.useState(!1),[dr,Xa]=x.useState(!1),va=20,Hi=x.useRef(null),fr=x.useCallback(async(C=!1)=>{if(ze)return;const q=C?0:pn;Wi(!0);try{const ne=await K.fetchGatewayConversations({offset:q,limit:va,q:Ge||void 0});ne.ok&&ne.conversations&&($n(ae=>C?ne.conversations:[...ae,...ne.conversations]),ma(ne.total??0),Yr(q+ne.conversations.length),ga(ne.hasMore??!1))}catch{}Wi(!1)},[ze,pn,Ge]);x.useEffect(()=>{e==="conversations"&&!dr&&!ze&&(Xa(!0),fr(!0))},[e,dr,ze,fr]),x.useEffect(()=>{const C=Hi.current;if(!C)return;const q=new IntersectionObserver(ne=>{var ae;(ae=ne[0])!=null&&ae.isIntersecting&&an&&!ze&&fr(!1)},{threshold:.1});return q.observe(C),()=>q.disconnect()},[an,ze,fr]),x.useEffect(()=>{const C=setTimeout(()=>{e==="conversations"&&dr&&($n([]),Yr(0),ga(!0),fr(!0))},300);return()=>clearTimeout(C)},[Ge]),x.useEffect(()=>K.onTypingEvent(q=>{Ne(ne=>{const ae=new Map(ne),ue=`${q.platform}:${q.channelId}`;return q.typing?ae.set(ue,{platform:q.platform,channelId:q.channelId,startedAt:Date.now()}):ae.delete(ue),ae})}),[]);const ya=x.useCallback((C,q)=>{q.stopPropagation(),It(ne=>{const ae=new Set(ne);return ae.has(C)?ae.delete(C):ae.add(C),ae})},[]),qs=x.useCallback(()=>{It(C=>C.size===At.length?new Set:new Set(At.map(q=>q.key)))},[At]),Qa=x.useCallback(async()=>{if(Oe.size!==0){rn(!0);try{await K.exportGatewayConversations([...Oe])}catch{}rn(!1)}},[Oe]);x.useEffect(()=>{e==="conversations"&&K.getAllConversationTags().then(C=>{C.ok&&C.tags&&it(C.tags)})},[e]);const Gi=x.useCallback(async(C,q)=>{if(!q.trim())return;(await K.addConversationTag(C,q.trim())).ok&&($n(ae=>ae.map(ue=>ue.key===C?{...ue,tags:[...ue.tags??[],q.trim().toLowerCase()]}:ue)),it(ae=>ae.includes(q.trim().toLowerCase())?ae:[...ae,q.trim().toLowerCase()].sort())),Yn(null),ur("")},[]),qi=x.useCallback(async(C,q)=>{(await K.removeConversationTag(C,q)).ok&&$n(ae=>ae.map(ue=>ue.key===C?{...ue,tags:(ue.tags??[]).filter(Pe=>Pe!==q)}:ue))},[]),Xn=x.useCallback((C,q)=>{q.stopPropagation();const ne=C.contactName||C.channelId,ae=[`Conversation with ${ne} (${C.platform})`,`Exported: ${new Date().toLocaleString()}`,`Messages: ${C.messageCount}`,"─".repeat(50),""];if(C.messages)for(const Ot of C.messages){const ke=Ot.role==="user"?ne:"Agent",Pt=new Date(Ot.ts).toLocaleString();ae.push(`[${Pt}] ${ke}:`),ae.push(Ot.content),ae.push("")}const ue=new Blob([ae.join(`
163
163
  `)],{type:"text/plain;charset=utf-8"}),Pe=URL.createObjectURL(ue),Tt=document.createElement("a");Tt.href=Pe,Tt.download=`conversation-${C.platform}-${C.channelId.replace(/[^\w]/g,"_")}-${new Date().toISOString().slice(0,10)}.txt`,document.body.appendChild(Tt),Tt.click(),document.body.removeChild(Tt),URL.revokeObjectURL(Pe)},[]),Ks=x.useCallback((C,q)=>{q.stopPropagation();const ne=C.contactName||C.channelId,ae=C.messages??[],ue=ble({displayName:ne,platform:C.platform,messageCount:C.messageCount,messages:ae},yle()),Pe=window.open("","_blank");Pe&&(Pe.document.write(ue),Pe.document.close(),setTimeout(()=>Pe.print(),300))},[]);x.useEffect(()=>{var q;const C=(q=n==null?void 0:n.conversations)==null?void 0:q.recent;!C||C.length===0||dr&&(pn>va||Ge||$n(ne=>{const ae=new Set(ne.map(ke=>ke.key)),ue=C.map(ke=>({...ke})),Pe=new Map(ne.map(ke=>[ke.key,ke]));for(const ke of ue)Pe.has(ke.key)&&Pe.set(ke.key,ke);const Ot=[...ue.filter(ke=>!ae.has(ke.key)),...Pe.values()];return Ot.sort((ke,Pt)=>Pt.lastActiveAt-ke.lastActiveAt),Ot}))},[(yd=n==null?void 0:n.conversations)==null?void 0:yd.recent]);const[ba,Ki]=x.useState(""),[Il,Vs]=x.useState([]),[$l,xa]=x.useState(!1),[wa,ka]=x.useState(!1),[Vi,H]=x.useState(null),[re,Ee]=x.useState(null),[Se,$e]=x.useState({}),[Ln,$t]=x.useState([]),[jt,Sa]=x.useState([]),[Xr,Ys]=x.useState(""),hr=C=>et?String(C??""):mM(C),cd=C=>{const q=C.match(/^(\d+)@/);if(!q)return"";const ne=q[1];return ne.length===12&&ne.startsWith("91")?`+${ne.slice(0,2)} ${ne.slice(2,7)} ${ne.slice(7)}`:ne.length===10?`+91 ${ne.slice(0,5)} ${ne.slice(5)}`:`+${ne}`},_m=C=>{const q=cd(C.channelId),ne=hr(C.channelId);return C.contactName?{name:C.contactName,phone:q||ne}:{name:q||ne,phone:""}},Za=x.useCallback(C=>{var q,ne;r(C),(q=C==null?void 0:C.channels)!=null&&q.statusRecipients&&Sa(C.channels.statusRecipients),(ne=C==null?void 0:C.channels)!=null&&ne.contacts&&$t(C.channels.contacts),C||l("Could not reach the dashboard server, or the server is older than this panel. Run `buff dashboard` to start it."),s(!1)},[]),Dn=x.useCallback(async()=>{u(!0),l(null),Za(await K.fetchHub()),u(!1)},[Za]);x.useEffect(()=>{Dn(),K.fetchAdminAuthStatus().then(C=>{C&&(f({configured:C.configured,authenticated:C.authenticated}),p(C.authenticated),g(C.role??null),v(C.user??null))})},[Dn,N]);const ud=((bd=n==null?void 0:n.subagents)==null?void 0:bd.running)??0;x.useEffect(()=>{if(ud===0)return;const C=setInterval(()=>{K.fetchHub().then(q=>{q&&Za(q)})},gle);return()=>clearInterval(C)},[ud,Za]);const Bt=h&&(m==="admin"||m==="operator"),dd=x.useRef(!1);x.useEffect(()=>{Bt&&!dd.current&&(dd.current=!0,Be(!0))},[Bt]);const Cm=async C=>{C==null||C.preventDefault();const q=ba.trim();if(!q)return;ka(!0),H(null);const ne=await K.marketplaceSearch(q);Vs(ne),xa(!0),ka(!1)},Am=async C=>{if(!h){H({kind:"err",text:"🔐 Log in (or set up admin access) to install skills."});return}if(!Bt){H({kind:"err",text:"Your role cannot install skills — admin or operator only."});return}Ee(C),H(null);const q=await K.marketplaceInstall(C);q.ok?(H({kind:"ok",text:`✅ Installed ${C} (quarantine checked) — it appears in the Skills list and loads via the skill tool next turn.`}),Dn()):H({kind:"err",text:q.quarantined?`⛔ ${q.error||"checksum mismatch — quarantined"}`:`❌ ${q.error||"Install failed."}`}),Ee(null)},fd=async C=>{if(!h){H({kind:"err",text:"🔐 Log in (or set up admin access) to uninstall skills."});return}if(!Bt){H({kind:"err",text:"Your role cannot uninstall skills — admin or operator only."});return}Ee(C),H(null);const q=await K.marketplaceUninstall(C);q.ok?(H({kind:"ok",text:`🗑️ Uninstalled ${C} — removed from .agents/skills/ and provenance.`}),Dn()):H({kind:"err",text:`❌ ${q.error||"Uninstall failed."}`}),Ee(null)},Yi=()=>{p(!1),f(C=>C&&{...C,authenticated:!1}),E("Session expired — log in again to toggle capabilities.")},Xi=async C=>{C.preventDefault(),_(!0),E(null);const q=await K.adminLogin(S,k);if(q.ok){p(!0),f({configured:!0,authenticated:!0}),g(q.role??"admin"),v(q.user??null),w(""),b("");const ne=A;O(null),ne&&await ja(ne.kind,ne.name,ne.enabled)}else E(q.error||"Login failed.");_(!1)},hd=async C=>{if(C.preventDefault(),_(!0),E(null),k.length<8){E("Password must be at least 8 characters."),_(!1);return}const q=await K.adminSetup(S,k);if(q.ok){p(!0),f({configured:!0,authenticated:!0}),g(q.role??"admin"),v(q.user??null),w(""),b("");const ne=A;O(null),ne&&await ja(ne.kind,ne.name,ne.enabled)}else E(q.error||"Setup failed.");_(!1)},Or=async()=>{await K.adminLogout(),p(!1),f(C=>C&&{...C,authenticated:!1}),g(null),v(null)},ja=async(C,q,ne)=>{$(q);const ae=C==="skill"?await K.setSkillEnabled(q,ne):await K.setToolsetEnabled(q,ne);ae.ok?(D(ue=>({...ue,[q]:`✅ ${ne?"Enabled":"Disabled"} — live for new agent runs`})),Dn()):ae.unauthorized?Yi():(D(ue=>({...ue,[q]:`❌ ${ae.error||"Toggle failed"}`})),ae.forbidden&&E(ae.error||"Your role cannot change capabilities.")),$(null)},Ll=(C,q)=>{if(!h){O({kind:"toolset",name:C,enabled:q});return}ja("toolset",C,q)},Xs=(C,q)=>{if(!h){O({kind:"skill",name:C,enabled:q});return}ja("skill",C,q)},Tm=async C=>{if(C.preventDefault(),!h){se({kind:"err",text:"🔐 Log in (or set up admin access) to send test messages."});return}if(!Bt){se({kind:"err",text:"🔒 Your role cannot send channel messages — requires the admin or operator role."});return}F(!0),se(null);const q=await K.sendChannelMessage(U.trim(),z);q.ok?(se({kind:"ok",text:`✅ Sent to ${U.trim()} (${q.platform}:${hr(q.channelId??"")})`}),T("")):q.unauthorized?(Yi(),se({kind:"err",text:q.error||"Session expired — log in again."})):se({kind:"err",text:q.error||"Send failed."}),F(!1)},sn=(C,q)=>{var ae,ue;return(((ue=(ae=n==null?void 0:n.channels)==null?void 0:ae.policies)==null?void 0:ue[C])??{})[q]??[]},pd=C=>C==="user"?"allowedUsers":C==="group"?"allowedGroups":"outboundSenders",Dl=(C,q,ne)=>{const ae=ne.trim();ae&&X(ue=>{var Pt;const Pe={...ue[C]??{}},Tt=pd(q),ke=[...((Pt=ue[C])==null?void 0:Pt[Tt])??sn(C,Tt)];return ke.includes(ae)||ke.push(ae),Pe[Tt]=ke,{...ue,[C]:Pe}})},Bl=(C,q,ne)=>{X(ae=>{var Pt;const ue=pd(q),Pe=sn(C,ue),Ot=(((Pt=ae[C])==null?void 0:Pt[ue])??Pe).filter(Kl=>Kl!==ne);if(Ot.length===0&&Pe.length===0){const Kl={...ae[C]??{}};delete Kl[ue];const Om={...ae};return Object.keys(Kl).length===0?delete Om[C]:Om[C]=Kl,Om}const ke={...ae[C]??{}};return ke[ue]=Ot,{...ae,[C]:ke}})},zl=(C,q)=>{const ne=C.trim().toLowerCase(),ae=q.trim().toLowerCase();if(ne==="*"||ae==="*"||ne===ae)return!0;const ue=ne.replace(/\D+/g,""),Pe=ae.replace(/\D+/g,"");return ue.length>0&&ue===Pe},md=C=>{const q=(Se[C]??"").trim(),ne=(xe[C]??"").trim();ne&&(Dl(C,"user",ne),q&&$t(ae=>[...ae.filter(Pe=>!(Pe.platform===C&&(zl(Pe.id,ne)||Pe.name.toLowerCase()===q.toLowerCase()))),{name:q,platform:C,id:ne,addedAt:Date.now()}]),we(ae=>({...ae,[C]:""})),$e(ae=>({...ae,[C]:""})))},gd=(C,q)=>{Bl(C,"user",q),$t(ne=>ne.filter(ae=>!(ae.platform===C&&zl(ae.id,q))))},Qs=(C,q)=>{X(ne=>{const ae={...ne[C]??{}};return q==="silentDrop"?ae.silentDrop=ae.silentDrop===!1:ae[q]?delete ae[q]:ae[q]=!0,{...ne,[C]:ae}})},vd=Object.keys(Te).length>0||Ln.length!==(((Ul=(xd=n==null?void 0:n.channels)==null?void 0:xd.contacts)==null?void 0:Ul.length)??0)||Ln.some((C,q)=>{var ne,ae;return!((ae=(ne=n==null?void 0:n.channels)==null?void 0:ne.contacts)!=null&&ae[q])||C.platform!==n.channels.contacts[q].platform||C.id!==n.channels.contacts[q].id||C.name!==n.channels.contacts[q].name})||jt.length!==(((L=(Wl=n==null?void 0:n.channels)==null?void 0:Wl.statusRecipients)==null?void 0:L.length)??0)||jt.some((C,q)=>{var ne,ae;return C!==((ae=(ne=n==null?void 0:n.channels)==null?void 0:ne.statusRecipients)==null?void 0:ae[q])}),Qr=async()=>{var q;if(!h){W({kind:"err",text:"🔐 Log in (or set up admin access) to change permissions."});return}if(!Bt){W({kind:"err",text:"🔒 Your role cannot change permissions — requires the admin or operator role."});return}ie(!0),W(null);const C=await K.saveGatewayPolicies(Te,jt,Ln);if(C.ok){const ne=(q=C.contactErrors)!=null&&q.length?`
164
- ⚠️ Some contacts were rejected: ${C.contactErrors.join("; ")}`:"";W({kind:ne?"warn":"ok",text:`✅ Permissions + saved contacts + status recipients saved — the running gateway applies them immediately.${ne}`}),X({}),Dn()}else C.unauthorized?(Yi(),W({kind:"err",text:C.error||"Session expired — log in again."})):W({kind:"err",text:C.error||"Failed to save permissions."});ie(!1)};if(a)return i.jsxs("div",{className:"admin-header",children:[i.jsx(Re,{icon:"🧰",title:"Agent Hub"}),i.jsxs("div",{className:"loading-state",children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("p",{children:"Loading hub…"})]})]});const Fl=!h&&A!==null;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"admin-header",children:[i.jsx(Re,{icon:"🧰",title:i.jsxs(i.Fragment,{children:["Agent Hub",y?i.jsxs("span",{className:`admin-role-badge admin-role-${m||"viewer"}`,children:[" ",y," · ",m||"viewer"]}):null]})}),i.jsxs("div",{className:"admin-header-actions",children:[i.jsxs("label",{className:"hub-reveal-toggle",children:[i.jsx("input",{type:"checkbox",checked:et,onChange:C=>Be(C.target.checked),disabled:!Bt}),"Show full ids"]}),Bt?null:i.jsx("span",{className:"admin-hint",children:"🔒 admins/operators only"}),i.jsx("button",{className:"admin-refresh-btn",onClick:()=>void Dn(),disabled:c,children:c?"⏳ Refreshing…":"🔄 Refresh"}),h?i.jsx("button",{className:"admin-logout-btn",onClick:()=>void Or(),children:"🚪 Log out"}):null]})]}),i.jsxs("p",{className:"admin-subtitle",children:["Capabilities, messaging, artifacts and skills in one place — a single 4-view management page. Toggles persist to ",i.jsx("code",{children:"buffconfig"})," and are honored by the runtime immediately (never cosmetic)."]}),o?i.jsx("div",{className:"admin-error",children:o}):null,Fl?i.jsxs("div",{className:"admin-header",children:[i.jsx("h2",{className:"section-subtitle",children:d!=null&&d.configured?`🔐 Log in to ${A.enabled?"enable":"disable"} '${A.name}'`:`🔐 Set up admin access to ${A.enabled?"enable":"disable"} '${A.name}'`}),i.jsxs("form",{className:"admin-gate-form",onSubmit:d!=null&&d.configured?Xi:hd,children:[i.jsxs("label",{children:[i.jsx("span",{children:"Username"}),i.jsx("input",{type:"text",value:S,onChange:C=>w(C.target.value),autoComplete:"username",placeholder:"admin"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:k,onChange:C=>b(C.target.value),autoComplete:d!=null&&d.configured?"current-password":"new-password",placeholder:"••••••••"})]}),j?i.jsx("div",{className:"admin-error",children:j}):null,i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:P||!S||!k,children:P?"⏳ …":d!=null&&d.configured?"🔐 Log in & apply":"🔐 Create admin & apply"}),d!=null&&d.configured?null:i.jsxs("p",{className:"admin-hint",children:["The first user is always an admin. Automation alternative: set"," ",i.jsx("code",{children:"BUFF_DASHBOARD_ADMIN_USER"})," / ",i.jsx("code",{children:"BUFF_DASHBOARD_ADMIN_PASSWORD"}),"."]})]})]}):null,!Fl&&!Bt&&h?i.jsxs("div",{className:"admin-readonly-note",children:["🔒 Your role (",i.jsx("code",{children:m||"viewer"}),") can view but not change capabilities — toggles require the ",i.jsx("code",{children:"admin"})," or ",i.jsx("code",{children:"operator"})," role."]}):null,i.jsx("div",{className:"hub-tabs",role:"tablist",children:ple.map(C=>{var ne,ae,ue;const q=C.id==="tools"?n?`${n.toolsets.enabled}/${n.toolsets.toolsets.length}`:"":C.id==="channels"?n?String(n.channels.delivery.total):"":C.id==="conversations"?n?String(((ne=n.conversations)==null?void 0:ne.total)??0):"":C.id==="artifacts"?n?String(n.artifacts.totalSessions):"":C.id==="subagents"?n?`${((ae=n.subagents)==null?void 0:ae.running)??0}/${((ue=n.subagents)==null?void 0:ue.total)??0}`:"":n?`${n.skills.enabled}/${n.skills.total}`:"";return i.jsxs("button",{role:"tab","aria-selected":e===C.id,className:`hub-tab${e===C.id?" active":""}`,onClick:()=>t(C.id),children:[C.icon," ",C.label,q?i.jsx("span",{className:"hub-tab-count",children:q}):null]},C.id)})}),e==="tools"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.enabled}),i.jsx("div",{className:"admin-summary-label",children:"Enabled toolsets"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.disabled}),i.jsx("div",{className:"admin-summary-label",children:"Disabled toolsets"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.totalTools}),i.jsx("div",{className:"admin-summary-label",children:"Registered tools"})]})]}),i.jsx("div",{className:"hub-toolset-grid",children:n.toolsets.toolsets.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.label}),i.jsx("span",{className:"hub-card-id",children:C.name})]}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.label}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.name||A!==null||h&&!Bt,onClick:()=>Ll(C.name,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsx("div",{className:"hub-card-tools",children:C.tools.length>0?C.tools.map(q=>i.jsx("span",{className:"hub-chip",children:q},q)):i.jsx("span",{className:"admin-hint",children:"gates dynamic MCP tools (no static names)"})}),M[C.name]?i.jsx("div",{className:"admin-row-msg",children:M[C.name]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Removed from the model schema — calls return an explicit error"})]},C.name))})]}):null,e==="channels"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.pending}),i.jsx("div",{className:"admin-summary-label",children:"⏳ Queued for retry"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.sent}),i.jsx("div",{className:"admin-summary-label",children:"✅ Delivered"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.failed}),i.jsx("div",{className:"admin-summary-label",children:"❌ Failed (max retries)"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.aliases.length}),i.jsx("div",{className:"admin-summary-label",children:"Channel aliases"})]})]}),i.jsx("h2",{className:"section-subtitle",children:"📮 Delivery ledger (guaranteed delivery)"}),n.channels.delivery.recent.length>0?i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Target"}),i.jsx("th",{children:"Platform"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Attempts"}),i.jsx("th",{children:"Next retry"}),i.jsx("th",{children:"Message"})]})}),i.jsx("tbody",{children:n.channels.delivery.recent.map(C=>i.jsxs("tr",{children:[i.jsx("td",{className:"admin-provider-type",children:hr(C.target)}),i.jsx("td",{children:C.platform}),i.jsx("td",{children:i.jsx("span",{className:`admin-check-badge admin-check-${C.status==="sent"?"pass":C.status==="failed"?"fail":"warn"}`,children:mle[C.status]||C.status})}),i.jsxs("td",{children:[C.attempts,"/5"]}),i.jsx("td",{children:C.status==="pending"?`${Math.max(0,Math.round((C.nextAttemptAt-Date.now())/1e3))}s`:"—"}),i.jsx("td",{className:"admin-hint",children:C.lastError?`⚠️ ${C.lastError}`:(C.text||"").slice(0,60)})]},C.id))})]})}):i.jsx("div",{className:"empty-state",children:"Delivery ledger is empty — every gateway send has gone through."}),i.jsx("h2",{className:"section-subtitle",children:"📥 Inbox (received messages)"}),n.channels.inbox.recent.length>0?i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Platform"}),i.jsx("th",{children:"From"}),i.jsx("th",{children:"Message"}),i.jsx("th",{children:"Handled"}),i.jsx("th",{children:"When"})]})}),i.jsx("tbody",{children:n.channels.inbox.recent.map(C=>i.jsxs("tr",{children:[i.jsxs("td",{className:"admin-provider-type",children:[C.platform,C.isGroup?i.jsx("span",{className:"hub-chip",children:"group"}):null]}),i.jsx("td",{children:hr(C.from||C.senderId||C.channelId)}),i.jsx("td",{className:"admin-hint",children:(C.text||"").slice(0,60)}),i.jsxs("td",{children:[i.jsx("span",{className:`admin-check-badge admin-check-${C.handled==="pipeline"?"pass":C.handled==="refused"?"fail":"warn"}`,children:C.handled}),C.reply?i.jsx("div",{className:"admin-hint",children:C.reply.slice(0,C.handled==="attachment_failed"?160:40)}):null]}),i.jsx("td",{className:"admin-hint",children:new Date(C.at).toLocaleString()})]},C.id))})]})}):i.jsx("div",{className:"empty-state",children:"Inbox is empty — messages the gateway receives will appear here."}),i.jsxs("p",{className:"admin-hint",children:[n.channels.inbox.total," received · ",n.channels.inbox.pipeline," triggered the pipeline ·"," ",n.channels.inbox.help," got the help line · ",n.channels.inbox.refused," refused by policy ·"," ",n.channels.inbox.duplicate??0," duplicate re-deliveries ignored ·"," ",n.channels.inbox.attachmentFailed??0," attachment(s) could not be read."]}),i.jsx("h2",{className:"section-subtitle",children:"🔌 Platform transports"}),i.jsx(fle,{canWrite:Bt,sessionExpired:Yi,mode:"table"}),i.jsx("h2",{className:"section-subtitle",children:"🔗 Channel aliases (buff gateway status)"}),n.channels.aliases.length>0?i.jsx("div",{className:"hub-alias-list",children:n.channels.aliases.map(C=>i.jsxs("div",{className:"hub-alias-row",children:[i.jsx("span",{className:"hub-chip",children:C.alias}),i.jsxs("span",{className:"admin-hint",children:["→ ",C.platform,":",hr(C.channelId)]})]},C.alias))}):i.jsxs("div",{className:"empty-state",children:["No aliases yet — register one with ",i.jsx("code",{children:"buff gateway alias <name> <platform> <channelId>"}),"."]}),vd?i.jsxs("div",{className:"hub-unsaved-banner",role:"status",children:[i.jsxs("span",{children:["⚠️ ",i.jsx("strong",{children:"Unsaved changes"})," — what you see below is a ",i.jsx("em",{children:"draft"}),". Press"," ",i.jsx("strong",{children:"💾 Save permissions"})," to apply it to the gateway; leaving the page discards it."]}),i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>void Qr(),children:Y?"⏳ Saving…":"💾 Save permissions"})]}):null,i.jsx("div",{style:{cursor:"pointer",userSelect:"none",display:"flex",alignItems:"center",gap:8,marginBottom:8},onClick:()=>ge(!he),children:i.jsxs("h2",{className:"section-subtitle",style:{margin:0},children:[he?"▼":"▶"," 🔐 Permissions — who can TRIGGER the agent"]})}),i.jsxs("p",{className:"admin-hint",style:{marginBottom:he?10:0},children:["This list controls ",i.jsx("strong",{children:"who may trigger the agent"})," when they message you on each platform (WhatsApp, Telegram, email, …). Click to ",he?"collapse":"expand"," and manage permissions."]}),he?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"admin-hint",style:{marginBottom:10},children:["⚠ ",i.jsx("strong",{children:"Not the same as send-by-name contacts:"})," a WhatsApp contact name (from"," ",i.jsx("code",{children:"buff whatsapp contact add"}),", shown in the WhatsApp bridge panel below) only lets"," ",i.jsx("em",{children:"you"})," send ",i.jsx("em",{children:"to"})," it by name — it does ",i.jsx("strong",{children:"not"})," let that number trigger the agent. Add the number here (or ",i.jsx("code",{children:"buff config gateway allow <platform> user <id>"}),") to grant inbound access."]}),i.jsx("div",{className:"hub-permissions",children:n.channels.platforms.map(C=>{const q={...n.channels.policies[C.platform]??{},...Te[C.platform]??{}},ne=q.allowedUsers??[],ae=q.allowedGroups??[];return i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsx("span",{className:"hub-chip",children:C.label}),i.jsx("span",{className:"hub-card-id",children:C.platform}),q.disabled?i.jsx("span",{className:"hub-chip",children:"disabled"}):null]}),i.jsx("div",{className:"admin-hint",style:{margin:"4px 0 8px"},children:"Allowed users — who may trigger the agent"}),i.jsxs("div",{className:"hub-alias-list",children:[ne.length===0?i.jsxs("span",{className:"admin-hint",children:["(blank — no one may trigger; add ",i.jsx("code",{children:"Allow-All"})," to allow everyone)"]}):null,ne.map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.allowedUsers)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.allowedUsers)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[hr(ue),Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>gd(C.platform,ue),children:"✕"})]},`u-${ue}`)})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:Se[C.platform]??"",onChange:ue=>$e(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"Name (optional)",disabled:Y}),i.jsx("input",{type:"text",value:xe[C.platform]??"",onChange:ue=>we(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"Contact no / sender id, or Allow-All",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(xe[C.platform]??"").trim(),onClick:()=>md(C.platform),children:"+ User"})]}),i.jsx("div",{className:"admin-hint",style:{margin:"4px 0 8px"},children:"Allowed groups"}),i.jsxs("div",{className:"hub-alias-list",children:[ae.length===0?i.jsx("span",{className:"admin-hint",children:"(none — any group may trigger)"}):null,ae.map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.allowedGroups)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.allowedGroups)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[ue,Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Bl(C.platform,"group",ue),children:"✕"})]},`g-${ue}`)})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:_e[C.platform]??"",onChange:ue=>ve(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"group id, e.g. 1203630283471234@g.us",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(_e[C.platform]??"").trim(),onClick:()=>{Dl(C.platform,"group",_e[C.platform]??""),ve(ue=>({...ue,[C.platform]:""}))},children:"+ Group"})]}),i.jsx("div",{className:"admin-hint",style:{margin:"12px 0 4px"},children:"Send authority — who may tell the agent to send to OTHER people"}),i.jsx("div",{className:"admin-hint",style:{margin:"0 0 6px",opacity:.8},children:(q.outboundSenders??[]).length===0?"Open — anyone above who can trigger the agent can also direct outbound sends. Add senders to restrict it.":"Restricted to the senders below (Allow-All = everyone)."}),i.jsx("div",{className:"hub-alias-list",children:(q.outboundSenders??[]).map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.outboundSenders)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.outboundSenders)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[hr(ue),Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Bl(C.platform,"send",ue),children:"✕"})]},`s-${ue}`)})}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:Le[C.platform]??"",onChange:ue=>pe(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"sender id, or Allow-All",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(Le[C.platform]??"").trim(),onClick:()=>{Dl(C.platform,"send",Le[C.platform]??""),pe(ue=>({...ue,[C.platform]:""}))},children:"+ Sender"})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 0"},children:[i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:q.silentDrop!==!1,disabled:Y,onChange:()=>Qs(C.platform,"silentDrop")}),i.jsx("span",{className:"admin-hint",children:"Silent (no reply to unapproved) — default"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:!!q.requireMention,disabled:Y,onChange:()=>Qs(C.platform,"requireMention")}),i.jsx("span",{className:"admin-hint",children:"Groups: mention only"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:!!q.disabled,disabled:Y,onChange:()=>Qs(C.platform,"disabled")}),i.jsx("span",{className:"admin-hint",children:"Disabled (off)"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[i.jsx("input",{type:"checkbox",checked:!!q.requireApprovedTarget,disabled:Y,onChange:()=>Qs(C.platform,"requireApprovedTarget")}),i.jsx("span",{className:"admin-hint",children:"Require approved recipients for sends"})]})]})]},C.platform)})})]}):null,i.jsx("h2",{className:"section-subtitle",style:{marginTop:22},children:"📇 Telegram User Onboarding"}),i.jsxs("div",{className:"onboarding-summary",children:[i.jsx("p",{className:"admin-hint",style:{marginBottom:12},children:"Users who message your bot are auto-registered here. Approve them to enable outbound messaging."}),(()=>{const C=Ln.filter(ae=>ae.status==="pending").length,q=Ln.filter(ae=>ae.status==="approved").length,ne=Ln.filter(ae=>ae.status==="rejected").length;return i.jsxs("div",{className:"onboarding-stats",children:[i.jsxs("span",{className:"onboarding-stat pending",children:["⏳ ",C," pending"]}),i.jsxs("span",{className:"onboarding-stat approved",children:["✅ ",q," approved"]}),i.jsxs("span",{className:"onboarding-stat rejected",children:["🚫 ",ne," rejected"]})]})})(),i.jsxs("div",{className:"onboarding-steps",children:[i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"1"}),i.jsxs("span",{children:["User sends any message to ",i.jsx("code",{children:"@agent_nuvira_bot"})]})]}),i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"2"}),i.jsxs("span",{children:["Bot auto-registers them as ",i.jsx("strong",{children:"⏳ pending"})]})]}),i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"3"}),i.jsx("span",{children:"Admin approves → they can receive outbound messages"})]})]}),i.jsx("a",{href:"/contacts",className:"admin-refresh-btn",style:{marginTop:12,display:"inline-block",textDecoration:"none"},children:"📋 Go to Contacts tab to manage →"})]}),i.jsx("h2",{className:"section-subtitle",style:{marginTop:22},children:"📊 Status recipients"}),i.jsxs("p",{className:"admin-hint",children:["Contacts/groups that ALWAYS receive the pipeline completion summary, whoever triggered it. Use a contact name, number, or ",i.jsx("code",{children:"platform:channelId"})," — e.g."," ",i.jsx("code",{children:"whatsapp:Name"}),", ",i.jsx("code",{children:"whatsapp:+91***"}),", ",i.jsx("code",{children:"telegram:123456"}),","," ",i.jsx("code",{children:"slack:ops"}),"."]}),jt.length>0?i.jsx("div",{className:"hub-alias-list",children:jt.map(C=>{var q,ne;return i.jsxs("div",{className:"hub-alias-row",children:[i.jsx("span",{className:"hub-chip",children:"📊"}),i.jsx("span",{className:"admin-hint",children:((ne=(q=n==null?void 0:n.channels)==null?void 0:q.statusRecipientDisplay)==null?void 0:ne[C])??C}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Sa(ae=>ae.filter(ue=>ue!==C)),children:"✕"})]},C)})}):i.jsx("div",{className:"empty-state",style:{padding:"14px"},children:"No status recipients — add one below."}),i.jsxs("div",{className:"hub-send-form",children:[i.jsx("input",{type:"text",value:Xr,onChange:C=>Ys(C.target.value),placeholder:"whatsapp:Name or whatsapp:+91***",disabled:Y,maxLength:128}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!Xr.trim()||jt.includes(Xr.trim()),onClick:()=>{Sa(C=>[...C,Xr.trim()]),Ys("")},children:"+ Add"})]}),i.jsxs("div",{className:"hub-send-form",style:{marginTop:10},children:[i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>void Qr(),children:Y?"⏳ Saving…":"💾 Save permissions"}),Object.keys(Te).length>0?i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>X({}),children:"Discard draft"}):null]}),de?i.jsx("div",{className:`admin-row-msg${de.kind==="err"?" admin-row-msg-err":""}`,children:de.text}):null,i.jsx("h2",{className:"section-subtitle",children:"📤 Test a channel (buff gateway send)"}),i.jsxs("form",{className:"hub-send-form",onSubmit:C=>void Tm(C),children:[i.jsxs("label",{className:"hub-send-target",children:[i.jsx("span",{className:"admin-hint",children:"Target — an alias or platform:channelId"}),i.jsx("input",{type:"text",value:U,onChange:C=>R(C.target.value),placeholder:"ops or slack:C0123 or email:team@example.com",disabled:Z,maxLength:128})]}),i.jsxs("label",{className:"hub-send-message",children:[i.jsx("span",{className:"admin-hint",children:"Message"}),i.jsx("input",{type:"text",value:z,onChange:C=>T(C.target.value),placeholder:"nightly build done 🎉",disabled:Z,maxLength:4e3})]}),i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:Z||!U.trim()||!z,children:Z?"⏳ Sending…":"📤 Send test message"})]}),I?i.jsx("div",{className:`admin-row-msg${I.kind==="ok"?"":" admin-row-msg-err"}`,children:I.text}):null,i.jsxs("p",{className:"admin-hint",children:["Sends through the same gateway the CLI uses — the dashboard process must have the platform's env token set (e.g. ",i.jsx("code",{children:"BUFF_SMTP_HOST"}),"). Requires admin or operator."]}),i.jsx("h2",{className:"section-subtitle",children:"🟢 WhatsApp bridge (buff whatsapp pair)"}),i.jsx(dle,{authed:h,canWrite:Bt,sessionExpired:Yi,reveal:et})]}):null,e==="conversations"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((J=n.conversations)==null?void 0:J.total)??0}),i.jsx("div",{className:"admin-summary-label",children:"Stored conversations"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>Date.now()-C.lastActiveAt<864e5).length}),i.jsx("div",{className:"admin-summary-label",children:"Active today"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>C.platform==="whatsapp").length}),i.jsx("div",{className:"admin-summary-label",children:"WhatsApp"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>C.platform==="telegram").length}),i.jsx("div",{className:"admin-summary-label",children:"Telegram"})]})]}),((te=n.conversations)==null?void 0:te.analytics)&&n.conversations.analytics.totalConversations>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"admin-refresh-btn",onClick:()=>ce(!Q),style:{marginBottom:12},children:Q?"📊 Hide Analytics":"📊 Show Analytics"}),Q?i.jsxs("div",{className:"hub-session-list",style:{marginBottom:16},children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.totalMessages}),i.jsx("div",{className:"admin-summary-label",children:"Total messages"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgMessagesPerConversation}),i.jsx("div",{className:"admin-summary-label",children:"Avg msgs/conversation"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgUserMessageLength}),i.jsx("div",{className:"admin-summary-label",children:"Avg user msg length"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgAssistantMessageLength}),i.jsx("div",{className:"admin-summary-label",children:"Avg assistant msg length"})]})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"🏆 Most Active Contacts"})})}),i.jsx("div",{style:{marginTop:8},children:n.conversations.analytics.topContacts.map((C,q)=>{var ue;const ne=((ue=n.conversations.analytics.topContacts[0])==null?void 0:ue.messageCount)||1,ae=Math.round(C.messageCount/ne*100);return i.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6,fontSize:13},children:[i.jsx("span",{style:{width:24,textAlign:"center",fontWeight:600,color:q<3?"var(--accent-yellow)":"var(--muted)"},children:q===0?"🥇":q===1?"🥈":q===2?"🥉":`${q+1}.`}),i.jsxs("span",{style:{flex:1,marginLeft:8},children:[C.platform==="whatsapp"?"📱":"✈️"," ",C.name]}),i.jsx("span",{style:{width:60,textAlign:"right",fontWeight:600},children:C.messageCount}),i.jsx("div",{style:{width:100,height:8,background:"var(--border)",borderRadius:4,marginLeft:8},children:i.jsx("div",{style:{width:`${ae}%`,height:"100%",background:"var(--accent-blue)",borderRadius:4}})})]},q)})})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"🕐 Peak Hours"})})}),i.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:80,marginTop:8,gap:2},children:n.conversations.analytics.hourlyDistribution.map(({hour:C,count:q})=>{const ne=Math.max(...n.conversations.analytics.hourlyDistribution.map(ue=>ue.count),1),ae=Math.round(q/ne*70);return i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:i.jsx("div",{style:{width:"100%",height:ae,background:C>=9&&C<=21?"var(--accent-blue)":"var(--text-muted)",borderRadius:2},title:`${C}:00 — ${q} messages`})},C)})}),i.jsx("div",{style:{display:"flex",fontSize:10,color:"var(--muted)",marginTop:4},children:[0,6,12,18,23].map(C=>i.jsxs("span",{style:{flex:1,textAlign:C===0?"left":C===23?"right":"center"},children:[C,":00"]},C))})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"📱 Platform Breakdown"})})}),i.jsx("div",{style:{marginTop:8},children:n.conversations.analytics.platformBreakdown.map(C=>i.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6,fontSize:13},children:[i.jsx("span",{className:"hub-chip",style:{width:80,textAlign:"center"},children:C.platform}),i.jsxs("span",{style:{marginLeft:8,flex:1},children:[C.conversations," conversations"]}),i.jsxs("span",{style:{fontWeight:600},children:[C.messages," msgs"]})]},C.platform))})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"📈 Daily Volume (14 days)"})})}),i.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:60,marginTop:8,gap:2},children:n.conversations.analytics.dailyVolume.map(({date:C,count:q})=>{const ne=Math.max(...n.conversations.analytics.dailyVolume.map(ue=>ue.count),1),ae=Math.round(q/ne*50);return i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:i.jsx("div",{style:{width:"100%",height:ae,background:"var(--accent-green)",borderRadius:2},title:`${C}: ${q} messages`})},C)})}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--muted)",marginTop:4},children:[i.jsx("span",{children:(je=n.conversations.analytics.dailyVolume[0])==null?void 0:je.date}),i.jsx("span",{children:(Cn=n.conversations.analytics.dailyVolume[n.conversations.analytics.dailyVolume.length-1])==null?void 0:Cn.date})]})]})]}):null]}),i.jsx("h2",{className:"section-subtitle",children:"💬 Per-contact chat history"}),i.jsx("p",{className:"admin-hint",children:"Conversation history is stored per-contact and survives gateway restarts. Messages older than 7 days are auto-pruned. Click a conversation to expand the full chat thread."}),At.length>0||ze?i.jsxs(i.Fragment,{children:[Vn.length>0&&i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:[i.jsx("span",{className:"admin-hint",style:{marginRight:4},children:"Filter by tag:"}),Vn.map(C=>i.jsxs("button",{type:"button",onClick:()=>hn(Dt===C?"":C),style:{padding:"2px 10px",borderRadius:12,fontSize:11,cursor:"pointer",border:`1px solid ${Dt===C?"var(--accent-blue)":"var(--border)"}`,background:Dt===C?"color-mix(in srgb, var(--accent-blue) 13%, transparent)":"transparent",color:Dt===C?"var(--accent-blue)":"var(--muted)"},children:["🏷️ ",C]},C))]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,flexWrap:"wrap"},children:[i.jsx("input",{type:"text",value:Ge,onChange:C=>wt(C.target.value),placeholder:"🔍 Search by contact name, phone number, or message content…",style:{flex:1,minWidth:200}}),i.jsxs("span",{className:"admin-hint",children:[Tr," conversation",Tr===1?"":"s",Ge?` matching "${Ge}"`:""]}),i.jsx("button",{type:"button",className:"admin-refresh-btn",onClick:qs,style:{fontSize:12,padding:"4px 10px"},children:Oe.size===At.length?"☑ Deselect All":"☐ Select All"}),Oe.size>0&&i.jsx("button",{type:"button",className:"admin-refresh-btn",disabled:De,onClick:()=>void Qa(),style:{fontSize:12,padding:"4px 10px",background:"var(--accent-blue)",color:"var(--text-on-accent)",border:"none"},children:De?"⏳ Exporting…":`📦 Export ${Oe.size} as ZIP`})]}),i.jsxs("div",{className:"hub-session-list",children:[At.filter(C=>!Dt||(C.tags??[]).includes(Dt)).map(C=>{const q=Date.now()-C.lastActiveAt,ne=q<6e4?"just now":q<36e5?`${Math.round(q/6e4)}m ago`:q<864e5?`${Math.round(q/36e5)}h ago`:`${Math.round(q/864e5)}d ago`,ae=Me===C.key,{name:ue,phone:Pe}=_m(C),Tt=async ke=>{if(ke.stopPropagation(),!h||!Bt){W({kind:"err",text:"🔐 Log in (admin/operator) to clear conversations."});return}G(C.key);try{await K.clearGatewayConversation(C.key),Dn()}catch{}G(null)},Ot=Oe.has(C.key);return i.jsxs("div",{className:"hub-card",style:{cursor:"pointer",borderLeft:`3px solid ${C.platform==="whatsapp"?"#25d366":C.platform==="telegram"?"#0088cc":"var(--text-muted)"}`,opacity:Oe.size>0&&!Ot?.5:1,transition:"opacity 0.2s"},onClick:()=>at(ae?null:C.key),children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("input",{type:"checkbox",checked:Ot,onClick:ke=>ya(C.key,ke),onChange:()=>{},style:{cursor:"pointer",width:16,height:16}}),i.jsxs("div",{className:"hub-card-title",children:[i.jsxs("span",{className:"hub-card-name",children:[C.platform==="whatsapp"?"📱":C.platform==="telegram"?"✈️":"💬"," ",ue]}),i.jsxs("span",{className:"hub-card-id",children:[Pe&&i.jsx("span",{style:{color:"var(--text-secondary, var(--text-secondary))",marginRight:6},children:Pe}),C.platform," · ",ne]})]})]}),i.jsxs("div",{className:"hub-card-actions",style:{gap:6},children:[i.jsxs("span",{className:"hub-chip",children:[C.messageCount," msgs"]}),ae&&C.messages&&C.messages.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"hub-mini-btn",onClick:ke=>Xn(C,ke),title:"Export as text file",children:"📄"}),i.jsx("button",{type:"button",className:"hub-mini-btn",onClick:ke=>Ks(C,ke),title:"Export as PDF (opens print dialog)",children:"📑"})]}),i.jsx("button",{type:"button",className:"hub-mini-btn",disabled:fn===C.key,onClick:Tt,title:"Clear conversation history",style:{color:"var(--accent-red)"},children:"🗑️"}),i.jsx("span",{style:{fontSize:18,transition:"transform 0.2s",transform:ae?"rotate(180deg)":"none"},children:"▼"})]})]}),i.jsxs("p",{className:"hub-card-desc",style:{fontStyle:"italic",color:"var(--text-muted, var(--text-muted))"},children:[i.jsx("span",{style:{color:"var(--text-primary, var(--text-primary))",fontWeight:500},children:"Last message:"})," ",C.lastUserMessage.slice(0,120),C.lastUserMessage.length>120?"…":""]}),i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[(C.tags??[]).map(ke=>i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:"2px 8px",borderRadius:12,fontSize:11,background:"color-mix(in srgb, var(--accent-blue) 13%, transparent)",color:"var(--accent-blue)",border:"1px solid color-mix(in srgb, var(--accent-blue) 25%, transparent)"},children:["🏷️ ",ke,i.jsx("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),qi(C.key,ke)},style:{background:"none",border:"none",color:"var(--accent-blue)",cursor:"pointer",padding:0,fontSize:12,lineHeight:1},children:"×"})]},ke)),Vr===C.key?i.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:i.jsx("input",{type:"text",value:_n,onChange:ke=>ur(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&Gi(C.key,_n),ke.key==="Escape"&&(Yn(null),ur(""))},placeholder:"tag name",autoFocus:!0,onClick:ke=>ke.stopPropagation(),style:{width:80,padding:"1px 6px",fontSize:11,borderRadius:8,border:"1px solid var(--border)"}})}):i.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),Yn(C.key),ur("")},style:{display:"inline-flex",alignItems:"center",gap:2,padding:"2px 8px",borderRadius:12,fontSize:11,background:"var(--border)",color:"var(--muted)",border:"none",cursor:"pointer"},children:"+ tag"})]}),ae&&C.messages&&C.messages.length>0?i.jsxs("div",{className:"conversation-thread",style:{marginTop:10,borderTop:"1px solid var(--border)",paddingTop:10,maxHeight:400,overflowY:"auto"},children:[C.messages.map((ke,Pt)=>i.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",alignItems:ke.role==="user"?"flex-end":"flex-start"},children:[i.jsxs("div",{style:{maxWidth:"80%",padding:"8px 12px",borderRadius:12,backgroundColor:ke.role==="user"?"var(--accent-blue)":"var(--bg-card, var(--bg-card))",color:ke.role==="user"?"var(--text-on-accent)":"var(--text-primary, var(--text-primary))",fontSize:13,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[ke.content.slice(0,500),ke.content.length>500?"…":""]}),i.jsxs("span",{style:{fontSize:10,color:"var(--muted)",marginTop:2,padding:"0 4px"},children:[ke.role==="user"?"👤":"🤖"," ",new Date(ke.ts).toLocaleString()]})]},Pt)),me.has(C.key)&&i.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsxs("div",{style:{padding:"8px 16px",borderRadius:12,backgroundColor:"var(--bg-card, var(--bg-card))",fontSize:13,display:"flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out"},children:"●"}),i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out 0.2s"},children:"●"}),i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out 0.4s"},children:"●"})]}),i.jsx("span",{style:{fontSize:10,color:"var(--muted)",marginTop:2,padding:"0 4px"},children:"🤖 typing…"})]})]}):ae?i.jsx("p",{className:"admin-hint",style:{marginTop:8},children:"No message details available."}):null]},C.key)}),an&&!ze&&i.jsx("div",{ref:Hi,style:{height:1}}),ze&&i.jsxs("div",{className:"loading-state",style:{padding:12},children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("span",{className:"admin-hint",style:{marginLeft:8},children:"Loading more conversations…"})]}),!ze&&!an&&At.length>0&&i.jsxs("p",{className:"admin-hint",style:{textAlign:"center",padding:12},children:["All ",Tr," conversation",Tr===1?"":"s"," loaded."]})]})]}):ze?i.jsxs("div",{className:"loading-state",children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("p",{className:"admin-hint",children:"Loading conversations…"})]}):i.jsx("div",{className:"empty-state",children:"No conversations stored yet. Conversations are created when users message the agent via WhatsApp/Telegram/etc."})]}):null,e==="artifacts"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.artifacts.totalSessions}),i.jsx("div",{className:"admin-summary-label",children:"Sessions"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.artifacts.totalArtifacts}),i.jsx("div",{className:"admin-summary-label",children:"Artifacts"})]})]}),n.artifacts.sessions.length>0?i.jsx("div",{className:"hub-session-list",children:n.artifacts.sessions.map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsx("div",{className:"hub-card-top",children:i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.sessionId}),i.jsxs("span",{className:"hub-card-id",children:[C.count," artifact",C.count===1?"":"s"," · ",new Date(C.latestAt).toLocaleString()]})]})}),C.recent.length>0?i.jsx("ul",{className:"hub-artifact-list",children:C.recent.map((q,ne)=>i.jsxs("li",{children:[i.jsx("span",{className:"hub-chip",children:q.kind}),i.jsx("span",{className:"hub-artifact-title",children:q.title||"(untitled)"}),q.preview?i.jsx("div",{className:"hub-artifact-preview",children:q.preview}):null]},ne))}):i.jsx("div",{className:"admin-hint",children:"No artifact details."})]},C.sessionId))}):i.jsx("div",{className:"empty-state",children:"No artifacts yet — tools that return a deliverable payload land here per session."})]}):null,e==="skills"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.enabled}),i.jsx("div",{className:"admin-summary-label",children:"Enabled skills"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.disabled}),i.jsx("div",{className:"admin-summary-label",children:"Disabled skills"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.hub.length}),i.jsx("div",{className:"admin-summary-label",children:"Hub skills (SKILL.md)"})]})]}),i.jsx("h2",{className:"section-subtitle",children:"📚 Compiled skills (SkillStore — matched at plan time)"}),n.skills.compiled.length>0?i.jsx("div",{className:"hub-session-list",children:n.skills.compiled.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsxs("span",{className:"hub-card-id",children:[C.id,C.version?` · v${C.version}`:""]})]}),i.jsxs("div",{className:"hub-card-actions",children:[C.bundled===!0?i.jsx("span",{className:"hub-chip hub-chip-bundled",children:"🧠 bundled"}):i.jsx("span",{className:"hub-chip",children:"community"}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.name}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.id||A!==null||h&&!Bt,onClick:()=>Xs(C.id,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[typeof C.usageCount=="number"?i.jsxs("span",{className:"hub-chip",children:[C.usageCount," uses"]}):null,C.enabled?null:i.jsx("span",{className:"hub-chip",children:"disabled"})]}),M[C.id]?i.jsx("div",{className:"admin-row-msg",children:M[C.id]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Excluded from skill matching — not injected into the planner"})]},`c-${C.id}`))}):i.jsx("div",{className:"empty-state",children:"No compiled skills."}),i.jsx("h2",{className:"section-subtitle",children:"🌍 Hub skills (installed SKILL.md)"}),n.skills.hub.length>0?i.jsx("div",{className:"hub-session-list",children:n.skills.hub.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsx("span",{className:"hub-card-id",children:C.id})]}),i.jsxs("div",{className:"hub-card-actions",children:[i.jsx("button",{type:"button",className:"hub-mini-btn",disabled:re===C.id||h&&!Bt,onClick:()=>void fd(C.id),children:"🗑 Uninstall"}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.name}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.id||A!==null||h&&!Bt,onClick:()=>Xs(C.id,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsx("span",{className:"hub-chip",children:"SKILL.md"}),C.enabled?null:i.jsx("span",{className:"hub-chip",children:"disabled"})]}),M[C.id]?i.jsx("div",{className:"admin-row-msg",children:M[C.id]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Excluded from skill matching — not injected into the planner"})]},`h-${C.id}`))}):i.jsxs("div",{className:"empty-state",children:["No hub skills installed — search the marketplace below or run ",i.jsx("code",{children:"buff skills install <name>"}),"."]}),i.jsx("h2",{className:"section-subtitle",children:"🛒 Marketplace (community skills)"}),i.jsxs("form",{className:"hub-market-search",onSubmit:Cm,children:[i.jsx("input",{type:"text",value:ba,onChange:C=>Ki(C.target.value),placeholder:"Search community skills (e.g. code-assist, deploy, testing)…"}),i.jsx("button",{type:"submit",className:"admin-refresh-btn",disabled:wa,children:wa?"Searching…":"🔎 Search"})]}),Vi?i.jsx("div",{className:`admin-row-msg${Vi.kind==="err"?" admin-row-msg-err":""}`,children:Vi.text}):null,$l&&!wa?Il.length>0?i.jsx("div",{className:"hub-session-list",children:Il.map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsxs("span",{className:"hub-card-id",children:["v",C.version," · ",C.sourceKind]})]}),i.jsx("button",{type:"button",className:"admin-refresh-btn",disabled:re===C.name||h&&!Bt,onClick:()=>void Am(C.name),children:re===C.name?"Installing…":"⬇ Install"})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsx("span",{className:"hub-chip",children:C.author}),C.tags.slice(0,3).map(q=>i.jsx("span",{className:"hub-chip",children:q},q))]})]},`m-${C.name}`))}):i.jsxs("div",{className:"empty-state",children:['No skills match "',ba,'" — try a broader term, or add a registry to ',i.jsx("code",{children:"skills.registries"})," in config."]}):null]}):null,e==="subagents"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((mn=n.subagents)==null?void 0:mn.total)??0}),i.jsx("div",{className:"admin-summary-label",children:"Runs recorded"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((ct=n.subagents)==null?void 0:ct.running)??0}),i.jsx("div",{className:"admin-summary-label",children:"Running now"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((Hl=n.subagents)==null?void 0:Hl.failed)??0}),i.jsx("div",{className:"admin-summary-label",children:"Failed"})]})]}),i.jsxs("p",{className:"admin-hint",children:["Each run is a separate child process. A transport of ",i.jsx("code",{children:"json"})," means the provider has no native tool protocol and the shared JSON fallback carried the tool calls; a refusal code means the run stopped deliberately instead of returning an answer."]}),(((Gl=n.subagents)==null?void 0:Gl.recent)??[]).length>0?i.jsx("div",{className:"hub-session-list",children:(((ql=n.subagents)==null?void 0:ql.recent)??[]).map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.goal||"(no goal recorded)"}),i.jsxs("span",{className:"hub-card-id",children:[C.id.slice(0,8),C.startedAt?` · ${new Date(C.startedAt).toLocaleString()}`:""]})]}),i.jsx("div",{className:"hub-card-actions",children:i.jsx("span",{className:"hub-chip",children:vle[C.status]??C.status})})]}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsxs("span",{className:"hub-chip",children:["🔌 ",C.provider??"provider unknown",C.model?` · ${C.model}`:""]}),i.jsxs("span",{className:"hub-chip",children:["🛠 ",C.transport??"transport unknown"," transport"]}),i.jsxs("span",{className:"hub-chip",children:[C.llmCalls," model call",C.llmCalls===1?"":"s"]}),i.jsxs("span",{className:"hub-chip",children:[C.toolCalls," tool call",C.toolCalls===1?"":"s"]}),typeof C.durationMs=="number"?i.jsxs("span",{className:"hub-chip",children:[(C.durationMs/1e3).toFixed(1),"s"]}):null]}),C.refusalCode?i.jsxs("div",{className:"hub-card-note",children:["⛔ Refused before answering — code ",i.jsx("code",{children:C.refusalCode})]}):null,C.error?i.jsx("div",{className:"admin-row-msg admin-row-msg-err",children:C.error}):null,C.resultPreview?i.jsx("div",{className:"hub-artifact-preview",children:C.resultPreview}):null]},C.id))}):i.jsxs("div",{className:"empty-state",children:["No subagent runs recorded yet — a run shows up here once the agent spawns one (the ",i.jsx("code",{children:"subagent"})," tool), and only if it actually started."]})]}):null]})}const wle=295,kle=58,Sle=[{name:"admin",description:"Admin governance policy for Auto routing (P6 M6.5) — allow/deny providers & models, hard cost cap, PII privacy, unblock control",commands:[{name:"admin policy",description:"Show the current governance policy + enforcement status",flags:["--json"]},{name:"admin allow",description:"Add providers to the allow-list (empty = all providers allowed)",flags:[]},{name:"admin deny",description:"Add providers to the deny-list (wins over the allow-list)",flags:[]},{name:"admin allow-model",description:"Add models to the allow-list — a provider survives only if one of its candidate models is listed",flags:[]},{name:"admin deny-model",description:"Add models to the deny-list (wins over the allow-list)",flags:[]},{name:"admin max-cost",description:"Set the admin hard max cost per call (USD); joins routing.maxCostUsd (stricter wins)",flags:[]},{name:"admin pii-min",description:"Set the minimum privacy score (0-1) required when a task matches a PII pattern (default 1.0 = local-only)",flags:[]},{name:"admin unblock",description:"Control whether `nuvira models unblock` may override REGISTRY-learned blocks (false = admin-hard)",flags:[]},{name:"admin clear",description:"Remove one governance rule (the policy becomes permissive on that field)",flags:[]},{name:"admin role",description:"Manage RBAC roles over the admin surface (P6 M6.1 — requires admin role)",flags:[]},{name:"admin role add",description:"Assign a role to a user (first assignment exits legacy single-user mode)",flags:[]},{name:"admin role remove",description:"Remove a user's role assignment (if none remain, legacy permissive mode resumes)",flags:[]},{name:"admin role list",description:"List all role assignments",flags:[]},{name:"admin whoami",description:"Show the current identity and its effective RBAC permissions",flags:[]},{name:"admin cron",description:"Scheduled tool invocations (J2 — cron/jobs.py)",flags:[]},{name:"admin cron add",description:'Add a cron job: nuvira admin cron add nightly-build "0 3 * * *" build',flags:["--args <args>","--channel <channel>","--dry-run"]},{name:"admin cron list",description:"List cron jobs with schedule + next run",flags:[]},{name:"admin cron remove",description:"Remove a cron job",flags:[]},{name:"admin cron run",description:"Run a cron job NOW (invoke its tool immediately)",flags:[]}]},{name:"chat",description:"Start an interactive chat session with AI",commands:[]},{name:"edit",description:"Edit a file using AI assistance",commands:[]},{name:"plan",description:"Generate an implementation plan for a codebase task",commands:[]},{name:"config",description:"Manage Nuvira configuration",commands:[{name:"config set",description:"Set a configuration value",flags:[]},{name:"config get",description:"Get a configuration value",flags:[]},{name:"config list",description:"List all providers and their status",flags:[]},{name:"config init",description:"Initialize configuration interactively",flags:[]},{name:"config vault",description:"Secret vault management (Phase A1)",flags:[]},{name:"config vault status",description:"Show the active vault tier and migration state",flags:[]},{name:"config vault log",description:"Show recent vault access-log entries (K3 tamper-evident audit)",flags:["--limit <limit>"]},{name:"config vault migrate-keys",description:"Move plaintext provider API keys from buffconfig.json into the vault",flags:[]},{name:"config gateway",description:"Manage gateway platform transports (tokens written to ~/.nuvira/.env)",flags:[]},{name:"config gateway list",description:"Show every platform transport and its env-var status",flags:[]},{name:"config gateway set",description:"Configure a platform transport (interactive wizard, or --set VAR=value)",flags:["--set <set>"]},{name:"config gateway remove",description:"Remove a platform transport from the env file",flags:["--yes"]},{name:"config gateway allow",description:"Allow a user/group to trigger the agent on a platform (written to gateway.policies in config)",flags:[]},{name:"config gateway disallow",description:"Remove a user/group from the allowed list of a platform",flags:[]},{name:"config gateway reply",description:"Set how unapproved senders are handled on a platform: polite (⛔ message) or silent (no reply)",flags:[]},{name:"config gateway send-authority",description:"Manage who may command the agent to send to OTHER people (gateway_send). Outbound-only gate — separate from `allow` (who may trigger).",flags:[]},{name:"config gateway notify",description:"Manage status recipients — contacts/groups that ALWAYS get pipeline completion summaries",flags:[]},{name:"config gateway ask-user-wait",description:"Ask-and-wait for clarifying questions on messaging channels: when a turn asks the sender a question, hold it for their reply instead of assuming option 1",flags:[]},{name:"config service",description:"Manage third-party service keys (image/video/search/vision/speech) in ~/.nuvira/.env",flags:[]},{name:"config service list",description:"Show every service backend and its env-var status",flags:[]},{name:"config service set",description:"Set a service key: config service set <serviceId> <ENV_VAR> <value> (or --set VAR=value)",flags:["--set <set>"]},{name:"config service unset",description:"Remove a service key (all vars, or one with [varName]) from the env file",flags:["--yes"]},{name:"config limit",description:"Show or change the size limits for document extraction and attachments",flags:[]},{name:"config limit list",description:"Show the effective extraction and attachment limits",flags:[]},{name:"config limit set",description:"Set a limit: config limit set <extract-max-chars|attachment-max-kb> <value>",flags:[]},{name:"config limit unset",description:"Restore a limit to its default",flags:[]},{name:"config capability",description:"Show or change the capability mode (balanced | max)",flags:[]},{name:"config capability show",description:"Show the effective capability mode",flags:[]},{name:"config capability set",description:"Set the capability mode: config capability set <balanced|max>",flags:[]},{name:"config capability unset",description:"Restore the default capability mode (balanced)",flags:[]},{name:"config catalog-feed",description:"Show or change the OpenRouter catalogue feed (cost/ecosystem priors only)",flags:[]},{name:"config catalog-feed show",description:"Show whether the catalogue feed is on, and how old its snapshot is",flags:[]},{name:"config catalog-feed set",description:"Enable or disable: config catalog-feed set <on|off>",flags:[]},{name:"config catalog-feed unset",description:"Remove the setting, restoring the default (off)",flags:[]},{name:"config catalog-feed refresh",description:"Fetch a fresh catalogue snapshot now (never runs during a turn)",flags:[]}]},{name:"cache",description:"Manage inference cache",commands:[{name:"cache stats",description:"Show cache statistics",flags:[]},{name:"cache clear",description:"Clear cached responses — all of them, or one workspace (project folder)",flags:["--unscoped"]}]},{name:"models",description:"List available models from inference providers",commands:[{name:"models refresh",description:"Probe providers and spot-check models, updating the Model Availability Registry",flags:["--json","--no-spot-check"]},{name:"models status",description:"Show the Model Availability Registry (verified / unavailable / quota-parked models)",flags:["--json","--verbose"]},{name:"models unblock",description:"Manually release a registry-blocked provider (escape hatch) and re-probe it against the live API",flags:["--json","--no-spot-check"]},{name:"models excluded",description:"Show which providers routing is currently skipping, and why (failure cooldowns, registry blocks, governance policy)",flags:["--json"]},{name:"models staleness",description:"Show model staleness: last probe time, days since verification, and removal risk",flags:["--json"]},{name:"models watch",description:"Run the model-registry maintenance daemon: probe + spot-check on a schedule",flags:["--interval <interval>","--no-spot-check"]}]},{name:"execute",description:"Run a multi-agent pipeline to accomplish a goal",commands:[]},{name:"run",description:"Execute a shell command and show output (lightweight alternative to the full pipeline)",commands:[]},{name:"workflow",description:"Run, manage, and share workflow templates",commands:[{name:"workflow list",description:"Show available workflow templates (built-in + installed)",flags:[]},{name:"workflow run",description:"Run a workflow template",flags:["--dry-run","--model <model>","--provider <provider>","--verbose"]},{name:"workflow search",description:"Search the GitHub workflow template registry",flags:["--refresh"]},{name:"workflow install",description:"Install a workflow template from the GitHub registry",flags:[]},{name:"workflow publish",description:"Prepare a local workflow template for publishing to the registry",flags:[]},{name:"workflow info",description:"Show detailed information about a registry template",flags:[]},{name:"workflow upgrade",description:"Check for and apply template upgrades from the registry",flags:[]}]},{name:"whatsapp",description:"WhatsApp bridge (Baileys) — pair a personal number via QR and check status (I8)",commands:[{name:"whatsapp pair",description:"Pair WhatsApp (personal number — no Meta Business account, no paid API)",flags:["--phone <phone>","--timeout <timeout>"]},{name:"whatsapp status",description:"Show bridge session path + pairing state",flags:[]},{name:"whatsapp contacts",description:"List resolvable contacts (mapping file + learned) — connects briefly to learn names from live traffic",flags:["--timeout <timeout>"]},{name:"whatsapp contact",description:'Manage the WhatsApp contact-name mapping (send by name: nuvira gateway send whatsapp:<Name> "message")',flags:[]},{name:"whatsapp contact add",description:"Map a display name to a number (E.164, no +): nuvira whatsapp contact add Name 919876543210",flags:[]},{name:"whatsapp contact remove",description:"Remove a mapped contact name",flags:[]}]},{name:"plugins",description:"Manage provider plugins, agent plugins, and workflow templates",commands:[{name:"plugins list",description:"List all discovered plugins and workflows",flags:[]},{name:"plugins scan",description:"Force re-scan all plugin directories",flags:[]}]},{name:"learn",description:"Self-improvement system — agent stats, patterns, and optimization",commands:[{name:"learn stats",description:"Show per-agent performance statistics",flags:[]},{name:"learn patterns",description:"Show extracted coding patterns",flags:["--extract","--model <model>","--provider <provider>"]},{name:"learn lessons",description:"Show failure lessons — what past runs learned from mistakes",flags:["--extract","--model <model>","--provider <provider>"]},{name:"learn optimize",description:"Generate optimized model-to-agent routing recommendations",flags:[]},{name:"learn status",description:"Show overall self-improvement status",flags:[]},{name:"learn clear",description:"Reset all learning data (stats, patterns, memory)",flags:["--force"]},{name:"learn compare",description:"Compare benchmark results between two models",flags:["--all","--last"]},{name:"learn feedback",description:"Rate a trajectory or view feedback statistics",flags:["--comment <comment>","--rating <rating>","--stats","--trajectory <trajectory>"]},{name:"learn quality",description:"Show pattern quality and decay metrics",flags:["--details"]},{name:"learn gc",description:"Garbage-collect low-quality patterns",flags:["--dry-run"]}]},{name:"init",description:"Scaffold a new project from a template",commands:[]},{name:"stats",description:"View usage statistics and cost tracking",commands:[{name:"stats cost",description:"Show API cost tracking details",flags:["--clear"]},{name:"stats history",description:"Show conversation history statistics",flags:[]}]},{name:"history",description:"Browse and search conversation history",commands:[{name:"history list",description:"Show all saved conversations",flags:["--limit <limit>"]},{name:"history search",description:"Search conversations by keyword or semantic similarity",flags:["--limit <limit>","--semantic"]},{name:"history show",description:"Show a specific conversation",flags:[]},{name:"history clear",description:"Clear all conversation history",flags:[]},{name:"history prune",description:"Remove conversations older than the retention period",flags:["--days <days>"]},{name:"history reindex",description:"Rebuild the semantic search index for all past conversations (embeds each session for vector search)",flags:[]}]},{name:"skill",description:"Manage and run compiled skills — reusable execution plans derived from past trajectories",commands:[{name:"skill list",description:"List all compiled skills",flags:["--quality <quality>"]},{name:"skill show",description:"Show detailed skill definition",flags:[]},{name:"skill run",description:"Run a skill — resolves parameters and invokes the multi-agent pipeline",flags:["--auto-route","--dry-run","--memory","--model <model>","--params <params>","--provider <provider>","--verbose"]},{name:"skill compile",description:"Force skill compilation from stored trajectories",flags:["--model <model>","--provider <provider>"]},{name:"skill search",description:"Search skills by name, tag, or description",flags:[]},{name:"skill gc",description:"Garbage-collect low-quality skills",flags:["--dry-run"]},{name:"skill quality",description:"Show skill quality and decay metrics",flags:["--details"]},{name:"skill clear",description:"Remove all compiled skills",flags:["--force"]}]},{name:"skills",description:"Skills hub — search, install, update, and audit community skills (J3)",commands:[{name:"skills search",description:"Search all configured skill registries (I7 P1 multi-source)",flags:["--refresh","--source <source>"]},{name:"skills install",description:"Install a skill from the configured registries into <project>/.agents/skills/ (sandboxed, checksummed)",flags:["--project <project>","--source <source>"]},{name:"skills uninstall",description:"Uninstall a skill: removes .agents/skills/<name> and its provenance record",flags:["--project <project>"]},{name:"skills update",description:"Update installed skills to newer registry versions (checksum-verified)",flags:["--project <project>"]},{name:"skills bundle",description:"P6b — skill bundles: group skills under one id and load them together (Hermes parity)",flags:["--create","--delete","--description <description>","--name <name>","--skills <skills>"]},{name:"skills list",description:"List installed skills with provenance (origin: registry vs local)",flags:["--origin <origin>","--project <project>"]}]},{name:"gateway",description:"Multi-channel gateway — talk to the agent from Telegram/Discord/Slack/WhatsApp/Email/Signal (J1)",commands:[{name:"gateway status",description:"Show configured adapters and reachable channels",flags:[]},{name:"gateway send",description:"Send a message to a channel alias or platform:channelId",flags:[]},{name:"gateway send-media",description:"Send a media file (image/video/audio/document) — type from the file extension; WhatsApp/Telegram/Discord",flags:["--caption <caption>"]},{name:"gateway alias",description:"Manage channel aliases",flags:[]},{name:"gateway alias add",description:"Register an alias: nuvira gateway alias add ops slack C0123",flags:[]},{name:"gateway alias remove",description:"Remove an alias",flags:[]},{name:"gateway contact",description:"Manage contacts for outbound messaging (name → platform:id resolution)",flags:[]},{name:"gateway contact list",description:"List all contacts with status, platform, and ID",flags:["--pending","--platform <platform>"]},{name:"gateway contact approve",description:"Approve a contact for outbound messaging",flags:["--platform <platform>"]},{name:"gateway contact reject",description:"Reject a contact (block outbound messages)",flags:["--platform <platform>"]},{name:"gateway contact delete",description:"Delete a contact permanently",flags:["--platform <platform>"]},{name:"gateway contact add",description:"Manually add a contact (e.g. nuvira gateway contact add Anuj telegram 616825477)",flags:["--phone <phone>"]},{name:"gateway delivery",description:"Show the delivery ledger (failed sends awaiting retry) and optionally drain it",flags:["--flush"]},{name:"gateway logs",description:"Show the structured gateway log (send failures, refused senders, pipeline outcomes)",flags:["--event <event>","--limit <limit>","--path"]},{name:"gateway history",description:"Manage per-contact conversation history (gateway chat memory)",flags:[]},{name:"gateway history list",description:"List all stored conversations with last message preview",flags:["--platform <platform>"]},{name:"gateway history show",description:"Show conversation history for a contact (e.g. nuvira gateway history show whatsapp:918800663237)",flags:["--limit <limit>"]},{name:"gateway history clear",description:"Clear conversation history for a contact",flags:[]},{name:"gateway history prune",description:"Remove conversations older than 7 days",flags:[]},{name:"gateway start",description:"Run all configured adapters in the foreground (Ctrl-C to stop; --supervise auto-restarts on crash)",flags:["--host <host>","--no-events","--port <port>","--supervise"]},{name:"gateway stop",description:"Stop a running gateway gracefully (SIGTERM — from any terminal)",flags:["--port <port>"]},{name:"gateway setup",description:"Interactive setup wizard for a messaging platform (e.g. nuvira gateway setup telegram)",flags:[]}]},{name:"omniroute",description:"Start / stop / inspect the external OmniRoute AI gateway (default port 20128)",commands:[{name:"omniroute status",description:"Probe the OmniRoute gateway and report whether it is reachable",flags:[]},{name:"omniroute start",description:"Start the OmniRoute gateway in the background and wait for it to answer",flags:[]},{name:"omniroute stop",description:"Stop the running OmniRoute gateway",flags:[]}]},{name:"model",description:"Manage inference providers and models — switch, list, inspect, and recommend",commands:[{name:"model list",description:"List all providers and their configuration status",flags:["--all","--json"]},{name:"model switch",description:"Switch active provider/model (interactive or via argument). Use `auto` for smart routing",flags:["--model <model>","--provider <provider>"]},{name:"model info",description:"Show current active provider and model configuration",flags:["--verbose"]},{name:"model recommend",description:"Show model routing recommendations",flags:[]},{name:"model explain",description:"Explain Auto model routing — why a provider/model would be picked for a task",flags:["--agent <agent>","--context-tokens <context_tokens>","--exclude-provider <exclude_provider>","--json","--since <since>"]},{name:"model health",description:"Quick health check for the currently active provider",flags:["--provider <provider>","--verbose"]},{name:"model bandit",description:"Show learning-router bandit state (Thompson-sampling priors per provider × complexity bucket). Action: reset",flags:["--json"]},{name:"model ml",description:"Show the ML task-similarity router state (learned outcomes per provider, kNN over task features). Action: reset",flags:["--json"]},{name:"model quota",description:"Show the central quota ledger (tokens/requests per provider × model, reset windows, parked state). Actions: reset | set <provider> | clear <provider>",flags:["--cost-usd <cost_usd>","--json","--requests <requests>","--tokens <tokens>","--window-ms <window_ms>"]}]},{name:"benchmark",description:"Run standardized model benchmarks against coding tasks",commands:[{name:"benchmark run",description:"Run the benchmark suite",flags:["--budget <budget>","--format <format>","--model <model>","--provider <provider>","--routing","--tasks <tasks>"]},{name:"benchmark list",description:"List available benchmark tasks",flags:[]},{name:"benchmark results",description:"Show previous benchmark results",flags:["--compare","--format <format>","--last"]},{name:"benchmark clear",description:"Clear all benchmark data",flags:[]}]},{name:"eval",description:"Run the Agent-Nuvira evaluation framework — measures if the agent is actually improving",commands:[{name:"eval run",description:"Run the evaluation suite",flags:["--budget <budget>","--engine <engine>","--format <format>","--keep-workspaces","--model <model>","--pace","--provider <provider>","--routing","--suite <suite>","--tasks <tasks>"]},{name:"eval parity",description:"Measure the capability gap: run the hard tasks under balanced AND max, then compare",flags:["--engine <engine>","--model <model>","--provider <provider>","--tasks <tasks>"]},{name:"eval verify-seeds",description:"Prove every seeded bug is genuinely broken (and genuinely fixable) — no provider needed",flags:["--tasks <tasks>"]},{name:"eval list",description:"List available eval tasks",flags:[]},{name:"eval results",description:"Show previous eval runs",flags:["--compare","--format <format>","--last"]},{name:"eval score",description:"Show the evaluation scoring rules",flags:[]},{name:"eval clear",description:"Clear all eval data",flags:[]}]},{name:"sandbox",description:"Manage Docker sandbox isolation for code execution",commands:[{name:"sandbox status",description:"Check Docker availability and sandbox status",flags:[]},{name:"sandbox config",description:"Show or update sandbox configuration",flags:["--cpu <cpu>","--disable","--disk <disk>","--enable","--image <image>","--memory <memory>","--network","--timeout <timeout>"]},{name:"sandbox images",description:"List available pre-defined sandbox images",flags:[]},{name:"sandbox run",description:"Run a command inside a new sandbox container",flags:["--cpu <cpu>","--image <image>","--memory <memory>","--network","--project <project>","--timeout <timeout>"]},{name:"sandbox cleanup",description:"Destroy all active sandbox containers",flags:[]}]},{name:"doctor",description:"Run diagnostic checks on all provider configurations and system health",commands:[]},{name:"memory",description:"Manage agent memory store — compression, pruning, and optimization",commands:[{name:"memory stats",description:"Show memory store statistics",flags:[]},{name:"memory optimize",description:"Run automatic memory compression and pruning",flags:["--aggressive","--dry-run"]},{name:"memory prune",description:"Prune old or low-quality trajectories",flags:["--max-age <max_age>","--max-count <max_count>","--min-score <min_score>","--verbose"]},{name:"memory summarize",description:"Summarize old trajectories by merging similar ones",flags:["--retention <retention>","--verbose"]},{name:"memory info",description:"Show detailed compression analysis",flags:[]},{name:"memory backend",description:"Show the active vector-search backend and why it was chosen",flags:["--check"]},{name:"memory list",description:"List all memory entries (facts, preferences, lessons, observations)",flags:["--limit <limit>","--type <type>"]},{name:"memory search",description:"Search memory entries by content",flags:["--limit <limit>","--type <type>"]},{name:"memory add",description:"Add a memory entry",flags:["--tags <tags>","--type <type>"]},{name:"memory delete",description:"Delete a memory entry by ID",flags:[]},{name:"memory export",description:"Export all memories to a JSON file",flags:["--output <output>"]},{name:"memory import",description:"Import memories from a JSON file",flags:["--merge"]},{name:"memory facts",description:"Fact & preference memory (project-scoped, cross-session)",flags:[]},{name:"memory facts list",description:"List facts, optionally for a project (git slug or cwd:<hash>)",flags:["--project <project>"]},{name:"memory facts add",description:"Manually store a fact for the current project",flags:["--project <project>","--tags <tags>"]},{name:"memory facts stats",description:"Show fact-store statistics",flags:[]},{name:"memory clear",description:"Clear all stored trajectories and reset memory",flags:["--force"]}]},{name:"dashboard",description:"Launch the web-based dashboard for visualizing agent execution and system status",commands:[{name:"dashboard stop",description:"Stop a running dashboard gracefully (SIGTERM — from any terminal)",flags:["--port <port>"]}]},{name:"agent",description:"Scaffold and manage custom agent-nuvira agents",commands:[{name:"agent create",description:"Create a new custom agent project from a template",flags:["--agent-name <agent_name>","--description <description>","--dir <dir>"]},{name:"agent list",description:"List all discovered custom agent plugins",flags:[]},{name:"agent info",description:"Show details about a discovered agent plugin",flags:[]}]},{name:"federation",description:"Connect to and manage remote agent instances",commands:[{name:"federation status",description:"Show federation connection status and configuration",flags:[]},{name:"federation start",description:"Start the federation server (listens for incoming connections)",flags:["--auth <auth>","--daemon","--host <host>","--oidc-public-key <oidc_public_key>","--port <port>","--secret <secret>"]},{name:"federation connect",description:"Connect to a remote federation server",flags:["--port <port>","--secret <secret>"]},{name:"federation disconnect",description:"Disconnect from the remote federation server",flags:[]},{name:"federation run",description:"Run a task on the remote federation server",flags:["--agent <agent>","--model <model>","--no-stream","--provider <provider>","--timeout <timeout>"]},{name:"federation health",description:"Check the health of the remote federation server",flags:[]},{name:"federation config",description:"Show or update federation configuration",flags:["--set-port <set_port>","--set-secret <set_secret>","--show"]},{name:"federation a2a",description:"A2A (Agent-to-Agent) protocol — discover and connect to external A2A-compliant agents",flags:[]},{name:"federation a2a discover",description:"Discover an A2A-compliant agent and fetch its AgentCard",flags:[]},{name:"federation a2a start",description:"Start the A2A server (listens for incoming A2A connections)",flags:["--host <host>","--port <port>"]},{name:"federation a2a status",description:"Check the health and status of a remote A2A agent",flags:[]},{name:"federation a2a run",description:"Delegate a task to a remote A2A-compliant agent",flags:["--agent <agent>","--skill <skill>","--timeout <timeout>"]}]},{name:"team",description:"Team collaboration — shared config, git-synced memory, and review workflow",commands:[{name:"team init",description:"Initialize team configuration in the working directory",flags:["--branch <branch>","--repo <repo>"]},{name:"team join",description:"Clone and join an existing team repository",flags:[]},{name:"team sync",description:"Sync team memory with remote (pull latest + push local changes)",flags:[]},{name:"team status",description:"Show team configuration and memory status",flags:[]},{name:"team share",description:"Share local trajectories and patterns with the team",flags:[]},{name:"team review",description:"Manage review bundles — agent PR → review → merge workflow",flags:[]},{name:"team review list",description:"List all review bundles",flags:["--limit <limit>"]},{name:"team review show",description:"Show a specific review bundle with full details",flags:[]},{name:"team review approve",description:"Approve a review bundle (sets status to approved)",flags:["--message <message>"]},{name:"team review request-changes",description:"Request changes on a review bundle",flags:[]},{name:"team review reject",description:"Reject a review bundle",flags:[]},{name:"team review merge",description:"Merge an approved review into the working directory",flags:[]},{name:"team review create",description:"Create a review bundle from specified files",flags:["--files <files>","--model <model>","--provider <provider>"]}]},{name:"sdk",description:"Create and manage custom agents with the Agent-Nuvira SDK",commands:[{name:"sdk scaffold",description:"Generate a new custom agent project",flags:["--agent-type <agent_type>","--template <template>"]},{name:"sdk templates",description:"List available scaffold templates",flags:[]},{name:"sdk info",description:"Show SDK package info and version",flags:[]},{name:"sdk register",description:"Register a custom agent with the orchestrator",flags:["--description <description>","--icon <icon>","--orchestrator-path <orchestrator_path>"]},{name:"sdk unregister",description:"Remove a custom agent from the orchestrator",flags:["--class-name <class_name>","--orchestrator-path <orchestrator_path>"]}]},{name:"provider",description:"List and check health of all inference providers",commands:[{name:"provider list",description:"Show all providers with color-coded status table",flags:["--all"]},{name:"provider health",description:"Show detailed health checks for one or all providers",flags:["--verbose","--watch"]}]},{name:"security",description:"Scan code, prompts, or files for security issues",commands:[{name:"security scan",description:"Scan for PII, injection attempts, or dangerous code patterns",flags:["--code","--file <file>","--generated","--json","--pii","--prompt","--stdin","--strict"]}]},{name:"audit",description:"Verify and export the tamper-evident (hash-chained) audit trail (P6 M6.3)",commands:[{name:"audit verify",description:"Verify hash-chain integrity of audit stores (tamper detection)",flags:["--file <file>","--json"]},{name:"audit export",description:"Export an audit store as SIEM-friendly CEF lines",flags:["--file <file>","--out <out>"]}]},{name:"sbom",description:"Generate and verify the CycloneDX software bill of materials (P6 M6.6)",commands:[]},{name:"feedback",description:"Record, view, and manage user feedback on agent outputs",commands:[{name:"feedback record",description:"Record feedback for a trajectory (interactive)",flags:["--comment <comment>","--negative","--neutral","--positive"]},{name:"feedback list",description:"Show recent feedback entries",flags:["--limit <limit>","--trajectory <trajectory>"]},{name:"feedback stats",description:"Show aggregated feedback statistics",flags:[]},{name:"feedback clear",description:"Clear all feedback data",flags:[]}]},{name:"nlu",description:"NLU request understanding — debug intent/entity/action resolution",commands:[{name:"nlu debug",description:"Debug how a request is understood (rule path + optional LLM verify)",flags:["--llm"]},{name:"nlu learnings",description:"Show the routing corrections learned from CONFIRMED misreadings (the agent improving itself)",flags:["--forget <forget>","--json"]}]},{name:"intent",description:"Plain-English → CLI routing — resolve an ask into the exact `nuvira` command(s) to run",commands:[{name:"intent resolve",description:'Resolve a plain-English ask (e.g. "stop the dashboard", "add Rahul to whatsapp") into CLI commands',flags:["--json","--semantic"]},{name:"intent eval",description:"Score deterministic vs semantic matching over a labeled ask corpus (novel phrasings included)",flags:["--json"]}]},{name:"code-map",description:"Project symbol map — functions, classes, methods with line numbers (AST engine)",commands:[]},{name:"tools",description:"Inspect the agent tool registry (pipeline + experience tools)",commands:[{name:"tools list",description:"List every registered tool (the H1 tool-calling surface)",flags:[]},{name:"tools show",description:"Show a tool's description and input schema",flags:[]},{name:"tools toolsets",description:"List toolset groups (capability gating) with enabled state; enable/disable a group",flags:["--disable <disable>","--enable <enable>"]},{name:"tools install",description:"Install the optional dependency an optional tool needs (see `nuvira tools optional`)",flags:["--package-only"]},{name:"tools optional",description:"List tools that are shipped but need an optional dependency installed",flags:[]}]},{name:"parity",description:"Surface-parity harness — prove the same experience on chat, execute, dashboard, gateway and subagents",commands:[{name:"parity surfaces",description:"Compare the surface registry against the real import graph",flags:[]},{name:"parity debt",description:"Check the anti-silo debt ratchet (observed surface debt must equal the frozen list)",flags:[]},{name:"parity matrix",description:"Show every capability × surface and any unproven `supported` claim",flags:[]},{name:"parity faults",description:"List the declared faults the harness can inject, and what each one proves",flags:[]},{name:"parity run",description:"Drive all five surfaces through the real harness and report the verdict",flags:[]}]},{name:"session",description:"Project-scoped session continuity (debug surface — `continue` is the primary path)",commands:[{name:"session list",description:"List recent sessions, optionally filtered by project + time range",flags:["--limit <limit>","--project <project>","--since <since>"]},{name:"session summarize",description:"Show summary + metadata for one session (transcript: nuvira history show)",flags:[]},{name:"session resume",description:"Run D1 auto-recall for a project and print the recall card",flags:["--project <project>","--since <since>"]}]},{name:"state",description:"Print this project’s tracked state in one read: plan, open sessions, per-file verification debt, git drift",commands:[]},{name:"marketplace",description:"Browse and install community plugins and workflow templates",commands:[{name:"marketplace browse",description:"Browse all available marketplace items",flags:["--plugins","--refresh","--workflows"]},{name:"marketplace search",description:"Search across plugins and workflow templates",flags:[]},{name:"marketplace install",description:"Install a workflow template from the registry",flags:[]},{name:"marketplace info",description:"Show detailed information about a marketplace item",flags:[]}]},{name:"mcp",description:"Manage MCP (Model Context Protocol) server connections",commands:[{name:"mcp list",description:"List all discovered MCP servers and their tools",flags:[]},{name:"mcp connect",description:"Connect to an MCP server",flags:["--all"]},{name:"mcp call",description:"Call a tool on an MCP server",flags:["--args <args>","--server <server>"]},{name:"mcp info",description:"Show detailed information for an MCP server",flags:[]},{name:"mcp refresh",description:"Re-discover and reconnect to all MCP servers",flags:[]},{name:"mcp catalog",description:"List MCP capability slots, their variants, and what each one needs on this machine",flags:["--search <search>"]},{name:"mcp install",description:"Install a catalog capability, choosing the best variant this machine can actually run",flags:["--command <command>","--env <env>","--force","--no-verify","--runtime <runtime>","--variant <variant>"]},{name:"mcp add",description:"Add a server that is NOT in the catalog — any stdio command or remote URL, like a config file",flags:["--arg <arg>","--command <command>","--env <env>","--force","--header <header>","--json <json>","--no-verify","--transport <transport>","--url <url>"]},{name:"mcp settings",description:"Show the resolved mcp.* configuration (caps, auto-connect, subagent inheritance)",flags:[]},{name:"mcp authorize",description:"Authorize an OAuth MCP server (opens the consent page, captures the loopback redirect, stores the token)",flags:["--no-browser","--redirect-uri <redirect_uri>"]},{name:"mcp uninstall",description:"Remove an installed MCP server config",flags:[]},{name:"mcp serve",description:"Expose the agent's H1 tools as an MCP server over stdio (MCP clients / IDEs / other agents can connect)",flags:["--memory","--with <with>"]}]},{name:"ci",description:"Headless CI/CD mode — structured JSON output and exit codes for pipelines",commands:[{name:"ci execute",description:"Execute a goal and emit JSON result (exit 0 = success, 1 = failure)",flags:["--context-limit <context_limit>","--context-prune <context_prune>","--github-annotations","--memory","--model <model>","--planner-model <planner_model>","--provider <provider>","--reviewer-model <reviewer_model>","--sandbox","--timeout <timeout>","--writer-model <writer_model>"]},{name:"ci check",description:"Run a gate check (exit 0 = pass, 1 = fail) — minimal output, ideal for workflow gates",flags:["--model <model>","--provider <provider>","--verbose"]},{name:"ci review",description:"Review one or more files and emit JSON findings",flags:["--context <context>","--format <format>","--model <model>","--provider <provider>"]}]},{name:"publish",description:"Autonomous publish workflow — version, build, publish to npm & GitHub",commands:[]},{name:"credentials",description:"Store GitHub/npm release credentials so the agent can release without re-entering them",commands:[{name:"credentials status",description:"Show which release credentials are available, and where each came from",flags:[]},{name:"credentials set",description:"Store a credential in the nuvira credential store",flags:["--stdin","--value <value>"]},{name:"credentials forget",description:"Delete a stored credential",flags:[]},{name:"credentials verify",description:"Check the stored GitHub and npm tokens against the live services",flags:[]}]},{name:"bedrock",description:"AWS Bedrock setup and management (dedicated onboarding for Bedrock)",commands:[{name:"bedrock setup",description:"Interactive wizard to configure AWS Bedrock (credentials, region, model access)",flags:[]},{name:"bedrock status",description:"Show current Bedrock configuration and connectivity status",flags:[]},{name:"bedrock test",description:"Probe Bedrock models and test inference",flags:["--region <region>"]}]},{name:"phase",description:"Phase-wise project scope execution — multi-goal pipelines",commands:[{name:"phase create",description:"Create a new phase scope with ordered goals",flags:["--output <output>"]},{name:"phase execute",description:"Execute a phase scope from start to finish",flags:["--dry-run","--model <model>","--non-interactive","--provider <provider>","--skip-tests","--verbose"]},{name:"phase resume",description:"Resume a saved phase scope from where it left off",flags:["--model <model>","--provider <provider>","--skip-tests","--verbose"]},{name:"phase status",description:"Show progress of a phase scope",flags:[]},{name:"phase delete",description:"Delete a saved phase scope",flags:[]},{name:"phase list",description:"List all saved phase scopes",flags:[]}]},{name:"retrieval",description:"Vector retrieval — token-efficient context via local embeddings",commands:[{name:"retrieval stats",description:"Show token-savings transparency (how many tokens retrieval saved)",flags:[]},{name:"retrieval index",description:"Index a repo/file into the retrieval store (chunks embedded locally)",flags:[]},{name:"retrieval query",description:"Semantic search over the indexed repo (top-k chunks)",flags:[]},{name:"retrieval clear",description:"Clear the retrieval index and token-savings stats",flags:[]}]},{name:"knowledge",description:"Knowledge base — answer questions from your own tagged documents (vector retrieval)",commands:[{name:"knowledge add",description:"Ingest files or folders under a tag (extracted, chunked and embedded once)",flags:[]},{name:"knowledge query",description:"Retrieve the most relevant passages for a question, scoped to a tag",flags:["--top-k <top_k>"]},{name:"knowledge toc",description:"List a tag's documents and the headings in each",flags:[]},{name:"knowledge read",description:"Print a document, or one named section, VERBATIM (not a summary)",flags:["--section <section>"]},{name:"knowledge remove",description:"Remove ONE document from a tag (its chunks, stored text and manifest row)",flags:[]},{name:"knowledge sync",description:"Bring a tag up to date with its folders — hash-gated, prunes files that vanished",flags:[]},{name:"knowledge list",description:"List knowledge tags with document and chunk counts",flags:[]},{name:"knowledge stats",description:"Show details for one knowledge tag",flags:[]},{name:"knowledge forget",description:"Remove a tag's vectors and manifest entry",flags:[]}]},{name:"hooks",description:"Declarative lifecycle hooks — list/add/remove the rules that deny, notify or secret-scan tool calls (the same hooks.json the dashboard Hooks page edits; a hook is data, never code)",commands:[{name:"hooks list",description:"List built-in and user hooks with their seam, action and state",flags:[]},{name:"hooks add",description:"Declare a new hook (it is enabled unless --disabled is given)",flags:["--action <action>","--arg <arg>","--cwd <cwd>","--deny-on-hit","--disabled","--event <event>","--id <id>","--label <label>","--message <message>","--reason <reason>","--surface <surface>","--tool <tool>"]},{name:"hooks remove",description:"Remove a user hook (a built-in cannot be deleted — disable it instead)",flags:[]},{name:"hooks enable",description:"Turn a hook on (works on a built-in too)",flags:[]},{name:"hooks disable",description:"Turn a hook off",flags:[]}]},{name:"trace",description:"Inspect and replay per-step reasoning traces (every LLM call in a pipeline)",commands:[{name:"trace list",description:"Show recent traces",flags:["--limit <limit>"]},{name:"trace show",description:"Show a single trace (goal, timing, step summary)",flags:[]},{name:"trace replay",description:"Step-by-step replay of a trace — every LLM call with prompt digest, model, tokens, latency, and routing",flags:["--full"]},{name:"trace degraded",description:"List provider × model pairs that served steps without agentic capability (derived, read-only, from the traces)",flags:["--limit <limit>"]},{name:"trace clear",description:"Delete all stored traces",flags:[]}]},{name:"rate",description:"Rate the last turn (good|bad) — records the one label a quality signal can be fit to (also on the dashboard Trace tab)",commands:[]},{name:"decisions",description:"The must-ask decisions recorded for this project — list, search, and revise them (written by ask_user)",commands:[{name:"decisions show",description:"",flags:["--json"]},{name:"decisions revise",description:"",flags:["--answer <answer>","--note <note>"]}]},{name:"continuity",description:"Session continuity — what is stored, and how to forget it",commands:[{name:"continuity list",description:"Show the continuity switches, stored sessions, and the semantic recall index",flags:[]},{name:"continuity clear",description:"Forget stored continuity data (no flags = both sessions and recall)",flags:["--recall","--sessions"]}]},{name:"website",description:"Open the Agent-Nuvira website — capabilities, commands, docs, setup",commands:[]}],wc={commandCount:wle,groupCount:kle,groups:Sle},dE=wc.groups;function jle(e,t){return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)}function Nle({onPick:e}){const[t,n]=x.useState(""),r=x.useId(),a=t.trim().toLowerCase(),s=x.useMemo(()=>a?dE.map(l=>l.name.toLowerCase().includes(a)?l:{...l,commands:l.commands.filter(c=>jle(c,a))}).filter(l=>l.commands.length>0):dE,[a]),o=s.reduce((l,c)=>l+c.commands.length,0);return i.jsxs("section",{className:"command-browser",children:[i.jsxs("div",{className:"command-browser-head",children:[i.jsx("h2",{className:"section-title command-browser-title",children:"Browse commands"}),i.jsx("p",{className:"command-browser-count",children:a?`${o} of ${wc.commandCount} commands match “${t.trim()}”`:`${wc.commandCount} commands in ${wc.groupCount} groups`})]}),i.jsx("label",{className:"sr-only",htmlFor:r,children:"Filter commands"}),i.jsx("input",{id:r,type:"search",className:"admin-input command-browser-search",placeholder:"Filter commands — e.g. eval, memory, gateway status",value:t,onChange:l=>n(l.target.value),autoComplete:"off",spellCheck:!1}),s.length===0?i.jsxs("p",{className:"command-browser-empty",children:["No command matches “",t.trim(),"”. Clear the filter to see all ",wc.groupCount," groups."]}):i.jsx("div",{className:"command-browser-groups",children:s.map(l=>i.jsxs("details",{className:"command-group",open:a?!0:void 0,children:[i.jsxs("summary",{className:"command-group-summary",children:[i.jsx("code",{className:"command-group-name",children:l.name}),i.jsx("span",{className:"command-group-description",children:l.description}),i.jsx("span",{className:"command-group-count",children:l.commands.length})]}),i.jsx("ul",{className:"command-list",children:l.commands.map(c=>i.jsx("li",{className:"command-item",children:i.jsxs("button",{type:"button",className:"command-use",onClick:()=>e(c.name),title:`Insert “${c.name}” into the command box`,children:[i.jsx("span",{className:"command-item-name",children:c.name}),i.jsx("span",{className:"command-item-description",children:c.description}),c.flags.length>0&&i.jsx("span",{className:"command-item-flags",children:c.flags.map(u=>i.jsx("code",{children:u},u))})]})},c.name))})]},`${l.name}:${a?"filtering":"browsing"}`))})]})}const fE={running:"⏳ running",done:"✅ done",failed:"❌ failed",cancelled:"⏹ cancelled",timeout:"⏰ timed out",error:"💥 error"};function hE(e){switch(e){case"done":return"task-status-done";case"running":return"task-status-running";case"failed":return"task-status-failed";case"cancelled":return"task-status-cancelled";case"timeout":return"task-status-timeout";default:return"task-status-error"}}function Ele(e){const t=[];let n="",r=null;for(const a of e.trim())r?a===r?r=null:n+=a:a==='"'||a==="'"?r=a:/\s/.test(a)?n&&(t.push(n),n=""):n+=a;return n&&t.push(n),t}function pE(e){return e===null?"—":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function _le(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;const n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function Cle(){const[e,t]=x.useState(null),n=Kr(),[r,a]=x.useState(""),[s,o]=x.useState(300),[l,c]=x.useState(!1),[u,d]=x.useState(""),[f,h]=x.useState(null),[p,m]=x.useState([]),[g,y]=x.useState(!0),v=x.useRef(null),S=x.useRef(null),w=x.useRef(null),N=x.useCallback(async()=>{const A=await K.listTasks();A&&m(A.tasks)},[]);x.useEffect(()=>{K.fetchAdminAuthStatus().then(A=>{t(A?{configured:A.configured,authenticated:A.authenticated,role:A.role??null}:{configured:!1,authenticated:!1,role:null}),A!=null&&A.authenticated&&N()})},[N,n]),x.useEffect(()=>{var A,O;if(g&&(f==null?void 0:f.status)==="running")try{(O=(A=v.current)==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"end"})}catch{}},[f==null?void 0:f.logs.length,f==null?void 0:f.status,g]),x.useEffect(()=>()=>{var A;return(A=w.current)==null?void 0:A.call(w)},[]);const k=x.useCallback((A,O)=>{var $;if(($=w.current)==null||$.call(w),h(A),d(""),!O)return;const B=K.subscribeTask(A.id,{onLog:M=>h(D=>D&&D.id===A.id?{...D,logs:[...D.logs,M]}:D),onStatus:M=>h(D=>D&&D.id===A.id?{...D,status:M}:D)});w.current=B},[]),b=x.useCallback(async()=>{const A=Ele(r);if(A.length===0){d("Type a command first — e.g. `eval run --task smoke-test` or `gateway status`.");return}c(!0),d("");const O=await K.startTask(A,s*1e3);if(c(!1),!O.ok||!O.task){d(O.error||"Failed to start task.");return}a(""),N(),k(O.task,!0)},[r,s,k,N]),j=x.useCallback(async A=>{await K.cancelTask(A)},[]),E=x.useCallback(A=>{var O;a(`${A} `),d(""),(O=S.current)==null||O.focus()},[]),P=x.useCallback(async A=>{const O=await K.getTask(A);O!=null&&O.task&&k(O.task,!1)},[k]),_=x.useCallback(()=>{var A;(A=w.current)==null||A.call(w),h(null)},[]);return e?e.authenticated?i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsx("p",{className:"admin-subtitle",children:"Run any agent-nuvira command — the same CLI, executed by the dashboard. Messaging, skills, tools, eval, memory, traces and more."}),i.jsxs("form",{className:"task-run-form",onSubmit:A=>{A.preventDefault(),b()},children:[i.jsx("input",{ref:S,className:"admin-input task-cmd-input",placeholder:"eval run --task smoke-test · gateway status · skill list · memory stats",value:r,onChange:A=>a(A.target.value),autoComplete:"off",spellCheck:!1}),i.jsxs("select",{className:"admin-input task-timeout-select",title:"Task timeout",value:s,onChange:A=>o(Number(A.target.value)),children:[i.jsx("option",{value:60,children:"1 min"}),i.jsx("option",{value:300,children:"5 min"}),i.jsx("option",{value:600,children:"10 min"}),i.jsx("option",{value:1800,children:"30 min"})]}),i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:l||r.trim()==="",children:l?"⏳ Starting…":"▶ Run"})]}),u&&i.jsx("div",{className:"admin-error",children:u}),i.jsx("p",{className:"task-hint",children:"Long-running commands stream their output live. Runs are capped at the chosen timeout and can be cancelled."}),i.jsx(Nle,{onPick:E}),f&&i.jsxs("div",{className:"task-console-wrap",children:[i.jsxs("div",{className:"task-console-header",children:[i.jsx("code",{className:"task-console-cmd",children:f.command}),i.jsx("span",{className:`task-status ${hE(f.status)}`,children:fE[f.status]}),i.jsxs("span",{className:"task-meta",children:["exit ",f.exitCode??"—"," · ",pE(f.durationMs)]}),f.status==="running"&&i.jsx("button",{className:"admin-mini-btn task-cancel-btn",onClick:()=>void j(f.id),children:"⏹ Cancel"}),i.jsx("button",{className:"admin-mini-btn",onClick:_,children:"✕ Close"})]}),i.jsxs("div",{className:"task-console",children:[f.logs.map((A,O)=>i.jsx("div",{className:`task-line task-line-${A.stream}`,children:A.text},O)),f.logs.length===0&&f.status==="running"&&i.jsx("div",{className:"task-line task-line-system",children:"⏳ waiting for output…"}),i.jsx("div",{ref:v})]}),i.jsxs("label",{className:"task-autoscroll",children:[i.jsx("input",{type:"checkbox",checked:g,onChange:A=>y(A.target.checked)})," auto-scroll"]})]}),i.jsx("h2",{className:"task-history-title",children:"History"}),p.length===0?i.jsx("div",{className:"empty-state",children:"No tasks yet — run your first command above."}):i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table task-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Command"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Exit"}),i.jsx("th",{children:"Duration"}),i.jsx("th",{children:"When"})]})}),i.jsx("tbody",{children:p.map(A=>i.jsxs("tr",{className:(f==null?void 0:f.id)===A.id?"task-row-active":"",onClick:()=>void P(A.id),children:[i.jsx("td",{children:i.jsx("code",{children:A.command})}),i.jsx("td",{children:i.jsx("span",{className:`task-status ${hE(A.status)}`,children:fE[A.status]})}),i.jsx("td",{children:A.exitCode??"—"}),i.jsx("td",{children:pE(A.durationMs)}),i.jsx("td",{children:_le(A.startedAt)})]},A.id))})]})})]}):i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsxs("div",{className:"empty-state",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"Log in to run tasks."})," The console executes commands on this machine, so it needs an admin session (like the Agent Hub toggles)."]}),i.jsx("p",{children:e.configured?i.jsx(Jt,{className:"admin-refresh-btn",to:"/admin",children:"🔐 Log in"}):i.jsx(Jt,{className:"admin-refresh-btn",to:"/admin",children:"🔐 Create admin account"})})]})]}):i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsx("div",{className:"loading-state",children:"Loading…"})]})}function Ale(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Tle=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ole=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ple={};function mE(e,t){return(Ple.jsx?Ole:Tle).test(e)}const Rle=/[ \t\n\f\r]/g;function Mle(e){return typeof e=="object"?e.type==="text"?gE(e.value):!1:gE(e)}function gE(e){return e.replace(Rle,"")===""}class id{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}id.prototype.normal={};id.prototype.property={};id.prototype.space=void 0;function gM(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new id(n,r,t)}function Fb(e){return e.toLowerCase()}class Kn{constructor(t,n){this.attribute=n,this.property=t}}Kn.prototype.attribute="";Kn.prototype.booleanish=!1;Kn.prototype.boolean=!1;Kn.prototype.commaOrSpaceSeparated=!1;Kn.prototype.commaSeparated=!1;Kn.prototype.defined=!1;Kn.prototype.mustUseProperty=!1;Kn.prototype.number=!1;Kn.prototype.overloadedBoolean=!1;Kn.prototype.property="";Kn.prototype.spaceSeparated=!1;Kn.prototype.space=void 0;let Ile=0;const Ie=Ws(),Ft=Ws(),Ub=Ws(),le=Ws(),ut=Ws(),js=Ws(),Zn=Ws();function Ws(){return 2**++Ile}const Wb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Ft,commaOrSpaceSeparated:Zn,commaSeparated:js,number:le,overloadedBoolean:Ub,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),Gg=Object.keys(Wb);class h0 extends Kn{constructor(t,n,r,a){let s=-1;if(super(t,n),vE(this,"space",a),typeof r=="number")for(;++s<Gg.length;){const o=Gg[s];vE(this,Gg[s],(r&Wb[o])===Wb[o])}}}h0.prototype.defined=!0;function vE(e,t,n){n&&(e[t]=n)}function Rl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new h0(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Fb(r)]=r,n[Fb(s.attribute)]=r}return new id(t,n,e.space)}const vM=Rl({properties:{ariaActiveDescendant:null,ariaAtomic:Ft,ariaAutoComplete:null,ariaBusy:Ft,ariaChecked:Ft,ariaColCount:le,ariaColIndex:le,ariaColSpan:le,ariaControls:ut,ariaCurrent:null,ariaDescribedBy:ut,ariaDetails:null,ariaDisabled:Ft,ariaDropEffect:ut,ariaErrorMessage:null,ariaExpanded:Ft,ariaFlowTo:ut,ariaGrabbed:Ft,ariaHasPopup:null,ariaHidden:Ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ut,ariaLevel:le,ariaLive:null,ariaModal:Ft,ariaMultiLine:Ft,ariaMultiSelectable:Ft,ariaOrientation:null,ariaOwns:ut,ariaPlaceholder:null,ariaPosInSet:le,ariaPressed:Ft,ariaReadOnly:Ft,ariaRelevant:null,ariaRequired:Ft,ariaRoleDescription:ut,ariaRowCount:le,ariaRowIndex:le,ariaRowSpan:le,ariaSelected:Ft,ariaSetSize:le,ariaSort:null,ariaValueMax:le,ariaValueMin:le,ariaValueNow:le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function yM(e,t){return t in e?e[t]:t}function bM(e,t){return yM(e,t.toLowerCase())}const $le=Rl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:js,acceptCharset:ut,accessKey:ut,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alpha:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:ut,autoFocus:Ie,autoPlay:Ie,blocking:ut,capture:null,charSet:null,checked:Ie,cite:null,className:ut,closedBy:null,colorSpace:null,cols:le,colSpan:le,command:null,commandFor:null,content:null,contentEditable:Ft,controls:Ie,controlsList:ut,coords:le|js,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Ub,draggable:Ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:ut,height:le,hidden:Ub,high:le,href:null,hrefLang:null,htmlFor:ut,httpEquiv:ut,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:ut,itemRef:ut,itemScope:Ie,itemType:ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:le,manifest:null,max:null,maxLength:le,media:null,method:null,min:null,minLength:le,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:le,pattern:null,ping:ut,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:ut,required:Ie,reversed:Ie,rows:le,rowSpan:le,sandbox:ut,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootCustomElementRegistry:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shadowRootSerializable:Ie,shape:null,size:le,sizes:null,slot:null,span:le,spellCheck:Ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:le,step:null,style:null,tabIndex:le,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Ft,width:le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ut,axis:null,background:null,bgColor:null,border:le,borderColor:null,bottomMargin:le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:le,leftMargin:le,link:null,longDesc:null,lowSrc:null,marginHeight:le,marginWidth:le,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:le,rules:null,scheme:null,scrolling:Ft,standby:null,summary:null,text:null,topMargin:le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:le,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ie,disablePictureInPicture:Ie,disableRemotePlayback:Ie,exportParts:js,part:ut,prefix:null,property:null,results:le,security:null,unselectable:null},space:"html",transform:bM}),Lle=Rl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Zn,accentHeight:le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:le,amplitude:le,arabicForm:null,ascent:le,attributeName:null,attributeType:null,azimuth:le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:le,by:null,calcMode:null,capHeight:le,className:ut,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:le,diffuseConstant:le,direction:null,display:null,dur:null,divisor:le,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:le,enableBackground:null,end:null,event:null,exponent:le,externalResourcesRequired:null,fill:null,fillOpacity:le,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:js,g2:js,glyphName:js,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:le,horizOriginX:le,horizOriginY:le,id:null,ideographic:le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:le,k:le,k1:le,k2:le,k3:le,k4:le,kernelMatrix:Zn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:le,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:le,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:le,overlineThickness:le,paintOrder:null,panose1:null,path:null,pathLength:le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:le,pointsAtY:le,pointsAtZ:le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Zn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Zn,rev:Zn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Zn,requiredFeatures:Zn,requiredFonts:Zn,requiredFormats:Zn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:le,specularExponent:le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:le,strikethroughThickness:le,string:null,stroke:null,strokeDashArray:Zn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:le,strokeOpacity:le,strokeWidth:null,style:null,surfaceScale:le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Zn,tabIndex:le,tableValues:null,target:null,targetX:le,targetY:le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Zn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:le,underlineThickness:le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:le,values:null,vAlphabetic:le,vMathematical:le,vectorEffect:null,vHanging:le,vIdeographic:le,version:null,vertAdvY:le,vertOriginX:le,vertOriginY:le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yM}),xM=Rl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),wM=Rl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:bM}),kM=Rl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Dle={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ble=/[A-Z]/g,yE=/-[a-z]/g,zle=/^data[-\w.:]+$/i;function Fle(e,t){const n=Fb(t);let r=t,a=Kn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&zle.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(yE,Wle);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!yE.test(s)){let o=s.replace(Ble,Ule);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=h0}return new a(r,t)}function Ule(e){return"-"+e.toLowerCase()}function Wle(e){return e.charAt(1).toUpperCase()}const Hle=gM([vM,$le,xM,wM,kM],"html"),p0=gM([vM,Lle,xM,wM,kM],"svg");function Gle(e){return e.join(" ").trim()}var m0={},bE=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,qle=/\n/g,Kle=/^\s*/,Vle=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Yle=/^:\s*/,Xle=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Qle=/^[;\s]*/,Zle=/^\s+|\s+$/g,Jle=`
164
+ ⚠️ Some contacts were rejected: ${C.contactErrors.join("; ")}`:"";W({kind:ne?"warn":"ok",text:`✅ Permissions + saved contacts + status recipients saved — the running gateway applies them immediately.${ne}`}),X({}),Dn()}else C.unauthorized?(Yi(),W({kind:"err",text:C.error||"Session expired — log in again."})):W({kind:"err",text:C.error||"Failed to save permissions."});ie(!1)};if(a)return i.jsxs("div",{className:"admin-header",children:[i.jsx(Re,{icon:"🧰",title:"Agent Hub"}),i.jsxs("div",{className:"loading-state",children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("p",{children:"Loading hub…"})]})]});const Fl=!h&&A!==null;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"admin-header",children:[i.jsx(Re,{icon:"🧰",title:i.jsxs(i.Fragment,{children:["Agent Hub",y?i.jsxs("span",{className:`admin-role-badge admin-role-${m||"viewer"}`,children:[" ",y," · ",m||"viewer"]}):null]})}),i.jsxs("div",{className:"admin-header-actions",children:[i.jsxs("label",{className:"hub-reveal-toggle",children:[i.jsx("input",{type:"checkbox",checked:et,onChange:C=>Be(C.target.checked),disabled:!Bt}),"Show full ids"]}),Bt?null:i.jsx("span",{className:"admin-hint",children:"🔒 admins/operators only"}),i.jsx("button",{className:"admin-refresh-btn",onClick:()=>void Dn(),disabled:c,children:c?"⏳ Refreshing…":"🔄 Refresh"}),h?i.jsx("button",{className:"admin-logout-btn",onClick:()=>void Or(),children:"🚪 Log out"}):null]})]}),i.jsxs("p",{className:"admin-subtitle",children:["Capabilities, messaging, artifacts and skills in one place — a single 4-view management page. Toggles persist to ",i.jsx("code",{children:"buffconfig"})," and are honored by the runtime immediately (never cosmetic)."]}),o?i.jsx("div",{className:"admin-error",children:o}):null,Fl?i.jsxs("div",{className:"admin-header",children:[i.jsx("h2",{className:"section-subtitle",children:d!=null&&d.configured?`🔐 Log in to ${A.enabled?"enable":"disable"} '${A.name}'`:`🔐 Set up admin access to ${A.enabled?"enable":"disable"} '${A.name}'`}),i.jsxs("form",{className:"admin-gate-form",onSubmit:d!=null&&d.configured?Xi:hd,children:[i.jsxs("label",{children:[i.jsx("span",{children:"Username"}),i.jsx("input",{type:"text",value:S,onChange:C=>w(C.target.value),autoComplete:"username",placeholder:"admin"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"Password"}),i.jsx("input",{type:"password",value:k,onChange:C=>b(C.target.value),autoComplete:d!=null&&d.configured?"current-password":"new-password",placeholder:"••••••••"})]}),j?i.jsx("div",{className:"admin-error",children:j}):null,i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:P||!S||!k,children:P?"⏳ …":d!=null&&d.configured?"🔐 Log in & apply":"🔐 Create admin & apply"}),d!=null&&d.configured?null:i.jsxs("p",{className:"admin-hint",children:["The first user is always an admin. Automation alternative: set"," ",i.jsx("code",{children:"BUFF_DASHBOARD_ADMIN_USER"})," / ",i.jsx("code",{children:"BUFF_DASHBOARD_ADMIN_PASSWORD"}),"."]})]})]}):null,!Fl&&!Bt&&h?i.jsxs("div",{className:"admin-readonly-note",children:["🔒 Your role (",i.jsx("code",{children:m||"viewer"}),") can view but not change capabilities — toggles require the ",i.jsx("code",{children:"admin"})," or ",i.jsx("code",{children:"operator"})," role."]}):null,i.jsx("div",{className:"hub-tabs",role:"tablist",children:ple.map(C=>{var ne,ae,ue;const q=C.id==="tools"?n?`${n.toolsets.enabled}/${n.toolsets.toolsets.length}`:"":C.id==="channels"?n?String(n.channels.delivery.total):"":C.id==="conversations"?n?String(((ne=n.conversations)==null?void 0:ne.total)??0):"":C.id==="artifacts"?n?String(n.artifacts.totalSessions):"":C.id==="subagents"?n?`${((ae=n.subagents)==null?void 0:ae.running)??0}/${((ue=n.subagents)==null?void 0:ue.total)??0}`:"":n?`${n.skills.enabled}/${n.skills.total}`:"";return i.jsxs("button",{role:"tab","aria-selected":e===C.id,className:`hub-tab${e===C.id?" active":""}`,onClick:()=>t(C.id),children:[C.icon," ",C.label,q?i.jsx("span",{className:"hub-tab-count",children:q}):null]},C.id)})}),e==="tools"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.enabled}),i.jsx("div",{className:"admin-summary-label",children:"Enabled toolsets"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.disabled}),i.jsx("div",{className:"admin-summary-label",children:"Disabled toolsets"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.toolsets.totalTools}),i.jsx("div",{className:"admin-summary-label",children:"Registered tools"})]})]}),i.jsx("div",{className:"hub-toolset-grid",children:n.toolsets.toolsets.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.label}),i.jsx("span",{className:"hub-card-id",children:C.name})]}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.label}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.name||A!==null||h&&!Bt,onClick:()=>Ll(C.name,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsx("div",{className:"hub-card-tools",children:C.tools.length>0?C.tools.map(q=>i.jsx("span",{className:"hub-chip",children:q},q)):i.jsx("span",{className:"admin-hint",children:"gates dynamic MCP tools (no static names)"})}),M[C.name]?i.jsx("div",{className:"admin-row-msg",children:M[C.name]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Removed from the model schema — calls return an explicit error"})]},C.name))})]}):null,e==="channels"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.pending}),i.jsx("div",{className:"admin-summary-label",children:"⏳ Queued for retry"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.sent}),i.jsx("div",{className:"admin-summary-label",children:"✅ Delivered"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.delivery.failed}),i.jsx("div",{className:"admin-summary-label",children:"❌ Failed (max retries)"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.channels.aliases.length}),i.jsx("div",{className:"admin-summary-label",children:"Channel aliases"})]})]}),i.jsx("h2",{className:"section-subtitle",children:"📮 Delivery ledger (guaranteed delivery)"}),n.channels.delivery.recent.length>0?i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Target"}),i.jsx("th",{children:"Platform"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Attempts"}),i.jsx("th",{children:"Next retry"}),i.jsx("th",{children:"Message"})]})}),i.jsx("tbody",{children:n.channels.delivery.recent.map(C=>i.jsxs("tr",{children:[i.jsx("td",{className:"admin-provider-type",children:hr(C.target)}),i.jsx("td",{children:C.platform}),i.jsx("td",{children:i.jsx("span",{className:`admin-check-badge admin-check-${C.status==="sent"?"pass":C.status==="failed"?"fail":"warn"}`,children:mle[C.status]||C.status})}),i.jsxs("td",{children:[C.attempts,"/5"]}),i.jsx("td",{children:C.status==="pending"?`${Math.max(0,Math.round((C.nextAttemptAt-Date.now())/1e3))}s`:"—"}),i.jsx("td",{className:"admin-hint",children:C.lastError?`⚠️ ${C.lastError}`:(C.text||"").slice(0,60)})]},C.id))})]})}):i.jsx("div",{className:"empty-state",children:"Delivery ledger is empty — every gateway send has gone through."}),i.jsx("h2",{className:"section-subtitle",children:"📥 Inbox (received messages)"}),n.channels.inbox.recent.length>0?i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Platform"}),i.jsx("th",{children:"From"}),i.jsx("th",{children:"Message"}),i.jsx("th",{children:"Handled"}),i.jsx("th",{children:"When"})]})}),i.jsx("tbody",{children:n.channels.inbox.recent.map(C=>i.jsxs("tr",{children:[i.jsxs("td",{className:"admin-provider-type",children:[C.platform,C.isGroup?i.jsx("span",{className:"hub-chip",children:"group"}):null]}),i.jsx("td",{children:hr(C.from||C.senderId||C.channelId)}),i.jsx("td",{className:"admin-hint",children:(C.text||"").slice(0,60)}),i.jsxs("td",{children:[i.jsx("span",{className:`admin-check-badge admin-check-${C.handled==="pipeline"?"pass":C.handled==="refused"?"fail":"warn"}`,children:C.handled}),C.reply?i.jsx("div",{className:"admin-hint",children:C.reply.slice(0,C.handled==="attachment_failed"?160:40)}):null]}),i.jsx("td",{className:"admin-hint",children:new Date(C.at).toLocaleString()})]},C.id))})]})}):i.jsx("div",{className:"empty-state",children:"Inbox is empty — messages the gateway receives will appear here."}),i.jsxs("p",{className:"admin-hint",children:[n.channels.inbox.total," received · ",n.channels.inbox.pipeline," triggered the pipeline ·"," ",n.channels.inbox.help," got the help line · ",n.channels.inbox.refused," refused by policy ·"," ",n.channels.inbox.duplicate??0," duplicate re-deliveries ignored ·"," ",n.channels.inbox.attachmentFailed??0," attachment(s) could not be read."]}),i.jsx("h2",{className:"section-subtitle",children:"🔌 Platform transports"}),i.jsx(fle,{canWrite:Bt,sessionExpired:Yi,mode:"table"}),i.jsx("h2",{className:"section-subtitle",children:"🔗 Channel aliases (buff gateway status)"}),n.channels.aliases.length>0?i.jsx("div",{className:"hub-alias-list",children:n.channels.aliases.map(C=>i.jsxs("div",{className:"hub-alias-row",children:[i.jsx("span",{className:"hub-chip",children:C.alias}),i.jsxs("span",{className:"admin-hint",children:["→ ",C.platform,":",hr(C.channelId)]})]},C.alias))}):i.jsxs("div",{className:"empty-state",children:["No aliases yet — register one with ",i.jsx("code",{children:"buff gateway alias <name> <platform> <channelId>"}),"."]}),vd?i.jsxs("div",{className:"hub-unsaved-banner",role:"status",children:[i.jsxs("span",{children:["⚠️ ",i.jsx("strong",{children:"Unsaved changes"})," — what you see below is a ",i.jsx("em",{children:"draft"}),". Press"," ",i.jsx("strong",{children:"💾 Save permissions"})," to apply it to the gateway; leaving the page discards it."]}),i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>void Qr(),children:Y?"⏳ Saving…":"💾 Save permissions"})]}):null,i.jsx("div",{style:{cursor:"pointer",userSelect:"none",display:"flex",alignItems:"center",gap:8,marginBottom:8},onClick:()=>ge(!he),children:i.jsxs("h2",{className:"section-subtitle",style:{margin:0},children:[he?"▼":"▶"," 🔐 Permissions — who can TRIGGER the agent"]})}),i.jsxs("p",{className:"admin-hint",style:{marginBottom:he?10:0},children:["This list controls ",i.jsx("strong",{children:"who may trigger the agent"})," when they message you on each platform (WhatsApp, Telegram, email, …). Click to ",he?"collapse":"expand"," and manage permissions."]}),he?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"admin-hint",style:{marginBottom:10},children:["⚠ ",i.jsx("strong",{children:"Not the same as send-by-name contacts:"})," a WhatsApp contact name (from"," ",i.jsx("code",{children:"buff whatsapp contact add"}),", shown in the WhatsApp bridge panel below) only lets"," ",i.jsx("em",{children:"you"})," send ",i.jsx("em",{children:"to"})," it by name — it does ",i.jsx("strong",{children:"not"})," let that number trigger the agent. Add the number here (or ",i.jsx("code",{children:"buff config gateway allow <platform> user <id>"}),") to grant inbound access."]}),i.jsx("div",{className:"hub-permissions",children:n.channels.platforms.map(C=>{const q={...n.channels.policies[C.platform]??{},...Te[C.platform]??{}},ne=q.allowedUsers??[],ae=q.allowedGroups??[];return i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsx("span",{className:"hub-chip",children:C.label}),i.jsx("span",{className:"hub-card-id",children:C.platform}),q.disabled?i.jsx("span",{className:"hub-chip",children:"disabled"}):null]}),i.jsx("div",{className:"admin-hint",style:{margin:"4px 0 8px"},children:"Allowed users — who may trigger the agent"}),i.jsxs("div",{className:"hub-alias-list",children:[ne.length===0?i.jsxs("span",{className:"admin-hint",children:["(blank — no one may trigger; add ",i.jsx("code",{children:"Allow-All"})," to allow everyone)"]}):null,ne.map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.allowedUsers)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.allowedUsers)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[hr(ue),Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>gd(C.platform,ue),children:"✕"})]},`u-${ue}`)})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:Se[C.platform]??"",onChange:ue=>$e(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"Name (optional)",disabled:Y}),i.jsx("input",{type:"text",value:xe[C.platform]??"",onChange:ue=>we(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"Contact no / sender id, or Allow-All",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(xe[C.platform]??"").trim(),onClick:()=>md(C.platform),children:"+ User"})]}),i.jsx("div",{className:"admin-hint",style:{margin:"4px 0 8px"},children:"Allowed groups"}),i.jsxs("div",{className:"hub-alias-list",children:[ae.length===0?i.jsx("span",{className:"admin-hint",children:"(none — any group may trigger)"}):null,ae.map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.allowedGroups)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.allowedGroups)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[ue,Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Bl(C.platform,"group",ue),children:"✕"})]},`g-${ue}`)})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:_e[C.platform]??"",onChange:ue=>ve(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"group id, e.g. 1203630283471234@g.us",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(_e[C.platform]??"").trim(),onClick:()=>{Dl(C.platform,"group",_e[C.platform]??""),ve(ue=>({...ue,[C.platform]:""}))},children:"+ Group"})]}),i.jsx("div",{className:"admin-hint",style:{margin:"12px 0 4px"},children:"Send authority — who may tell the agent to send to OTHER people"}),i.jsx("div",{className:"admin-hint",style:{margin:"0 0 6px",opacity:.8},children:(q.outboundSenders??[]).length===0?"Open — anyone above who can trigger the agent can also direct outbound sends. Add senders to restrict it.":"Restricted to the senders below (Allow-All = everyone)."}),i.jsx("div",{className:"hub-alias-list",children:(q.outboundSenders??[]).map(ue=>{var Tt,Ot,ke,Pt;const Pe=(((Tt=Te[C.platform])==null?void 0:Tt.outboundSenders)??[]).includes(ue)&&!(((Pt=(ke=(Ot=n==null?void 0:n.channels)==null?void 0:Ot.policies)==null?void 0:ke[C.platform])==null?void 0:Pt.outboundSenders)??[]).includes(ue);return i.jsxs("div",{className:"hub-alias-row",children:[i.jsxs("span",{className:`hub-chip${Pe?" hub-chip-pending":""}`,title:Pe?"Not saved yet — press 💾 Save permissions":void 0,children:[hr(ue),Pe?" · unsaved":""]}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Bl(C.platform,"send",ue),children:"✕"})]},`s-${ue}`)})}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 10px"},children:[i.jsx("input",{type:"text",value:Le[C.platform]??"",onChange:ue=>pe(Pe=>({...Pe,[C.platform]:ue.target.value})),placeholder:"sender id, or Allow-All",disabled:Y}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!(Le[C.platform]??"").trim(),onClick:()=>{Dl(C.platform,"send",Le[C.platform]??""),pe(ue=>({...ue,[C.platform]:""}))},children:"+ Sender"})]}),i.jsxs("div",{className:"hub-send-form",style:{margin:"6px 0 0"},children:[i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:q.silentDrop!==!1,disabled:Y,onChange:()=>Qs(C.platform,"silentDrop")}),i.jsx("span",{className:"admin-hint",children:"Silent (no reply to unapproved) — default"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:!!q.requireMention,disabled:Y,onChange:()=>Qs(C.platform,"requireMention")}),i.jsx("span",{className:"admin-hint",children:"Groups: mention only"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6,marginRight:12},children:[i.jsx("input",{type:"checkbox",checked:!!q.disabled,disabled:Y,onChange:()=>Qs(C.platform,"disabled")}),i.jsx("span",{className:"admin-hint",children:"Disabled (off)"})]}),i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[i.jsx("input",{type:"checkbox",checked:!!q.requireApprovedTarget,disabled:Y,onChange:()=>Qs(C.platform,"requireApprovedTarget")}),i.jsx("span",{className:"admin-hint",children:"Require approved recipients for sends"})]})]})]},C.platform)})})]}):null,i.jsx("h2",{className:"section-subtitle",style:{marginTop:22},children:"📇 Telegram User Onboarding"}),i.jsxs("div",{className:"onboarding-summary",children:[i.jsx("p",{className:"admin-hint",style:{marginBottom:12},children:"Users who message your bot are auto-registered here. Approve them to enable outbound messaging."}),(()=>{const C=Ln.filter(ae=>ae.status==="pending").length,q=Ln.filter(ae=>ae.status==="approved").length,ne=Ln.filter(ae=>ae.status==="rejected").length;return i.jsxs("div",{className:"onboarding-stats",children:[i.jsxs("span",{className:"onboarding-stat pending",children:["⏳ ",C," pending"]}),i.jsxs("span",{className:"onboarding-stat approved",children:["✅ ",q," approved"]}),i.jsxs("span",{className:"onboarding-stat rejected",children:["🚫 ",ne," rejected"]})]})})(),i.jsxs("div",{className:"onboarding-steps",children:[i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"1"}),i.jsxs("span",{children:["User sends any message to ",i.jsx("code",{children:"@agent_nuvira_bot"})]})]}),i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"2"}),i.jsxs("span",{children:["Bot auto-registers them as ",i.jsx("strong",{children:"⏳ pending"})]})]}),i.jsxs("div",{className:"onboarding-step",children:[i.jsx("span",{className:"onboarding-step-num",children:"3"}),i.jsx("span",{children:"Admin approves → they can receive outbound messages"})]})]}),i.jsx("a",{href:"/contacts",className:"admin-refresh-btn",style:{marginTop:12,display:"inline-block",textDecoration:"none"},children:"📋 Go to Contacts tab to manage →"})]}),i.jsx("h2",{className:"section-subtitle",style:{marginTop:22},children:"📊 Status recipients"}),i.jsxs("p",{className:"admin-hint",children:["Contacts/groups that ALWAYS receive the pipeline completion summary, whoever triggered it. Use a contact name, number, or ",i.jsx("code",{children:"platform:channelId"})," — e.g."," ",i.jsx("code",{children:"whatsapp:Name"}),", ",i.jsx("code",{children:"whatsapp:+91***"}),", ",i.jsx("code",{children:"telegram:123456"}),","," ",i.jsx("code",{children:"slack:ops"}),"."]}),jt.length>0?i.jsx("div",{className:"hub-alias-list",children:jt.map(C=>{var q,ne;return i.jsxs("div",{className:"hub-alias-row",children:[i.jsx("span",{className:"hub-chip",children:"📊"}),i.jsx("span",{className:"admin-hint",children:((ne=(q=n==null?void 0:n.channels)==null?void 0:q.statusRecipientDisplay)==null?void 0:ne[C])??C}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y,onClick:()=>Sa(ae=>ae.filter(ue=>ue!==C)),children:"✕"})]},C)})}):i.jsx("div",{className:"empty-state",style:{padding:"14px"},children:"No status recipients — add one below."}),i.jsxs("div",{className:"hub-send-form",children:[i.jsx("input",{type:"text",value:Xr,onChange:C=>Ys(C.target.value),placeholder:"whatsapp:Name or whatsapp:+91***",disabled:Y,maxLength:128}),i.jsx("button",{className:"admin-refresh-btn",disabled:Y||!Xr.trim()||jt.includes(Xr.trim()),onClick:()=>{Sa(C=>[...C,Xr.trim()]),Ys("")},children:"+ Add"})]}),i.jsxs("div",{className:"hub-send-form",style:{marginTop:10},children:[i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>void Qr(),children:Y?"⏳ Saving…":"💾 Save permissions"}),Object.keys(Te).length>0?i.jsx("button",{className:"admin-refresh-btn",type:"button",disabled:Y,onClick:()=>X({}),children:"Discard draft"}):null]}),de?i.jsx("div",{className:`admin-row-msg${de.kind==="err"?" admin-row-msg-err":""}`,children:de.text}):null,i.jsx("h2",{className:"section-subtitle",children:"📤 Test a channel (buff gateway send)"}),i.jsxs("form",{className:"hub-send-form",onSubmit:C=>void Tm(C),children:[i.jsxs("label",{className:"hub-send-target",children:[i.jsx("span",{className:"admin-hint",children:"Target — an alias or platform:channelId"}),i.jsx("input",{type:"text",value:U,onChange:C=>R(C.target.value),placeholder:"ops or slack:C0123 or email:team@example.com",disabled:Z,maxLength:128})]}),i.jsxs("label",{className:"hub-send-message",children:[i.jsx("span",{className:"admin-hint",children:"Message"}),i.jsx("input",{type:"text",value:z,onChange:C=>T(C.target.value),placeholder:"nightly build done 🎉",disabled:Z,maxLength:4e3})]}),i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:Z||!U.trim()||!z,children:Z?"⏳ Sending…":"📤 Send test message"})]}),I?i.jsx("div",{className:`admin-row-msg${I.kind==="ok"?"":" admin-row-msg-err"}`,children:I.text}):null,i.jsxs("p",{className:"admin-hint",children:["Sends through the same gateway the CLI uses — the dashboard process must have the platform's env token set (e.g. ",i.jsx("code",{children:"BUFF_SMTP_HOST"}),"). Requires admin or operator."]}),i.jsx("h2",{className:"section-subtitle",children:"🟢 WhatsApp bridge (buff whatsapp pair)"}),i.jsx(dle,{authed:h,canWrite:Bt,sessionExpired:Yi,reveal:et})]}):null,e==="conversations"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((J=n.conversations)==null?void 0:J.total)??0}),i.jsx("div",{className:"admin-summary-label",children:"Stored conversations"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>Date.now()-C.lastActiveAt<864e5).length}),i.jsx("div",{className:"admin-summary-label",children:"Active today"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>C.platform==="whatsapp").length}),i.jsx("div",{className:"admin-summary-label",children:"WhatsApp"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:At.filter(C=>C.platform==="telegram").length}),i.jsx("div",{className:"admin-summary-label",children:"Telegram"})]})]}),((te=n.conversations)==null?void 0:te.analytics)&&n.conversations.analytics.totalConversations>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"admin-refresh-btn",onClick:()=>ce(!Q),style:{marginBottom:12},children:Q?"📊 Hide Analytics":"📊 Show Analytics"}),Q?i.jsxs("div",{className:"hub-session-list",style:{marginBottom:16},children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.totalMessages}),i.jsx("div",{className:"admin-summary-label",children:"Total messages"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgMessagesPerConversation}),i.jsx("div",{className:"admin-summary-label",children:"Avg msgs/conversation"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgUserMessageLength}),i.jsx("div",{className:"admin-summary-label",children:"Avg user msg length"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.conversations.analytics.avgAssistantMessageLength}),i.jsx("div",{className:"admin-summary-label",children:"Avg assistant msg length"})]})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"🏆 Most Active Contacts"})})}),i.jsx("div",{style:{marginTop:8},children:n.conversations.analytics.topContacts.map((C,q)=>{var ue;const ne=((ue=n.conversations.analytics.topContacts[0])==null?void 0:ue.messageCount)||1,ae=Math.round(C.messageCount/ne*100);return i.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6,fontSize:13},children:[i.jsx("span",{style:{width:24,textAlign:"center",fontWeight:600,color:q<3?"var(--accent-yellow)":"var(--muted)"},children:q===0?"🥇":q===1?"🥈":q===2?"🥉":`${q+1}.`}),i.jsxs("span",{style:{flex:1,marginLeft:8},children:[C.platform==="whatsapp"?"📱":"✈️"," ",C.name]}),i.jsx("span",{style:{width:60,textAlign:"right",fontWeight:600},children:C.messageCount}),i.jsx("div",{style:{width:100,height:8,background:"var(--border)",borderRadius:4,marginLeft:8},children:i.jsx("div",{style:{width:`${ae}%`,height:"100%",background:"var(--accent-blue)",borderRadius:4}})})]},q)})})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"🕐 Peak Hours"})})}),i.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:80,marginTop:8,gap:2},children:n.conversations.analytics.hourlyDistribution.map(({hour:C,count:q})=>{const ne=Math.max(...n.conversations.analytics.hourlyDistribution.map(ue=>ue.count),1),ae=Math.round(q/ne*70);return i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:i.jsx("div",{style:{width:"100%",height:ae,background:C>=9&&C<=21?"var(--accent-blue)":"var(--text-muted)",borderRadius:2},title:`${C}:00 — ${q} messages`})},C)})}),i.jsx("div",{style:{display:"flex",fontSize:10,color:"var(--muted)",marginTop:4},children:[0,6,12,18,23].map(C=>i.jsxs("span",{style:{flex:1,textAlign:C===0?"left":C===23?"right":"center"},children:[C,":00"]},C))})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"📱 Platform Breakdown"})})}),i.jsx("div",{style:{marginTop:8},children:n.conversations.analytics.platformBreakdown.map(C=>i.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6,fontSize:13},children:[i.jsx("span",{className:"hub-chip",style:{width:80,textAlign:"center"},children:C.platform}),i.jsxs("span",{style:{marginLeft:8,flex:1},children:[C.conversations," conversations"]}),i.jsxs("span",{style:{fontWeight:600},children:[C.messages," msgs"]})]},C.platform))})]}),i.jsxs("div",{className:"hub-card",style:{marginTop:12},children:[i.jsx("div",{className:"hub-card-top",children:i.jsx("div",{className:"hub-card-title",children:i.jsx("span",{className:"hub-card-name",children:"📈 Daily Volume (14 days)"})})}),i.jsx("div",{style:{display:"flex",alignItems:"flex-end",height:60,marginTop:8,gap:2},children:n.conversations.analytics.dailyVolume.map(({date:C,count:q})=>{const ne=Math.max(...n.conversations.analytics.dailyVolume.map(ue=>ue.count),1),ae=Math.round(q/ne*50);return i.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:i.jsx("div",{style:{width:"100%",height:ae,background:"var(--accent-green)",borderRadius:2},title:`${C}: ${q} messages`})},C)})}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--muted)",marginTop:4},children:[i.jsx("span",{children:(je=n.conversations.analytics.dailyVolume[0])==null?void 0:je.date}),i.jsx("span",{children:(Cn=n.conversations.analytics.dailyVolume[n.conversations.analytics.dailyVolume.length-1])==null?void 0:Cn.date})]})]})]}):null]}),i.jsx("h2",{className:"section-subtitle",children:"💬 Per-contact chat history"}),i.jsx("p",{className:"admin-hint",children:"Conversation history is stored per-contact and survives gateway restarts. Messages older than 7 days are auto-pruned. Click a conversation to expand the full chat thread."}),At.length>0||ze?i.jsxs(i.Fragment,{children:[Vn.length>0&&i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginBottom:8},children:[i.jsx("span",{className:"admin-hint",style:{marginRight:4},children:"Filter by tag:"}),Vn.map(C=>i.jsxs("button",{type:"button",onClick:()=>hn(Dt===C?"":C),style:{padding:"2px 10px",borderRadius:12,fontSize:11,cursor:"pointer",border:`1px solid ${Dt===C?"var(--accent-blue)":"var(--border)"}`,background:Dt===C?"color-mix(in srgb, var(--accent-blue) 13%, transparent)":"transparent",color:Dt===C?"var(--accent-blue)":"var(--muted)"},children:["🏷️ ",C]},C))]}),i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,flexWrap:"wrap"},children:[i.jsx("input",{type:"text",value:Ge,onChange:C=>wt(C.target.value),placeholder:"🔍 Search by contact name, phone number, or message content…",style:{flex:1,minWidth:200}}),i.jsxs("span",{className:"admin-hint",children:[Tr," conversation",Tr===1?"":"s",Ge?` matching "${Ge}"`:""]}),i.jsx("button",{type:"button",className:"admin-refresh-btn",onClick:qs,style:{fontSize:12,padding:"4px 10px"},children:Oe.size===At.length?"☑ Deselect All":"☐ Select All"}),Oe.size>0&&i.jsx("button",{type:"button",className:"admin-refresh-btn",disabled:De,onClick:()=>void Qa(),style:{fontSize:12,padding:"4px 10px",background:"var(--accent-blue)",color:"var(--text-on-accent)",border:"none"},children:De?"⏳ Exporting…":`📦 Export ${Oe.size} as ZIP`})]}),i.jsxs("div",{className:"hub-session-list",children:[At.filter(C=>!Dt||(C.tags??[]).includes(Dt)).map(C=>{const q=Date.now()-C.lastActiveAt,ne=q<6e4?"just now":q<36e5?`${Math.round(q/6e4)}m ago`:q<864e5?`${Math.round(q/36e5)}h ago`:`${Math.round(q/864e5)}d ago`,ae=Me===C.key,{name:ue,phone:Pe}=_m(C),Tt=async ke=>{if(ke.stopPropagation(),!h||!Bt){W({kind:"err",text:"🔐 Log in (admin/operator) to clear conversations."});return}G(C.key);try{await K.clearGatewayConversation(C.key),Dn()}catch{}G(null)},Ot=Oe.has(C.key);return i.jsxs("div",{className:"hub-card",style:{cursor:"pointer",borderLeft:`3px solid ${C.platform==="whatsapp"?"#25d366":C.platform==="telegram"?"#0088cc":"var(--text-muted)"}`,opacity:Oe.size>0&&!Ot?.5:1,transition:"opacity 0.2s"},onClick:()=>at(ae?null:C.key),children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[i.jsx("input",{type:"checkbox",checked:Ot,onClick:ke=>ya(C.key,ke),onChange:()=>{},style:{cursor:"pointer",width:16,height:16}}),i.jsxs("div",{className:"hub-card-title",children:[i.jsxs("span",{className:"hub-card-name",children:[C.platform==="whatsapp"?"📱":C.platform==="telegram"?"✈️":"💬"," ",ue]}),i.jsxs("span",{className:"hub-card-id",children:[Pe&&i.jsx("span",{style:{color:"var(--text-secondary, var(--text-secondary))",marginRight:6},children:Pe}),C.platform," · ",ne]})]})]}),i.jsxs("div",{className:"hub-card-actions",style:{gap:6},children:[i.jsxs("span",{className:"hub-chip",children:[C.messageCount," msgs"]}),ae&&C.messages&&C.messages.length>0&&i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"hub-mini-btn",onClick:ke=>Xn(C,ke),title:"Export as text file",children:"📄"}),i.jsx("button",{type:"button",className:"hub-mini-btn",onClick:ke=>Ks(C,ke),title:"Export as PDF (opens print dialog)",children:"📑"})]}),i.jsx("button",{type:"button",className:"hub-mini-btn",disabled:fn===C.key,onClick:Tt,title:"Clear conversation history",style:{color:"var(--accent-red)"},children:"🗑️"}),i.jsx("span",{style:{fontSize:18,transition:"transform 0.2s",transform:ae?"rotate(180deg)":"none"},children:"▼"})]})]}),i.jsxs("p",{className:"hub-card-desc",style:{fontStyle:"italic",color:"var(--text-muted, var(--text-muted))"},children:[i.jsx("span",{style:{color:"var(--text-primary, var(--text-primary))",fontWeight:500},children:"Last message:"})," ",C.lastUserMessage.slice(0,120),C.lastUserMessage.length>120?"…":""]}),i.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:4},children:[(C.tags??[]).map(ke=>i.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,padding:"2px 8px",borderRadius:12,fontSize:11,background:"color-mix(in srgb, var(--accent-blue) 13%, transparent)",color:"var(--accent-blue)",border:"1px solid color-mix(in srgb, var(--accent-blue) 25%, transparent)"},children:["🏷️ ",ke,i.jsx("button",{type:"button",onClick:Pt=>{Pt.stopPropagation(),qi(C.key,ke)},style:{background:"none",border:"none",color:"var(--accent-blue)",cursor:"pointer",padding:0,fontSize:12,lineHeight:1},children:"×"})]},ke)),Vr===C.key?i.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:i.jsx("input",{type:"text",value:_n,onChange:ke=>ur(ke.target.value),onKeyDown:ke=>{ke.key==="Enter"&&Gi(C.key,_n),ke.key==="Escape"&&(Yn(null),ur(""))},placeholder:"tag name",autoFocus:!0,onClick:ke=>ke.stopPropagation(),style:{width:80,padding:"1px 6px",fontSize:11,borderRadius:8,border:"1px solid var(--border)"}})}):i.jsx("button",{type:"button",onClick:ke=>{ke.stopPropagation(),Yn(C.key),ur("")},style:{display:"inline-flex",alignItems:"center",gap:2,padding:"2px 8px",borderRadius:12,fontSize:11,background:"var(--border)",color:"var(--muted)",border:"none",cursor:"pointer"},children:"+ tag"})]}),ae&&C.messages&&C.messages.length>0?i.jsxs("div",{className:"conversation-thread",style:{marginTop:10,borderTop:"1px solid var(--border)",paddingTop:10,maxHeight:400,overflowY:"auto"},children:[C.messages.map((ke,Pt)=>i.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",alignItems:ke.role==="user"?"flex-end":"flex-start"},children:[i.jsxs("div",{style:{maxWidth:"80%",padding:"8px 12px",borderRadius:12,backgroundColor:ke.role==="user"?"var(--accent-blue)":"var(--bg-card, var(--bg-card))",color:ke.role==="user"?"var(--text-on-accent)":"var(--text-primary, var(--text-primary))",fontSize:13,lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[ke.content.slice(0,500),ke.content.length>500?"…":""]}),i.jsxs("span",{style:{fontSize:10,color:"var(--muted)",marginTop:2,padding:"0 4px"},children:[ke.role==="user"?"👤":"🤖"," ",new Date(ke.ts).toLocaleString()]})]},Pt)),me.has(C.key)&&i.jsxs("div",{style:{marginBottom:8,display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[i.jsxs("div",{style:{padding:"8px 16px",borderRadius:12,backgroundColor:"var(--bg-card, var(--bg-card))",fontSize:13,display:"flex",alignItems:"center",gap:4},children:[i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out"},children:"●"}),i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out 0.2s"},children:"●"}),i.jsx("span",{style:{animation:"typingBlink 1.4s infinite ease-in-out 0.4s"},children:"●"})]}),i.jsx("span",{style:{fontSize:10,color:"var(--muted)",marginTop:2,padding:"0 4px"},children:"🤖 typing…"})]})]}):ae?i.jsx("p",{className:"admin-hint",style:{marginTop:8},children:"No message details available."}):null]},C.key)}),an&&!ze&&i.jsx("div",{ref:Hi,style:{height:1}}),ze&&i.jsxs("div",{className:"loading-state",style:{padding:12},children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("span",{className:"admin-hint",style:{marginLeft:8},children:"Loading more conversations…"})]}),!ze&&!an&&At.length>0&&i.jsxs("p",{className:"admin-hint",style:{textAlign:"center",padding:12},children:["All ",Tr," conversation",Tr===1?"":"s"," loaded."]})]})]}):ze?i.jsxs("div",{className:"loading-state",children:[i.jsx("div",{className:"loading-spinner"}),i.jsx("p",{className:"admin-hint",children:"Loading conversations…"})]}):i.jsx("div",{className:"empty-state",children:"No conversations stored yet. Conversations are created when users message the agent via WhatsApp/Telegram/etc."})]}):null,e==="artifacts"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.artifacts.totalSessions}),i.jsx("div",{className:"admin-summary-label",children:"Sessions"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.artifacts.totalArtifacts}),i.jsx("div",{className:"admin-summary-label",children:"Artifacts"})]})]}),n.artifacts.sessions.length>0?i.jsx("div",{className:"hub-session-list",children:n.artifacts.sessions.map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsx("div",{className:"hub-card-top",children:i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.sessionId}),i.jsxs("span",{className:"hub-card-id",children:[C.count," artifact",C.count===1?"":"s"," · ",new Date(C.latestAt).toLocaleString()]})]})}),C.recent.length>0?i.jsx("ul",{className:"hub-artifact-list",children:C.recent.map((q,ne)=>i.jsxs("li",{children:[i.jsx("span",{className:"hub-chip",children:q.kind}),i.jsx("span",{className:"hub-artifact-title",children:q.title||"(untitled)"}),q.preview?i.jsx("div",{className:"hub-artifact-preview",children:q.preview}):null]},ne))}):i.jsx("div",{className:"admin-hint",children:"No artifact details."})]},C.sessionId))}):i.jsx("div",{className:"empty-state",children:"No artifacts yet — tools that return a deliverable payload land here per session."})]}):null,e==="skills"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.enabled}),i.jsx("div",{className:"admin-summary-label",children:"Enabled skills"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.disabled}),i.jsx("div",{className:"admin-summary-label",children:"Disabled skills"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:n.skills.hub.length}),i.jsx("div",{className:"admin-summary-label",children:"Hub skills (SKILL.md)"})]})]}),i.jsx("h2",{className:"section-subtitle",children:"📚 Compiled skills (SkillStore — matched at plan time)"}),n.skills.compiled.length>0?i.jsx("div",{className:"hub-session-list",children:n.skills.compiled.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsxs("span",{className:"hub-card-id",children:[C.id,C.version?` · v${C.version}`:""]})]}),i.jsxs("div",{className:"hub-card-actions",children:[C.bundled===!0?i.jsx("span",{className:"hub-chip hub-chip-bundled",children:"🧠 bundled"}):i.jsx("span",{className:"hub-chip",children:"community"}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.name}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.id||A!==null||h&&!Bt,onClick:()=>Xs(C.id,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[typeof C.usageCount=="number"?i.jsxs("span",{className:"hub-chip",children:[C.usageCount," uses"]}):null,C.enabled?null:i.jsx("span",{className:"hub-chip",children:"disabled"})]}),M[C.id]?i.jsx("div",{className:"admin-row-msg",children:M[C.id]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Excluded from skill matching — not injected into the planner"})]},`c-${C.id}`))}):i.jsx("div",{className:"empty-state",children:"No compiled skills."}),i.jsx("h2",{className:"section-subtitle",children:"🌍 Hub skills (installed SKILL.md)"}),n.skills.hub.length>0?i.jsx("div",{className:"hub-session-list",children:n.skills.hub.map(C=>i.jsxs("div",{className:`hub-card${C.enabled?"":" hub-card-disabled"}`,children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsx("span",{className:"hub-card-id",children:C.id})]}),i.jsxs("div",{className:"hub-card-actions",children:[i.jsx("button",{type:"button",className:"hub-mini-btn",disabled:re===C.id||h&&!Bt,onClick:()=>void fd(C.id),children:"🗑 Uninstall"}),i.jsx("button",{role:"switch","aria-checked":C.enabled,"aria-label":`${C.enabled?"Disable":"Enable"} ${C.name}`,className:`hub-switch${C.enabled?" on":""}`,disabled:B===C.id||A!==null||h&&!Bt,onClick:()=>Xs(C.id,!C.enabled),children:i.jsx("span",{className:"hub-switch-knob"})})]})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsx("span",{className:"hub-chip",children:"SKILL.md"}),C.enabled?null:i.jsx("span",{className:"hub-chip",children:"disabled"})]}),M[C.id]?i.jsx("div",{className:"admin-row-msg",children:M[C.id]}):null,C.enabled?null:i.jsx("div",{className:"hub-card-note",children:"⛔ Excluded from skill matching — not injected into the planner"})]},`h-${C.id}`))}):i.jsxs("div",{className:"empty-state",children:["No hub skills installed — search the marketplace below or run ",i.jsx("code",{children:"buff skills install <name>"}),"."]}),i.jsx("h2",{className:"section-subtitle",children:"🛒 Marketplace (community skills)"}),i.jsxs("form",{className:"hub-market-search",onSubmit:Cm,children:[i.jsx("input",{type:"text",value:ba,onChange:C=>Ki(C.target.value),placeholder:"Search community skills (e.g. code-assist, deploy, testing)…"}),i.jsx("button",{type:"submit",className:"admin-refresh-btn",disabled:wa,children:wa?"Searching…":"🔎 Search"})]}),Vi?i.jsx("div",{className:`admin-row-msg${Vi.kind==="err"?" admin-row-msg-err":""}`,children:Vi.text}):null,$l&&!wa?Il.length>0?i.jsx("div",{className:"hub-session-list",children:Il.map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.name}),i.jsxs("span",{className:"hub-card-id",children:["v",C.version," · ",C.sourceKind]})]}),i.jsx("button",{type:"button",className:"admin-refresh-btn",disabled:re===C.name||h&&!Bt,onClick:()=>void Am(C.name),children:re===C.name?"Installing…":"⬇ Install"})]}),i.jsx("p",{className:"hub-card-desc",children:C.description}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsx("span",{className:"hub-chip",children:C.author}),C.tags.slice(0,3).map(q=>i.jsx("span",{className:"hub-chip",children:q},q))]})]},`m-${C.name}`))}):i.jsxs("div",{className:"empty-state",children:['No skills match "',ba,'" — try a broader term, or add a registry to ',i.jsx("code",{children:"skills.registries"})," in config."]}):null]}):null,e==="subagents"&&n?i.jsxs("div",{role:"tabpanel",children:[i.jsxs("div",{className:"admin-summary-grid",children:[i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((mn=n.subagents)==null?void 0:mn.total)??0}),i.jsx("div",{className:"admin-summary-label",children:"Runs recorded"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((ct=n.subagents)==null?void 0:ct.running)??0}),i.jsx("div",{className:"admin-summary-label",children:"Running now"})]}),i.jsxs("div",{className:"admin-summary-card",children:[i.jsx("div",{className:"admin-summary-value",children:((Hl=n.subagents)==null?void 0:Hl.failed)??0}),i.jsx("div",{className:"admin-summary-label",children:"Failed"})]})]}),i.jsxs("p",{className:"admin-hint",children:["Each run is a separate child process. A transport of ",i.jsx("code",{children:"json"})," means the provider has no native tool protocol and the shared JSON fallback carried the tool calls; a refusal code means the run stopped deliberately instead of returning an answer."]}),(((Gl=n.subagents)==null?void 0:Gl.recent)??[]).length>0?i.jsx("div",{className:"hub-session-list",children:(((ql=n.subagents)==null?void 0:ql.recent)??[]).map(C=>i.jsxs("div",{className:"hub-card",children:[i.jsxs("div",{className:"hub-card-top",children:[i.jsxs("div",{className:"hub-card-title",children:[i.jsx("span",{className:"hub-card-name",children:C.goal||"(no goal recorded)"}),i.jsxs("span",{className:"hub-card-id",children:[C.id.slice(0,8),C.startedAt?` · ${new Date(C.startedAt).toLocaleString()}`:""]})]}),i.jsx("div",{className:"hub-card-actions",children:i.jsx("span",{className:"hub-chip",children:vle[C.status]??C.status})})]}),i.jsxs("div",{className:"hub-card-tools",children:[i.jsxs("span",{className:"hub-chip",children:["🔌 ",C.provider??"provider unknown",C.model?` · ${C.model}`:""]}),i.jsxs("span",{className:"hub-chip",children:["🛠 ",C.transport??"transport unknown"," transport"]}),i.jsxs("span",{className:"hub-chip",children:[C.llmCalls," model call",C.llmCalls===1?"":"s"]}),i.jsxs("span",{className:"hub-chip",children:[C.toolCalls," tool call",C.toolCalls===1?"":"s"]}),typeof C.durationMs=="number"?i.jsxs("span",{className:"hub-chip",children:[(C.durationMs/1e3).toFixed(1),"s"]}):null]}),C.refusalCode?i.jsxs("div",{className:"hub-card-note",children:["⛔ Refused before answering — code ",i.jsx("code",{children:C.refusalCode})]}):null,C.error?i.jsx("div",{className:"admin-row-msg admin-row-msg-err",children:C.error}):null,C.resultPreview?i.jsx("div",{className:"hub-artifact-preview",children:C.resultPreview}):null]},C.id))}):i.jsxs("div",{className:"empty-state",children:["No subagent runs recorded yet — a run shows up here once the agent spawns one (the ",i.jsx("code",{children:"subagent"})," tool), and only if it actually started."]})]}):null]})}const wle=296,kle=58,Sle=[{name:"admin",description:"Admin governance policy for Auto routing (P6 M6.5) — allow/deny providers & models, hard cost cap, PII privacy, unblock control",commands:[{name:"admin policy",description:"Show the current governance policy + enforcement status",flags:["--json"]},{name:"admin allow",description:"Add providers to the allow-list (empty = all providers allowed)",flags:[]},{name:"admin deny",description:"Add providers to the deny-list (wins over the allow-list)",flags:[]},{name:"admin allow-model",description:"Add models to the allow-list — a provider survives only if one of its candidate models is listed",flags:[]},{name:"admin deny-model",description:"Add models to the deny-list (wins over the allow-list)",flags:[]},{name:"admin max-cost",description:"Set the admin hard max cost per call (USD); joins routing.maxCostUsd (stricter wins)",flags:[]},{name:"admin pii-min",description:"Set the minimum privacy score (0-1) required when a task matches a PII pattern (default 1.0 = local-only)",flags:[]},{name:"admin unblock",description:"Control whether `nuvira models unblock` may override REGISTRY-learned blocks (false = admin-hard)",flags:[]},{name:"admin clear",description:"Remove one governance rule (the policy becomes permissive on that field)",flags:[]},{name:"admin role",description:"Manage RBAC roles over the admin surface (P6 M6.1 — requires admin role)",flags:[]},{name:"admin role add",description:"Assign a role to a user (first assignment exits legacy single-user mode)",flags:[]},{name:"admin role remove",description:"Remove a user's role assignment (if none remain, legacy permissive mode resumes)",flags:[]},{name:"admin role list",description:"List all role assignments",flags:[]},{name:"admin whoami",description:"Show the current identity and its effective RBAC permissions",flags:[]},{name:"admin cron",description:"Scheduled tool invocations (J2 — cron/jobs.py)",flags:[]},{name:"admin cron add",description:'Add a cron job: nuvira admin cron add nightly-build "0 3 * * *" build',flags:["--args <args>","--channel <channel>","--dry-run"]},{name:"admin cron list",description:"List cron jobs with schedule + next run",flags:[]},{name:"admin cron remove",description:"Remove a cron job",flags:[]},{name:"admin cron run",description:"Run a cron job NOW (invoke its tool immediately)",flags:[]}]},{name:"chat",description:"Start an interactive chat session with AI",commands:[]},{name:"edit",description:"Edit a file using AI assistance",commands:[]},{name:"plan",description:"Generate an implementation plan for a codebase task",commands:[]},{name:"config",description:"Manage Nuvira configuration",commands:[{name:"config set",description:"Set a configuration value",flags:[]},{name:"config get",description:"Get a configuration value",flags:[]},{name:"config list",description:"List all providers and their status",flags:[]},{name:"config init",description:"Initialize configuration interactively",flags:[]},{name:"config vault",description:"Secret vault management (Phase A1)",flags:[]},{name:"config vault status",description:"Show the active vault tier and migration state",flags:[]},{name:"config vault log",description:"Show recent vault access-log entries (K3 tamper-evident audit)",flags:["--limit <limit>"]},{name:"config vault migrate-keys",description:"Move plaintext provider API keys from buffconfig.json into the vault",flags:[]},{name:"config gateway",description:"Manage gateway platform transports (tokens written to ~/.nuvira/.env)",flags:[]},{name:"config gateway list",description:"Show every platform transport and its env-var status",flags:[]},{name:"config gateway set",description:"Configure a platform transport (interactive wizard, or --set VAR=value)",flags:["--set <set>"]},{name:"config gateway remove",description:"Remove a platform transport from the env file",flags:["--yes"]},{name:"config gateway allow",description:"Allow a user/group to trigger the agent on a platform (written to gateway.policies in config)",flags:[]},{name:"config gateway disallow",description:"Remove a user/group from the allowed list of a platform",flags:[]},{name:"config gateway reply",description:"Set how unapproved senders are handled on a platform: polite (⛔ message) or silent (no reply)",flags:[]},{name:"config gateway send-authority",description:"Manage who may command the agent to send to OTHER people (gateway_send). Outbound-only gate — separate from `allow` (who may trigger).",flags:[]},{name:"config gateway notify",description:"Manage status recipients — contacts/groups that ALWAYS get pipeline completion summaries",flags:[]},{name:"config gateway ask-user-wait",description:"Ask-and-wait for clarifying questions on messaging channels: when a turn asks the sender a question, hold it for their reply instead of assuming option 1",flags:[]},{name:"config service",description:"Manage third-party service keys (image/video/search/vision/speech) in ~/.nuvira/.env",flags:[]},{name:"config service list",description:"Show every service backend and its env-var status",flags:[]},{name:"config service set",description:"Set a service key: config service set <serviceId> <ENV_VAR> <value> (or --set VAR=value)",flags:["--set <set>"]},{name:"config service unset",description:"Remove a service key (all vars, or one with [varName]) from the env file",flags:["--yes"]},{name:"config limit",description:"Show or change the size limits for document extraction and attachments",flags:[]},{name:"config limit list",description:"Show the effective extraction and attachment limits",flags:[]},{name:"config limit set",description:"Set a limit: config limit set <extract-max-chars|attachment-max-kb> <value>",flags:[]},{name:"config limit unset",description:"Restore a limit to its default",flags:[]},{name:"config capability",description:"Show or change the capability mode (balanced | max)",flags:[]},{name:"config capability show",description:"Show the effective capability mode",flags:[]},{name:"config capability set",description:"Set the capability mode: config capability set <balanced|max>",flags:[]},{name:"config capability unset",description:"Restore the default capability mode (balanced)",flags:[]},{name:"config catalog-feed",description:"Show or change the OpenRouter catalogue feed (cost/ecosystem priors only)",flags:[]},{name:"config catalog-feed show",description:"Show whether the catalogue feed is on, and how old its snapshot is",flags:[]},{name:"config catalog-feed set",description:"Enable or disable: config catalog-feed set <on|off>",flags:[]},{name:"config catalog-feed unset",description:"Remove the setting, restoring the default (off)",flags:[]},{name:"config catalog-feed refresh",description:"Fetch a fresh catalogue snapshot now (never runs during a turn)",flags:[]}]},{name:"cache",description:"Manage inference cache",commands:[{name:"cache stats",description:"Show cache statistics",flags:[]},{name:"cache clear",description:"Clear cached responses — all of them, or one workspace (project folder)",flags:["--unscoped"]}]},{name:"models",description:"List available models from inference providers",commands:[{name:"models refresh",description:"Probe providers and spot-check models, updating the Model Availability Registry",flags:["--json","--no-spot-check"]},{name:"models status",description:"Show the Model Availability Registry (verified / unavailable / quota-parked models)",flags:["--json","--verbose"]},{name:"models unblock",description:"Manually release a registry-blocked provider (escape hatch) and re-probe it against the live API",flags:["--json","--no-spot-check"]},{name:"models warm",description:"Run one warmup cycle now: keep hot models warm, verify new ones, refresh the stale pool",flags:["--json"]},{name:"models excluded",description:"Show which providers routing is currently skipping, and why (failure cooldowns, registry blocks, governance policy)",flags:["--json"]},{name:"models staleness",description:"Show model staleness: last probe time, days since verification, and removal risk",flags:["--json"]},{name:"models watch",description:"Run the model-registry maintenance daemon: probe + spot-check on a schedule",flags:["--interval <interval>","--no-spot-check"]}]},{name:"execute",description:"Run a multi-agent pipeline to accomplish a goal",commands:[]},{name:"run",description:"Execute a shell command and show output (lightweight alternative to the full pipeline)",commands:[]},{name:"workflow",description:"Run, manage, and share workflow templates",commands:[{name:"workflow list",description:"Show available workflow templates (built-in + installed)",flags:[]},{name:"workflow run",description:"Run a workflow template",flags:["--dry-run","--model <model>","--provider <provider>","--verbose"]},{name:"workflow search",description:"Search the GitHub workflow template registry",flags:["--refresh"]},{name:"workflow install",description:"Install a workflow template from the GitHub registry",flags:[]},{name:"workflow publish",description:"Prepare a local workflow template for publishing to the registry",flags:[]},{name:"workflow info",description:"Show detailed information about a registry template",flags:[]},{name:"workflow upgrade",description:"Check for and apply template upgrades from the registry",flags:[]}]},{name:"whatsapp",description:"WhatsApp bridge (Baileys) — pair a personal number via QR and check status (I8)",commands:[{name:"whatsapp pair",description:"Pair WhatsApp (personal number — no Meta Business account, no paid API)",flags:["--phone <phone>","--timeout <timeout>"]},{name:"whatsapp status",description:"Show bridge session path + pairing state",flags:[]},{name:"whatsapp contacts",description:"List resolvable contacts (mapping file + learned) — connects briefly to learn names from live traffic",flags:["--timeout <timeout>"]},{name:"whatsapp contact",description:'Manage the WhatsApp contact-name mapping (send by name: nuvira gateway send whatsapp:<Name> "message")',flags:[]},{name:"whatsapp contact add",description:"Map a display name to a number (E.164, no +): nuvira whatsapp contact add Name 919876543210",flags:[]},{name:"whatsapp contact remove",description:"Remove a mapped contact name",flags:[]}]},{name:"plugins",description:"Manage provider plugins, agent plugins, and workflow templates",commands:[{name:"plugins list",description:"List all discovered plugins and workflows",flags:[]},{name:"plugins scan",description:"Force re-scan all plugin directories",flags:[]}]},{name:"learn",description:"Self-improvement system — agent stats, patterns, and optimization",commands:[{name:"learn stats",description:"Show per-agent performance statistics",flags:[]},{name:"learn patterns",description:"Show extracted coding patterns",flags:["--extract","--model <model>","--provider <provider>"]},{name:"learn lessons",description:"Show failure lessons — what past runs learned from mistakes",flags:["--extract","--model <model>","--provider <provider>"]},{name:"learn optimize",description:"Generate optimized model-to-agent routing recommendations",flags:[]},{name:"learn status",description:"Show overall self-improvement status",flags:[]},{name:"learn clear",description:"Reset all learning data (stats, patterns, memory)",flags:["--force"]},{name:"learn compare",description:"Compare benchmark results between two models",flags:["--all","--last"]},{name:"learn feedback",description:"Rate a trajectory or view feedback statistics",flags:["--comment <comment>","--rating <rating>","--stats","--trajectory <trajectory>"]},{name:"learn quality",description:"Show pattern quality and decay metrics",flags:["--details"]},{name:"learn gc",description:"Garbage-collect low-quality patterns",flags:["--dry-run"]}]},{name:"init",description:"Scaffold a new project from a template",commands:[]},{name:"stats",description:"View usage statistics and cost tracking",commands:[{name:"stats cost",description:"Show API cost tracking details",flags:["--clear"]},{name:"stats history",description:"Show conversation history statistics",flags:[]}]},{name:"history",description:"Browse and search conversation history",commands:[{name:"history list",description:"Show all saved conversations",flags:["--limit <limit>"]},{name:"history search",description:"Search conversations by keyword or semantic similarity",flags:["--limit <limit>","--semantic"]},{name:"history show",description:"Show a specific conversation",flags:[]},{name:"history clear",description:"Clear all conversation history",flags:[]},{name:"history prune",description:"Remove conversations older than the retention period",flags:["--days <days>"]},{name:"history reindex",description:"Rebuild the semantic search index for all past conversations (embeds each session for vector search)",flags:[]}]},{name:"skill",description:"Manage and run compiled skills — reusable execution plans derived from past trajectories",commands:[{name:"skill list",description:"List all compiled skills",flags:["--quality <quality>"]},{name:"skill show",description:"Show detailed skill definition",flags:[]},{name:"skill run",description:"Run a skill — resolves parameters and invokes the multi-agent pipeline",flags:["--auto-route","--dry-run","--memory","--model <model>","--params <params>","--provider <provider>","--verbose"]},{name:"skill compile",description:"Force skill compilation from stored trajectories",flags:["--model <model>","--provider <provider>"]},{name:"skill search",description:"Search skills by name, tag, or description",flags:[]},{name:"skill gc",description:"Garbage-collect low-quality skills",flags:["--dry-run"]},{name:"skill quality",description:"Show skill quality and decay metrics",flags:["--details"]},{name:"skill clear",description:"Remove all compiled skills",flags:["--force"]}]},{name:"skills",description:"Skills hub — search, install, update, and audit community skills (J3)",commands:[{name:"skills search",description:"Search all configured skill registries (I7 P1 multi-source)",flags:["--refresh","--source <source>"]},{name:"skills install",description:"Install a skill from the configured registries into <project>/.agents/skills/ (sandboxed, checksummed)",flags:["--project <project>","--source <source>"]},{name:"skills uninstall",description:"Uninstall a skill: removes .agents/skills/<name> and its provenance record",flags:["--project <project>"]},{name:"skills update",description:"Update installed skills to newer registry versions (checksum-verified)",flags:["--project <project>"]},{name:"skills bundle",description:"P6b — skill bundles: group skills under one id and load them together (Hermes parity)",flags:["--create","--delete","--description <description>","--name <name>","--skills <skills>"]},{name:"skills list",description:"List installed skills with provenance (origin: registry vs local)",flags:["--origin <origin>","--project <project>"]}]},{name:"gateway",description:"Multi-channel gateway — talk to the agent from Telegram/Discord/Slack/WhatsApp/Email/Signal (J1)",commands:[{name:"gateway status",description:"Show configured adapters and reachable channels",flags:[]},{name:"gateway send",description:"Send a message to a channel alias or platform:channelId",flags:[]},{name:"gateway send-media",description:"Send a media file (image/video/audio/document) — type from the file extension; WhatsApp/Telegram/Discord",flags:["--caption <caption>"]},{name:"gateway alias",description:"Manage channel aliases",flags:[]},{name:"gateway alias add",description:"Register an alias: nuvira gateway alias add ops slack C0123",flags:[]},{name:"gateway alias remove",description:"Remove an alias",flags:[]},{name:"gateway contact",description:"Manage contacts for outbound messaging (name → platform:id resolution)",flags:[]},{name:"gateway contact list",description:"List all contacts with status, platform, and ID",flags:["--pending","--platform <platform>"]},{name:"gateway contact approve",description:"Approve a contact for outbound messaging",flags:["--platform <platform>"]},{name:"gateway contact reject",description:"Reject a contact (block outbound messages)",flags:["--platform <platform>"]},{name:"gateway contact delete",description:"Delete a contact permanently",flags:["--platform <platform>"]},{name:"gateway contact add",description:"Manually add a contact (e.g. nuvira gateway contact add Anuj telegram 616825477)",flags:["--phone <phone>"]},{name:"gateway delivery",description:"Show the delivery ledger (failed sends awaiting retry) and optionally drain it",flags:["--flush"]},{name:"gateway logs",description:"Show the structured gateway log (send failures, refused senders, pipeline outcomes)",flags:["--event <event>","--limit <limit>","--path"]},{name:"gateway history",description:"Manage per-contact conversation history (gateway chat memory)",flags:[]},{name:"gateway history list",description:"List all stored conversations with last message preview",flags:["--platform <platform>"]},{name:"gateway history show",description:"Show conversation history for a contact (e.g. nuvira gateway history show whatsapp:918800663237)",flags:["--limit <limit>"]},{name:"gateway history clear",description:"Clear conversation history for a contact",flags:[]},{name:"gateway history prune",description:"Remove conversations older than 7 days",flags:[]},{name:"gateway start",description:"Run all configured adapters in the foreground (Ctrl-C to stop; --supervise auto-restarts on crash)",flags:["--host <host>","--no-events","--port <port>","--supervise"]},{name:"gateway stop",description:"Stop a running gateway gracefully (SIGTERM — from any terminal)",flags:["--port <port>"]},{name:"gateway setup",description:"Interactive setup wizard for a messaging platform (e.g. nuvira gateway setup telegram)",flags:[]}]},{name:"omniroute",description:"Start / stop / inspect the external OmniRoute AI gateway (default port 20128)",commands:[{name:"omniroute status",description:"Probe the OmniRoute gateway and report whether it is reachable",flags:[]},{name:"omniroute start",description:"Start the OmniRoute gateway in the background and wait for it to answer",flags:[]},{name:"omniroute stop",description:"Stop the running OmniRoute gateway",flags:[]}]},{name:"model",description:"Manage inference providers and models — switch, list, inspect, and recommend",commands:[{name:"model list",description:"List all providers and their configuration status",flags:["--all","--json"]},{name:"model switch",description:"Switch active provider/model (interactive or via argument). Use `auto` for smart routing",flags:["--model <model>","--provider <provider>"]},{name:"model info",description:"Show current active provider and model configuration",flags:["--verbose"]},{name:"model recommend",description:"Show model routing recommendations",flags:[]},{name:"model explain",description:"Explain Auto model routing — why a provider/model would be picked for a task",flags:["--agent <agent>","--context-tokens <context_tokens>","--exclude-provider <exclude_provider>","--json","--since <since>"]},{name:"model health",description:"Quick health check for the currently active provider",flags:["--provider <provider>","--verbose"]},{name:"model bandit",description:"Show learning-router bandit state (Thompson-sampling priors per provider × complexity bucket). Action: reset",flags:["--json"]},{name:"model ml",description:"Show the ML task-similarity router state (learned outcomes per provider, kNN over task features). Action: reset",flags:["--json"]},{name:"model quota",description:"Show the central quota ledger (tokens/requests per provider × model, reset windows, parked state). Actions: reset | set <provider> | clear <provider>",flags:["--cost-usd <cost_usd>","--json","--requests <requests>","--tokens <tokens>","--window-ms <window_ms>"]}]},{name:"benchmark",description:"Run standardized model benchmarks against coding tasks",commands:[{name:"benchmark run",description:"Run the benchmark suite",flags:["--budget <budget>","--format <format>","--model <model>","--provider <provider>","--routing","--tasks <tasks>"]},{name:"benchmark list",description:"List available benchmark tasks",flags:[]},{name:"benchmark results",description:"Show previous benchmark results",flags:["--compare","--format <format>","--last"]},{name:"benchmark clear",description:"Clear all benchmark data",flags:[]}]},{name:"eval",description:"Run the Agent-Nuvira evaluation framework — measures if the agent is actually improving",commands:[{name:"eval run",description:"Run the evaluation suite",flags:["--budget <budget>","--engine <engine>","--format <format>","--keep-workspaces","--model <model>","--pace","--provider <provider>","--routing","--suite <suite>","--tasks <tasks>"]},{name:"eval parity",description:"Measure the capability gap: run the hard tasks under balanced AND max, then compare",flags:["--engine <engine>","--model <model>","--provider <provider>","--tasks <tasks>"]},{name:"eval verify-seeds",description:"Prove every seeded bug is genuinely broken (and genuinely fixable) — no provider needed",flags:["--tasks <tasks>"]},{name:"eval list",description:"List available eval tasks",flags:[]},{name:"eval results",description:"Show previous eval runs",flags:["--compare","--format <format>","--last"]},{name:"eval score",description:"Show the evaluation scoring rules",flags:[]},{name:"eval clear",description:"Clear all eval data",flags:[]}]},{name:"sandbox",description:"Manage Docker sandbox isolation for code execution",commands:[{name:"sandbox status",description:"Check Docker availability and sandbox status",flags:[]},{name:"sandbox config",description:"Show or update sandbox configuration",flags:["--cpu <cpu>","--disable","--disk <disk>","--enable","--image <image>","--memory <memory>","--network","--timeout <timeout>"]},{name:"sandbox images",description:"List available pre-defined sandbox images",flags:[]},{name:"sandbox run",description:"Run a command inside a new sandbox container",flags:["--cpu <cpu>","--image <image>","--memory <memory>","--network","--project <project>","--timeout <timeout>"]},{name:"sandbox cleanup",description:"Destroy all active sandbox containers",flags:[]}]},{name:"doctor",description:"Run diagnostic checks on all provider configurations and system health",commands:[]},{name:"memory",description:"Manage agent memory store — compression, pruning, and optimization",commands:[{name:"memory stats",description:"Show memory store statistics",flags:[]},{name:"memory optimize",description:"Run automatic memory compression and pruning",flags:["--aggressive","--dry-run"]},{name:"memory prune",description:"Prune old or low-quality trajectories",flags:["--max-age <max_age>","--max-count <max_count>","--min-score <min_score>","--verbose"]},{name:"memory summarize",description:"Summarize old trajectories by merging similar ones",flags:["--retention <retention>","--verbose"]},{name:"memory info",description:"Show detailed compression analysis",flags:[]},{name:"memory backend",description:"Show the active vector-search backend and why it was chosen",flags:["--check"]},{name:"memory list",description:"List all memory entries (facts, preferences, lessons, observations)",flags:["--limit <limit>","--type <type>"]},{name:"memory search",description:"Search memory entries by content",flags:["--limit <limit>","--type <type>"]},{name:"memory add",description:"Add a memory entry",flags:["--tags <tags>","--type <type>"]},{name:"memory delete",description:"Delete a memory entry by ID",flags:[]},{name:"memory export",description:"Export all memories to a JSON file",flags:["--output <output>"]},{name:"memory import",description:"Import memories from a JSON file",flags:["--merge"]},{name:"memory facts",description:"Fact & preference memory (project-scoped, cross-session)",flags:[]},{name:"memory facts list",description:"List facts, optionally for a project (git slug or cwd:<hash>)",flags:["--project <project>"]},{name:"memory facts add",description:"Manually store a fact for the current project",flags:["--project <project>","--tags <tags>"]},{name:"memory facts stats",description:"Show fact-store statistics",flags:[]},{name:"memory clear",description:"Clear all stored trajectories and reset memory",flags:["--force"]}]},{name:"dashboard",description:"Launch the web-based dashboard for visualizing agent execution and system status",commands:[{name:"dashboard stop",description:"Stop a running dashboard gracefully (SIGTERM — from any terminal)",flags:["--port <port>"]}]},{name:"agent",description:"Scaffold and manage custom agent-nuvira agents",commands:[{name:"agent create",description:"Create a new custom agent project from a template",flags:["--agent-name <agent_name>","--description <description>","--dir <dir>"]},{name:"agent list",description:"List all discovered custom agent plugins",flags:[]},{name:"agent info",description:"Show details about a discovered agent plugin",flags:[]}]},{name:"federation",description:"Connect to and manage remote agent instances",commands:[{name:"federation status",description:"Show federation connection status and configuration",flags:[]},{name:"federation start",description:"Start the federation server (listens for incoming connections)",flags:["--auth <auth>","--daemon","--host <host>","--oidc-public-key <oidc_public_key>","--port <port>","--secret <secret>"]},{name:"federation connect",description:"Connect to a remote federation server",flags:["--port <port>","--secret <secret>"]},{name:"federation disconnect",description:"Disconnect from the remote federation server",flags:[]},{name:"federation run",description:"Run a task on the remote federation server",flags:["--agent <agent>","--model <model>","--no-stream","--provider <provider>","--timeout <timeout>"]},{name:"federation health",description:"Check the health of the remote federation server",flags:[]},{name:"federation config",description:"Show or update federation configuration",flags:["--set-port <set_port>","--set-secret <set_secret>","--show"]},{name:"federation a2a",description:"A2A (Agent-to-Agent) protocol — discover and connect to external A2A-compliant agents",flags:[]},{name:"federation a2a discover",description:"Discover an A2A-compliant agent and fetch its AgentCard",flags:[]},{name:"federation a2a start",description:"Start the A2A server (listens for incoming A2A connections)",flags:["--host <host>","--port <port>"]},{name:"federation a2a status",description:"Check the health and status of a remote A2A agent",flags:[]},{name:"federation a2a run",description:"Delegate a task to a remote A2A-compliant agent",flags:["--agent <agent>","--skill <skill>","--timeout <timeout>"]}]},{name:"team",description:"Team collaboration — shared config, git-synced memory, and review workflow",commands:[{name:"team init",description:"Initialize team configuration in the working directory",flags:["--branch <branch>","--repo <repo>"]},{name:"team join",description:"Clone and join an existing team repository",flags:[]},{name:"team sync",description:"Sync team memory with remote (pull latest + push local changes)",flags:[]},{name:"team status",description:"Show team configuration and memory status",flags:[]},{name:"team share",description:"Share local trajectories and patterns with the team",flags:[]},{name:"team review",description:"Manage review bundles — agent PR → review → merge workflow",flags:[]},{name:"team review list",description:"List all review bundles",flags:["--limit <limit>"]},{name:"team review show",description:"Show a specific review bundle with full details",flags:[]},{name:"team review approve",description:"Approve a review bundle (sets status to approved)",flags:["--message <message>"]},{name:"team review request-changes",description:"Request changes on a review bundle",flags:[]},{name:"team review reject",description:"Reject a review bundle",flags:[]},{name:"team review merge",description:"Merge an approved review into the working directory",flags:[]},{name:"team review create",description:"Create a review bundle from specified files",flags:["--files <files>","--model <model>","--provider <provider>"]}]},{name:"sdk",description:"Create and manage custom agents with the Agent-Nuvira SDK",commands:[{name:"sdk scaffold",description:"Generate a new custom agent project",flags:["--agent-type <agent_type>","--template <template>"]},{name:"sdk templates",description:"List available scaffold templates",flags:[]},{name:"sdk info",description:"Show SDK package info and version",flags:[]},{name:"sdk register",description:"Register a custom agent with the orchestrator",flags:["--description <description>","--icon <icon>","--orchestrator-path <orchestrator_path>"]},{name:"sdk unregister",description:"Remove a custom agent from the orchestrator",flags:["--class-name <class_name>","--orchestrator-path <orchestrator_path>"]}]},{name:"provider",description:"List and check health of all inference providers",commands:[{name:"provider list",description:"Show all providers with color-coded status table",flags:["--all"]},{name:"provider health",description:"Show detailed health checks for one or all providers",flags:["--verbose","--watch"]}]},{name:"security",description:"Scan code, prompts, or files for security issues",commands:[{name:"security scan",description:"Scan for PII, injection attempts, or dangerous code patterns",flags:["--code","--file <file>","--generated","--json","--pii","--prompt","--stdin","--strict"]}]},{name:"audit",description:"Verify and export the tamper-evident (hash-chained) audit trail (P6 M6.3)",commands:[{name:"audit verify",description:"Verify hash-chain integrity of audit stores (tamper detection)",flags:["--file <file>","--json"]},{name:"audit export",description:"Export an audit store as SIEM-friendly CEF lines",flags:["--file <file>","--out <out>"]}]},{name:"sbom",description:"Generate and verify the CycloneDX software bill of materials (P6 M6.6)",commands:[]},{name:"feedback",description:"Record, view, and manage user feedback on agent outputs",commands:[{name:"feedback record",description:"Record feedback for a trajectory (interactive)",flags:["--comment <comment>","--negative","--neutral","--positive"]},{name:"feedback list",description:"Show recent feedback entries",flags:["--limit <limit>","--trajectory <trajectory>"]},{name:"feedback stats",description:"Show aggregated feedback statistics",flags:[]},{name:"feedback clear",description:"Clear all feedback data",flags:[]}]},{name:"nlu",description:"NLU request understanding — debug intent/entity/action resolution",commands:[{name:"nlu debug",description:"Debug how a request is understood (rule path + optional LLM verify)",flags:["--llm"]},{name:"nlu learnings",description:"Show the routing corrections learned from CONFIRMED misreadings (the agent improving itself)",flags:["--forget <forget>","--json"]}]},{name:"intent",description:"Plain-English → CLI routing — resolve an ask into the exact `nuvira` command(s) to run",commands:[{name:"intent resolve",description:'Resolve a plain-English ask (e.g. "stop the dashboard", "add Rahul to whatsapp") into CLI commands',flags:["--json","--semantic"]},{name:"intent eval",description:"Score deterministic vs semantic matching over a labeled ask corpus (novel phrasings included)",flags:["--json"]}]},{name:"code-map",description:"Project symbol map — functions, classes, methods with line numbers (AST engine)",commands:[]},{name:"tools",description:"Inspect the agent tool registry (pipeline + experience tools)",commands:[{name:"tools list",description:"List every registered tool (the H1 tool-calling surface)",flags:[]},{name:"tools show",description:"Show a tool's description and input schema",flags:[]},{name:"tools toolsets",description:"List toolset groups (capability gating) with enabled state; enable/disable a group",flags:["--disable <disable>","--enable <enable>"]},{name:"tools install",description:"Install the optional dependency an optional tool needs (see `nuvira tools optional`)",flags:["--package-only"]},{name:"tools optional",description:"List tools that are shipped but need an optional dependency installed",flags:[]}]},{name:"parity",description:"Surface-parity harness — prove the same experience on chat, execute, dashboard, gateway and subagents",commands:[{name:"parity surfaces",description:"Compare the surface registry against the real import graph",flags:[]},{name:"parity debt",description:"Check the anti-silo debt ratchet (observed surface debt must equal the frozen list)",flags:[]},{name:"parity matrix",description:"Show every capability × surface and any unproven `supported` claim",flags:[]},{name:"parity faults",description:"List the declared faults the harness can inject, and what each one proves",flags:[]},{name:"parity run",description:"Drive all five surfaces through the real harness and report the verdict",flags:[]}]},{name:"session",description:"Project-scoped session continuity (debug surface — `continue` is the primary path)",commands:[{name:"session list",description:"List recent sessions, optionally filtered by project + time range",flags:["--limit <limit>","--project <project>","--since <since>"]},{name:"session summarize",description:"Show summary + metadata for one session (transcript: nuvira history show)",flags:[]},{name:"session resume",description:"Run D1 auto-recall for a project and print the recall card",flags:["--project <project>","--since <since>"]}]},{name:"state",description:"Print this project’s tracked state in one read: plan, open sessions, per-file verification debt, git drift",commands:[]},{name:"marketplace",description:"Browse and install community plugins and workflow templates",commands:[{name:"marketplace browse",description:"Browse all available marketplace items",flags:["--plugins","--refresh","--workflows"]},{name:"marketplace search",description:"Search across plugins and workflow templates",flags:[]},{name:"marketplace install",description:"Install a workflow template from the registry",flags:[]},{name:"marketplace info",description:"Show detailed information about a marketplace item",flags:[]}]},{name:"mcp",description:"Manage MCP (Model Context Protocol) server connections",commands:[{name:"mcp list",description:"List all discovered MCP servers and their tools",flags:[]},{name:"mcp connect",description:"Connect to an MCP server",flags:["--all"]},{name:"mcp call",description:"Call a tool on an MCP server",flags:["--args <args>","--server <server>"]},{name:"mcp info",description:"Show detailed information for an MCP server",flags:[]},{name:"mcp refresh",description:"Re-discover and reconnect to all MCP servers",flags:[]},{name:"mcp catalog",description:"List MCP capability slots, their variants, and what each one needs on this machine",flags:["--search <search>"]},{name:"mcp install",description:"Install a catalog capability, choosing the best variant this machine can actually run",flags:["--command <command>","--env <env>","--force","--no-verify","--runtime <runtime>","--variant <variant>"]},{name:"mcp add",description:"Add a server that is NOT in the catalog — any stdio command or remote URL, like a config file",flags:["--arg <arg>","--command <command>","--env <env>","--force","--header <header>","--json <json>","--no-verify","--transport <transport>","--url <url>"]},{name:"mcp settings",description:"Show the resolved mcp.* configuration (caps, auto-connect, subagent inheritance)",flags:[]},{name:"mcp authorize",description:"Authorize an OAuth MCP server (opens the consent page, captures the loopback redirect, stores the token)",flags:["--no-browser","--redirect-uri <redirect_uri>"]},{name:"mcp uninstall",description:"Remove an installed MCP server config",flags:[]},{name:"mcp serve",description:"Expose the agent's H1 tools as an MCP server over stdio (MCP clients / IDEs / other agents can connect)",flags:["--memory","--with <with>"]}]},{name:"ci",description:"Headless CI/CD mode — structured JSON output and exit codes for pipelines",commands:[{name:"ci execute",description:"Execute a goal and emit JSON result (exit 0 = success, 1 = failure)",flags:["--context-limit <context_limit>","--context-prune <context_prune>","--github-annotations","--memory","--model <model>","--planner-model <planner_model>","--provider <provider>","--reviewer-model <reviewer_model>","--sandbox","--timeout <timeout>","--writer-model <writer_model>"]},{name:"ci check",description:"Run a gate check (exit 0 = pass, 1 = fail) — minimal output, ideal for workflow gates",flags:["--model <model>","--provider <provider>","--verbose"]},{name:"ci review",description:"Review one or more files and emit JSON findings",flags:["--context <context>","--format <format>","--model <model>","--provider <provider>"]}]},{name:"publish",description:"Autonomous publish workflow — version, build, publish to npm & GitHub",commands:[]},{name:"credentials",description:"Store GitHub/npm release credentials so the agent can release without re-entering them",commands:[{name:"credentials status",description:"Show which release credentials are available, and where each came from",flags:[]},{name:"credentials set",description:"Store a credential in the nuvira credential store",flags:["--stdin","--value <value>"]},{name:"credentials forget",description:"Delete a stored credential",flags:[]},{name:"credentials verify",description:"Check the stored GitHub and npm tokens against the live services",flags:[]}]},{name:"bedrock",description:"AWS Bedrock setup and management (dedicated onboarding for Bedrock)",commands:[{name:"bedrock setup",description:"Interactive wizard to configure AWS Bedrock (credentials, region, model access)",flags:[]},{name:"bedrock status",description:"Show current Bedrock configuration and connectivity status",flags:[]},{name:"bedrock test",description:"Probe Bedrock models and test inference",flags:["--region <region>"]}]},{name:"phase",description:"Phase-wise project scope execution — multi-goal pipelines",commands:[{name:"phase create",description:"Create a new phase scope with ordered goals",flags:["--output <output>"]},{name:"phase execute",description:"Execute a phase scope from start to finish",flags:["--dry-run","--model <model>","--non-interactive","--provider <provider>","--skip-tests","--verbose"]},{name:"phase resume",description:"Resume a saved phase scope from where it left off",flags:["--model <model>","--provider <provider>","--skip-tests","--verbose"]},{name:"phase status",description:"Show progress of a phase scope",flags:[]},{name:"phase delete",description:"Delete a saved phase scope",flags:[]},{name:"phase list",description:"List all saved phase scopes",flags:[]}]},{name:"retrieval",description:"Vector retrieval — token-efficient context via local embeddings",commands:[{name:"retrieval stats",description:"Show token-savings transparency (how many tokens retrieval saved)",flags:[]},{name:"retrieval index",description:"Index a repo/file into the retrieval store (chunks embedded locally)",flags:[]},{name:"retrieval query",description:"Semantic search over the indexed repo (top-k chunks)",flags:[]},{name:"retrieval clear",description:"Clear the retrieval index and token-savings stats",flags:[]}]},{name:"knowledge",description:"Knowledge base — answer questions from your own tagged documents (vector retrieval)",commands:[{name:"knowledge add",description:"Ingest files or folders under a tag (extracted, chunked and embedded once)",flags:[]},{name:"knowledge query",description:"Retrieve the most relevant passages for a question, scoped to a tag",flags:["--top-k <top_k>"]},{name:"knowledge toc",description:"List a tag's documents and the headings in each",flags:[]},{name:"knowledge read",description:"Print a document, or one named section, VERBATIM (not a summary)",flags:["--section <section>"]},{name:"knowledge remove",description:"Remove ONE document from a tag (its chunks, stored text and manifest row)",flags:[]},{name:"knowledge sync",description:"Bring a tag up to date with its folders — hash-gated, prunes files that vanished",flags:[]},{name:"knowledge list",description:"List knowledge tags with document and chunk counts",flags:[]},{name:"knowledge stats",description:"Show details for one knowledge tag",flags:[]},{name:"knowledge forget",description:"Remove a tag's vectors and manifest entry",flags:[]}]},{name:"hooks",description:"Declarative lifecycle hooks — list/add/remove the rules that deny, notify or secret-scan tool calls (the same hooks.json the dashboard Hooks page edits; a hook is data, never code)",commands:[{name:"hooks list",description:"List built-in and user hooks with their seam, action and state",flags:[]},{name:"hooks add",description:"Declare a new hook (it is enabled unless --disabled is given)",flags:["--action <action>","--arg <arg>","--cwd <cwd>","--deny-on-hit","--disabled","--event <event>","--id <id>","--label <label>","--message <message>","--reason <reason>","--surface <surface>","--tool <tool>"]},{name:"hooks remove",description:"Remove a user hook (a built-in cannot be deleted — disable it instead)",flags:[]},{name:"hooks enable",description:"Turn a hook on (works on a built-in too)",flags:[]},{name:"hooks disable",description:"Turn a hook off",flags:[]}]},{name:"trace",description:"Inspect and replay per-step reasoning traces (every LLM call in a pipeline)",commands:[{name:"trace list",description:"Show recent traces",flags:["--limit <limit>"]},{name:"trace show",description:"Show a single trace (goal, timing, step summary)",flags:[]},{name:"trace replay",description:"Step-by-step replay of a trace — every LLM call with prompt digest, model, tokens, latency, and routing",flags:["--full"]},{name:"trace degraded",description:"List provider × model pairs that served steps without agentic capability (derived, read-only, from the traces)",flags:["--limit <limit>"]},{name:"trace clear",description:"Delete all stored traces",flags:[]}]},{name:"rate",description:"Rate the last turn (good|bad) — records the one label a quality signal can be fit to (also on the dashboard Trace tab)",commands:[]},{name:"decisions",description:"The must-ask decisions recorded for this project — list, search, and revise them (written by ask_user)",commands:[{name:"decisions show",description:"",flags:["--json"]},{name:"decisions revise",description:"",flags:["--answer <answer>","--note <note>"]}]},{name:"continuity",description:"Session continuity — what is stored, and how to forget it",commands:[{name:"continuity list",description:"Show the continuity switches, stored sessions, and the semantic recall index",flags:[]},{name:"continuity clear",description:"Forget stored continuity data (no flags = both sessions and recall)",flags:["--recall","--sessions"]}]},{name:"website",description:"Open the Agent-Nuvira website — capabilities, commands, docs, setup",commands:[]}],wc={commandCount:wle,groupCount:kle,groups:Sle},dE=wc.groups;function jle(e,t){return e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)}function Nle({onPick:e}){const[t,n]=x.useState(""),r=x.useId(),a=t.trim().toLowerCase(),s=x.useMemo(()=>a?dE.map(l=>l.name.toLowerCase().includes(a)?l:{...l,commands:l.commands.filter(c=>jle(c,a))}).filter(l=>l.commands.length>0):dE,[a]),o=s.reduce((l,c)=>l+c.commands.length,0);return i.jsxs("section",{className:"command-browser",children:[i.jsxs("div",{className:"command-browser-head",children:[i.jsx("h2",{className:"section-title command-browser-title",children:"Browse commands"}),i.jsx("p",{className:"command-browser-count",children:a?`${o} of ${wc.commandCount} commands match “${t.trim()}”`:`${wc.commandCount} commands in ${wc.groupCount} groups`})]}),i.jsx("label",{className:"sr-only",htmlFor:r,children:"Filter commands"}),i.jsx("input",{id:r,type:"search",className:"admin-input command-browser-search",placeholder:"Filter commands — e.g. eval, memory, gateway status",value:t,onChange:l=>n(l.target.value),autoComplete:"off",spellCheck:!1}),s.length===0?i.jsxs("p",{className:"command-browser-empty",children:["No command matches “",t.trim(),"”. Clear the filter to see all ",wc.groupCount," groups."]}):i.jsx("div",{className:"command-browser-groups",children:s.map(l=>i.jsxs("details",{className:"command-group",open:a?!0:void 0,children:[i.jsxs("summary",{className:"command-group-summary",children:[i.jsx("code",{className:"command-group-name",children:l.name}),i.jsx("span",{className:"command-group-description",children:l.description}),i.jsx("span",{className:"command-group-count",children:l.commands.length})]}),i.jsx("ul",{className:"command-list",children:l.commands.map(c=>i.jsx("li",{className:"command-item",children:i.jsxs("button",{type:"button",className:"command-use",onClick:()=>e(c.name),title:`Insert “${c.name}” into the command box`,children:[i.jsx("span",{className:"command-item-name",children:c.name}),i.jsx("span",{className:"command-item-description",children:c.description}),c.flags.length>0&&i.jsx("span",{className:"command-item-flags",children:c.flags.map(u=>i.jsx("code",{children:u},u))})]})},c.name))})]},`${l.name}:${a?"filtering":"browsing"}`))})]})}const fE={running:"⏳ running",done:"✅ done",failed:"❌ failed",cancelled:"⏹ cancelled",timeout:"⏰ timed out",error:"💥 error"};function hE(e){switch(e){case"done":return"task-status-done";case"running":return"task-status-running";case"failed":return"task-status-failed";case"cancelled":return"task-status-cancelled";case"timeout":return"task-status-timeout";default:return"task-status-error"}}function Ele(e){const t=[];let n="",r=null;for(const a of e.trim())r?a===r?r=null:n+=a:a==='"'||a==="'"?r=a:/\s/.test(a)?n&&(t.push(n),n=""):n+=a;return n&&t.push(n),t}function pE(e){return e===null?"—":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function _le(e){const t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;const n=Math.floor(t/60);return n<60?`${n}m ago`:`${Math.floor(n/60)}h ago`}function Cle(){const[e,t]=x.useState(null),n=Kr(),[r,a]=x.useState(""),[s,o]=x.useState(300),[l,c]=x.useState(!1),[u,d]=x.useState(""),[f,h]=x.useState(null),[p,m]=x.useState([]),[g,y]=x.useState(!0),v=x.useRef(null),S=x.useRef(null),w=x.useRef(null),N=x.useCallback(async()=>{const A=await K.listTasks();A&&m(A.tasks)},[]);x.useEffect(()=>{K.fetchAdminAuthStatus().then(A=>{t(A?{configured:A.configured,authenticated:A.authenticated,role:A.role??null}:{configured:!1,authenticated:!1,role:null}),A!=null&&A.authenticated&&N()})},[N,n]),x.useEffect(()=>{var A,O;if(g&&(f==null?void 0:f.status)==="running")try{(O=(A=v.current)==null?void 0:A.scrollIntoView)==null||O.call(A,{block:"end"})}catch{}},[f==null?void 0:f.logs.length,f==null?void 0:f.status,g]),x.useEffect(()=>()=>{var A;return(A=w.current)==null?void 0:A.call(w)},[]);const k=x.useCallback((A,O)=>{var $;if(($=w.current)==null||$.call(w),h(A),d(""),!O)return;const B=K.subscribeTask(A.id,{onLog:M=>h(D=>D&&D.id===A.id?{...D,logs:[...D.logs,M]}:D),onStatus:M=>h(D=>D&&D.id===A.id?{...D,status:M}:D)});w.current=B},[]),b=x.useCallback(async()=>{const A=Ele(r);if(A.length===0){d("Type a command first — e.g. `eval run --task smoke-test` or `gateway status`.");return}c(!0),d("");const O=await K.startTask(A,s*1e3);if(c(!1),!O.ok||!O.task){d(O.error||"Failed to start task.");return}a(""),N(),k(O.task,!0)},[r,s,k,N]),j=x.useCallback(async A=>{await K.cancelTask(A)},[]),E=x.useCallback(A=>{var O;a(`${A} `),d(""),(O=S.current)==null||O.focus()},[]),P=x.useCallback(async A=>{const O=await K.getTask(A);O!=null&&O.task&&k(O.task,!1)},[k]),_=x.useCallback(()=>{var A;(A=w.current)==null||A.call(w),h(null)},[]);return e?e.authenticated?i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsx("p",{className:"admin-subtitle",children:"Run any agent-nuvira command — the same CLI, executed by the dashboard. Messaging, skills, tools, eval, memory, traces and more."}),i.jsxs("form",{className:"task-run-form",onSubmit:A=>{A.preventDefault(),b()},children:[i.jsx("input",{ref:S,className:"admin-input task-cmd-input",placeholder:"eval run --task smoke-test · gateway status · skill list · memory stats",value:r,onChange:A=>a(A.target.value),autoComplete:"off",spellCheck:!1}),i.jsxs("select",{className:"admin-input task-timeout-select",title:"Task timeout",value:s,onChange:A=>o(Number(A.target.value)),children:[i.jsx("option",{value:60,children:"1 min"}),i.jsx("option",{value:300,children:"5 min"}),i.jsx("option",{value:600,children:"10 min"}),i.jsx("option",{value:1800,children:"30 min"})]}),i.jsx("button",{className:"admin-refresh-btn",type:"submit",disabled:l||r.trim()==="",children:l?"⏳ Starting…":"▶ Run"})]}),u&&i.jsx("div",{className:"admin-error",children:u}),i.jsx("p",{className:"task-hint",children:"Long-running commands stream their output live. Runs are capped at the chosen timeout and can be cancelled."}),i.jsx(Nle,{onPick:E}),f&&i.jsxs("div",{className:"task-console-wrap",children:[i.jsxs("div",{className:"task-console-header",children:[i.jsx("code",{className:"task-console-cmd",children:f.command}),i.jsx("span",{className:`task-status ${hE(f.status)}`,children:fE[f.status]}),i.jsxs("span",{className:"task-meta",children:["exit ",f.exitCode??"—"," · ",pE(f.durationMs)]}),f.status==="running"&&i.jsx("button",{className:"admin-mini-btn task-cancel-btn",onClick:()=>void j(f.id),children:"⏹ Cancel"}),i.jsx("button",{className:"admin-mini-btn",onClick:_,children:"✕ Close"})]}),i.jsxs("div",{className:"task-console",children:[f.logs.map((A,O)=>i.jsx("div",{className:`task-line task-line-${A.stream}`,children:A.text},O)),f.logs.length===0&&f.status==="running"&&i.jsx("div",{className:"task-line task-line-system",children:"⏳ waiting for output…"}),i.jsx("div",{ref:v})]}),i.jsxs("label",{className:"task-autoscroll",children:[i.jsx("input",{type:"checkbox",checked:g,onChange:A=>y(A.target.checked)})," auto-scroll"]})]}),i.jsx("h2",{className:"task-history-title",children:"History"}),p.length===0?i.jsx("div",{className:"empty-state",children:"No tasks yet — run your first command above."}):i.jsx("div",{className:"admin-table-wrapper",children:i.jsxs("table",{className:"admin-table task-table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Command"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Exit"}),i.jsx("th",{children:"Duration"}),i.jsx("th",{children:"When"})]})}),i.jsx("tbody",{children:p.map(A=>i.jsxs("tr",{className:(f==null?void 0:f.id)===A.id?"task-row-active":"",onClick:()=>void P(A.id),children:[i.jsx("td",{children:i.jsx("code",{children:A.command})}),i.jsx("td",{children:i.jsx("span",{className:`task-status ${hE(A.status)}`,children:fE[A.status]})}),i.jsx("td",{children:A.exitCode??"—"}),i.jsx("td",{children:pE(A.durationMs)}),i.jsx("td",{children:_le(A.startedAt)})]},A.id))})]})})]}):i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsxs("div",{className:"empty-state",children:[i.jsxs("p",{children:[i.jsx("strong",{children:"Log in to run tasks."})," The console executes commands on this machine, so it needs an admin session (like the Agent Hub toggles)."]}),i.jsx("p",{children:e.configured?i.jsx(Jt,{className:"admin-refresh-btn",to:"/admin",children:"🔐 Log in"}):i.jsx(Jt,{className:"admin-refresh-btn",to:"/admin",children:"🔐 Create admin account"})})]})]}):i.jsxs("div",{className:"panel",children:[i.jsx(Re,{icon:"🚀",title:"Command Console"}),i.jsx("div",{className:"loading-state",children:"Loading…"})]})}function Ale(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const Tle=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ole=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ple={};function mE(e,t){return(Ple.jsx?Ole:Tle).test(e)}const Rle=/[ \t\n\f\r]/g;function Mle(e){return typeof e=="object"?e.type==="text"?gE(e.value):!1:gE(e)}function gE(e){return e.replace(Rle,"")===""}class id{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}id.prototype.normal={};id.prototype.property={};id.prototype.space=void 0;function gM(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new id(n,r,t)}function Fb(e){return e.toLowerCase()}class Kn{constructor(t,n){this.attribute=n,this.property=t}}Kn.prototype.attribute="";Kn.prototype.booleanish=!1;Kn.prototype.boolean=!1;Kn.prototype.commaOrSpaceSeparated=!1;Kn.prototype.commaSeparated=!1;Kn.prototype.defined=!1;Kn.prototype.mustUseProperty=!1;Kn.prototype.number=!1;Kn.prototype.overloadedBoolean=!1;Kn.prototype.property="";Kn.prototype.spaceSeparated=!1;Kn.prototype.space=void 0;let Ile=0;const Ie=Ws(),Ft=Ws(),Ub=Ws(),le=Ws(),ut=Ws(),js=Ws(),Zn=Ws();function Ws(){return 2**++Ile}const Wb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ie,booleanish:Ft,commaOrSpaceSeparated:Zn,commaSeparated:js,number:le,overloadedBoolean:Ub,spaceSeparated:ut},Symbol.toStringTag,{value:"Module"})),Gg=Object.keys(Wb);class h0 extends Kn{constructor(t,n,r,a){let s=-1;if(super(t,n),vE(this,"space",a),typeof r=="number")for(;++s<Gg.length;){const o=Gg[s];vE(this,Gg[s],(r&Wb[o])===Wb[o])}}}h0.prototype.defined=!0;function vE(e,t,n){n&&(e[t]=n)}function Rl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const s=new h0(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[Fb(r)]=r,n[Fb(s.attribute)]=r}return new id(t,n,e.space)}const vM=Rl({properties:{ariaActiveDescendant:null,ariaAtomic:Ft,ariaAutoComplete:null,ariaBusy:Ft,ariaChecked:Ft,ariaColCount:le,ariaColIndex:le,ariaColSpan:le,ariaControls:ut,ariaCurrent:null,ariaDescribedBy:ut,ariaDetails:null,ariaDisabled:Ft,ariaDropEffect:ut,ariaErrorMessage:null,ariaExpanded:Ft,ariaFlowTo:ut,ariaGrabbed:Ft,ariaHasPopup:null,ariaHidden:Ft,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:ut,ariaLevel:le,ariaLive:null,ariaModal:Ft,ariaMultiLine:Ft,ariaMultiSelectable:Ft,ariaOrientation:null,ariaOwns:ut,ariaPlaceholder:null,ariaPosInSet:le,ariaPressed:Ft,ariaReadOnly:Ft,ariaRelevant:null,ariaRequired:Ft,ariaRoleDescription:ut,ariaRowCount:le,ariaRowIndex:le,ariaRowSpan:le,ariaSelected:Ft,ariaSetSize:le,ariaSort:null,ariaValueMax:le,ariaValueMin:le,ariaValueNow:le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function yM(e,t){return t in e?e[t]:t}function bM(e,t){return yM(e,t.toLowerCase())}const $le=Rl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:js,acceptCharset:ut,accessKey:ut,action:null,allow:null,allowFullScreen:Ie,allowPaymentRequest:Ie,allowUserMedia:Ie,alpha:Ie,alt:null,as:null,async:Ie,autoCapitalize:null,autoComplete:ut,autoFocus:Ie,autoPlay:Ie,blocking:ut,capture:null,charSet:null,checked:Ie,cite:null,className:ut,closedBy:null,colorSpace:null,cols:le,colSpan:le,command:null,commandFor:null,content:null,contentEditable:Ft,controls:Ie,controlsList:ut,coords:le|js,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ie,defer:Ie,dir:null,dirName:null,disabled:Ie,download:Ub,draggable:Ft,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ie,formTarget:null,headers:ut,height:le,hidden:Ub,high:le,href:null,hrefLang:null,htmlFor:ut,httpEquiv:ut,id:null,imageSizes:null,imageSrcSet:null,inert:Ie,inputMode:null,integrity:null,is:null,isMap:Ie,itemId:null,itemProp:ut,itemRef:ut,itemScope:Ie,itemType:ut,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ie,low:le,manifest:null,max:null,maxLength:le,media:null,method:null,min:null,minLength:le,multiple:Ie,muted:Ie,name:null,nonce:null,noModule:Ie,noValidate:Ie,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ie,optimum:le,pattern:null,ping:ut,placeholder:null,playsInline:Ie,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ie,referrerPolicy:null,rel:ut,required:Ie,reversed:Ie,rows:le,rowSpan:le,sandbox:ut,scope:null,scoped:Ie,seamless:Ie,selected:Ie,shadowRootClonable:Ie,shadowRootCustomElementRegistry:Ie,shadowRootDelegatesFocus:Ie,shadowRootMode:null,shadowRootSerializable:Ie,shape:null,size:le,sizes:null,slot:null,span:le,spellCheck:Ft,src:null,srcDoc:null,srcLang:null,srcSet:null,start:le,step:null,style:null,tabIndex:le,target:null,title:null,translate:null,type:null,typeMustMatch:Ie,useMap:null,value:Ft,width:le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:ut,axis:null,background:null,bgColor:null,border:le,borderColor:null,bottomMargin:le,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ie,declare:Ie,event:null,face:null,frame:null,frameBorder:null,hSpace:le,leftMargin:le,link:null,longDesc:null,lowSrc:null,marginHeight:le,marginWidth:le,noResize:Ie,noHref:Ie,noShade:Ie,noWrap:Ie,object:null,profile:null,prompt:null,rev:null,rightMargin:le,rules:null,scheme:null,scrolling:Ft,standby:null,summary:null,text:null,topMargin:le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:le,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ie,disablePictureInPicture:Ie,disableRemotePlayback:Ie,exportParts:js,part:ut,prefix:null,property:null,results:le,security:null,unselectable:null},space:"html",transform:bM}),Lle=Rl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Zn,accentHeight:le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:le,amplitude:le,arabicForm:null,ascent:le,attributeName:null,attributeType:null,azimuth:le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:le,by:null,calcMode:null,capHeight:le,className:ut,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:le,diffuseConstant:le,direction:null,display:null,dur:null,divisor:le,dominantBaseline:null,download:Ie,dx:null,dy:null,edgeMode:null,editable:null,elevation:le,enableBackground:null,end:null,event:null,exponent:le,externalResourcesRequired:null,fill:null,fillOpacity:le,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:js,g2:js,glyphName:js,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:le,horizOriginX:le,horizOriginY:le,id:null,ideographic:le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:le,k:le,k1:le,k2:le,k3:le,k4:le,kernelMatrix:Zn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:le,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:le,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:le,overlineThickness:le,paintOrder:null,panose1:null,path:null,pathLength:le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:ut,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:le,pointsAtY:le,pointsAtZ:le,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Zn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Zn,rev:Zn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Zn,requiredFeatures:Zn,requiredFonts:Zn,requiredFormats:Zn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:le,specularExponent:le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:le,strikethroughThickness:le,string:null,stroke:null,strokeDashArray:Zn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:le,strokeOpacity:le,strokeWidth:null,style:null,surfaceScale:le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Zn,tabIndex:le,tableValues:null,target:null,targetX:le,targetY:le,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Zn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:le,underlineThickness:le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:le,values:null,vAlphabetic:le,vMathematical:le,vectorEffect:null,vHanging:le,vIdeographic:le,version:null,vertAdvY:le,vertOriginX:le,vertOriginY:le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yM}),xM=Rl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),wM=Rl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:bM}),kM=Rl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Dle={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},Ble=/[A-Z]/g,yE=/-[a-z]/g,zle=/^data[-\w.:]+$/i;function Fle(e,t){const n=Fb(t);let r=t,a=Kn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&zle.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(yE,Wle);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!yE.test(s)){let o=s.replace(Ble,Ule);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=h0}return new a(r,t)}function Ule(e){return"-"+e.toLowerCase()}function Wle(e){return e.charAt(1).toUpperCase()}const Hle=gM([vM,$le,xM,wM,kM],"html"),p0=gM([vM,Lle,xM,wM,kM],"svg");function Gle(e){return e.join(" ").trim()}var m0={},bE=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,qle=/\n/g,Kle=/^\s*/,Vle=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Yle=/^:\s*/,Xle=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,Qle=/^[;\s]*/,Zle=/^\s+|\s+$/g,Jle=`
165
165
  `,xE="/",wE="*",cs="",ece="comment",tce="declaration";function nce(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function a(m){var g=m.match(qle);g&&(n+=g.length);var y=m.lastIndexOf(Jle);r=~y?m.length-y:r+m.length}function s(){var m={line:n,column:r};return function(g){return g.position=new o(m),u(),g}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function l(m){var g=new Error(t.source+":"+n+":"+r+": "+m);if(g.reason=m,g.filename=t.source,g.line=n,g.column=r,g.source=e,!t.silent)throw g}function c(m){var g=m.exec(e);if(g){var y=g[0];return a(y),e=e.slice(y.length),g}}function u(){c(Kle)}function d(m){var g;for(m=m||[];g=f();)g!==!1&&m.push(g);return m}function f(){var m=s();if(!(xE!=e.charAt(0)||wE!=e.charAt(1))){for(var g=2;cs!=e.charAt(g)&&(wE!=e.charAt(g)||xE!=e.charAt(g+1));)++g;if(g+=2,cs===e.charAt(g-1))return l("End of comment missing");var y=e.slice(2,g-2);return r+=2,a(y),e=e.slice(g),r+=2,m({type:ece,comment:y})}}function h(){var m=s(),g=c(Vle);if(g){if(f(),!c(Yle))return l("property missing ':'");var y=c(Xle),v=m({type:tce,property:kE(g[0].replace(bE,cs)),value:y?kE(y[0].replace(bE,cs)):cs});return c(Qle),v}}function p(){var m=[];d(m);for(var g;g=h();)g!==!1&&(m.push(g),d(m));return m}return u(),p()}function kE(e){return e?e.replace(Zle,cs):cs}var rce=nce,ace=ui&&ui.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(m0,"__esModule",{value:!0});m0.default=sce;const ice=ace(rce);function sce(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,ice.default)(e),a=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:l}=s;a?t(o,l,s):l&&(n=n||{},n[o]=l)}),n}var xm={};Object.defineProperty(xm,"__esModule",{value:!0});xm.camelCase=void 0;var oce=/^--[a-zA-Z0-9_-]+$/,lce=/-([a-z])/g,cce=/^[^-]+$/,uce=/^-(webkit|moz|ms|o|khtml)-/,dce=/^-(ms)-/,fce=function(e){return!e||cce.test(e)||oce.test(e)},hce=function(e,t){return t.toUpperCase()},SE=function(e,t){return"".concat(t,"-")},pce=function(e,t){return t===void 0&&(t={}),fce(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(dce,SE):e=e.replace(uce,SE),e.replace(lce,hce))};xm.camelCase=pce;var mce=ui&&ui.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},gce=mce(m0),vce=xm;function Hb(e,t){var n={};return!e||typeof e!="string"||(0,gce.default)(e,function(r,a){r&&a&&(n[(0,vce.camelCase)(r,t)]=a)}),n}Hb.default=Hb;var yce=Hb;const bce=Je(yce),SM=jM("end"),g0=jM("start");function jM(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function xce(e){const t=g0(e),n=SM(e);if(t&&n)return{start:t,end:n}}function Lc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?jE(e.position):"start"in e||"end"in e?jE(e):"line"in e||"column"in e?Gb(e):""}function Gb(e){return NE(e&&e.line)+":"+NE(e&&e.column)}function jE(e){return Gb(e&&e.start)+"-"+Gb(e&&e.end)}function NE(e){return e&&typeof e=="number"?e:1}class En extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?a=t:!s.cause&&t&&(o=!0,a=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?s.ruleId=r:(s.source=r.slice(0,c),s.ruleId=r.slice(c+1))}if(!s.place&&s.ancestors&&s.ancestors){const c=s.ancestors[s.ancestors.length-1];c&&(s.place=c.position)}const l=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=l?l.line:void 0,this.name=Lc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}En.prototype.file="";En.prototype.name="";En.prototype.reason="";En.prototype.message="";En.prototype.stack="";En.prototype.column=void 0;En.prototype.line=void 0;En.prototype.ancestors=void 0;En.prototype.cause=void 0;En.prototype.fatal=void 0;En.prototype.place=void 0;En.prototype.ruleId=void 0;En.prototype.source=void 0;const v0={}.hasOwnProperty,wce=new Map,kce=/[A-Z]/g,Sce=new Set(["table","tbody","thead","tfoot","tr"]),jce=new Set(["td","th"]),NM="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Nce(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=Rce(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=Pce(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?p0:Hle,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=EM(a,e,void 0);return s&&typeof s!="string"?s:a.create(e,a.Fragment,{children:s||void 0},void 0)}function EM(e,t,n){if(t.type==="element")return Ece(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return _ce(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Ace(e,t,n);if(t.type==="mdxjsEsm")return Cce(e,t);if(t.type==="root")return Tce(e,t,n);if(t.type==="text")return Oce(e,t)}function Ece(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=p0,e.schema=a),e.ancestors.push(t);const s=CM(e,t.tagName,!1),o=Mce(e,t);let l=b0(e,t);return Sce.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!Mle(c):!0})),_M(e,o,s,t),y0(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function _ce(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Uu(e,t.position)}function Cce(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Uu(e,t.position)}function Ace(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=p0,e.schema=a),e.ancestors.push(t);const s=t.name===null?e.Fragment:CM(e,t.name,!0),o=Ice(e,t),l=b0(e,t);return _M(e,o,s,t),y0(o,l),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Tce(e,t,n){const r={};return y0(r,b0(e,t)),e.create(t,e.Fragment,r,n)}function Oce(e,t){return t.value}function _M(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function y0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Pce(e,t,n){return r;function r(a,s,o,l){const u=Array.isArray(o.children)?n:t;return l?u(s,o,l):u(s,o)}}function Rce(e,t){return n;function n(r,a,s,o){const l=Array.isArray(s.children),c=g0(r);return t(a,s,o,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function Mce(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&v0.call(t.properties,a)){const s=$ce(e,a,t.properties[a]);if(s){const[o,l]=s;e.tableCellAlignToStyle&&o==="align"&&typeof l=="string"&&jce.has(t.tagName)?r=l:n[o]=l}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function Ice(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const l=o.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Uu(e,t.position);else{const a=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,s=e.evaluater.evaluateExpression(l.expression)}else Uu(e,t.position);else s=r.value===null?!0:r.value;n[a]=s}return n}function b0(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:wce;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const c=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(c){const u=a.get(c)||0;o=c+"-"+u,a.set(c,u+1)}}const l=EM(e,s,o);l!==void 0&&n.push(l)}return n}function $ce(e,t,n){const r=Fle(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?Ale(n):Gle(n)),r.property==="style"){let a=typeof n=="object"?n:Lce(e,String(n));return e.stylePropertyNameCase==="css"&&(a=Dce(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?Dle[r.property]||r.property:r.attribute,n]}}function Lce(e,t){try{return bce(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new En("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=NM+"#cannot-parse-style-attribute",a}}function CM(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let s=-1,o;for(;++s<a.length;){const l=mE(a[s])?{type:"Identifier",name:a[s]}:{type:"Literal",value:a[s]};o=o?{type:"MemberExpression",object:o,property:l,computed:!!(s&&l.type==="Literal"),optional:!1}:l}r=o}else r=mE(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return v0.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);Uu(e)}function Uu(e,t){const n=new En("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=NM+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Dce(e){const t={};let n;for(n in e)v0.call(e,n)&&(t[Bce(n)]=e[n]);return t}function Bce(e){let t=e.replace(kce,zce);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function zce(e){return"-"+e.toLowerCase()}const qg={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},Fce={};function x0(e,t){const n=Fce,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return AM(e,r,a)}function AM(e,t,n){if(Uce(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return EE(e.children,t,n)}return Array.isArray(e)?EE(e,t,n):""}function EE(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=AM(e[a],t,n);return r.join("")}function Uce(e){return!!(e&&typeof e=="object")}const _E=document.createElement("i");function w0(e){const t="&"+e+";";_E.innerHTML=t;const n=_E.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function ir(e,t,n,r){const a=e.length;let s=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function xr(e,t){return e.length>0?(ir(e,e.length,0,t),e):t}const CE={}.hasOwnProperty;function TM(e){const t={};let n=-1;for(;++n<e.length;)Wce(t,e[n]);return t}function Wce(e,t){let n;for(n in t){const a=(CE.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){CE.call(a,o)||(a[o]=[]);const l=s[o];Hce(a[o],Array.isArray(l)?l:l?[l]:[])}}}function Hce(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);ir(e,0,0,r)}function OM(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Hr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const On=Ui(/[A-Za-z]/),jn=Ui(/[\dA-Za-z]/),Gce=Ui(/[#-'*+\--9=?A-Z^-~]/);function ap(e){return e!==null&&(e<32||e===127)}const qb=Ui(/\d/),qce=Ui(/[\dA-Fa-f]/),Kce=Ui(/[!-/:-@[-`{-~]/);function Ce(e){return e!==null&&e<-2}function ft(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const wm=Ui(new RegExp("\\p{P}|\\p{S}","u")),$s=Ui(/\s/);function Ui(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Ml(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&jn(e.charCodeAt(n+1))&&jn(e.charCodeAt(n+2)))a=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const l=e.charCodeAt(n+1);s<56320&&l>56319&&l<57344?(o=String.fromCharCode(s,l),a=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function He(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(c){return Ue(c)?(e.enter(n),l(c)):t(c)}function l(c){return Ue(c)&&s++<a?(e.consume(c),l):(e.exit(n),t(c))}}const Vce={tokenize:Yce};function Yce(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),He(e,t,"linePrefix")}function a(l){return e.enter("paragraph"),s(l)}function s(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,o(l)}function o(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return Ce(l)?(e.consume(l),e.exit("chunkText"),s):(e.consume(l),o)}}const Xce={tokenize:Qce},AE={tokenize:Zce};function Qce(e){const t=this,n=[];let r=0,a,s,o;return l;function l(w){if(r<n.length){const N=n[r];return t.containerState=N[1],e.attempt(N[0].continuation,c,u)(w)}return u(w)}function c(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&S();const N=t.events.length;let k=N,b;for(;k--;)if(t.events[k][0]==="exit"&&t.events[k][1].type==="chunkFlow"){b=t.events[k][1].end;break}v(r);let j=N;for(;j<t.events.length;)t.events[j][1].end={...b},j++;return ir(t.events,k+1,0,t.events.slice(N)),t.events.length=j,u(w)}return l(w)}function u(w){if(r===n.length){if(!a)return h(w);if(a.currentConstruct&&a.currentConstruct.concrete)return m(w);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(AE,d,f)(w)}function d(w){return a&&S(),v(r),h(w)}function f(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(w)}function h(w){return t.containerState={},e.attempt(AE,p,m)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),h(w)}function m(w){if(w===null){a&&S(),v(0),e.consume(w);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:s}),g(w)}function g(w){if(w===null){y(e.exit("chunkFlow"),!0),v(0),e.consume(w);return}return Ce(w)?(e.consume(w),y(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),g)}function y(w,N){const k=t.sliceStream(w);if(N&&k.push(null),w.previous=s,s&&(s.next=w),s=w,a.defineSkip(w.start),a.write(k),t.parser.lazy[w.start.line]){let b=a.events.length;for(;b--;)if(a.events[b][1].start.offset<o&&(!a.events[b][1].end||a.events[b][1].end.offset>o))return;const j=t.events.length;let E=j,P,_;for(;E--;)if(t.events[E][0]==="exit"&&t.events[E][1].type==="chunkFlow"){if(P){_=t.events[E][1].end;break}P=!0}for(v(r),b=j;b<t.events.length;)t.events[b][1].end={..._},b++;ir(t.events,E+1,0,t.events.slice(j)),t.events.length=b}}function v(w){let N=n.length;for(;N-- >w;){const k=n[N];t.containerState=k[1],k[0].exit.call(t,e)}n.length=w}function S(){a.write([null]),s=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Zce(e,t,n){return He(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function pl(e){if(e===null||ft(e)||$s(e))return 1;if(wm(e))return 2}function km(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const s=e[a].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const Kb={name:"attention",resolveAll:Jce,tokenize:eue};function Jce(e,t){let n=-1,r,a,s,o,l,c,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const f={...e[r][1].end},h={...e[n][1].start};TE(f,-c),TE(h,c),o={type:c>1?"strongSequence":"emphasisSequence",start:f,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:h},s={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:c>1?"strong":"emphasis",start:{...o.start},end:{...l.end}},e[r][1].end={...o.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=xr(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=xr(u,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",s,t]]),u=xr(u,km(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=xr(u,[["exit",s,t],["enter",l,t],["exit",l,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=xr(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,ir(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function eue(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=pl(r);let s;return o;function o(c){return s=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===s)return e.consume(c),l;const u=e.exit("attentionSequence"),d=pl(c),f=!d||d===2&&a||n.includes(c),h=!a||a===2&&d||n.includes(r);return u._open=!!(s===42?f:f&&(a||!h)),u._close=!!(s===42?h:h&&(d||!f)),t(c)}}function TE(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const tue={name:"autolink",tokenize:nue};function nue(e,t,n){let r=0;return a;function a(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return On(p)?(e.consume(p),o):p===64?n(p):u(p)}function o(p){return p===43||p===45||p===46||jn(p)?(r=1,l(p)):u(p)}function l(p){return p===58?(e.consume(p),r=0,c):(p===43||p===45||p===46||jn(p))&&r++<32?(e.consume(p),l):(r=0,u(p))}function c(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ap(p)?n(p):(e.consume(p),c)}function u(p){return p===64?(e.consume(p),d):Gce(p)?(e.consume(p),u):n(p)}function d(p){return jn(p)?f(p):n(p)}function f(p){return p===46?(e.consume(p),r=0,d):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):h(p)}function h(p){if((p===45||jn(p))&&r++<63){const m=p===45?h:f;return e.consume(p),m}return n(p)}}const sd={partial:!0,tokenize:rue};function rue(e,t,n){return r;function r(s){return Ue(s)?He(e,a,"linePrefix")(s):a(s)}function a(s){return s===null||Ce(s)?t(s):n(s)}}const PM={continuation:{tokenize:iue},exit:sue,name:"blockQuote",tokenize:aue};function aue(e,t,n){const r=this;return a;function a(o){if(o===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function iue(e,t,n){const r=this;return a;function a(o){return Ue(o)?He(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(PM,t,n)(o)}}function sue(e){e.exit("blockQuote")}const RM={name:"characterEscape",tokenize:oue};function oue(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),a}function a(s){return Kce(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const MM={name:"characterReference",tokenize:lue};function lue(e,t,n){const r=this;let a=0,s,o;return l;function l(f){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),c}function c(f){return f===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(f),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),s=31,o=jn,d(f))}function u(f){return f===88||f===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(f),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=qce,d):(e.enter("characterReferenceValue"),s=7,o=qb,d(f))}function d(f){if(f===59&&a){const h=e.exit("characterReferenceValue");return o===jn&&!w0(r.sliceSerialize(h))?n(f):(e.enter("characterReferenceMarker"),e.consume(f),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(f)&&a++<s?(e.consume(f),d):n(f)}}const OE={partial:!0,tokenize:uue},PE={concrete:!0,name:"codeFenced",tokenize:cue};function cue(e,t,n){const r=this,a={partial:!0,tokenize:k};let s=0,o=0,l;return c;function c(b){return u(b)}function u(b){const j=r.events[r.events.length-1];return s=j&&j[1].type==="linePrefix"?j[2].sliceSerialize(j[1],!0).length:0,l=b,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(b)}function d(b){return b===l?(o++,e.consume(b),d):o<3?n(b):(e.exit("codeFencedFenceSequence"),Ue(b)?He(e,f,"whitespace")(b):f(b))}function f(b){return b===null||Ce(b)?(e.exit("codeFencedFence"),r.interrupt?t(b):e.check(OE,g,N)(b)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),h(b))}function h(b){return b===null||Ce(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(b)):Ue(b)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),He(e,p,"whitespace")(b)):b===96&&b===l?n(b):(e.consume(b),h)}function p(b){return b===null||Ce(b)?f(b):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(b))}function m(b){return b===null||Ce(b)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(b)):b===96&&b===l?n(b):(e.consume(b),m)}function g(b){return e.attempt(a,N,y)(b)}function y(b){return e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),v}function v(b){return s>0&&Ue(b)?He(e,S,"linePrefix",s+1)(b):S(b)}function S(b){return b===null||Ce(b)?e.check(OE,g,N)(b):(e.enter("codeFlowValue"),w(b))}function w(b){return b===null||Ce(b)?(e.exit("codeFlowValue"),S(b)):(e.consume(b),w)}function N(b){return e.exit("codeFenced"),t(b)}function k(b,j,E){let P=0;return _;function _(M){return b.enter("lineEnding"),b.consume(M),b.exit("lineEnding"),A}function A(M){return b.enter("codeFencedFence"),Ue(M)?He(b,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):O(M)}function O(M){return M===l?(b.enter("codeFencedFenceSequence"),B(M)):E(M)}function B(M){return M===l?(P++,b.consume(M),B):P>=o?(b.exit("codeFencedFenceSequence"),Ue(M)?He(b,$,"whitespace")(M):$(M)):E(M)}function $(M){return M===null||Ce(M)?(b.exit("codeFencedFence"),j(M)):E(M)}}}function uue(e,t,n){const r=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Kg={name:"codeIndented",tokenize:fue},due={partial:!0,tokenize:hue};function fue(e,t,n){const r=this;return a;function a(u){return e.enter("codeIndented"),He(e,s,"linePrefix",5)(u)}function s(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?c(u):Ce(u)?e.attempt(due,o,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||Ce(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function hue(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):Ce(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):He(e,s,"linePrefix",5)(o)}function s(o){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):Ce(o)?a(o):n(o)}}const pue={name:"codeText",previous:gue,resolve:mue,tokenize:vue};function mue(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function gue(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function vue(e,t,n){let r=0,a,s;return o;function o(f){return e.enter("codeText"),e.enter("codeTextSequence"),l(f)}function l(f){return f===96?(e.consume(f),r++,l):(e.exit("codeTextSequence"),c(f))}function c(f){return f===null?n(f):f===32?(e.enter("space"),e.consume(f),e.exit("space"),c):f===96?(s=e.enter("codeTextSequence"),a=0,d(f)):Ce(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(f))}function u(f){return f===null||f===32||f===96||Ce(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),a++,d):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(s.type="codeTextData",u(f))}}class yue{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&hc(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),hc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),hc(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);hc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);hc(this.left,n.reverse())}}}function hc(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function IM(e){const t={};let n=-1,r,a,s,o,l,c,u;const d=new yue(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,s=0,s<c.length&&c[s][1].type==="lineEndingBlank"&&(s+=2),s<c.length&&c[s][1].type==="content"))for(;++s<c.length&&c[s][1].type!=="content";)c[s][1].type==="chunkText"&&(c[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,bue(d,n)),n=t[n],u=!0);else if(r[1]._container){for(s=n,a=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(d.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(r[1].end={...d.get(a)[1].start},l=d.slice(a,n),l.unshift(r),d.splice(a,n-a+1,l))}}return ir(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function bue(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const l=o.events,c=[],u={};let d,f,h=-1,p=n,m=0,g=0;const y=[g];for(;p;){for(;e.get(++a)[1]!==p;);s.push(a),p._tokenizer||(d=r.sliceStream(p),p.next||d.push(null),f&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),f=p,p=p.next}for(p=n;++h<l.length;)l[h][0]==="exit"&&l[h-1][0]==="enter"&&l[h][1].type===l[h-1][1].type&&l[h][1].start.line!==l[h][1].end.line&&(g=h+1,y.push(g),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):y.pop(),h=y.length;h--;){const v=l.slice(y[h],y[h+1]),S=s.pop();c.push([S,S+v.length-1]),e.splice(S,2,v)}for(c.reverse(),h=-1;++h<c.length;)u[m+c[h][0]]=m+c[h][1],m+=c[h][1]-c[h][0]-1;return u}const xue={resolve:kue,tokenize:Sue},wue={partial:!0,tokenize:jue};function kue(e){return IM(e),e}function Sue(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(l)}function a(l){return l===null?s(l):Ce(l)?e.check(wue,o,s)(l):(e.consume(l),a)}function s(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function o(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function jue(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),He(e,s,"linePrefix")}function s(o){if(o===null||Ce(o))return n(o);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function $M(e,t,n,r,a,s,o,l,c){const u=c||Number.POSITIVE_INFINITY;let d=0;return f;function f(v){return v===60?(e.enter(r),e.enter(a),e.enter(s),e.consume(v),e.exit(s),h):v===null||v===32||v===41||ap(v)?n(v):(e.enter(r),e.enter(o),e.enter(l),e.enter("chunkString",{contentType:"string"}),g(v))}function h(v){return v===62?(e.enter(s),e.consume(v),e.exit(s),e.exit(a),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),p(v))}function p(v){return v===62?(e.exit("chunkString"),e.exit(l),h(v)):v===null||v===60||Ce(v)?n(v):(e.consume(v),v===92?m:p)}function m(v){return v===60||v===62||v===92?(e.consume(v),p):p(v)}function g(v){return!d&&(v===null||v===41||ft(v))?(e.exit("chunkString"),e.exit(l),e.exit(o),e.exit(r),t(v)):d<u&&v===40?(e.consume(v),d++,g):v===41?(e.consume(v),d--,g):v===null||v===32||v===40||ap(v)?n(v):(e.consume(v),v===92?y:g)}function y(v){return v===40||v===41||v===92?(e.consume(v),g):g(v)}}function LM(e,t,n,r,a,s){const o=this;let l=0,c;return u;function u(p){return e.enter(r),e.enter(a),e.consume(p),e.exit(a),e.enter(s),d}function d(p){return l>999||p===null||p===91||p===93&&!c||p===94&&!l&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(a),e.consume(p),e.exit(a),e.exit(r),t):Ce(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===null||p===91||p===93||Ce(p)||l++>999?(e.exit("chunkString"),d(p)):(e.consume(p),c||(c=!Ue(p)),p===92?h:f)}function h(p){return p===91||p===92||p===93?(e.consume(p),l++,f):f(p)}}function DM(e,t,n,r,a,s){let o;return l;function l(h){return h===34||h===39||h===40?(e.enter(r),e.enter(a),e.consume(h),e.exit(a),o=h===40?41:h,c):n(h)}function c(h){return h===o?(e.enter(a),e.consume(h),e.exit(a),e.exit(r),t):(e.enter(s),u(h))}function u(h){return h===o?(e.exit(s),c(o)):h===null?n(h):Ce(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),He(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===o||h===null||Ce(h)?(e.exit("chunkString"),u(h)):(e.consume(h),h===92?f:d)}function f(h){return h===o||h===92?(e.consume(h),d):d(h)}}function Dc(e,t){let n;return r;function r(a){return Ce(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Ue(a)?He(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const Nue={name:"definition",tokenize:_ue},Eue={partial:!0,tokenize:Cue};function _ue(e,t,n){const r=this;let a;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return LM.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function l(p){return a=Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),c):n(p)}function c(p){return ft(p)?Dc(e,u)(p):u(p)}function u(p){return $M(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function d(p){return e.attempt(Eue,f,f)(p)}function f(p){return Ue(p)?He(e,h,"whitespace")(p):h(p)}function h(p){return p===null||Ce(p)?(e.exit("definition"),r.parser.defined.push(a),t(p)):n(p)}}function Cue(e,t,n){return r;function r(l){return ft(l)?Dc(e,a)(l):n(l)}function a(l){return DM(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function s(l){return Ue(l)?He(e,o,"whitespace")(l):o(l)}function o(l){return l===null||Ce(l)?t(l):n(l)}}const Aue={name:"hardBreakEscape",tokenize:Tue};function Tue(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),a}function a(s){return Ce(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Oue={name:"headingAtx",resolve:Pue,tokenize:Rue};function Pue(e,t){let n=e.length-2,r=3,a,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},ir(e,r,n-r+1,[["enter",a,t],["enter",s,t],["exit",s,t],["exit",a,t]])),e}function Rue(e,t,n){let r=0;return a;function a(d){return e.enter("atxHeading"),s(d)}function s(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||ft(d)?(e.exit("atxHeadingSequence"),l(d)):n(d)}function l(d){return d===35?(e.enter("atxHeadingSequence"),c(d)):d===null||Ce(d)?(e.exit("atxHeading"),t(d)):Ue(d)?He(e,l,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function c(d){return d===35?(e.consume(d),c):(e.exit("atxHeadingSequence"),l(d))}function u(d){return d===null||d===35||ft(d)?(e.exit("atxHeadingText"),l(d)):(e.consume(d),u)}}const Mue=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],RE=["pre","script","style","textarea"],Iue={concrete:!0,name:"htmlFlow",resolveTo:Due,tokenize:Bue},$ue={partial:!0,tokenize:Fue},Lue={partial:!0,tokenize:zue};function Due(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Bue(e,t,n){const r=this;let a,s,o,l,c;return u;function u(I){return d(I)}function d(I){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(I),f}function f(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),s=!0,g):I===63?(e.consume(I),a=3,r.interrupt?t:T):On(I)?(e.consume(I),o=String.fromCharCode(I),y):n(I)}function h(I){return I===45?(e.consume(I),a=2,p):I===91?(e.consume(I),a=5,l=0,m):On(I)?(e.consume(I),a=4,r.interrupt?t:T):n(I)}function p(I){return I===45?(e.consume(I),r.interrupt?t:T):n(I)}function m(I){const se="CDATA[";return I===se.charCodeAt(l++)?(e.consume(I),l===se.length?r.interrupt?t:O:m):n(I)}function g(I){return On(I)?(e.consume(I),o=String.fromCharCode(I),y):n(I)}function y(I){if(I===null||I===47||I===62||ft(I)){const se=I===47,he=o.toLowerCase();return!se&&!s&&RE.includes(he)?(a=1,r.interrupt?t(I):O(I)):Mue.includes(o.toLowerCase())?(a=6,se?(e.consume(I),v):r.interrupt?t(I):O(I)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(I):s?S(I):w(I))}return I===45||jn(I)?(e.consume(I),o+=String.fromCharCode(I),y):n(I)}function v(I){return I===62?(e.consume(I),r.interrupt?t:O):n(I)}function S(I){return Ue(I)?(e.consume(I),S):_(I)}function w(I){return I===47?(e.consume(I),_):I===58||I===95||On(I)?(e.consume(I),N):Ue(I)?(e.consume(I),w):_(I)}function N(I){return I===45||I===46||I===58||I===95||jn(I)?(e.consume(I),N):k(I)}function k(I){return I===61?(e.consume(I),b):Ue(I)?(e.consume(I),k):w(I)}function b(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),c=I,j):Ue(I)?(e.consume(I),b):E(I)}function j(I){return I===c?(e.consume(I),c=null,P):I===null||Ce(I)?n(I):(e.consume(I),j)}function E(I){return I===null||I===34||I===39||I===47||I===60||I===61||I===62||I===96||ft(I)?k(I):(e.consume(I),E)}function P(I){return I===47||I===62||Ue(I)?w(I):n(I)}function _(I){return I===62?(e.consume(I),A):n(I)}function A(I){return I===null||Ce(I)?O(I):Ue(I)?(e.consume(I),A):n(I)}function O(I){return I===45&&a===2?(e.consume(I),D):I===60&&a===1?(e.consume(I),U):I===62&&a===4?(e.consume(I),Z):I===63&&a===3?(e.consume(I),T):I===93&&a===5?(e.consume(I),z):Ce(I)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check($ue,F,B)(I)):I===null||Ce(I)?(e.exit("htmlFlowData"),B(I)):(e.consume(I),O)}function B(I){return e.check(Lue,$,F)(I)}function $(I){return e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),M}function M(I){return I===null||Ce(I)?B(I):(e.enter("htmlFlowData"),O(I))}function D(I){return I===45?(e.consume(I),T):O(I)}function U(I){return I===47?(e.consume(I),o="",R):O(I)}function R(I){if(I===62){const se=o.toLowerCase();return RE.includes(se)?(e.consume(I),Z):O(I)}return On(I)&&o.length<8?(e.consume(I),o+=String.fromCharCode(I),R):O(I)}function z(I){return I===93?(e.consume(I),T):O(I)}function T(I){return I===62?(e.consume(I),Z):I===45&&a===2?(e.consume(I),T):O(I)}function Z(I){return I===null||Ce(I)?(e.exit("htmlFlowData"),F(I)):(e.consume(I),Z)}function F(I){return e.exit("htmlFlow"),t(I)}}function zue(e,t,n){const r=this;return a;function a(o){return Ce(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Fue(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(sd,t,n)}}const Uue={name:"htmlText",tokenize:Wue};function Wue(e,t,n){const r=this;let a,s,o;return l;function l(T){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(T),c}function c(T){return T===33?(e.consume(T),u):T===47?(e.consume(T),k):T===63?(e.consume(T),w):On(T)?(e.consume(T),E):n(T)}function u(T){return T===45?(e.consume(T),d):T===91?(e.consume(T),s=0,m):On(T)?(e.consume(T),S):n(T)}function d(T){return T===45?(e.consume(T),p):n(T)}function f(T){return T===null?n(T):T===45?(e.consume(T),h):Ce(T)?(o=f,U(T)):(e.consume(T),f)}function h(T){return T===45?(e.consume(T),p):f(T)}function p(T){return T===62?D(T):T===45?h(T):f(T)}function m(T){const Z="CDATA[";return T===Z.charCodeAt(s++)?(e.consume(T),s===Z.length?g:m):n(T)}function g(T){return T===null?n(T):T===93?(e.consume(T),y):Ce(T)?(o=g,U(T)):(e.consume(T),g)}function y(T){return T===93?(e.consume(T),v):g(T)}function v(T){return T===62?D(T):T===93?(e.consume(T),v):g(T)}function S(T){return T===null||T===62?D(T):Ce(T)?(o=S,U(T)):(e.consume(T),S)}function w(T){return T===null?n(T):T===63?(e.consume(T),N):Ce(T)?(o=w,U(T)):(e.consume(T),w)}function N(T){return T===62?D(T):w(T)}function k(T){return On(T)?(e.consume(T),b):n(T)}function b(T){return T===45||jn(T)?(e.consume(T),b):j(T)}function j(T){return Ce(T)?(o=j,U(T)):Ue(T)?(e.consume(T),j):D(T)}function E(T){return T===45||jn(T)?(e.consume(T),E):T===47||T===62||ft(T)?P(T):n(T)}function P(T){return T===47?(e.consume(T),D):T===58||T===95||On(T)?(e.consume(T),_):Ce(T)?(o=P,U(T)):Ue(T)?(e.consume(T),P):D(T)}function _(T){return T===45||T===46||T===58||T===95||jn(T)?(e.consume(T),_):A(T)}function A(T){return T===61?(e.consume(T),O):Ce(T)?(o=A,U(T)):Ue(T)?(e.consume(T),A):P(T)}function O(T){return T===null||T===60||T===61||T===62||T===96?n(T):T===34||T===39?(e.consume(T),a=T,B):Ce(T)?(o=O,U(T)):Ue(T)?(e.consume(T),O):(e.consume(T),$)}function B(T){return T===a?(e.consume(T),a=void 0,M):T===null?n(T):Ce(T)?(o=B,U(T)):(e.consume(T),B)}function $(T){return T===null||T===34||T===39||T===60||T===61||T===96?n(T):T===47||T===62||ft(T)?P(T):(e.consume(T),$)}function M(T){return T===47||T===62||ft(T)?P(T):n(T)}function D(T){return T===62?(e.consume(T),e.exit("htmlTextData"),e.exit("htmlText"),t):n(T)}function U(T){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),R}function R(T){return Ue(T)?He(e,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(T):z(T)}function z(T){return e.enter("htmlTextData"),o(T)}}const k0={name:"labelEnd",resolveAll:Kue,resolveTo:Vue,tokenize:Yue},Hue={tokenize:Xue},Gue={tokenize:Que},que={tokenize:Zue};function Kue(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&ir(e,0,e.length,n),e}function Vue(e,t){let n=e.length,r=0,a,s,o,l;for(;n--;)if(a=e[n][1],s){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(s=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(o=n);const c={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=xr(l,e.slice(s+1,s+r+3)),l=xr(l,[["enter",d,t]]),l=xr(l,km(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),l=xr(l,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),l=xr(l,e.slice(o+1)),l=xr(l,[["exit",c,t]]),ir(e,s,e.length,l),e}function Yue(e,t,n){const r=this;let a=r.events.length,s,o;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){s=r.events[a][1];break}return l;function l(h){return s?s._inactive?f(h):(o=r.parser.defined.includes(Hr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(h),e.exit("labelMarker"),e.exit("labelEnd"),c):n(h)}function c(h){return h===40?e.attempt(Hue,d,o?d:f)(h):h===91?e.attempt(Gue,d,o?u:f)(h):o?d(h):f(h)}function u(h){return e.attempt(que,d,f)(h)}function d(h){return t(h)}function f(h){return s._balanced=!0,n(h)}}function Xue(e,t,n){return r;function r(f){return e.enter("resource"),e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),a}function a(f){return ft(f)?Dc(e,s)(f):s(f)}function s(f){return f===41?d(f):$M(e,o,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function o(f){return ft(f)?Dc(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?DM(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return ft(f)?Dc(e,d)(f):d(f)}function d(f){return f===41?(e.enter("resourceMarker"),e.consume(f),e.exit("resourceMarker"),e.exit("resource"),t):n(f)}}function Que(e,t,n){const r=this;return a;function a(l){return LM.call(r,e,s,o,"reference","referenceMarker","referenceString")(l)}function s(l){return r.parser.defined.includes(Hr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function o(l){return n(l)}}function Zue(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),a}function a(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const Jue={name:"labelStartImage",resolveAll:k0.resolveAll,tokenize:ede};function ede(e,t,n){const r=this;return a;function a(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),s}function s(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),o):n(l)}function o(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const tde={name:"labelStartLink",resolveAll:k0.resolveAll,tokenize:nde};function nde(e,t,n){const r=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Vg={name:"lineEnding",tokenize:rde};function rde(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),He(e,t,"linePrefix")}}const _f={name:"thematicBreak",tokenize:ade};function ade(e,t,n){let r=0,a;return s;function s(u){return e.enter("thematicBreak"),o(u)}function o(u){return a=u,l(u)}function l(u){return u===a?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||Ce(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===a?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Ue(u)?He(e,l,"whitespace")(u):l(u))}}const Bn={continuation:{tokenize:lde},exit:ude,name:"list",tokenize:ode},ide={partial:!0,tokenize:dde},sde={partial:!0,tokenize:cde};function ode(e,t,n){const r=this,a=r.events[r.events.length-1];let s=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return l;function l(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:qb(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(_f,n,u)(p):u(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(p)}return n(p)}function c(p){return qb(p)&&++o<10?(e.consume(p),c):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),u(p)):n(p)}function u(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(sd,r.interrupt?n:d,e.attempt(ide,h,f))}function d(p){return r.containerState.initialBlankLine=!0,s++,h(p)}function f(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),h):n(p)}function h(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function lde(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(sd,a,s);function a(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,He(e,t,"listItemIndent",r.containerState.size+1)(l)}function s(l){return r.containerState.furtherBlankLines||!Ue(l)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(l)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(sde,t,o)(l))}function o(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,He(e,e.attempt(Bn,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function cde(e,t,n){const r=this;return He(e,a,"listItemIndent",r.containerState.size+1);function a(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function ude(e){e.exit(this.containerState.type)}function dde(e,t,n){const r=this;return He(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ME={name:"setextUnderline",resolveTo:fde,tokenize:hde};function fde(e,t){let n=e.length,r,a,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",s?(e.splice(a,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function hde(e,t,n){const r=this;let a;return s;function s(u){let d=r.events.length,f;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){f=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||f)?(e.enter("setextHeadingLine"),a=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===a?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),Ue(u)?He(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||Ce(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const pde={tokenize:mde};function mde(e){const t=this,n=e.attempt(sd,r,e.attempt(this.parser.constructs.flowInitial,a,He(e,e.attempt(this.parser.constructs.flow,a,e.attempt(xue,a)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const gde={resolveAll:zM()},vde=BM("string"),yde=BM("text");function BM(e){return{resolveAll:zM(e==="text"?bde:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],s=n.attempt(a,o,l);return o;function o(d){return u(d)?s(d):l(d)}function l(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),c}function c(d){return u(d)?(n.exit("data"),s(d)):(n.consume(d),c)}function u(d){if(d===null)return!0;const f=a[d];let h=-1;if(f)for(;++h<f.length;){const p=f[h];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function zM(e){return t;function t(n,r){let a=-1,s;for(;++a<=n.length;)s===void 0?n[a]&&n[a][1].type==="data"&&(s=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==s+2&&(n[s][1].end=n[a-1][1].end,n.splice(s+2,a-s-2),a=s+2),s=void 0);return e?e(n,r):n}}function bde(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let s=a.length,o=-1,l=0,c;for(;s--;){const u=a[s];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)l++,o--;if(o)break;o=-1}else if(u===-2)c=!0,l++;else if(u!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const xde={42:Bn,43:Bn,45:Bn,48:Bn,49:Bn,50:Bn,51:Bn,52:Bn,53:Bn,54:Bn,55:Bn,56:Bn,57:Bn,62:PM},wde={91:Nue},kde={[-2]:Kg,[-1]:Kg,32:Kg},Sde={35:Oue,42:_f,45:[ME,_f],60:Iue,61:ME,95:_f,96:PE,126:PE},jde={38:MM,92:RM},Nde={[-5]:Vg,[-4]:Vg,[-3]:Vg,33:Jue,38:MM,42:Kb,60:[tue,Uue],91:tde,92:[Aue,RM],93:k0,95:Kb,96:pue},Ede={null:[Kb,gde]},_de={null:[42,95]},Cde={null:[]},Ade=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:_de,contentInitial:wde,disable:Cde,document:xde,flow:Sde,flowInitial:kde,insideSpan:Ede,string:jde,text:Nde},Symbol.toStringTag,{value:"Module"}));function Tde(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},s=[];let o=[],l=[];const c={attempt:j(k),check:j(b),consume:S,enter:w,exit:N,interrupt:j(b,{interrupt:!0})},u={code:null,containerState:{},defineSkip:g,events:[],now:m,parser:e,previous:null,sliceSerialize:h,sliceStream:p,write:f};let d=t.tokenize.call(u,c);return t.resolveAll&&s.push(t),u;function f(A){return o=xr(o,A),y(),o[o.length-1]!==null?[]:(E(t,0),u.events=km(s,u.events,u),u.events)}function h(A,O){return Pde(p(A),O)}function p(A){return Ode(o,A)}function m(){const{_bufferIndex:A,_index:O,line:B,column:$,offset:M}=r;return{_bufferIndex:A,_index:O,line:B,column:$,offset:M}}function g(A){a[A.line]=A.column,_()}function y(){let A;for(;r._index<o.length;){const O=o[r._index];if(typeof O=="string")for(A=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===A&&r._bufferIndex<O.length;)v(O.charCodeAt(r._bufferIndex));else v(O)}}function v(A){d=d(A)}function S(A){Ce(A)?(r.line++,r.column=1,r.offset+=A===-3?2:1,_()):A!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=A}function w(A,O){const B=O||{};return B.type=A,B.start=m(),u.events.push(["enter",B,u]),l.push(B),B}function N(A){const O=l.pop();return O.end=m(),u.events.push(["exit",O,u]),O}function k(A,O){E(A,O.from)}function b(A,O){O.restore()}function j(A,O){return B;function B($,M,D){let U,R,z,T;return Array.isArray($)?F($):"tokenize"in $?F([$]):Z($);function Z(ge){return Te;function Te(X){const Y=X!==null&&ge[X],ie=X!==null&&ge.null,de=[...Array.isArray(Y)?Y:Y?[Y]:[],...Array.isArray(ie)?ie:ie?[ie]:[]];return F(de)(X)}}function F(ge){return U=ge,R=0,ge.length===0?D:I(ge[R])}function I(ge){return Te;function Te(X){return T=P(),z=ge,ge.partial||(u.currentConstruct=ge),ge.name&&u.parser.constructs.disable.null.includes(ge.name)?he():ge.tokenize.call(O?Object.assign(Object.create(u),O):u,c,se,he)(X)}}function se(ge){return A(z,T),M}function he(ge){return T.restore(),++R<U.length?I(U[R]):D}}}function E(A,O){A.resolveAll&&!s.includes(A)&&s.push(A),A.resolve&&ir(u.events,O,u.events.length-O,A.resolve(u.events.slice(O),u)),A.resolveTo&&(u.events=A.resolveTo(u.events,u))}function P(){const A=m(),O=u.previous,B=u.currentConstruct,$=u.events.length,M=Array.from(l);return{from:$,restore:D};function D(){r=A,u.previous=O,u.currentConstruct=B,u.events.length=$,l=M,_()}}function _(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function Ode(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,s=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(r,s)];else{if(o=e.slice(n,a),r>-1){const l=o[0];typeof l=="string"?o[0]=l.slice(r):o.shift()}s>0&&o.push(e[a].slice(0,s))}return o}function Pde(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
166
166
  `;break}case-3:{o=`\r
167
167
  `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&a)continue;o=" ";break}default:o=String.fromCharCode(s)}a=s===-2,r.push(o)}return r.join("")}function Rde(e){const r={constructs:TM([Ade,...(e||{}).extensions||[]]),content:a(Vce),defined:[],document:a(Xce),flow:a(pde),lazy:{},string:a(vde),text:a(yde)};return r;function a(s){return o;function o(l){return Tde(r,s,l)}}}function Mde(e){for(;!IM(e););return e}const IE=/[\0\t\n\r]/g;function Ide(){let e=1,t="",n=!0,r;return a;function a(s,o,l){const c=[];let u,d,f,h,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),f=0,t="",n&&(s.charCodeAt(0)===65279&&f++,n=void 0);f<s.length;){if(IE.lastIndex=f,u=IE.exec(s),h=u&&u.index!==void 0?u.index:s.length,p=s.charCodeAt(h),!u){t=s.slice(f);break}if(p===10&&f===h&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),f<h&&(c.push(s.slice(f,h)),e+=h-f),p){case 0:{c.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,c.push(-2);e++<d;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}f=h+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const $de=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Lde(e){return e.replace($de,Dde)}function Dde(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),s=a===120||a===88;return OM(n.slice(s?2:1),s?16:10)}return w0(n)||e}const FM={}.hasOwnProperty;function Bde(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),zde(n)(Mde(Rde(n).document().write(Ide()(e,t,!0))))}function zde(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(et),autolinkProtocol:P,autolinkEmail:P,atxHeading:s(_e),blockQuote:s(ie),characterEscape:P,characterReference:P,codeFenced:s(de),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(de,o),codeText:s(W,o),codeTextData:P,data:P,codeFlowValue:P,definition:s(xe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(we),hardBreakEscape:s(ve),hardBreakTrailing:s(ve),htmlFlow:s(Le,o),htmlFlowData:P,htmlText:s(Le,o),htmlTextData:P,image:s(pe),label:o,link:s(et),listItem:s(Me),listItemValue:h,listOrdered:s(Be,f),listUnordered:s(Be),paragraph:s(at),reference:I,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(_e),strong:s(Ge),thematicBreak:s(fn)},exit:{atxHeading:c(),atxHeadingSequence:k,autolink:c(),autolinkEmail:Y,autolinkProtocol:X,blockQuote:c(),characterEscapeValue:_,characterReferenceMarkerHexadecimal:he,characterReferenceMarkerNumeric:he,characterReferenceValue:ge,characterReference:Te,codeFenced:c(y),codeFencedFence:g,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:_,codeIndented:c(v),codeText:c(M),codeTextData:_,data:_,definition:c(),definitionDestinationString:N,definitionLabelString:S,definitionTitleString:w,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(B),htmlFlowData:_,htmlText:c($),htmlTextData:_,image:c(U),label:z,labelText:R,lineEnding:A,link:c(D),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:T,resourceTitleString:Z,resource:F,setextHeading:c(E),setextHeadingLineSequence:j,setextHeadingText:b,strong:c(),thematicBreak:c()}};UM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(G){let Q={type:"root",children:[]};const ce={stack:[Q],tokenStack:[],config:t,enter:l,exit:u,buffer:o,resume:d,data:n},me=[];let Ne=-1;for(;++Ne<G.length;)if(G[Ne][1].type==="listOrdered"||G[Ne][1].type==="listUnordered")if(G[Ne][0]==="enter")me.push(Ne);else{const Oe=me.pop();Ne=a(G,Oe,Ne)}for(Ne=-1;++Ne<G.length;){const Oe=t[G[Ne][0]];FM.call(Oe,G[Ne][1].type)&&Oe[G[Ne][1].type].call(Object.assign({sliceSerialize:G[Ne][2].sliceSerialize},ce),G[Ne][1])}if(ce.tokenStack.length>0){const Oe=ce.tokenStack[ce.tokenStack.length-1];(Oe[1]||$E).call(ce,void 0,Oe[0])}for(Q.position={start:ni(G.length>0?G[0][1].start:{line:1,column:1,offset:0}),end:ni(G.length>0?G[G.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<t.transforms.length;)Q=t.transforms[Ne](Q)||Q;return Q}function a(G,Q,ce){let me=Q-1,Ne=-1,Oe=!1,It,De,rn,Vn;for(;++me<=ce;){const it=G[me];switch(it[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{it[0]==="enter"?Ne++:Ne--,Vn=void 0;break}case"lineEndingBlank":{it[0]==="enter"&&(It&&!Vn&&!Ne&&!rn&&(rn=me),Vn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:Vn=void 0}if(!Ne&&it[0]==="enter"&&it[1].type==="listItemPrefix"||Ne===-1&&it[0]==="exit"&&(it[1].type==="listUnordered"||it[1].type==="listOrdered")){if(It){let Dt=me;for(De=void 0;Dt--;){const hn=G[Dt];if(hn[1].type==="lineEnding"||hn[1].type==="lineEndingBlank"){if(hn[0]==="exit")continue;De&&(G[De][1].type="lineEndingBlank",Oe=!0),hn[1].type="lineEnding",De=Dt}else if(!(hn[1].type==="linePrefix"||hn[1].type==="blockQuotePrefix"||hn[1].type==="blockQuotePrefixWhitespace"||hn[1].type==="blockQuoteMarker"||hn[1].type==="listItemIndent"))break}rn&&(!De||rn<De)&&(It._spread=!0),It.end=Object.assign({},De?G[De][1].start:it[1].end),G.splice(De||me,0,["exit",It,it[2]]),me++,ce++}if(it[1].type==="listItemPrefix"){const Dt={type:"listItem",_spread:!1,start:Object.assign({},it[1].start),end:void 0};It=Dt,G.splice(me,0,["enter",Dt,it[2]]),me++,ce++,rn=void 0,Vn=!0}}}return G[Q][1]._spread=Oe,ce}function s(G,Q){return ce;function ce(me){l.call(this,G(me),me),Q&&Q.call(this,me)}}function o(){this.stack.push({type:"fragment",children:[]})}function l(G,Q,ce){this.stack[this.stack.length-1].children.push(G),this.stack.push(G),this.tokenStack.push([Q,ce||void 0]),G.position={start:ni(Q.start),end:void 0}}function c(G){return Q;function Q(ce){G&&G.call(this,ce),u.call(this,ce)}}function u(G,Q){const ce=this.stack.pop(),me=this.tokenStack.pop();if(me)me[0].type!==G.type&&(Q?Q.call(this,G,me[0]):(me[1]||$E).call(this,G,me[0]));else throw new Error("Cannot close `"+G.type+"` ("+Lc({start:G.start,end:G.end})+"): it’s not open");ce.position.end=ni(G.end)}function d(){return x0(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function h(G){if(this.data.expectingFirstListItemValue){const Q=this.stack[this.stack.length-2];Q.start=Number.parseInt(this.sliceSerialize(G),10),this.data.expectingFirstListItemValue=void 0}}function p(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.lang=G}function m(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.meta=G}function g(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function y(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G.replace(/(\r?\n|\r)$/g,"")}function S(G){const Q=this.resume(),ce=this.stack[this.stack.length-1];ce.label=Q,ce.identifier=Hr(this.sliceSerialize(G)).toLowerCase()}function w(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.title=G}function N(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.url=G}function k(G){const Q=this.stack[this.stack.length-1];if(!Q.depth){const ce=this.sliceSerialize(G).length;Q.depth=ce}}function b(){this.data.setextHeadingSlurpLineEnding=!0}function j(G){const Q=this.stack[this.stack.length-1];Q.depth=this.sliceSerialize(G).codePointAt(0)===61?1:2}function E(){this.data.setextHeadingSlurpLineEnding=void 0}function P(G){const ce=this.stack[this.stack.length-1].children;let me=ce[ce.length-1];(!me||me.type!=="text")&&(me=wt(),me.position={start:ni(G.start),end:void 0},ce.push(me)),this.stack.push(me)}function _(G){const Q=this.stack.pop();Q.value+=this.sliceSerialize(G),Q.position.end=ni(G.end)}function A(G){const Q=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ce=Q.children[Q.children.length-1];ce.position.end=ni(G.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Q.type)&&(P.call(this,G),_.call(this,G))}function O(){this.data.atHardBreak=!0}function B(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function $(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function M(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.value=G}function D(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Q,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function U(){const G=this.stack[this.stack.length-1];if(this.data.inReference){const Q=this.data.referenceType||"shortcut";G.type+="Reference",G.referenceType=Q,delete G.url,delete G.title}else delete G.identifier,delete G.label;this.data.referenceType=void 0}function R(G){const Q=this.sliceSerialize(G),ce=this.stack[this.stack.length-2];ce.label=Lde(Q),ce.identifier=Hr(Q).toLowerCase()}function z(){const G=this.stack[this.stack.length-1],Q=this.resume(),ce=this.stack[this.stack.length-1];if(this.data.inReference=!0,ce.type==="link"){const me=G.children;ce.children=me}else ce.alt=Q}function T(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.url=G}function Z(){const G=this.resume(),Q=this.stack[this.stack.length-1];Q.title=G}function F(){this.data.inReference=void 0}function I(){this.data.referenceType="collapsed"}function se(G){const Q=this.resume(),ce=this.stack[this.stack.length-1];ce.label=Q,ce.identifier=Hr(this.sliceSerialize(G)).toLowerCase(),this.data.referenceType="full"}function he(G){this.data.characterReferenceType=G.type}function ge(G){const Q=this.sliceSerialize(G),ce=this.data.characterReferenceType;let me;ce?(me=OM(Q,ce==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):me=w0(Q);const Ne=this.stack[this.stack.length-1];Ne.value+=me}function Te(G){const Q=this.stack.pop();Q.position.end=ni(G.end)}function X(G){_.call(this,G);const Q=this.stack[this.stack.length-1];Q.url=this.sliceSerialize(G)}function Y(G){_.call(this,G);const Q=this.stack[this.stack.length-1];Q.url="mailto:"+this.sliceSerialize(G)}function ie(){return{type:"blockquote",children:[]}}function de(){return{type:"code",lang:null,meta:null,value:""}}function W(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function we(){return{type:"emphasis",children:[]}}function _e(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function Le(){return{type:"html",value:""}}function pe(){return{type:"image",title:null,url:"",alt:null}}function et(){return{type:"link",title:null,url:"",children:[]}}function Be(G){return{type:"list",ordered:G.type==="listOrdered",start:null,spread:G._spread,children:[]}}function Me(G){return{type:"listItem",spread:G._spread,checked:null,children:[]}}function at(){return{type:"paragraph",children:[]}}function Ge(){return{type:"strong",children:[]}}function wt(){return{type:"text",value:""}}function fn(){return{type:"thematicBreak"}}}function ni(e){return{line:e.line,column:e.column,offset:e.offset}}function UM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?UM(e,r):Fde(e,r)}}function Fde(e,t){let n;for(n in t)if(FM.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function $E(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Lc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Lc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Lc({start:t.start,end:t.end})+") is still open")}function Ude(e){const t=this;t.parser=n;function n(r){return Bde(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Wde(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Hde(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
@@ -233,4 +233,4 @@ ${A.warnings.join(`
233
233
  `)}`:"")),l(null),v(mv),await S((e==null?void 0:e.deep)===!0)},b=async _=>{s(_);const A=await lB(_);if(s(null),!A.ok){l(A.reason??"Could not remove that server.");return}u(`Removed ${_}`),await S((e==null?void 0:e.deep)===!0)},j=(e==null?void 0:e.canWrite)??!1,E=(e==null?void 0:e.servers)??[];return i.jsxs("div",{className:"page",children:[i.jsx(Re,{icon:"🔌",title:"MCP",description:"External MCP servers — configured once here and used by the agent on every surface. These controls write the same mcp.* config the CLI does."}),i.jsxs("div",{className:"mcp-card",children:[i.jsxs("div",{className:"mcp-muted",children:["Config file: ",i.jsx("code",{children:(e==null?void 0:e.configDir)??"…"})," — these controls write the same"," ",i.jsx("code",{children:"mcp.*"})," keys as ",i.jsx("code",{children:"nuvira config set mcp.*"}),", so the terminal and this page can never disagree."]}),i.jsxs("div",{style:{marginTop:10},children:[i.jsx("button",{className:"mcp-btn secondary",onClick:()=>void S(!0),disabled:n,children:"Check dependencies"}),i.jsx("span",{className:"mcp-muted",style:{marginLeft:8},children:e!=null&&e.deep?"service checks ran (e.g. docker daemon)":"service checks skipped on page load — press to probe them"})]})]}),o&&i.jsx("div",{className:"mcp-card mcp-problem",style:{whiteSpace:"pre-wrap"},children:o}),c&&i.jsx("div",{className:"mcp-card mcp-muted",children:c}),n&&i.jsx("div",{className:"mcp-card mcp-muted",children:"Loading MCP configuration…"}),e&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mcp-card",children:[i.jsx("h3",{children:"Settings"}),i.jsx("div",{className:"mcp-muted",children:"Applies to every MCP server on every surface."}),i.jsx(oo,{label:"Enabled",hint:"Master switch — false makes MCP inert everywhere (true/false)",value:String(e.settings.enabled),disabled:!j,onSave:_=>w("mcp.enabled",_)}),i.jsx(oo,{label:"Auto-connect",hint:"Connect configured servers at the start of a turn (bounded, never fatal)",value:String(e.settings.autoConnect),disabled:!j,onSave:_=>w("mcp.autoConnect",_)}),i.jsx(oo,{label:"Connect timeout (ms)",hint:"Wall-clock budget for the connect step; exceeding it proceeds without MCP",value:String(e.settings.connectTimeoutMs),disabled:!j,onSave:_=>w("mcp.connectTimeoutMs",_)}),i.jsx(oo,{label:"Tools per server",hint:"Per-server eager-schema cap — stored and reported; enforcement is not wired yet (nothing is truncated today)",value:String(e.settings.maxToolsPerServer),disabled:!j,onSave:_=>w("mcp.maxToolsPerServer",_)}),i.jsx(oo,{label:"Tools in total",hint:"Cross-server ceiling — stored and reported; enforcement is not wired yet (nothing is truncated today)",value:String(e.settings.maxToolsTotal),disabled:!j,onSave:_=>w("mcp.maxToolsTotal",_)}),i.jsx(oo,{label:"Subagents inherit",hint:"conservative = only when the parent had MCP AND the child's allowance covers it; full = pass the parent's whole MCP set down (reach, never approval)",value:e.settings.subagentInheritance,disabled:!j,onSave:_=>w("mcp.subagent.inherit",_)}),((P=e.settings.warnings)==null?void 0:P.length)>0&&i.jsx("div",{className:"mcp-error",children:e.settings.warnings.join(`
234
234
  `)})]}),i.jsxs("div",{className:"mcp-card",children:[i.jsxs("h3",{children:["Configured servers (",E.length,")"]}),E.length===0&&i.jsx("div",{className:"mcp-muted",children:"None yet. Add one by hand below (any server), install one from the catalog, or drop a JSON file into the config directory."}),E.map(_=>{const A=e.settings.servers[_.name]??{};return i.jsxs("div",{className:"mcp-variant",children:[i.jsxs("div",{children:[i.jsx("strong",{children:_.name}),i.jsx("span",{className:"mcp-badge",children:_.transport}),_.variant&&i.jsxs("span",{className:"mcp-badge",children:["variant ",_.variant]}),i.jsx("span",{className:`mcp-badge ${_.enabled?"ok":"bad"}`,children:_.enabled?"enabled":"disabled"}),_.connected&&i.jsx("span",{className:"mcp-badge ok",children:"connected"})]}),i.jsxs("div",{className:"mcp-muted",children:[_.command?`${_.command} ${_.args.join(" ")}`:_.url,_.runtime?` (runtime: ${[_.runtime.command,..._.runtime.args??[]].join(" ")})`:"",_.envKeys.length>0?` · credentials: ${_.envKeys.join(", ")}`:"",_.headerKeys.length>0?` · headers: ${_.headerKeys.join(", ")}`:""]}),i.jsxs("div",{style:{marginTop:6,display:"flex",gap:8,flexWrap:"wrap"},children:[i.jsx("button",{className:"mcp-btn secondary",disabled:!j,onClick:()=>v(Bbe(_)),children:"Edit"}),i.jsx("button",{className:"mcp-btn secondary",disabled:!j||a===_.name,onClick:()=>void w(`mcp.servers.${_.name}.enabled`,_.enabled?"false":"true"),children:_.enabled?"Disable":"Enable"}),i.jsx("input",{className:"mcp-input",style:{minWidth:260},placeholder:"runtime override, e.g. /opt/node20/bin/node /usr/local/bin/npx",defaultValue:A.runtime?[A.runtime.command,...A.runtime.args??[]].join(" "):"",disabled:!j,onKeyDown:O=>{O.key==="Enter"&&w(`mcp.servers.${_.name}.runtime.command`,O.target.value)}}),i.jsx("button",{className:"mcp-btn secondary",disabled:!j,onClick:()=>void w(`mcp.servers.${_.name}.runtime.command`,""),children:"Clear runtime"}),i.jsx("button",{className:"mcp-btn secondary",disabled:!j||a===_.name,onClick:()=>void b(_.name),children:"Uninstall"})]})]},_.name)})]}),i.jsxs("div",{className:"mcp-card",children:[i.jsx("h3",{children:"Add a server"}),i.jsxs("div",{className:"mcp-muted",children:["Any MCP server — a local command or a remote endpoint — not only the ones in the catalog below. This writes ",i.jsxs("code",{children:[e.configDir,"/<name>.json"]}),", the same file"," ",i.jsx("code",{children:"nuvira mcp add"})," writes, so the agent uses it on the next turn: no code, no release. Use ",i.jsx("strong",{children:"Edit"})," on a configured server to change it."]}),i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr",gap:10,alignItems:"center",marginTop:10},children:[i.jsx("label",{className:"mcp-setting-label",children:"Name"}),i.jsx("input",{className:"mcp-input",placeholder:"my-server",value:y.name,disabled:!j||a==="__custom__",onChange:_=>v({...y,name:_.target.value})}),i.jsx("label",{className:"mcp-setting-label",children:"Transport"}),i.jsxs("div",{children:[i.jsxs("label",{className:"mcp-muted",style:{marginRight:12},children:[i.jsx("input",{type:"radio",name:"custom-transport",checked:y.transport==="stdio",disabled:!j,onChange:()=>v({...y,transport:"stdio"})})," ","stdio (a local process)"]}),i.jsxs("label",{className:"mcp-muted",children:[i.jsx("input",{type:"radio",name:"custom-transport",checked:y.transport==="sse",disabled:!j,onChange:()=>v({...y,transport:"sse"})})," ","remote (Streamable HTTP)"]})]}),y.transport==="stdio"?i.jsxs(i.Fragment,{children:[i.jsx("label",{className:"mcp-setting-label",children:"Command"}),i.jsx("input",{className:"mcp-input",placeholder:"npx",value:y.command,disabled:!j||a==="__custom__",onChange:_=>v({...y,command:_.target.value})}),i.jsx("label",{className:"mcp-setting-label",children:"Arguments"}),i.jsx("input",{className:"mcp-input",placeholder:"-y, @modelcontextprotocol/server-filesystem, /path/to/dir",value:y.args,disabled:!j||a==="__custom__",onChange:_=>v({...y,args:_.target.value})}),i.jsx("label",{className:"mcp-setting-label",children:"Environment"}),i.jsx("textarea",{className:"mcp-input",rows:3,placeholder:`TOKEN=…
235
235
  ANOTHER=…`,value:y.env,disabled:!j||a==="__custom__",onChange:_=>v({...y,env:_.target.value})})]}):i.jsxs(i.Fragment,{children:[i.jsx("label",{className:"mcp-setting-label",children:"URL"}),i.jsx("input",{className:"mcp-input",placeholder:"https://example.com/mcp",value:y.url,disabled:!j||a==="__custom__",onChange:_=>v({...y,url:_.target.value})}),i.jsx("label",{className:"mcp-setting-label",children:"Headers"}),i.jsx("textarea",{className:"mcp-input",rows:3,placeholder:"Authorization: Bearer …",value:y.headers,disabled:!j||a==="__custom__",onChange:_=>v({...y,headers:_.target.value})})]})]}),i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:10,flexWrap:"wrap"},children:[i.jsxs("label",{className:"mcp-muted",children:[i.jsx("input",{type:"checkbox",checked:y.overwrite,disabled:!j||a==="__custom__",onChange:_=>v({...y,overwrite:_.target.checked})})," ","Replace the existing config for this name"]}),i.jsx("button",{className:"mcp-btn",disabled:!j||a==="__custom__",onClick:()=>void k(),children:a==="__custom__"?"Saving…":y.overwrite?"Save server":"Add server"}),i.jsx("button",{className:"mcp-btn secondary",disabled:a==="__custom__",onClick:()=>v(mv),children:"Clear"})]}),i.jsx("div",{className:"mcp-muted",style:{marginTop:8},children:"Credentials typed here go into the config file (mode 0600) and are never sent back to this page — editing an existing server keeps the secrets it already has unless you type a new value over them."})]}),i.jsxs("div",{className:"mcp-card",children:[i.jsxs("h3",{children:["Catalog (",e.catalog.length," capabilities)"]}),i.jsx("div",{className:"mcp-muted",children:"Each capability lists every way it can run on THIS machine, what that way needs, and what you get. A dependency that is missing (install it) is different from a service that is down (start it)."}),e.catalog.map(_=>i.jsxs("div",{className:"mcp-variant",children:[i.jsxs("div",{children:[i.jsx("strong",{children:_.name}),_.installed&&i.jsx("span",{className:"mcp-badge ok",children:"installed"}),i.jsxs("span",{className:"mcp-muted",children:[" — ",_.description]})]}),i.jsx("ul",{className:"mcp-offers",children:_.offers.map(A=>i.jsx("li",{children:A},A))}),_.supersedes&&i.jsxs("div",{className:"mcp-muted",children:["supersedes: ",_.supersedes]}),_.variants.map(A=>i.jsxs("div",{className:"mcp-muted",style:{marginLeft:12},children:[i.jsxs("label",{children:[i.jsx("input",{type:"radio",name:`variant-${_.name}`,checked:(h[_.name]??"")===A.id,disabled:A.optIn===!1&&h[_.name]!==A.id?!1:!j,onChange:()=>p(O=>({...O,[_.name]:A.id}))})," ",i.jsx("strong",{children:A.id})," — ",A.label," ",i.jsx("span",{className:`mcp-badge ${A.status.ok?"ok":"bad"}`,children:A.status.ok?"runnable":"cannot run yet"}),A.optIn&&i.jsx("span",{className:"mcp-badge",children:"opt-in"}),i.jsx("span",{className:"mcp-badge",children:A.trust})]}),i.jsx("div",{children:A.command?`${A.command} ${A.args.join(" ")}`:A.url}),A.status.problems.map(O=>i.jsxs("div",{className:"mcp-problem",children:["⚠ ",O]},O)),A.status.unverified.map(O=>i.jsxs("div",{children:["note: ",O]},O)),A.note&&i.jsxs("div",{children:["caveat: ",A.note]})]},A.id)),i.jsxs("div",{style:{marginTop:6,display:"flex",gap:8,flexWrap:"wrap"},children:[(_.variants.find(O=>O.id===h[_.name])??_.variants.find(O=>!O.optIn)??_.variants[0]).requires.filter(O=>O.kind==="env").map(O=>i.jsx("input",{className:"mcp-input",style:{minWidth:280},type:"password",placeholder:`${O.name} (${O.hint})`,disabled:!j,value:d[`${_.name}:${O.name}`]??"",onChange:B=>f($=>({...$,[`${_.name}:${O.name}`]:B.target.value}))},O.name)),i.jsx("input",{className:"mcp-input",placeholder:"runtime override (optional)",disabled:!j,value:m[_.name]??"",onChange:A=>g(O=>({...O,[_.name]:A.target.value}))}),i.jsx("button",{className:"mcp-btn",disabled:!j||a===_.name||_.installed,onClick:()=>void N(_),children:a===_.name?"Installing…":_.installed?"Installed":"Install"})]})]},_.name))]})]})]})}function Fbe(){const[e,t]=x.useState(null),[n,r]=x.useState(!1),[a,s]=x.useState("--"),[o,l]=x.useState(!1),u=Ii().pathname==="/chat",[d,f]=x.useState(u);x.useEffect(()=>{u&&f(!0)},[u]);const h=x.useCallback(g=>{t(g),s(new Date().toLocaleTimeString())},[]),p=x.useCallback(g=>{r(g)},[]),m=x.useCallback(async()=>{l(!0);try{const g=await K.fetchAll();g&&h(g)}finally{l(!1)}},[h]);return x.useEffect(()=>{K.fetchAll().then(v=>{v&&h(v)});const g=K.subscribe(h),y=K.onConnectionChange(p);return K.connect(),()=>{g(),y(),K.disconnect()}},[h,p]),i.jsxs(xB,{connected:n,lastUpdated:a,onRefresh:m,refreshing:o,children:[d&&i.jsx("div",{style:{display:u?void 0:"none"},children:i.jsx(ebe,{})}),i.jsx("div",{style:{display:u?"none":void 0},children:i.jsxs(I2,{children:[i.jsx(qe,{path:"/",element:i.jsx(Zk,{to:"/overview",replace:!0})}),i.jsx(qe,{path:"/overview",element:i.jsx(ese,{data:e,onRefresh:m,refreshing:o})}),i.jsx(qe,{path:"/chat",element:null}),i.jsx(qe,{path:"/dag",element:i.jsx(dse,{data:e})}),i.jsx(qe,{path:"/costs",element:i.jsx(hse,{data:e})}),i.jsx(qe,{path:"/benchmarks",element:i.jsx(mse,{data:e})}),i.jsx(qe,{path:"/models",element:i.jsx(aoe,{})}),i.jsx(qe,{path:"/models/timeline",element:i.jsx(hbe,{})}),i.jsx(qe,{path:"/routing",element:i.jsx(Boe,{data:e})}),i.jsx(qe,{path:"/requests",element:i.jsx(Goe,{data:e})}),i.jsx(qe,{path:"/traces",element:i.jsx(rle,{})}),i.jsx(qe,{path:"/hub",element:i.jsx(xle,{})}),i.jsx(qe,{path:"/capabilities",element:i.jsx(Mbe,{})}),i.jsx(qe,{path:"/tasks",element:i.jsx(Cle,{})}),i.jsx(qe,{path:"/evals",element:i.jsx(abe,{data:e})}),i.jsx(qe,{path:"/platforms",element:i.jsx(obe,{})}),i.jsx(qe,{path:"/mcp",element:i.jsx(zbe,{})}),i.jsx(qe,{path:"/bedrock",element:i.jsx(cbe,{canWrite:!0,sessionExpired:g=>console.error(g)})}),i.jsx(qe,{path:"/contacts",element:i.jsx(ube,{})}),i.jsx(qe,{path:"/gateway",element:i.jsx(sbe,{})}),i.jsx(qe,{path:"/env",element:i.jsx(Nbe,{})}),i.jsx(qe,{path:"/process-env",element:i.jsx(Cbe,{})}),i.jsx(qe,{path:"/hooks",element:i.jsx(Obe,{})}),i.jsx(qe,{path:"/memory",element:i.jsx(gbe,{data:e})}),i.jsx(qe,{path:"/knowledge",element:i.jsx(vbe,{})}),i.jsx(qe,{path:"/history",element:i.jsx(xbe,{data:e})}),i.jsx(qe,{path:"/decisions",element:i.jsx(kbe,{})}),i.jsx(qe,{path:"/executions",element:i.jsx(Sbe,{onFetch:g=>K.fetchExecutionAudit(g)})}),i.jsx(qe,{path:"/system",element:i.jsx(xse,{data:e,connected:n,lastUpdated:a})}),i.jsx(qe,{path:"/admin",element:i.jsx(cle,{})}),i.jsx(qe,{path:"/help",element:i.jsx(tse,{})}),i.jsx(qe,{path:"*",element:i.jsx(Zk,{to:"/overview",replace:!0})})]})})]})}Jx(CT());hT(document.getElementById("root")).render(i.jsx(x.StrictMode,{children:i.jsx(W2,{children:i.jsx(Fbe,{})})}));
236
- //# sourceMappingURL=index-yky0dw5e.js.map
236
+ //# sourceMappingURL=index-Bik91KJh.js.map