bazilion 0.26.1 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +405 -244
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +1572 -749
- package/dist/daemon.js.map +1 -1
- package/dist/web/client/assets/ConfigPage-_FY--9PB.js +1 -0
- package/dist/web/client/assets/ConfirmDialog-BblXqMVb.js +1 -0
- package/dist/web/client/assets/ConnectionsView-BZHJysCa.js +1 -0
- package/dist/web/client/assets/FieldRow-k05wfDy9.js +1 -0
- package/dist/web/client/assets/SectionTabs-DlfXtepS.js +1 -0
- package/dist/web/client/assets/{SkillFindings-8LX6bYf_.js → SkillFindings-CHf5ZGY0.js} +1 -1
- package/dist/web/client/assets/SpawnDialog-C-Ujb4bC.js +1 -0
- package/dist/web/client/assets/TeamForm-D6EAAF7m.js +1 -0
- package/dist/web/client/assets/TeamThread-DpUOwMoi.js +1 -0
- package/dist/web/client/assets/UnsavedChangesGuard-DTUP7hwu.js +1 -0
- package/dist/web/client/assets/_id-C94dgBDe.js +1 -0
- package/dist/web/client/assets/_id-CxmEfoEp.js +1 -0
- package/dist/web/client/assets/agents-C-bJ5R_0.js +1 -0
- package/dist/web/client/assets/agents-odqBNx-A.js +1 -0
- package/dist/web/client/assets/api-CPzQ_z9m.js +1 -0
- package/dist/web/client/assets/arrow-right-Dyta3p06.js +1 -0
- package/dist/web/client/assets/attention-D0e7o7fh.js +1 -0
- package/dist/web/client/assets/chevron-right-B2YEg9rw.js +1 -0
- package/dist/web/client/assets/config-B7Y5MtpM.js +3 -0
- package/dist/web/client/assets/createLucideIcon-Cgab8gqu.js +1 -0
- package/dist/web/client/assets/index-CNVw44IE.js +54 -0
- package/dist/web/client/assets/link-ClwtaO_E.js +1 -0
- package/dist/web/client/assets/login-Br1F4rQx.js +1 -0
- package/dist/web/client/assets/mcp-B8bIAY6k.js +1 -0
- package/dist/web/client/assets/routes-BZdlkRdC.js +76 -0
- package/dist/web/client/assets/save-ZqeB_I-c.js +1 -0
- package/dist/web/client/assets/{services-B2f7e5jV.js → services-CPJxDrVG.js} +1 -1
- package/dist/web/client/assets/skills-DE_kQQGj.js +1 -0
- package/dist/web/client/assets/style-BWShXY3e.js +7 -0
- package/dist/web/client/assets/styles-Tney8jZq.css +2 -0
- package/dist/web/client/assets/teams-AcuSLc3I.js +1 -0
- package/dist/web/client/assets/teams-tRamPg7O.js +1 -0
- package/dist/web/client/assets/telegram-Ku69-GAv.js +1 -0
- package/dist/web/client/assets/tokens-DuLNZMgi.js +1 -0
- package/dist/web/client/assets/welcome-CrQk6n6I.js +1 -0
- package/dist/web/server/assets/{ConfigPage-CGld_wCK.js → ConfigPage-DSLM5CLw.js} +2 -2
- package/dist/web/server/assets/{ConfirmDialog-LdVlEanK.js → ConfirmDialog-CvLZgbfY.js} +1 -1
- package/dist/web/server/assets/ConnectionsView-DVLNH81Y.js +708 -0
- package/dist/web/server/assets/{FieldRow-Dah2KKqo.js → FieldRow-DQBzMtcR.js} +4 -4
- package/dist/web/server/assets/{Page-CMSYKXWJ.js → Page-KIL1CsME.js} +1 -1
- package/dist/web/server/assets/Rail-D8LhjS38.js +756 -0
- package/dist/web/server/assets/{SectionTabs-CqFg9Vwx.js → SectionTabs-CNcvxbR8.js} +1 -16
- package/dist/web/server/assets/{SkillFindings-Bd6e81Wu.js → SkillFindings-DX8lCMG7.js} +1 -1
- package/dist/web/server/assets/{SpawnDialog-BGNaMfFb.js → SpawnDialog-Brmkl_ll.js} +24 -6
- package/dist/web/server/assets/{TeamForm-C93tpn9r.js → TeamForm-CvQAs2FA.js} +1 -1
- package/dist/web/server/assets/TeamThread-BNJi6gPM.js +205 -0
- package/dist/web/server/assets/{UnsavedChangesGuard-Dm4a27_5.js → UnsavedChangesGuard-B3Lpl08z.js} +8 -4
- package/dist/web/server/assets/{TeamPolicyEditor-BHS3J0R9.js → _id-BH1631a8.js} +114 -263
- package/dist/web/server/assets/{_id-sW6zXrTP.js → _id-CA3QO7J5.js} +1 -1
- package/dist/web/server/assets/{_id-lOVnT5sS.js → _id-CO1PgvyG.js} +5 -5
- package/dist/web/server/assets/{_id-B0x1ffz3.js → _id-DIXUiIaB.js} +1 -1
- package/dist/web/server/assets/{_id-ByiXeIPS.js → _id-E2N4gZ4O.js} +2 -2
- package/dist/web/server/assets/{_id-Bdf_Rg62.js → _id-TVruGcOd.js} +1 -1
- package/dist/web/server/assets/_tanstack-start-manifest_v-BVfrV7LQ.js +191 -0
- package/dist/web/server/assets/{agents-BNPkidbH.js → agents-BnWgFo6o.js} +1 -1
- package/dist/web/server/assets/{agents-BK8OmB8g.js → agents-C63VycUw.js} +2 -2
- package/dist/web/server/assets/{agents-D4tqK1kH.js → agents-CalSKogx.js} +14 -15
- package/dist/web/server/assets/{agents-Cn9GkXFX.js → agents-CdZvooeQ.js} +1 -1
- package/dist/web/server/assets/{agents-lOqc6VGd.js → agents-DPZVni4Q.js} +1 -1
- package/dist/web/server/assets/{agents-DycxHDt8.js → agents-DrkEwIpR.js} +8 -8
- package/dist/web/server/assets/{attention-DULVjdmF.js → attention-BbE4yc-V.js} +1 -1
- package/dist/web/server/assets/{attention-YWnLKA2E.js → attention-Cr7puThv.js} +1 -1
- package/dist/web/server/assets/{attention-BIm455bC.js → attention-DIyX3VMB.js} +6 -6
- package/dist/web/server/assets/{auth-DiN92ydD.js → auth-dJnrFW6y.js} +1 -1
- package/dist/web/server/assets/{config-C1VB28se.js → config-3tPtOmPE.js} +1 -1
- package/dist/web/server/assets/{config-BNEgu7WG.js → config-DJGZiPBJ.js} +13 -13
- package/dist/web/server/assets/{config-TdVqnqNL.js → config-rUqhMjIs.js} +1 -1
- package/dist/web/server/assets/{daemon-client-DL2ik2Em.js → daemon-client-B_ZRIIrT.js} +2 -1
- package/dist/web/server/assets/{mcp-BwmpNQPN.js → mcp-C97uAZe1.js} +1 -1
- package/dist/web/server/assets/{mcp-B09_O05r.js → mcp-Cf7KzOJ9.js} +9 -9
- package/dist/web/server/assets/{mcp-CqdTfXcn.js → mcp-DE14q5c0.js} +1 -1
- package/dist/web/server/assets/{router-BI9gmY3S.js → router-w2yPgmC1.js} +412 -259
- package/dist/web/server/assets/routes-1FEodTRm.js +16 -0
- package/dist/web/server/assets/routes-B6AO0LjK.js +57 -0
- package/dist/web/server/assets/routes-D1NHwz6f.js +7644 -0
- package/dist/web/server/assets/{services-tCfB1B83.js → services-BjroGXgC.js} +4 -4
- package/dist/web/server/assets/{services-Q9HYQXXB.js → services-Cdk40QHq.js} +1 -1
- package/dist/web/server/assets/{services-BLvAvb8g.js → services-DsHRLL8q.js} +1 -1
- package/dist/web/server/assets/{skills-BZg_txbf.js → skills-CA17GjuZ.js} +1 -1
- package/dist/web/server/assets/{skills-C7fqRPna.js → skills-DC1OTc8n.js} +11 -11
- package/dist/web/server/assets/{skills-C_g8IKag.js → skills-h5aHa7Q8.js} +1 -1
- package/dist/web/server/assets/style-GYDODk2F.js +178 -0
- package/dist/web/server/assets/{teams-D4CaU76n.js → teams-Bm63mbTt.js} +1 -1
- package/dist/web/server/assets/{teams-DX2HmKqi.js → teams-BxnvFTyn.js} +1 -1
- package/dist/web/server/assets/{teams-BS-oweRl.js → teams-Cg-QQWpH.js} +23 -15
- package/dist/web/server/assets/{teams-BHkhnt6b.js → teams-D6Tx-Jyn.js} +1 -1
- package/dist/web/server/assets/{teams-BSflKBP8.js → teams-OzHTyVi9.js} +6 -6
- package/dist/web/server/assets/{teams-CNyB5nM9.js → teams-YrmyutM4.js} +1 -1
- package/dist/web/server/assets/{telegram-CrJiygCX.js → telegram-BJ4l_TA_.js} +6 -6
- package/dist/web/server/assets/{telegram-C4v1HhyJ.js → telegram-Gy7_9yih.js} +1 -1
- package/dist/web/server/assets/{telegram-BUdnc8oF.js → telegram-xU-vXgef.js} +1 -1
- package/dist/web/server/assets/{tokens-DqldzPUq.js → tokens-ByPTGFBQ.js} +1 -1
- package/dist/web/server/assets/{tokens-B1twAJdd.js → tokens-CEdl8puR.js} +1 -1
- package/dist/web/server/assets/{tokens-DdjEyALj.js → tokens-CsqoRt5T.js} +10 -10
- package/dist/web/server/assets/{welcome-D0d38Pzx.js → welcome-O6Rjd7yO.js} +1 -1
- package/dist/web/server/assets/workspace-DeEYMPDX.js +658 -0
- package/dist/web/server/server.js +20 -72
- package/dist/worker.js +51 -7
- package/dist/worker.js.map +1 -1
- package/package.json +1 -2
- package/dist/web/client/assets/AgentAvatar-DWx-bM6n.js +0 -1
- package/dist/web/client/assets/ChatPane-DOV_HJg-.js +0 -72
- package/dist/web/client/assets/ConfigPage-Dfu9DzFX.js +0 -1
- package/dist/web/client/assets/ConfirmDialog-536ziJ5P.js +0 -1
- package/dist/web/client/assets/FieldRow-z1JqCdqn.js +0 -1
- package/dist/web/client/assets/ResultCard-X4nTbjYY.js +0 -1
- package/dist/web/client/assets/SectionTabs-DXHzXmmb.js +0 -1
- package/dist/web/client/assets/SpawnDialog-DoZl-yes.js +0 -1
- package/dist/web/client/assets/SpawnTeamModal-C638hEoN.js +0 -1
- package/dist/web/client/assets/TeamForm-C-WzvOl4.js +0 -1
- package/dist/web/client/assets/TeamPolicyEditor-CSKBx0oK.js +0 -7
- package/dist/web/client/assets/UnsavedChangesGuard-GC-vzw7h.js +0 -1
- package/dist/web/client/assets/_id-BKLynswT.js +0 -1
- package/dist/web/client/assets/_id-BYM_NORr.js +0 -1
- package/dist/web/client/assets/_id-Cxa98a9m.js +0 -1
- package/dist/web/client/assets/_id-D4hV1U1t.js +0 -1
- package/dist/web/client/assets/agent-actions-CXQCoxKO.js +0 -1
- package/dist/web/client/assets/agents-BxPS1_Bp.js +0 -1
- package/dist/web/client/assets/agents-GozAWW-l.js +0 -1
- package/dist/web/client/assets/attention-Cz9rZcrr.js +0 -1
- package/dist/web/client/assets/chevron-right-CPAb1zac.js +0 -1
- package/dist/web/client/assets/config-9vv9Lipb.js +0 -3
- package/dist/web/client/assets/inbox-DHLArXxl.js +0 -1
- package/dist/web/client/assets/index-1YXquAq8.js +0 -52
- package/dist/web/client/assets/learning-PvtXm8Ne.js +0 -1
- package/dist/web/client/assets/login-DIJpNQFo.js +0 -1
- package/dist/web/client/assets/mcp-pKBL0xIf.js +0 -1
- package/dist/web/client/assets/members-DHWsgsEs.js +0 -1
- package/dist/web/client/assets/memory-CEVppPyU.js +0 -1
- package/dist/web/client/assets/plus-BaIRdB10.js +0 -1
- package/dist/web/client/assets/policy-DEh4BLSw.js +0 -1
- package/dist/web/client/assets/preload-helper-eUUcpe2S.js +0 -1
- package/dist/web/client/assets/results-DgJPjEZF.js +0 -1
- package/dist/web/client/assets/review-BbshafTQ.js +0 -1
- package/dist/web/client/assets/route-Ccb8v41z.js +0 -1
- package/dist/web/client/assets/route-D1d6kCEV.js +0 -1
- package/dist/web/client/assets/routes-g7V4ru7T.js +0 -1
- package/dist/web/client/assets/settings-B6elpcYm.js +0 -1
- package/dist/web/client/assets/skills-CngE7TF8.js +0 -1
- package/dist/web/client/assets/styles-xUnZ-ep_.css +0 -2
- package/dist/web/client/assets/teams-BdJZXOan.js +0 -1
- package/dist/web/client/assets/teams-c496ISsT.js +0 -1
- package/dist/web/client/assets/telegram-B_-hK6EC.js +0 -1
- package/dist/web/client/assets/tokens-CKz8gx4-.js +0 -1
- package/dist/web/client/assets/triggers-DCEPciGW.js +0 -1
- package/dist/web/client/assets/welcome-D-zVOLGA.js +0 -1
- package/dist/web/server/assets/AgentAvatar-8gTAy_tP.js +0 -37
- package/dist/web/server/assets/ChatPane-De_FPEoD.js +0 -1887
- package/dist/web/server/assets/ResultCard-CZn1w4KA.js +0 -97
- package/dist/web/server/assets/Sidebar-puq47KyR.js +0 -430
- package/dist/web/server/assets/SpawnTeamModal-C6GbfScI.js +0 -97
- package/dist/web/server/assets/_id-BR6tnR6I.js +0 -23
- package/dist/web/server/assets/_id-Bm611NQz.js +0 -13
- package/dist/web/server/assets/_id-D5UCoyES.js +0 -359
- package/dist/web/server/assets/_id-DHx5UmmL.js +0 -12
- package/dist/web/server/assets/_id-DLpGmOVm.js +0 -19
- package/dist/web/server/assets/_id-Y5ctILG2.js +0 -13
- package/dist/web/server/assets/_id-dDA0pdVo.js +0 -54
- package/dist/web/server/assets/_tanstack-start-manifest_v-B8u80HjK.js +0 -292
- package/dist/web/server/assets/agent-actions-BBdFVdoa.js +0 -20
- package/dist/web/server/assets/api-WWxPqx67.js +0 -85
- package/dist/web/server/assets/inbox-4Vj5jTT8.js +0 -245
- package/dist/web/server/assets/inbox-D4IqUv3l.js +0 -38
- package/dist/web/server/assets/inbox-Dle24AfV.js +0 -23
- package/dist/web/server/assets/learning-BScq7VbO.js +0 -12
- package/dist/web/server/assets/learning-CBWFEnhg.js +0 -263
- package/dist/web/server/assets/learning-DWAKevhF.js +0 -25
- package/dist/web/server/assets/members-B8QBF6TF.js +0 -12
- package/dist/web/server/assets/members-DsF02Wp7.js +0 -12
- package/dist/web/server/assets/members-tWZA9b15.js +0 -36
- package/dist/web/server/assets/memory-BNN0b-0x.js +0 -12
- package/dist/web/server/assets/memory-CTl1E1Rm.js +0 -267
- package/dist/web/server/assets/memory-CV5uCBb2.js +0 -12
- package/dist/web/server/assets/policy-C9M6zV6w.js +0 -79
- package/dist/web/server/assets/policy-h-6NpU3m.js +0 -19
- package/dist/web/server/assets/policy-xEw9X0DK.js +0 -12
- package/dist/web/server/assets/results-D3A3UA4d.js +0 -182
- package/dist/web/server/assets/results-D6Ui5S8D.js +0 -12
- package/dist/web/server/assets/results-DWmxvfyn.js +0 -15
- package/dist/web/server/assets/review-CyQky-WQ.js +0 -40
- package/dist/web/server/assets/review-Sq0GGcPV.js +0 -322
- package/dist/web/server/assets/review-XWbSF8cF.js +0 -12
- package/dist/web/server/assets/route-BErtkz6t.js +0 -19
- package/dist/web/server/assets/route-CLoV-An_.js +0 -48
- package/dist/web/server/assets/route-WQ19JkBa.js +0 -19
- package/dist/web/server/assets/route-dEK_2GLj.js +0 -203
- package/dist/web/server/assets/route-iHTkhO81.js +0 -16
- package/dist/web/server/assets/route-zs8uUQtB.js +0 -16
- package/dist/web/server/assets/routes-081s4n24.js +0 -45
- package/dist/web/server/assets/routes-CWo5WPsr.js +0 -15
- package/dist/web/server/assets/routes-Cqp1ufHm.js +0 -56
- package/dist/web/server/assets/settings-CVaGv-xF.js +0 -12
- package/dist/web/server/assets/settings-D9viV-86.js +0 -561
- package/dist/web/server/assets/settings-DaZNZ_CC.js +0 -27
- package/dist/web/server/assets/triggers-B7LW784F.js +0 -214
- package/dist/web/server/assets/triggers-C5sMCZXv2.js +0 -12
- package/dist/web/server/assets/triggers-DMfVdImD.js +0 -12
- package/dist/web/client/assets/{TeamPolicyEditor-DLioOiRN.css → style-DLioOiRN.css} +0 -0
- package/dist/web/server/assets/{start-DTX6aKCi.js → start-DhW7sy23.js} +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ConnectionsView-BZHJysCa.js","assets/jsx-runtime-bzQ4Vb5N.js","assets/index-CNVw44IE.js","assets/api-CPzQ_z9m.js","assets/link-ClwtaO_E.js","assets/createLucideIcon-Cgab8gqu.js","assets/index-Cofc7zhl.css","assets/ConfirmDialog-BblXqMVb.js","assets/TeamThread-DpUOwMoi.js","assets/SpawnDialog-C-Ujb4bC.js","assets/ModelSelect-CvOHjUyB.js","assets/entities-xVoB-p2j.js","assets/TeamForm-D6EAAF7m.js","assets/arrow-right-Dyta3p06.js","assets/save-ZqeB_I-c.js","assets/chevron-right-B2YEg9rw.js","assets/UnsavedChangesGuard-DTUP7hwu.js","assets/style-BWShXY3e.js","assets/style-DLioOiRN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,n as t,t as n}from"./jsx-runtime-bzQ4Vb5N.js";import{a as r,t as i}from"./link-ClwtaO_E.js";import{t as a}from"./UnsavedChangesGuard-DTUP7hwu.js";import{a as o,i as s,n as c,r as l,t as u}from"./api-CPzQ_z9m.js";import{t as d}from"./createLucideIcon-Cgab8gqu.js";import{C as f,E as p,S as m,T as h,_ as g,a as _,b as v,c as y,d as b,f as x,g as S,h as C,i as w,l as T,m as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as j,v as M,w as ne,x as N,y as re}from"./TeamThread-DpUOwMoi.js";import{t as P}from"./arrow-right-Dyta3p06.js";import{n as ie,r as ae,t as oe}from"./save-ZqeB_I-c.js";import{t as se}from"./chevron-right-B2YEg9rw.js";import{i as ce,n as le,r as ue,t as F}from"./ConfirmDialog-BblXqMVb.js";import{A as I,B as L,C as de,D as R,E as fe,F as pe,I as me,L as he,M as ge,N as _e,O as z,P as ve,Q as ye,R as be,S as xe,T as Se,X as Ce,Y as we,Z as Te,b as Ee,g as De,it as Oe,j as ke,k as Ae,lt as je,m as Me,rt as Ne,st as B,ut as Pe,v as Fe,w as Ie,x as Le,z as Re}from"./index-CNVw44IE.js";import{i as ze}from"./entities-xVoB-p2j.js";import{a as Be,n as Ve,r as He,t as Ue}from"./SpawnDialog-C-Ujb4bC.js";import{n as We,t as Ge}from"./ModelSelect-CvOHjUyB.js";import{n as Ke,t as qe}from"./SkillFindings-CHf5ZGY0.js";var Je=d(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),Ye=d(`book-open-check`,[[`path`,{d:`M12 21V7`,key:`gj6g52`}],[`path`,{d:`m16 12 2 2 4-4`,key:`mdajum`}],[`path`,{d:`M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3`,key:`8arnkb`}]]),Xe=d(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),Ze=d(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),Qe=d(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),V=d(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),$e=d(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),et=d(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),tt=d(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),nt=d(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),rt=d(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),it=d(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),at=d(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),ot=d(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),st=d(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),ct=d(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),lt=d(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),ut=d(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),dt=d(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ft=d(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),pt=d(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),H=e(t(),1);function mt(e){switch(e){case`added`:return`added`;case`modified`:return`modified`;case`deleted`:return`deleted`;case`renamed`:return`renamed`;case`copied`:return`copied`;case`type_changed`:return`type changed`;case`unmerged`:return`unmerged`;case`untracked`:return`untracked`;default:return`changed`}}function ht(e){let t=mt(e.status);return e.excludedReason===`credential_shaped`?`${t} · content withheld (credential-shaped)`:e.excludedReason===`bazilion_state`?`${t} · content withheld (Bazilion state)`:e.binary?`${t} · binary`:e.addedLines===null||e.deletedLines===null?t:`${t} · +${e.addedLines} −${e.deletedLines}`}function gt(e,t){switch(e){case`not_repository`:return`This Team workspace is not a Git repository, so there are no changes to review.`;case`unsupported_layout`:return`${t} Bazilion does not widen mounts or run repository helpers to make inspection work; use a repository whose work tree and metadata are reachable from the Team root.`;case`invalid_base`:return`That comparison base is not a branch, tag, commit id or revision such as HEAD~1.`;case`unknown_base`:return`That comparison base does not name a commit in this repository.`;default:return t}}var U=n(),_t=e=>e?e.slice(0,7):`no commit`;function vt({changes:e,base:t,loading:n,onBase:r,onRefresh:i}){let[a,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(t),u=e?.identity,d=u?u.headState===`detached`?`detached at ${_t(u.head)}`:u.branch??`unknown branch`:``;return a?(0,U.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),r(c.trim()),s(!1)},children:[(0,U.jsx)(`input`,{autoFocus:!0,"aria-label":`Comparison base`,placeholder:`HEAD, main, HEAD~1, a commit…`,value:c,onChange:e=>l(e.target.value),className:`min-h-9 min-w-0 flex-1 basis-40 py-1.5 font-mono text-xs`}),(0,U.jsx)(o,{variant:`primary`,type:`submit`,className:`min-h-9 px-3 py-1 text-xs`,children:`Compare`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-9 px-3 py-1 text-xs`,onClick:()=>s(!1),children:`Cancel`}),(0,U.jsx)(`p`,{className:`m-0 basis-full text-xs text-muted-foreground`,children:`A branch name is pinned to its commit when the review loads. Empty means HEAD: what is not committed yet.`})]}):(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs`,children:[(0,U.jsx)(tt,{className:`size-3.5 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-foreground`,title:d,children:d||`…`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{l(t),s(!0)},title:`Change the comparison base`,className:`unstyled shrink-0 rounded-full border border-border bg-card px-2 py-0.5 font-mono text-mocha hover:border-sapphire-light hover:text-sapphire`,children:[`since `,e?e.base.requestedRef:t||`HEAD`,e?` (${_t(e.base.resolvedOid)})`:``]}),(0,U.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Refresh the changes`,title:`Refresh`,className:`unstyled ml-auto flex size-7 shrink-0 items-center justify-center rounded-lg text-mocha hover:bg-muted hover:text-sapphire`,children:(0,U.jsx)(lt,{className:`size-3.5 ${n?`animate-spin`:``}`,"aria-hidden":`true`})})]})}var yt=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function bt(e){let t=[],n=[],r=0,i=0,a=!1,o=e.replace(/\n$/,``).split(`
|
|
3
|
+
`);for(let e of o){let o=yt.exec(e);o?(r=Number(o[1]),i=Number(o[2]),a=!0,n.push({kind:`hunk`,text:e})):a?e.startsWith(`+`)?n.push({kind:`add`,text:e.slice(1),newLine:i++}):e.startsWith(`-`)?n.push({kind:`remove`,text:e.slice(1),oldLine:r++}):e.startsWith(`\\`)?n.push({kind:`note`,text:e.slice(1).trim()}):n.push({kind:`context`,text:e.slice(1),oldLine:r++,newLine:i++}):t.push(e)}return{header:t,lines:n}}function xt(e){let t=[],n=[],r=[],i=()=>{for(let e=0;e<Math.max(n.length,r.length);e++)t.push({kind:`pair`,left:n[e]??null,right:r[e]??null});n=[],r=[]};for(let a of e)a.kind===`remove`?(r.length>0&&i(),n.push({line:a.oldLine,text:a.text,changed:!0})):a.kind===`add`?r.push({line:a.newLine,text:a.text,changed:!0}):(i(),a.kind===`context`?t.push({kind:`pair`,left:{line:a.oldLine,text:a.text,changed:!1},right:{line:a.newLine,text:a.text,changed:!1}}):t.push(a));return i(),t}var St=1500,Ct=`select-none px-2 text-right text-[0.7rem] leading-[1.6] text-mocha-light tabular-nums`,wt=`whitespace-pre-wrap px-2 leading-[1.6] [overflow-wrap:anywhere]`;function Tt({line:e,active:t,onClick:n}){return n?(0,U.jsxs)(`button`,{type:`button`,onClick:n,title:`Comment on line ${e}`,"aria-label":`Comment on line ${e}`,className:`unstyled group/line relative ${Ct} hover:bg-primary hover:text-primary-foreground ${t?`bg-primary text-primary-foreground`:``}`,children:[(0,U.jsx)(`span`,{className:`group-hover/line:invisible`,children:e}),(0,U.jsx)(ot,{className:`invisible absolute right-1.5 top-1/2 size-3.5 -translate-y-1/2 group-hover/line:visible`,"aria-hidden":`true`})]}):(0,U.jsx)(`span`,{className:Ct,children:e})}function Et({line:e,onAdd:t,onCancel:n}){let[r,i]=(0,H.useState)(``),a=()=>{r.trim()&&t(r.trim())};return(0,U.jsxs)(`div`,{className:`border-y border-primary/30 bg-accent/40 px-3 py-2.5 font-body`,children:[(0,U.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Comment on line ${e}`,placeholder:`What should change on line ${e}?`,rows:2,maxLength:2e3,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n(),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&a()},className:`min-h-16 text-sm`}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(o,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,disabled:!r.trim(),onClick:a,children:`Add to the review`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:n,children:`Cancel`})]})]})}function Dt({comments:e,onRemove:t}){return(0,U.jsx)(`div`,{className:`space-y-1.5 border-y border-primary/25 bg-accent/30 px-3 py-2 font-body`,children:e.map(e=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded-[10px] border border-border bg-card px-2.5 py-1.5 text-sm`,children:[(0,U.jsx)(`p`,{className:`m-0 min-w-0 flex-1 whitespace-pre-wrap break-words text-chocolate`,children:e.note}),t&&(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove this comment`,onClick:()=>t(e.id),className:`unstyled flex size-6 shrink-0 items-center justify-center rounded-md text-mocha hover:bg-muted hover:text-danger`,children:(0,U.jsx)(ce,{className:`size-3.5`,"aria-hidden":`true`})})]},e.id))})}function Ot({comments:e,onAddComment:t,onRemoveComment:n}){let[r,i]=(0,H.useState)(null),a=(0,H.useMemo)(()=>{let t=new Map;for(let n of e)n.line!==void 0&&t.set(n.line,[...t.get(n.line)??[],n]);return t},[e]);return{composing:r,under:e=>{if(e===void 0)return null;let o=a.get(e);return!o&&r!==e?null:(0,U.jsxs)(`div`,{className:`col-span-full`,children:[o&&(0,U.jsx)(Dt,{comments:o,onRemove:n}),r===e&&t&&(0,U.jsx)(Et,{line:e,onAdd:n=>{t(e,n),i(null)},onCancel:()=>i(null)})]})},startOn:t?e=>()=>i(t=>t===e?null:e):()=>void 0}}function kt({hidden:e,onShow:t}){return e<=0?null:(0,U.jsx)(`div`,{className:`col-span-full border-t border-frost/70 px-3 py-2 font-body`,children:(0,U.jsxs)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:t,children:[`Show `,e.toLocaleString(),` more line`,e===1?``:`s`]})})}var At=`col-span-full bg-accent/50 px-3 py-0.5 text-[0.7rem] text-accent-foreground`,jt=`col-span-full px-3 py-0.5 font-body text-[0.7rem] italic text-mocha-light`;function Mt(e){let t=(0,H.useMemo)(()=>bt(e.patch).lines,[e.patch]),[n,r]=(0,H.useState)(!1),{composing:i,under:a,startOn:o}=Ot(e),s=n?t:t.slice(0,St);return(0,U.jsxs)(`div`,{className:`grid grid-cols-[2.6rem_2.6rem_minmax(0,1fr)] font-mono text-xs text-chocolate`,children:[s.map((e,t)=>{if(e.kind===`hunk`)return(0,U.jsx)(`div`,{className:At,children:e.text},t);if(e.kind===`note`)return(0,U.jsx)(`div`,{className:jt,children:e.text},t);let n=e.kind===`add`?`bg-success/[0.13]`:e.kind===`remove`?`bg-danger/[0.13]`:``,r=e.kind===`add`?`bg-success/20`:e.kind===`remove`?`bg-danger/20`:`bg-muted/60`,s=e.kind===`remove`?void 0:e.newLine;return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(`span`,{className:`${Ct} ${r}`,children:e.kind===`add`?``:e.oldLine}),s===void 0?(0,U.jsx)(`span`,{className:`${Ct} ${r}`}):(0,U.jsx)(`span`,{className:`grid ${r}`,children:(0,U.jsx)(Tt,{line:s,active:i===s,onClick:o(s)})}),(0,U.jsxs)(`span`,{className:`${wt} ${n}`,children:[(0,U.jsx)(`span`,{className:`select-none text-mocha-light`,children:e.kind===`add`?`+`:e.kind===`remove`?`−`:` `}),e.text]}),a(s)]},t)}),(0,U.jsx)(kt,{hidden:t.length-s.length,onShow:()=>r(!0)})]})}function Nt(e){let t=(0,H.useMemo)(()=>xt(bt(e.patch).lines),[e.patch]),[n,r]=(0,H.useState)(!1),{composing:i,under:a,startOn:o}=Ot(e),s=n?t:t.slice(0,St);return(0,U.jsxs)(`div`,{className:`grid grid-cols-[2.8rem_minmax(0,1fr)_2.8rem_minmax(0,1fr)] font-mono text-xs text-chocolate`,children:[s.map((e,t)=>{if(e.kind===`hunk`)return(0,U.jsx)(`div`,{className:At,children:e.text},t);if(e.kind===`note`)return(0,U.jsx)(`div`,{className:jt,children:e.text},t);let{left:n,right:r}=e,s=n?.changed?`bg-danger/[0.13]`:n?``:`bg-muted/50`,c=r?.changed?`bg-success/[0.13]`:r?``:`bg-muted/50`;return(0,U.jsxs)(H.Fragment,{children:[(0,U.jsx)(`span`,{className:`${Ct} ${n?.changed?`bg-danger/20`:`bg-muted/60`}`,children:n?.line}),(0,U.jsx)(`span`,{className:`${wt} border-r border-frost/70 ${s}`,children:n?.text}),r?(0,U.jsx)(`span`,{className:`grid ${r.changed?`bg-success/20`:`bg-muted/60`}`,children:(0,U.jsx)(Tt,{line:r.line,active:i===r.line,onClick:o(r.line)})}):(0,U.jsx)(`span`,{className:`${Ct} bg-muted/60`}),(0,U.jsx)(`span`,{className:`${wt} ${c}`,children:r?.text}),a(r?.line)]},t)}),(0,U.jsx)(kt,{hidden:t.length-s.length,onShow:()=>r(!0)})]})}var Pt={base:``,comments:[],note:``},Ft=(0,H.createContext)(null);function It({children:e}){let[t,n]=(0,H.useState)({}),r=(0,H.useRef)(0),i=(0,H.useCallback)((e,t)=>{n(n=>({...n,[e]:t(n[e]??Pt)}))},[]),a=(0,H.useCallback)(()=>++r.current,[]),o=(0,H.useMemo)(()=>({sessions:t,update:i,nextId:a}),[t,i,a]);return(0,U.jsx)(Ft.Provider,{value:o,children:e})}function Lt(e){let t=(0,H.useContext)(Ft);if(!t)throw Error(`useReviewSession needs a ReviewProvider`);let{sessions:n,update:r,nextId:i}=t,a=n[e]??Pt;return(0,H.useMemo)(()=>({...a,setBase:t=>r(e,e=>({...e,base:t})),setNote:t=>r(e,e=>({...e,note:t})),addComment:t=>r(e,e=>({...e,comments:[...e.comments,{...t,id:i()}]})),removeComment:t=>r(e,e=>({...e,comments:e.comments.filter(e=>e.id!==t)})),clear:()=>r(e,e=>({...e,comments:[],note:``}))}),[a,e,r,i])}function Rt(e,t){let n=new URLSearchParams(t).toString();return`/api/teams/${encodeURIComponent(e)}/review${n?`?${n}`:``}`}function zt(e,t){let{turnsEnded:n}=z();return M(async n=>{try{return{review:await c(Rt(e,{authors:`1`,...t?{base:t}:{}}),{signal:n}),unavailable:null}}catch(e){if(!(e instanceof u)||n.aborted)throw e;return{review:null,unavailable:{code:e.code,message:s(e)}}}},[e,t,n])}function Bt(e,t,n,r){return M(async r=>{if(!n)return null;let i=(await c(Rt(e,{patches:`1`,path:n,...t?{base:t}:{}}),{signal:r})).changes.changes.find(e=>e.path===n);return{path:n,patch:i?.patch??null,truncated:i?.patchTruncated??!1,omitted:i?.contentOmitted??null}},[e,t,n,r])}var Vt={added:`A`,modified:`M`,deleted:`D`,renamed:`R`,copied:`C`,type_changed:`T`,unmerged:`U`,untracked:`N`,unknown:`?`},Ht={added:`bg-success/15 text-success`,untracked:`bg-success/15 text-success`,copied:`bg-success/15 text-success`,modified:`bg-accent text-accent-foreground`,renamed:`bg-accent text-accent-foreground`,type_changed:`bg-accent text-accent-foreground`,deleted:`bg-danger/15 text-danger`,unmerged:`bg-warning/15 text-warning`,unknown:`bg-frost text-mocha`};function Ut({status:e}){return(0,U.jsx)(`span`,{className:`inline-flex size-[18px] shrink-0 items-center justify-center rounded font-mono text-[0.7rem] font-semibold ${Ht[e]}`,"aria-hidden":`true`,children:Vt[e]})}function Wt(e){let t=e.lastIndexOf(`/`);return t<0?{dir:``,name:e}:{dir:e.slice(0,t+1),name:e.slice(t+1)}}function Gt(e){return e.excludedReason?(0,U.jsx)(`span`,{className:`text-xs text-mocha`,children:`withheld`}):e.binary?(0,U.jsx)(`span`,{className:`text-xs text-mocha`,children:`binary`}):(0,U.jsxs)(`span`,{className:`flex shrink-0 gap-1.5 font-mono text-[0.7rem] font-medium`,children:[e.addedLines?(0,U.jsxs)(`span`,{className:`text-success`,children:[`+`,e.addedLines]}):null,e.deletedLines?(0,U.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.deletedLines]}):null]})}function Kt({changes:e,authors:t,comments:n,selected:r,onSelect:i}){let{agentById:a}=k();return e.changes.length===0?(0,U.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:`Nothing changed since this base.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{className:`m-0 list-none divide-y divide-frost/70 overflow-hidden rounded-2xl border border-border p-0`,children:e.changes.map(e=>{let{dir:o,name:s}=Wt(e.path),c=t[e.path],l=n.filter(t=>t.path===e.path).length,u=e.path===r;return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,"aria-current":u?`true`:void 0,onClick:()=>i(e.path),title:`${e.previousPath?`${e.previousPath} → `:``}${e.path} · ${ht(e)}`,className:`unstyled flex min-h-10 w-full items-center gap-2 px-2.5 py-1.5 text-left hover:bg-accent/50 ${u?`bg-accent/60`:``}`,children:[(0,U.jsx)(Ut,{status:e.status}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:[(0,U.jsx)(`span`,{className:`text-mocha-light`,children:o}),(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:s})]}),l>0&&(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-0.5 text-xs font-semibold text-accent-foreground`,children:[(0,U.jsx)(f,{className:`size-3`,"aria-hidden":`true`}),l]}),Gt(e),c&&(0,U.jsxs)(`span`,{title:`Last written by ${c.agentName}`,className:`shrink-0`,children:[(0,U.jsx)(Fe,{identity:a(c.agentId)?.identity,size:18}),(0,U.jsxs)(`span`,{className:`sr-only`,children:[`Last written by `,c.agentName]})]})]})},`${e.status}:${e.path}`)})}),e.truncated&&(0,U.jsx)(`p`,{className:`m-0 mt-2 text-xs text-warning`,children:`This list is incomplete: more files changed than a review shows.`}),(e.withheld.excluded>0||e.withheld.untracked>0)&&(0,U.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:[`Not shown: `,e.withheld.excluded,` excluded and `,e.withheld.untracked,` untracked path`,e.withheld.excluded+e.withheld.untracked===1?``:`s`,`.`]}),e.issues.map(e=>(0,U.jsx)(`p`,{className:`m-0 mt-2 text-xs text-muted-foreground`,children:e.message},`${e.code}:${e.message}`))]})}var qt=20;function Jt(e,t,n,r){let i=new Map;for(let n of e.comments){let e=t[n.path]?.agentId;e&&i.set(e,(i.get(e)??0)+1)}let a=[...i].sort((e,t)=>t[1]-e[1])[0]?.[0],o=e=>n.some(t=>t.id===e);return o(a)?a:o(r)?r:n[0]?.id??``}function Yt({teamId:e,session:t,authors:n,onOpenFile:r}){let{agents:a,agent:l,to:d}=k(),f=z(),p=a.filter(t=>t.teamId===e),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(null),S=Jt(t,n,p,l?.agent.id),C=m&&p.some(e=>e.id===m)?m:S,w=t.comments.length;async function T(){_(!0),y(``);try{let n={agentId:C,comments:t.comments.map(({path:e,line:t,note:n})=>({path:e,...t===void 0?{}:{line:t},...n?{note:n}:{}})),...t.note.trim()?{note:t.note.trim()}:{},...t.base?{base:t.base}:{}};x({agentId:C,message:(await c(`/api/teams/${encodeURIComponent(e)}/review/feedback`,{body:n})).message}),t.clear(),f.refresh()}catch(e){y(gt(e instanceof u?e.code:void 0,s(e)))}finally{_(!1)}}if(w===0){let e=b?p.find(e=>e.id===b.agentId):void 0;return b?(0,U.jsxs)(`div`,{role:`status`,className:`rounded-2xl border border-success/30 bg-success/[0.08] px-3 py-2.5 text-sm`,children:[(0,U.jsxs)(`p`,{className:`m-0 font-semibold text-foreground`,children:[`Sent to `,e?.name??`the Agent`,`. It runs the review as its next turn.`]}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[e&&(0,U.jsx)(i,{to:`/`,search:d({agent:e.id,view:void 0,file:void 0}),className:`ghost-btn min-h-8 px-3 py-1 text-xs`,children:`Open the conversation`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>x(null),children:`Dismiss`})]}),(0,U.jsxs)(`details`,{className:`mt-2`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-xs text-mocha`,children:`The message it received`}),(0,U.jsx)(`pre`,{className:`m-0 mt-1.5 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-[10px] bg-card p-2.5 font-mono text-xs`,children:b.message})]})]}):(0,U.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-3 text-sm text-muted-foreground`,children:`No comments yet. Click a line number in a diff, or comment on a whole file. The comments go to one Agent together.`})}return(0,U.jsxs)(`div`,{className:`rounded-2xl border border-primary/25 bg-accent/25 p-3`,children:[(0,U.jsxs)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:[`Your review · `,w,` comment`,w===1?``:`s`]}),(0,U.jsx)(`ul`,{className:`m-0 mt-2 list-none space-y-1.5 p-0`,children:t.comments.map(e=>{let{name:n}=Wt(e.path);return(0,U.jsxs)(`li`,{className:`flex items-start gap-2 rounded-[10px] border border-border bg-card px-2.5 py-1.5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e.path),title:e.path,className:`unstyled block max-w-full truncate font-mono text-xs font-medium text-accent-foreground hover:underline`,children:[n,e.line===void 0?``:`:${e.line}`]}),(0,U.jsx)(`p`,{className:`m-0 mt-0.5 line-clamp-3 whitespace-pre-wrap break-words text-xs text-chocolate`,children:e.note||`No note: the Agent gets the file and its diff.`})]}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Remove this comment`,onClick:()=>t.removeComment(e.id),className:`unstyled flex size-6 shrink-0 items-center justify-center rounded-md text-mocha hover:bg-muted hover:text-danger`,children:(0,U.jsx)(ce,{className:`size-3.5`,"aria-hidden":`true`})})]},e.id)})}),(0,U.jsxs)(`label`,{className:`mb-0 mt-2.5 text-xs`,children:[`About the review as a whole (optional)`,(0,U.jsx)(`textarea`,{rows:2,maxLength:2e3,value:t.note,onChange:e=>t.setNote(e.target.value),className:`min-h-14 text-sm`})]}),(0,U.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap items-end gap-2`,children:[(0,U.jsxs)(`label`,{className:`m-0 min-w-0 flex-1 basis-40 text-xs`,children:[`Send to`,(0,U.jsx)(`select`,{value:C,onChange:e=>h(e.target.value),children:p.map(e=>(0,U.jsxs)(`option`,{value:e.id,children:[e.name,e.id===S&&t.comments.some(t=>n[t.path]?.agentId===e.id)?` (wrote these files)`:``]},e.id))})]}),(0,U.jsx)(o,{variant:`primary`,disabled:g||!C||w>qt,onClick:()=>void T(),children:g?`Sending…`:`Send review`})]}),w>qt&&(0,U.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-danger`,children:[`A review takes `,qt,` comments at most: remove `,w-qt,`.`]}),p.length===0&&(0,U.jsx)(`p`,{className:`m-0 mt-2 text-xs text-danger`,children:`This Team has no Agent to send a review to.`}),v&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-xs text-danger`,children:v})]})}function Xt(e){let{turnsEnded:t}=z();return M(async t=>{if(!e)return{changes:null,files:null};let n=encodeURIComponent(e),[r,i]=await Promise.all([c(`/api/teams/${n}/review`,{signal:t}).then(e=>e.changes.changes.length).catch(()=>null),c(`/api/results?teamId=${n}&limit=1`,{signal:t}).then(e=>e.total).catch(()=>null)]);return{changes:r,files:i}},[e,t]).data??{changes:null,files:null}}function Zt({agent:e}){let t=r(),n=M(e=>c(Ge,{signal:e}),[]),i=e.agent.modelOverride??``,[a,l]=(0,H.useState)(i),[u,d]=(0,H.useState)(e.reasoningLevel),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),[g,_]=(0,H.useState)(null),v=a!==i||u!==e.reasoningLevel;async function y(n){n.preventDefault(),p(!0),_(null),h(!1);try{await c(`/api/agents/${encodeURIComponent(e.agent.id)}`,{method:`PATCH`,body:{modelOverride:a||null,reasoningLevel:u}}),await t.invalidate({sync:!0}),h(!0)}catch(e){_(s(e))}finally{p(!1)}}return(0,U.jsxs)(`form`,{onSubmit:e=>void y(e),className:`[&_label]:mt-0`,children:[(0,U.jsx)(We,{label:`Model`,value:a,onChange:e=>{l(e),h(!1)},groups:n.data?.teams??[],emptyOption:`The template's (${e.profile.defaultModel})`}),(0,U.jsxs)(`label`,{children:[`Reasoning`,(0,U.jsx)(`select`,{value:u,onChange:e=>{d(e.target.value),h(!1)},children:ze.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:f||!v,children:f?`Saving…`:`Save`}),m&&!v&&(0,U.jsx)(`span`,{role:`status`,className:`text-sm text-success`,children:`Saved. It applies from the next turn.`}),(g??n.error)&&(0,U.jsx)(`span`,{role:`alert`,className:`text-sm text-danger`,children:g??n.error})]})]})}function Qt({value:e,className:t,ariaLabel:n=`Copy to clipboard`,title:r=`Copy to clipboard`}){let[i,a]=(0,H.useState)(!1);async function o(){if(!e)return;let t=!1;try{navigator.clipboard?.writeText&&(await navigator.clipboard.writeText(e),t=!0)}catch{}if(!t){let n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.opacity=`0`,document.body.appendChild(n),n.select();try{t=document.execCommand(`copy`)}catch{}n.remove()}t&&(a(!0),setTimeout(()=>a(!1),1e3))}return(0,U.jsx)(`button`,{type:`button`,onClick:o,title:r,"aria-label":n,className:`inline-flex h-[1.3rem] w-[1.6rem] items-center justify-center rounded-sm border border-transparent text-mocha-light transition-colors hover:border-frost hover:bg-snow hover:text-mocha ${i?`border-[#bcd9bc] bg-[#eef7ee] text-[#3b7a3b] hover:border-[#bcd9bc] hover:bg-[#eef7ee] hover:text-[#3b7a3b]`:``} ${t??``}`,children:i?`✓`:`⧉`})}var $t=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function en({agent:e}){let{agent:t}=e,{teams:n,to:a,search:l}=k(),u=z(),d=r(),f=S(),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),b=t.status===`archived`,x=`/api/agents/${encodeURIComponent(t.id)}`,C=u.stateOf(t.id),w=u.byAgent.get(t.id)?.lastActivityAt??null,T=M(async e=>{let[t,n,r]=await Promise.all([c(`${x}/triggers`,{signal:e}),c(`${x}/lesson-proposals`,{signal:e}),c(`${x}/messages?unread=1`,{signal:e})]);return{schedules:t.triggers.filter(e=>e.enabled).length,schedulesOff:t.triggers.filter(e=>!e.enabled).length,proposals:n.proposals.filter(e=>e.status===`pending`).length,unread:r.messages.length}},[x,u.turnsEnded,l.section]),E=M(e=>c(`/api/config/telegram`,{signal:e}).catch(()=>({configured:!1})),[]);async function D(){v(null);try{await Be(t.id),await d.invalidate()}catch(e){v(s(e))}}let O=T.data,A=[{section:`schedules`,icon:Ze,label:`Schedules`,detail:O?O.schedules+O.schedulesOff===0?`None`:`${O.schedules} on${O.schedulesOff?`, ${O.schedulesOff} off`:``}`:``},{section:`learning`,icon:Ye,label:`Learning`,detail:O?.proposals?`${$t(O.proposals,`lesson`)} to review`:e.privateLessons.length?`${$t(e.privateLessons.length,`lesson`)} applied`:t.reviewEnabled?`Reviews every ${t.reviewEveryNTurns} turns`:`Periodic review off`},{section:`mailbox`,icon:it,label:`Mailbox`,detail:O?O.unread?`${O.unread} unread`:`Nothing unread`:``},{section:`skills`,icon:we,label:`Skills`,detail:e.profile.skillsMode===`all`&&e.skills.length===0?`From the template`:`${e.skills.length} attached`},...E.data?.configured?[{section:`telegram`,icon:re,label:`Telegram`,detail:t.telegramTopicId===null?`Not bound`:`Topic #${t.telegramTopicId}`}]:[],{section:`browser`,icon:nt,label:`Browser`,detail:`Session and saved profile`}];return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(Fe,{identity:t.identity,size:44}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate text-base font-semibold text-foreground`,children:t.name}),b&&(0,U.jsx)(je,{variant:`warning`,children:`Archived`})]}),(t.identity?.creature||t.identity?.vibe)&&(0,U.jsx)(`p`,{className:`m-0 truncate text-xs text-muted-foreground`,children:[t.identity?.creature,t.identity?.vibe].filter(Boolean).join(` · `)}),(0,U.jsxs)(`p`,{className:`m-0 mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,U.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${y[C.kind]}`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:C.text}),f&&w!==null&&C.kind!==`working`&&(0,U.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`· last active `,fe(w)]})]})]})]}),_&&(0,U.jsx)(`p`,{role:`alert`,className:`err mt-3`,children:_}),b&&(0,U.jsxs)(`div`,{className:`mt-3 rounded-[10px] border border-warning/30 bg-warning/[0.07] px-3 py-2 text-sm text-chocolate`,children:[`This Agent is archived: it is hidden from the list and receives no work.`,(0,U.jsx)(`div`,{className:`mt-2`,children:(0,U.jsx)(o,{variant:`ghost`,onClick:()=>void D(),children:`Restore`})})]}),(0,U.jsx)(Cn,{children:`Model`}),(0,U.jsx)(Zt,{agent:e}),(0,U.jsx)(Cn,{children:`More about this Agent`}),(0,U.jsx)(wn,{children:A.map(({section:e,icon:t,label:n,detail:r})=>(0,U.jsxs)(i,{to:`/`,search:a({panel:`agent`,section:e}),className:`flex min-h-11 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50`,children:[(0,U.jsx)(t,{className:`size-4 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`shrink-0 text-sm font-semibold`,children:n}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right text-xs ${e===`learning`&&O?.proposals||e===`mailbox`&&O?.unread?`font-semibold text-warning`:`text-muted-foreground`}`,children:r}),(0,U.jsx)(se,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e))}),(0,U.jsx)(Cn,{children:`Team`}),(0,U.jsx)(tn,{agentId:t.id,teamId:e.team.id,teams:n},e.team.id),(0,U.jsx)(Cn,{children:`Details`}),(0,U.jsxs)(`dl`,{className:`m-0 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-1.5 text-xs`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Template`}),(0,U.jsx)(`dd`,{className:`m-0 min-w-0 truncate`,children:(0,U.jsx)(`a`,{href:`/templates/agents/${encodeURIComponent(e.profile.id)}`,children:e.profile.name||e.profile.id})}),(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`ID`}),(0,U.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`min-w-0 select-all truncate font-mono text-mocha`,children:t.id}),(0,U.jsx)(Qt,{value:t.id,ariaLabel:`Copy the Agent's ID`,title:`Copy the ID`})]}),(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Files`}),(0,U.jsx)(`dd`,{className:`m-0 min-w-0 truncate font-mono text-mocha`,title:t.dir,children:t.dir})]}),(0,U.jsxs)(`div`,{className:`mt-5 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`ghost`,onClick:()=>m(!0),children:`Rename`}),!b&&(0,U.jsx)(o,{variant:`ghost`,onClick:()=>g(`archive`),children:`Archive`}),(0,U.jsx)(o,{variant:`danger`,onClick:()=>g(`delete`),children:`Delete`})]}),p&&(0,U.jsx)(ee,{agent:t,onClose:()=>m(!1),onRenamed:()=>d.invalidate()}),(0,U.jsx)(F,{open:h!==null,onOpenChange:e=>{e||g(null)},title:h===`delete`?`Delete ${t.name} permanently?`:`Archive ${t.name}?`,description:h===`delete`?(0,U.jsx)(`p`,{children:`This removes its conversations, messages, schedules, skill attachments and private files. Files it saved for the Team stay. This cannot be undone.`}):(0,U.jsx)(`p`,{children:`The Agent leaves the list and receives no work. Restore it later under Manage, Agents, with “Show archived”.`}),confirmLabel:h===`delete`?`Delete permanently`:`Archive agent`,confirmVariant:h===`delete`?`danger`:`primary`,onConfirm:async()=>{h===`delete`?await He(t.id):await Ve(t.id),await d.navigate({to:`/`,search:{team:e.team.id}}),await d.invalidate()}})]})}function tn({agentId:e,teamId:t,teams:n}){let i=r(),[a,l]=(0,H.useState)(t),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null);async function m(t){t.preventDefault(),d(!0),p(null);try{await c(`/api/agents/${encodeURIComponent(e)}/team`,{method:`PATCH`,body:{teamId:a}}),await i.invalidate({sync:!0})}catch(e){p(s(e))}finally{d(!1)}}return(0,U.jsxs)(`form`,{onSubmit:e=>void m(e),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`select`,{"aria-label":`Team`,value:a,onChange:e=>l(e.target.value),className:`min-w-0 flex-1`,children:n.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:u||a===t,children:u?`Moving…`:`Move`})]}),a!==t&&(0,U.jsx)(`p`,{className:`m-0 mt-1.5 text-xs text-muted-foreground`,children:`Moving leaves this Agent's connections behind; it joins the other Team with none.`}),f&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 mt-1.5 text-xs text-danger`,children:f})]})}function nn({team:e}){let{to:t,search:n,agentById:r}=k(),{turnsEnded:a}=z(),o=M(t=>c(`/api/teams/${encodeURIComponent(e.id)}/policy`,{signal:t}),[e.id,a,n.view]),s=D(e.id);if(o.error)return(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:o.error});if(!o.data)return(0,U.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the connections…`});let{mode:l,edges:u}=o.data,d=o.data.members.filter(e=>e.status!==`archived`),f=_(s.data??[]),p=(e,t)=>u.some(n=>n.from===e&&n.to===t);return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`rounded-2xl border border-border bg-muted/50 px-3 py-2.5`,children:[(0,U.jsx)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:l===`open`?`Open Team`:`Restricted Team`}),(0,U.jsxs)(`p`,{className:`m-0 mt-0.5 text-xs leading-relaxed text-mocha`,children:[l===`open`?`Members message each other freely. A connection is only needed to reach other Teams.`:`A member can message a teammate only along a connection.`,` `,`You can always talk to every Agent.`]}),(0,U.jsxs)(i,{to:`/`,search:t({view:`connections`,section:void 0}),className:`btn-primary mt-2.5 min-h-9 w-full py-1.5 text-sm no-underline`,children:[(0,U.jsx)(m,{className:`size-4`,"aria-hidden":`true`}),`Open the map`]})]}),(0,U.jsx)(Cn,{children:`Who can message whom`}),d.length===0?(0,U.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:`This Team has no members yet.`}):(0,U.jsx)(wn,{children:d.map(e=>{let t=[...d.filter(t=>t.id!==e.id),null].flatMap(t=>{let n=t?.id??`outside`,r=p(e.id,n),i=p(n,e.id);return l===`open`&&t||!r&&!i?[]:[{id:n,name:t?.name??`Other teams`,out:r,back:i}]}),n=d.reduce((t,n)=>{if(n.id===e.id)return t;let r=f.get(w(e.id,n.id));return r?t+(e.id<n.id?r.forward:r.back):t},0);return(0,U.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,U.jsx)(Fe,{identity:r(e.id)?.identity,size:22}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.name}),n>0&&(0,U.jsxs)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:[n,` sent`]})]}),(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1.5 pl-[30px]`,children:[l===`open`&&(0,U.jsx)(`span`,{className:`rounded-full bg-frost px-2 py-0.5 text-xs text-chocolate`,children:`Everyone in the Team`}),t.map(t=>(0,U.jsxs)(`span`,{title:t.out&&t.back?`${e.name} and ${t.name} can message each other`:t.out?`${e.name} can message ${t.name}`:`${t.name} can message ${e.name}`,className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs ${t.out?`bg-accent text-accent-foreground`:`bg-frost text-mocha`}`,children:[t.out&&t.back?(0,U.jsx)(Je,{className:`size-3`,"aria-hidden":`true`}):t.out?(0,U.jsx)(P,{className:`size-3`,"aria-hidden":`true`}):(0,U.jsx)(P,{className:`size-3 rotate-180`,"aria-hidden":`true`}),t.name]},t.id)),l===`restricted`&&t.length===0&&(0,U.jsx)(`span`,{className:`rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning`,children:`No connections: it can only talk to you`})]})]},e.id)})}),(0,U.jsx)(Cn,{children:`Recent messages`}),s.error?(0,U.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:s.error}):(0,U.jsx)(te,{messages:s.data??[],limit:12})]})}var rn=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],an=[`text/plain`,`text/markdown`];function on(e){return rn.includes(e.mimeType)&&e.byteLength<=10*1024*1024}function sn(e){return an.includes(e.mimeType)&&e.byteLength<=256*1024}function cn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(+(e<10*1024))} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ln(e,t){if(e.startsWith(`image/`))return`${e.slice(6).toUpperCase()} image`;if(e===`text/markdown`)return`Markdown`;if(e===`text/plain`)return`Text`;if(e===`application/pdf`)return`PDF`;let n=/\.([a-z0-9]{1,6})$/i.exec(t)?.[1];return n?n.toUpperCase():e}var un=(e,t)=>`/api/results/${encodeURIComponent(e)}${t?`/${t}`:``}`;function dn(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))r&&t.set(n,r);return`/api/results/archive?${t}`}function fn({resultId:e,result:t,detail:n,open:r,selected:a=!1,compact:d=!1,onPick:f}){let[p,m]=(0,H.useState)(t??null),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(null);(0,H.useEffect)(()=>{if(t){m(t);return}let n=new AbortController;return c(un(e),{signal:n.signal}).then(e=>m(e.result)).catch(e=>{n.signal.aborted||g(e instanceof u&&e.status===404?`This saved file is unavailable (it may have been deleted).`:s(e))}),()=>n.abort()},[e,t]);async function y(){if(_!==null)return v(null);g(``);try{v(await(await l(un(e,`preview`))).text())}catch(e){g(s(e))}}if(!p)return(0,U.jsx)(`div`,{className:`rounded-[10px] border border-border bg-muted p-3 text-sm text-muted-foreground`,children:h?(0,U.jsx)(`span`,{role:`alert`,children:h}):(0,U.jsx)(`span`,{role:`status`,children:`Loading saved file…`})});let b=[cn(p.byteLength),ln(p.mimeType,p.name),p.imageModel?`made with ${p.imageModel}`:null].filter(Boolean).join(` · `),x=(0,U.jsx)(`a`,{href:un(p.id,`download`),download:p.name,"aria-label":`Download ${p.name}`,title:`Download`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border border-border bg-card text-foreground hover:border-sapphire-light hover:text-sapphire`,children:(0,U.jsx)($e,{className:`size-[15px]`,"aria-hidden":`true`})}),S=`min-w-0 overflow-hidden rounded-[10px] border bg-muted ${a?`border-primary ring-1 ring-primary`:`border-border`}`;if(d){let e=on(p)?(0,U.jsx)(`img`,{src:un(p.id,`preview`),alt:p.name,loading:`lazy`,className:`block aspect-[4/3] w-full bg-card object-contain p-1.5`}):(0,U.jsxs)(`span`,{className:`flex aspect-[4/3] w-full flex-col items-center justify-center gap-1.5 bg-card text-mocha`,children:[(0,U.jsx)(et,{className:`size-7`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-full truncate px-2 font-mono text-[0.7rem] font-medium uppercase tracking-wide`,children:ln(p.mimeType,p.name)})]});return(0,U.jsxs)(`figure`,{className:`m-0 ${S}`,children:[f?(0,U.jsx)(`button`,{type:`button`,onClick:f,"aria-label":`Choose ${p.name}`,"aria-pressed":a,className:`unstyled block w-full`,children:e}):r?(0,U.jsx)(i,{to:`/`,search:r,"aria-label":`Open ${p.name}`,"aria-current":a?`true`:void 0,className:`block`,children:e}):e,(0,U.jsxs)(`figcaption`,{className:`flex items-center gap-1.5 py-1.5 pl-2.5 pr-1.5`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.8rem] font-semibold text-foreground`,title:p.name,children:p.name}),(0,U.jsx)(`span`,{className:`block truncate text-[0.7rem] text-mocha`,children:n??b})]}),x]})]})}if(on(p)){let e=(0,U.jsx)(`img`,{src:un(p.id,`preview`),alt:p.name,loading:`lazy`,className:`block max-h-80 w-full bg-card object-contain`});return(0,U.jsxs)(`figure`,{className:`m-0 ${S}`,children:[r?(0,U.jsx)(i,{to:`/`,search:r,"aria-label":`Open ${p.name} in Files`,className:`block`,children:e}):e,(0,U.jsxs)(`figcaption`,{className:`flex items-center gap-2 py-1.5 pl-2.5 pr-1.5`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.82rem] font-semibold text-foreground`,children:p.name}),(0,U.jsx)(`span`,{className:`block truncate text-[0.72rem] text-mocha`,children:n??b})]}),x]})]})}return(0,U.jsxs)(`div`,{className:S,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 py-2 pl-2.5 pr-1.5`,children:[(0,U.jsx)(et,{className:`size-[18px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[r?(0,U.jsx)(i,{to:`/`,search:r,className:`block truncate text-[0.82rem] font-semibold text-foreground hover:text-sapphire`,children:p.name}):(0,U.jsx)(`span`,{className:`block truncate text-[0.82rem] font-semibold text-foreground`,children:p.name}),(0,U.jsx)(`span`,{className:`block truncate text-[0.72rem] text-mocha`,children:n??b})]}),sn(p)&&(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-2.5 py-1 text-xs`,onClick:()=>void y(),children:_===null?`Preview`:`Hide`}),x]}),_!==null&&(0,U.jsx)(`pre`,{className:`m-0 max-h-80 overflow-auto whitespace-pre-wrap break-words border-t border-border bg-card p-3 text-xs`,children:_}),h&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 border-t border-border px-3 py-2 text-xs text-danger`,children:h})]})}var pn=100;function mn(e,t,n=24){let{turnsEnded:r}=z(),[i,a]=(0,H.useState)(n),o=`${e}|${t.agentId??``}|${t.sessionId??``}`;(0,H.useEffect)(()=>a(n),[o,n]);let s=M(async n=>{let r=[],a=0;for(let o=0;o<i;o+=pn){let s=new URLSearchParams({teamId:e,limit:String(Math.min(pn,i-o)),offset:String(o)});t.agentId&&s.set(`agentId`,t.agentId),t.sessionId&&s.set(`sessionId`,t.sessionId);let l=await c(`/api/results?${s}`,{signal:n});if(r.push(...l.results),a=l.total,r.length>=a)break}return{results:r,total:a}},[o,i,r]),l=s.data?.results??[],u=s.data?.total??0;return{results:l,total:u,loading:s.loading,error:s.error,hasMore:l.length<u,more:()=>a(e=>e+n),reload:s.reload}}var hn=`unstyled inline-flex h-7 items-center rounded-full border px-2.5 text-xs font-semibold transition-colors`,gn=`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`;function _n({team:e}){let{agent:t,agentById:n,conversationId:r,to:a}=k(),s=S(),[c,l]=(0,H.useState)(`team`),u=t&&t.team.id===e.id?t.agent:null,d=c===`agent`&&!u||c===`conversation`&&!r?`team`:c,f=d===`agent`&&u?{agentId:u.id}:d===`conversation`&&r?{sessionId:r}:{},p=mn(e.id,f,12),m=[{id:`team`,label:`Whole Team`},...u?[{id:`agent`,label:u.name}]:[],...u&&r?[{id:`conversation`,label:`This conversation`}]:[]];return(0,U.jsxs)(`div`,{children:[m.length>1&&(0,U.jsx)(`fieldset`,{"aria-label":`Whose files`,className:`m-0 mb-3 flex min-w-0 flex-wrap gap-1.5 border-0 p-0`,children:m.map(e=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":d===e.id,onClick:()=>l(e.id),className:`${hn} ${d===e.id?`border-primary/30 bg-accent text-accent-foreground`:`border-border bg-card text-mocha hover:text-foreground`}`,children:e.label},e.id))}),(0,U.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,U.jsx)(`p`,{className:`m-0 text-xs text-muted-foreground`,children:p.loading&&p.results.length===0?`Loading…`:`${p.total} saved file${p.total===1?``:`s`}`}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[p.total>0&&(0,U.jsxs)(`a`,{href:dn({teamId:e.id,...f}),download:!0,className:gn,title:`Download these files as one zip`,children:[(0,U.jsx)($e,{className:`size-3.5`,"aria-hidden":`true`}),`All (.zip)`]}),(0,U.jsxs)(i,{to:`/`,search:a({view:`files`,section:void 0}),className:gn,children:[(0,U.jsx)(ne,{className:`size-3.5`,"aria-hidden":`true`}),`Gallery`]})]})]}),p.error&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:p.error}),!p.loading&&!p.error&&p.total===0&&(0,U.jsxs)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:[`Nothing saved `,d===`team`?`in this Team`:`here`,` yet. Files an Agent delivers or pictures it generates are kept here with their original contents.`]}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:p.results.map(e=>{let t=n(e.agentId)?.name;return(0,U.jsx)(fn,{resultId:e.id,result:e,compact:!0,detail:[t,s?fe(e.createdAt):null].filter(Boolean).join(` · `),open:a({view:`files`,result:e.id,section:void 0})},e.id)})}),p.hasMore&&(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(o,{variant:`ghost`,className:`w-full`,disabled:p.loading,onClick:p.more,children:p.loading?`Loading…`:`Show more (${p.total-p.results.length} left)`})})]})}var vn=`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`;function yn({team:e}){let{agents:t,profiles:n,teams:a,teamTemplates:o,agent:s,to:c,search:l}=k(),u=z(),d=r(),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),g=t.filter(t=>t.teamId===e.id),_=o.filter(e=>e.slots.length>0),v=_.find(e=>e.id===m);return(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-base font-semibold text-foreground`,children:e.name}),(0,U.jsx)(`p`,{className:`m-0 truncate font-mono text-xs text-muted-foreground`,title:e.path,children:e.path})]}),(0,U.jsx)(i,{to:`/`,search:c({panel:`connections`,section:void 0}),title:e.policyMode===`open`?`Members message each other freely`:`Members message each other only along connections`,className:`shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,children:e.policyMode===`open`?`Open`:`Restricted`})]}),(0,U.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(Cn,{children:[g.length,` member`,g.length===1?``:`s`]}),(0,U.jsxs)(`button`,{type:`button`,className:`unstyled ${vn}`,onClick:()=>p(!0),children:[(0,U.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`}),`Add agent`]})]}),g.length===0?(0,U.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-4 text-sm text-muted-foreground`,children:[(0,U.jsx)(`p`,{className:`m-0`,children:`No Agents in this Team yet.`}),_.length>0&&(0,U.jsxs)(`label`,{className:`mb-0 mt-3 text-xs`,children:[`Or spawn a whole Team template here`,(0,U.jsxs)(`select`,{value:``,onChange:e=>h(e.target.value||null),children:[(0,U.jsx)(`option`,{value:``,children:`Choose a Team template…`}),_.map(e=>(0,U.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.slots.length,` member`,e.slots.length===1?``:`s`,`)`]},e.id))]})]})]}):(0,U.jsx)(wn,{children:g.map(e=>{let t=u.stateOf(e.id),n=e.id===s?.agent.id;return(0,U.jsxs)(i,{to:`/`,search:{agent:e.id,panel:`team`},"aria-current":n?`true`:void 0,className:`flex min-h-12 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50 ${n?`bg-accent/40`:``}`,children:[(0,U.jsx)(Fe,{identity:e.identity,size:28}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-sm font-semibold`,children:e.name}),(0,U.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,U.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${y[t.kind]}`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t.text})]})]}),!n&&(0,U.jsx)(se,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]},e.id)})}),(0,U.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,U.jsx)(Cn,{children:`USER.md`}),(0,U.jsx)(i,{to:`/`,search:c({panel:`team`,section:`user-md`}),className:vn,children:`Edit`})]}),e.userMd.trim()?(0,U.jsx)(i,{to:`/`,search:c({panel:`team`,section:`user-md`}),className:`block rounded-2xl border border-border bg-muted/50 px-3 py-2.5 hover:border-sapphire-light`,children:(0,U.jsx)(`span`,{className:`line-clamp-5 whitespace-pre-wrap break-words font-mono text-xs leading-relaxed text-chocolate`,children:e.userMd.trim()})}):(0,U.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-3 py-3 text-sm text-muted-foreground`,children:`Empty. Tell this Team's Agents who you are and how you like to work; every member reads it on every turn.`}),(0,U.jsx)(bn,{team:e},`${e.id}:${l.section??``}`),(0,U.jsx)(Cn,{children:`Settings`}),(0,U.jsx)(wn,{children:(0,U.jsxs)(i,{to:`/`,search:c({panel:`team`,section:`settings`}),className:`flex min-h-11 items-center gap-2.5 px-3 py-2 text-foreground hover:bg-accent/50`,children:[(0,U.jsx)(Ce,{className:`size-4 shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block text-sm font-semibold`,children:`Workspace and templates`}),(0,U.jsx)(`span`,{className:`block truncate text-xs text-muted-foreground`,children:`Sandbox defaults, Telegram topic names, save as a template`})]}),(0,U.jsx)(se,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]})}),f&&(0,U.jsx)(Ue,{profiles:n,teams:a,teamId:e.id,onClose:()=>p(!1)}),v&&(0,U.jsx)(j,{template:v,teams:[e],initialTeamId:e.id,onClose:()=>h(null),onSpawned:()=>{h(null),d.invalidate()}})]})}function bn({team:e}){let{to:t}=k(),{turnsEnded:n}=z(),r=`/api/teams/${encodeURIComponent(e.id)}/memory`,[a,o]=(0,H.useState)(``),[s,l]=(0,H.useState)(``);(0,H.useEffect)(()=>{let e=setTimeout(()=>l(a.trim()),200);return()=>clearTimeout(e)},[a]);let u=M(async e=>{if(s)return{rows:(await c(`${r}/search?q=${encodeURIComponent(s)}&limit=8`,{signal:e})).map(e=>({key:e.key,preview:e.snippet})),total:null};let t=await c(r,{signal:e});return{rows:[...t].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,5).map(e=>({key:e.key,preview:e.content.slice(0,120)})),total:t.length}},[r,s,n]),d=u.data?.total;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(Cn,{children:[`Shared memory`,typeof d==`number`?` · ${d} note${d===1?``:`s`}`:``]}),(0,U.jsx)(i,{to:`/`,search:t({panel:`team`,section:`memory`,note:void 0}),className:vn,children:`Open`})]}),(0,U.jsx)(`input`,{type:`search`,"aria-label":`Search the Team's memory`,placeholder:`Search the notes`,autoComplete:`off`,value:a,onChange:e=>o(e.target.value),className:`mb-2 min-h-9 py-1.5 text-sm`}),u.error?(0,U.jsx)(`p`,{role:`alert`,className:`m-0 text-xs text-danger`,children:u.error}):u.data?u.data.rows.length===0?(0,U.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:s?`No note matches.`:`No notes yet. Agents write here what the whole Team should remember.`}):(0,U.jsx)(wn,{children:u.data.rows.map(e=>(0,U.jsxs)(i,{to:`/`,search:t({panel:`team`,section:`memory`,note:e.key}),className:`block px-3 py-2 hover:bg-accent/50`,children:[(0,U.jsx)(`span`,{className:`block truncate font-mono text-xs font-medium text-foreground`,children:e.key}),e.preview&&(0,U.jsx)(`span`,{className:`mt-0.5 line-clamp-2 break-words text-xs leading-snug text-mocha`,children:e.preview})]},e.key))}):(0,U.jsx)(`p`,{role:`status`,className:`m-0 text-xs text-muted-foreground`,children:`Loading…`})]})}function xn({tab:e}){let{agent:t,team:n,to:r}=k(),a=Xt(n?.id),o={changes:a.changes,files:a.files};return(0,U.jsxs)(`aside`,{"aria-label":`About the work`,className:`flex h-full flex-col overflow-hidden rounded-[16px] border border-border bg-card shadow-baziu-sm`,children:[(0,U.jsxs)(`div`,{role:`tablist`,"aria-label":`Side panel`,className:`flex flex-wrap items-center gap-1 border-b border-border bg-muted/60 p-2`,children:[Le.map(t=>{let n=t===e,a=o[t];return(0,U.jsxs)(i,{to:`/`,search:r({panel:t,section:void 0}),role:`tab`,"aria-selected":n,className:`inline-flex h-8 items-center gap-1.5 rounded-[10px] border px-2 text-[0.8rem] font-semibold ${n?`border-border bg-card text-foreground shadow-baziu-sm`:`border-transparent text-mocha hover:bg-card/70 hover:text-foreground`}`,children:[Ee[t],typeof a==`number`&&a>0&&(0,U.jsx)(`span`,{className:`rounded-full bg-frost px-1.5 font-mono text-[0.7rem] font-medium text-chocolate`,children:a})]},t)}),(0,U.jsx)(i,{to:`/`,search:r({panel:`none`,section:void 0}),"aria-label":`Close the side panel`,className:`ml-auto flex size-8 items-center justify-center rounded-[10px] text-mocha hover:bg-card hover:text-foreground xl:hidden`,children:(0,U.jsx)(ce,{className:`size-4`,"aria-hidden":`true`})})]}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 pb-5 pt-3.5`,children:e===`agent`?t?(0,U.jsx)(en,{agent:t},t.agent.id):(0,U.jsx)(Sn,{children:`Open an Agent's conversation to see its settings here.`}):n?e===`team`?(0,U.jsx)(yn,{team:n},n.id):e===`connections`?(0,U.jsx)(nn,{team:n},n.id):e===`changes`?(0,U.jsx)(Tn,{team:n},n.id):(0,U.jsx)(_n,{team:n},n.id):(0,U.jsx)(Sn,{children:`Pick an Agent or a Team on the left.`})})]})}function Sn({children:e}){return(0,U.jsx)(`p`,{className:`m-0 py-10 text-center text-sm text-muted-foreground`,children:e})}function Cn({children:e}){return(0,U.jsx)(`h2`,{className:`m-0 mb-1.5 mt-5 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground first:mt-0`,children:e})}function wn({children:e}){return(0,U.jsx)(`div`,{className:`divide-y divide-frost/70 overflow-hidden rounded-2xl border border-border`,children:e})}function Tn({team:e}){let{search:t,to:n}=k(),a=r(),o=Lt(e.id),s=zt(e.id,o.base),c=s.data?.review?.changes??null,l=s.data?.review?.authors??{},u=c?.changes.find(e=>e.path===t.file)?.path??null,d=Bt(e.id,o.base,u,s.data),f=e=>void a.navigate({to:`/`,search:n({file:e}),replace:!0});return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(vt,{changes:c,base:o.base,loading:s.loading,onBase:o.setBase,onRefresh:()=>void s.reload()}),s.error&&(0,U.jsx)(`p`,{role:`alert`,className:`err mt-3`,children:s.error}),s.data?.unavailable&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 mt-3 rounded-2xl border border-border bg-muted/50 px-3 py-3 text-sm`,children:gt(s.data.unavailable.code,s.data.unavailable.message)}),!s.data&&!s.error&&(0,U.jsx)(`p`,{role:`status`,className:`m-0 mt-3 text-sm text-muted-foreground`,children:`Loading the changes…`}),c&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-2`,children:[(0,U.jsxs)(Cn,{children:[c.changes.length,` changed file`,c.changes.length===1?``:`s`]}),c.changes.length>0&&(0,U.jsxs)(i,{to:`/`,search:n({view:`changes`,file:u??c.changes[0]?.path}),className:`inline-flex h-7 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,U.jsx)(V,{className:`size-3.5`,"aria-hidden":`true`}),`Side by side`]})]}),(0,U.jsx)(Kt,{changes:c,authors:l,comments:o.comments,selected:u,onSelect:e=>f(e===u?void 0:e)})]}),u&&(0,U.jsxs)(`section`,{"aria-label":`Diff of ${u}`,className:`mt-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h3`,{className:`m-0 min-w-0 flex-1 truncate font-mono text-xs font-medium text-foreground`,title:u,children:Wt(u).name}),(0,U.jsx)(En,{onAdd:e=>o.addComment({path:u,note:e})})]}),(0,U.jsx)(`div`,{className:`mt-2 max-h-[55vh] overflow-auto rounded-2xl border border-border bg-card`,children:d.error?(0,U.jsx)(`p`,{role:`alert`,className:`m-0 p-3 text-sm text-danger`,children:d.error}):d.data?d.data.patch===null?(0,U.jsxs)(`p`,{className:`m-0 p-3 text-sm text-muted-foreground`,children:[`No diff text for this file`,d.data.omitted?` (${d.data.omitted.replaceAll(`_`,` `)})`:``,`.`]}):(0,U.jsx)(Mt,{patch:d.data.patch,comments:o.comments.filter(e=>e.path===u),onAddComment:(e,t)=>o.addComment({path:u,line:e,note:t}),onRemoveComment:o.removeComment}):(0,U.jsx)(`p`,{role:`status`,className:`m-0 p-3 text-sm text-muted-foreground`,children:`Loading the diff…`})}),d.data?.truncated&&(0,U.jsx)(`p`,{className:`m-0 mt-1.5 text-xs text-warning`,children:`This diff was cut: the file changed more.`})]}),c&&c.changes.length>0&&(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(Yt,{teamId:e.id,session:o,authors:l,onOpenFile:e=>f(e)})})]})}function En({onAdd:e}){let[t,n]=(0,H.useState)(!1),[r,i]=(0,H.useState)(``);if(!t)return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(!0),className:`unstyled inline-flex h-7 shrink-0 items-center gap-1 rounded-[10px] border border-border bg-card px-2 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:[(0,U.jsx)(ot,{className:`size-3.5`,"aria-hidden":`true`}),`Comment on the file`]});let a=()=>{e(r.trim()),i(``),n(!1)};return(0,U.jsxs)(`div`,{className:`basis-full rounded-[10px] border border-primary/30 bg-accent/40 p-2.5`,children:[(0,U.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Comment on the file`,placeholder:`What should change in this file? (optional: the Agent gets the diff either way)`,rows:2,maxLength:2e3,value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Escape`&&n(!1),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&a()},className:`min-h-16 text-sm`}),(0,U.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`primary`,className:`min-h-8 px-3 py-1 text-xs`,onClick:a,children:`Add to the review`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:()=>n(!1),children:`Cancel`})]})]})}var Dn=`bz_diff_layout`;function On({team:e}){let{search:t,to:n,agentById:a}=k(),o=r(),s=S(),c=Lt(e.id),l=zt(e.id,c.base),u=l.data?.review?.changes??null,d=l.data?.review?.authors??{},f=u?.changes.find(e=>e.path===t.file)??u?.changes[0]??null,p=f?.path??null,m=Bt(e.id,c.base,p,l.data),h=p?d[p]:void 0,[_,v]=(0,H.useState)(`split`);(0,H.useEffect)(()=>{try{window.localStorage.getItem(Dn)===`unified`&&v(`unified`)}catch{}},[]);let y=e=>{v(e);try{window.localStorage.setItem(Dn,e)}catch{}},x=e=>void o.navigate({to:`/`,search:n({file:e}),replace:!0}),w=g(`(min-width: 768px)`),T=_===`split`&&w?Nt:Mt;return(0,U.jsx)(b,{view:`changes`,actions:w&&(0,U.jsx)(C,{label:`Diff layout`,value:_,options:[{id:`split`,label:`Side by side`},{id:`unified`,label:`One column`}],onChange:y}),children:(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 lg:grid-cols-[21rem_minmax(0,1fr)]`,children:[(0,U.jsxs)(`div`,{className:`min-h-0 space-y-3 overflow-y-auto border-border p-3 max-lg:max-h-[42vh] max-lg:border-b lg:border-r`,children:[(0,U.jsx)(vt,{changes:u,base:c.base,loading:l.loading,onBase:c.setBase,onRefresh:()=>void l.reload()}),l.error&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:l.error}),l.data?.unavailable&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 rounded-2xl border border-border bg-muted/50 px-3 py-3 text-sm`,children:gt(l.data.unavailable.code,l.data.unavailable.message)}),!l.data&&!l.error&&(0,U.jsx)(`p`,{role:`status`,className:`m-0 text-sm text-muted-foreground`,children:`Loading the changes…`}),u&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Kt,{changes:u,authors:d,comments:c.comments,selected:p,onSelect:x}),u.changes.length>0&&(0,U.jsx)(Yt,{teamId:e.id,session:c,authors:d,onOpenFile:x})]})]}),(0,U.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col`,children:f&&p?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border px-3 py-2`,children:[(0,U.jsx)(Ut,{status:f.status}),(0,U.jsxs)(`h2`,{className:`m-0 min-w-0 flex-1 basis-48 break-all font-mono text-[0.82rem] font-medium leading-snug text-foreground`,children:[f.previousPath?`${f.previousPath} → `:``,f.path]}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:ht(f)}),h&&(0,U.jsxs)(i,{to:`/`,search:{agent:h.agentId,conversation:h.conversationId,panel:`changes`,file:p},title:`Open the conversation this was written in`,className:`inline-flex h-7 shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,children:[(0,U.jsx)(Fe,{identity:a(h.agentId)?.identity,size:16}),h.agentName,s&&(0,U.jsx)(`span`,{className:`font-normal text-muted-foreground`,children:fe(h.at)})]}),(0,U.jsx)(En,{onAdd:e=>c.addComment({path:p,note:e})})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[m.error?(0,U.jsx)(`p`,{role:`alert`,className:`m-0 p-4 text-sm text-danger`,children:m.error}):m.data?m.data.patch===null?(0,U.jsxs)(`p`,{className:`m-0 p-4 text-sm text-muted-foreground`,children:[`No diff text for this file`,m.data.omitted?` (${m.data.omitted.replaceAll(`_`,` `)})`:``,`. A comment on the file still reaches the Agent.`]}):(0,U.jsx)(T,{patch:m.data.patch,comments:c.comments.filter(e=>e.path===p),onAddComment:(e,t)=>c.addComment({path:p,line:e,note:t}),onRemoveComment:c.removeComment}):(0,U.jsx)(`p`,{role:`status`,className:`m-0 p-4 text-sm text-muted-foreground`,children:`Loading the diff…`}),m.data?.truncated&&(0,U.jsx)(`p`,{className:`m-0 border-t border-border px-4 py-2 text-xs text-warning`,children:`This diff was cut: the file changed more than a review shows.`})]})]}):(0,U.jsx)(`div`,{className:`flex min-h-40 flex-1 items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:u?`Nothing changed since this base.`:l.data?.unavailable?`There is nothing to compare.`:``})})]})})}function kn({agentId:e,agentName:t,refreshKey:n}){let[r,i]=(0,H.useState)([]);return(0,H.useEffect)(()=>{let t=new AbortController;return c(`/api/agents/${encodeURIComponent(e)}/questions`,{signal:t.signal}).then(e=>i(e.questions)).catch(()=>{}),()=>t.abort()},[e,n]),r.length?(0,U.jsx)(`section`,{"aria-label":`Agent questions`,className:`max-h-[45vh] min-w-0 shrink-0 space-y-3 overflow-y-auto border-t border-frost px-5 py-3`,children:r.map(e=>(0,U.jsx)(An,{item:e,agentName:t},e.id))}):null}function An({item:e,agentName:t}){let n=Ae(),r=S(),[i,a]=(0,H.useState)(``),[l,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(``);async function g(t,r){d(!0),h(``);try{await c(`/api/agents/${encodeURIComponent(e.agentId)}/questions/${encodeURIComponent(e.id)}/answer`,{body:{answer:t}}),p(r),n?.refresh()}catch(e){h(e instanceof u&&e.status===404?`This question is no longer open.`:s(e))}finally{d(!1)}}return f===null?(0,U.jsxs)(`article`,{className:`min-w-0 rounded-2xl border border-warning/35 bg-warning/[0.07] px-4 py-3.5`,children:[(0,U.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-[0.72rem] font-bold uppercase tracking-[0.08em] text-warning`,children:[(0,U.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full bg-warning`,"aria-hidden":`true`}),t,` is waiting for you`]}),(0,U.jsx)(`p`,{className:`m-0 mt-1.5 break-words text-[0.95rem] font-semibold text-charcoal`,children:e.question.prompt}),(0,U.jsxs)(`fieldset`,{disabled:l,className:`m-0 mt-3 min-w-0 border-0 p-0`,children:[(0,U.jsx)(`legend`,{className:`sr-only`,children:`Answer this question`}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.question.choices.map((t,n)=>{let r=e.question.recommendedIndex===n;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void g({kind:`choice`,index:n},t.label),className:`unstyled min-h-[3.25rem] min-w-0 flex-1 basis-56 rounded-[10px] bg-card px-3 py-2 text-left transition-colors hover:bg-accent/60 disabled:opacity-60 ${r?`border-[1.5px] border-primary`:`border border-border`}`,children:[(0,U.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-bold ${r?`text-accent-foreground`:`text-foreground`}`,children:[(0,U.jsx)(`span`,{className:`min-w-0 break-words [overflow-wrap:anywhere]`,children:t.label}),r&&(0,U.jsx)(`span`,{className:`rounded-full bg-accent px-1.5 text-[0.7rem] font-semibold`,children:`Suggested`})]}),t.description&&(0,U.jsx)(`span`,{className:`mt-0.5 block break-words text-[0.8rem] text-mocha`,children:t.description})]},t.label)})}),(0,U.jsxs)(`form`,{className:`mt-2.5 flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),i.trim()&&g({kind:`text`,text:i},i.trim())},children:[(0,U.jsx)(`input`,{"aria-label":`Answer in your own words`,placeholder:`Or answer in your own words`,value:i,maxLength:4096,onChange:e=>a(e.target.value),className:`min-h-10 min-w-0 flex-1 basis-48 text-sm`}),i.trim()&&(0,U.jsx)(o,{variant:`primary`,type:`submit`,className:`min-h-10`,children:`Send answer`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-10`,onClick:()=>void g({kind:`skip`},`Skipped`),children:`Skip`})]})]}),(0,U.jsxs)(`p`,{className:`m-0 mt-2 text-xs text-mocha`,children:[r?`Waiting until ${new Date(e.expiresAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}. `:``,`An answer is information only; it grants no permission.`]}),m&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 mt-2 text-sm text-danger`,children:m})]}):(0,U.jsxs)(`p`,{role:`status`,className:`m-0 flex flex-wrap items-center gap-2 rounded-[10px] border border-border bg-muted px-3 py-2 text-sm`,children:[(0,U.jsx)(`span`,{className:`text-mocha`,children:e.question.prompt}),(0,U.jsx)(`span`,{className:`font-semibold text-foreground`,children:f})]})}function jn(e,t){return{message:e,attachments:t,bashApprovalMode:`interactive`,questionMode:`web`}}function Mn(e){return`/api/shell-approvals?agentId=${encodeURIComponent(e)}`}var Nn=e=>e.startsWith(`image/`);function Pn(e){let t=[],n=null,r=()=>(n||(n={type:`tool`,items:[]},t.push(n)),n);for(let i of e)if(i.role===`user`)n=null,t.push({type:`user`,content:i.content,...i.images?.length?{images:i.images}:{}});else if(i.role===`assistant`){i.content&&(n=null,t.push({type:`assistant`,content:i.content}));for(let e of i.toolCalls??[])r().items.push({kind:`call`,id:e.id,name:e.name,body:e.arguments})}else if(i.role===`tool`){r().items.push({kind:/^error:/i.test(i.content)?`error`:`result`,id:i.toolCallId??``,name:i.toolName??``,body:i.content});for(let e of i.results??[])t.push({type:`result`,resultId:e.resultId}),n=null;i.images?.length&&(t.push({type:`images`,images:i.images}),n=null)}return t}function Fn(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.id);if(r.kind===`call`){let e={id:r.id,name:r.name,args:r.body,status:`running`,output:``};t.push(e),n.set(r.id,e)}else e?(r.kind===`progress`||(e.status=r.kind===`error`?`failed`:`done`),e.output=r.body):r.kind!==`progress`&&t.push({id:r.id,name:r.name,args:``,status:r.kind===`error`?`failed`:`done`,output:r.body})}return t}function In(e){let t=[],n=null;return e.forEach((e,r)=>{if(e.type===`tool`||e.type===`result`){n||(n={type:`work`,index:r,items:[],resultIds:[]},t.push(n)),e.type===`tool`?n.items.push(...e.items):n.resultIds.push(e.resultId);return}n=null,t.push({type:`entry`,index:r,entry:e})}),t}function Ln(e,t){let n=e.findIndex(e=>e.type===`command_approval`&&e.approval.id===t.id);if(n===-1)return[...e,{type:`command_approval`,approval:t}];let r=[...e];return r[n]={type:`command_approval`,approval:t},r}function Rn(e,t){let n={kind:`progress`,id:t.id,name:t.name,body:t.output};for(let r=e.length-1;r>=0;r--){let i=e[r];if(i?.type!==`tool`)continue;let a=i.items.findIndex(e=>e.id===t.id);if(a<0)continue;let o=[...i.items],s=o.findIndex(e=>e.kind===`progress`&&e.id===t.id);s>=0?o[s]=n:o.splice(a+1,0,n);let c=[...e];return c[r]={type:`tool`,items:o},c}return zn(e,n)}function zn(e,t){let n=e[e.length-1];return n?.type===`tool`?[...e.slice(0,-1),{type:`tool`,items:[...n.items,t]}]:[...e,{type:`tool`,items:[t]}]}function Bn(e,t){let n=e[e.length-1];return n?.type===`assistant`?[...e.slice(0,-1),{type:`assistant`,content:t(n.content)}]:[...e,{type:`assistant`,content:t(``)}]}function Vn(e,t){switch(t.type){case`assistant_delta`:return Bn(e,e=>e+t.delta);case`assistant_message`:return Bn(e,()=>t.text);case`command_approval`:return Ln(e,t.approval);case`tool_progress`:return Rn(e,t);case`tool_call`:return zn(e,{kind:`call`,id:t.id,name:t.name,body:t.arguments});case`tool_result`:case`tool_error`:{let n=zn(e.map(e=>e.type===`tool`?{...e,items:e.items.filter(e=>!(e.kind===`progress`&&e.id===t.id))}:e),t.type===`tool_result`?{kind:`result`,id:t.id,name:t.name,body:t.result}:{kind:`error`,id:t.id,name:t.name,body:t.error});return t.type===`tool_result`&&t.images?.length?[...n,{type:`images`,images:t.images}]:n}case`file`:return[...e,{type:`result`,resultId:t.result.resultId}];case`error`:return[...e,{type:`error`,content:`[error] ${t.error}`}];default:return e}}function Hn(e){return e.map(e=>e.type===`command_approval`&&e.approval.status===`pending`?{type:`command_approval`,approval:{...e.approval,status:`cancelled`}}:e)}async function*Un(e){let t=e.getReader(),n=new TextDecoder,r=``;for(;;){let{done:e,value:i}=await t.read();r+=e?n.decode():n.decode(i,{stream:!0});let a=r.split(`
|
|
4
|
+
`);r=e?``:a.pop()??``;for(let e of a)if(e.trim())try{yield JSON.parse(e)}catch{}if(e)return}}var Wn=200;function Gn(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let n=String(r.result);t({name:e.name,data:n.slice(n.indexOf(`,`)+1),mimeType:e.type||`application/octet-stream`})},r.onerror=()=>n(r.error),r.readAsDataURL(e)})}function Kn(e){return Promise.all(Array.from(e).map(Gn))}function qn({agentName:e,value:t,onChange:n,onSubmit:r,attachments:i,onAddFiles:a,onRemoveAttachment:s,editing:c,onCancelEdit:l,agentBusy:u,onStop:d,inputRef:f}){let p=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{let e=f.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,Wn)}px`)},[t]),(0,U.jsxs)(U.Fragment,{children:[c&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-frost bg-sapphire-glow px-5 py-2 text-[0.85em] text-sapphire-deep`,children:[(0,U.jsx)(`span`,{children:`editing last message — submit to replace, or`}),(0,U.jsx)(`button`,{type:`button`,onClick:l,className:`ml-auto rounded-sm border border-sapphire-light bg-transparent px-2 py-0.5 text-[0.92em] text-sapphire-deep hover:bg-snow`,children:`cancel`})]}),i.length>0&&(0,U.jsx)(`div`,{className:`flex max-h-24 shrink-0 flex-wrap gap-2 overflow-y-auto border-t border-frost bg-ivory px-5 pt-3`,children:i.map((e,t)=>Nn(e.mimeType)?(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`pending attachment`,className:`h-16 w-16 rounded-md border border-frost object-cover`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-full border border-frost bg-snow text-[0.7em] text-mocha hover:border-sapphire hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},t):(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md border border-frost bg-snow px-2 py-1 text-[0.82em] text-mocha`,children:[(0,U.jsx)(et,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-[160px] truncate`,children:e.name??`file`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(t),className:`text-[0.85em] text-mocha hover:text-sapphire`,"aria-label":`remove attachment`,children:`✕`})]},t))}),(0,U.jsxs)(`form`,{className:`grid shrink-0 grid-cols-[auto_minmax(0,1fr)] items-end gap-2 border-t border-frost bg-ivory px-3 py-3 sm:grid-cols-[auto_minmax(0,1fr)_auto] sm:px-5`,onSubmit:e=>{e.preventDefault(),r()},children:[(0,U.jsx)(`input`,{ref:p,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{e.target.files&&a(e.target.files),e.target.value=``}}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>p.current?.click(),title:`attach images or files`,"aria-label":`attach files`,className:`flex h-11 items-center justify-center rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[1em] text-mocha transition-colors hover:border-sapphire hover:text-sapphire`,children:(0,U.jsx)(st,{className:`size-[18px]`,"aria-hidden":`true`})}),(0,U.jsx)(`textarea`,{ref:f,rows:1,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),r())},onPaste:e=>{let t=Array.from(e.clipboardData.files);t.some(e=>Nn(e.type))&&(e.preventDefault(),a(t))},placeholder:`Message ${e}`,title:`Shift+Enter for a new line. Paste or attach files with the paperclip.`,autoComplete:`off`,"aria-label":`Message ${e}`,className:`max-h-[200px] min-h-11 min-w-0 flex-1 resize-none overflow-y-auto rounded-md border-[1.5px] border-frost bg-snow px-3 py-2 text-[0.93em] leading-[1.45] text-chocolate outline-none transition-colors focus:border-sapphire focus:shadow-[0_0_0_3px_var(--color-sapphire-glow)]`}),(0,U.jsxs)(`div`,{className:`col-span-2 flex flex-wrap justify-end gap-2 sm:col-span-1`,children:[(0,U.jsx)(o,{variant:`primary`,type:`submit`,className:`min-h-11 whitespace-normal text-center`,disabled:!t.trim()&&i.length===0,children:u?`Queue follow-up`:`Send`}),u&&(0,U.jsx)(o,{variant:`danger`,className:`min-h-11`,onClick:d,"aria-label":`Stop response`,children:`Stop`})]}),(0,U.jsx)(`p`,{className:`col-span-full m-0 hidden text-[0.72rem] text-mocha-light sm:block`,children:`Enter sends · Shift+Enter adds a line · /help lists commands`})]})]})}function Jn({agentId:e,queue:t,onChanged:n,onViewConversation:r}){let[i,a]=(0,H.useState)(null),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(``);if(!t||t.items.length===0&&!t.paused)return null;let p=`/api/agents/${encodeURIComponent(e)}/queue`;async function m(e,t){u(!0),f(``);try{await c(`${p}${e}`,t),a(null)}catch(e){f(s(e))}finally{u(!1),n()}}let h=t.items.some(e=>e.status===`pending`);return(0,U.jsxs)(`section`,{"aria-label":`Follow-up queue`,className:`max-h-[35%] min-w-0 shrink-0 space-y-3 overflow-y-auto border-t border-frost px-5 py-3 text-sm`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,U.jsxs)(`strong`,{children:[`Follow-ups`,t.paused?` · paused`:``]}),(t.paused||h)&&(0,U.jsx)(o,{variant:`ghost`,disabled:l,onClick:()=>void m(`/control`,{body:{paused:!t.paused}}),children:t.paused?`Resume queue`:`Pause queue`})]}),d&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 break-words text-danger`,children:d}),t.items.map(e=>(0,U.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-frost bg-ivory p-3`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`strong`,{className:`rounded-full bg-frost px-2 py-0.5 text-xs capitalize`,children:e.status}),(0,U.jsx)(`span`,{className:`text-xs text-mocha`,children:e.source===`telegram`?`Telegram`:`Web / API`}),(0,U.jsx)(o,{variant:`ghost`,className:`ml-auto`,onClick:()=>r(e.conversationId),children:`View conversation`})]}),i?.id===e.id?(0,U.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-2`,onSubmit:t=>{t.preventDefault(),m(`/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:{message:i.text}})},children:[(0,U.jsx)(`textarea`,{"aria-label":`Edit follow-up`,rows:3,className:`w-full resize-y`,value:i.text,onChange:t=>a({id:e.id,text:t.target.value})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:l,children:`Save`}),(0,U.jsx)(o,{variant:`ghost`,onClick:()=>a(null),children:`Cancel`})]})]}):(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:e.text}),e.attachments.map((e,t)=>(0,U.jsxs)(`p`,{className:`m-0 break-all text-xs text-mocha`,children:[e.name??`Attachment`,` · `,e.byteLength,` bytes`]},t)),e.diagnostic&&(0,U.jsx)(`p`,{className:`m-0 break-words`,children:e.diagnostic}),e.status!==`running`&&i?.id!==e.id&&(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.status===`pending`&&(0,U.jsx)(o,{variant:`ghost`,disabled:l,onClick:()=>a({id:e.id,text:e.text}),children:`Edit`}),(0,U.jsx)(o,{variant:`danger`,disabled:l,onClick:()=>void m(`/${encodeURIComponent(e.id)}`,{method:`DELETE`}),children:`Remove`})]})]},e.id))]})}function Yn(e){let t=e.split(`
|
|
5
|
+
`).find(e=>e.startsWith(`--- from `));if(!t)return`Teammate update received`;let n=/^--- from (.+?) \(message [0-9a-f-]+(?:, reply to [0-9a-f-]+)?\) ---$/.exec(t);if(!n)return`Teammate update received`;let r=n[1]?.replace(/ \([0-9a-f-]{36}\)$/,``).trim();return!r||/^[0-9a-f-]{36}$/.test(r)?`Teammate update received`:`Update from ${r.slice(0,100)}`}function Xn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Zn(e){if(Array.isArray(e))return e}function Qn(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function $n(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
6
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function er(e,t){return Zn(e)||Qn(e,t)||tr(e,t)||$n()}function tr(e,t){if(e){if(typeof e==`string`)return Xn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Xn(e,t):void 0}}var nr=Object.entries,rr=Object.setPrototypeOf,ir=Object.isFrozen,ar=Object.getPrototypeOf,or=Object.getOwnPropertyDescriptor,W=Object.freeze,G=Object.seal,sr=Object.create,cr=typeof Reflect<`u`&&Reflect,lr=cr.apply,ur=cr.construct;W||=function(e){return e},G||=function(e){return e},lr||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ur||=function(e){return new e(...[...arguments].slice(1))};var dr=J(Array.prototype.forEach),fr=J(Array.prototype.lastIndexOf),pr=J(Array.prototype.pop),mr=J(Array.prototype.push),hr=J(Array.prototype.splice),gr=Array.isArray,_r=J(String.prototype.toLowerCase),vr=J(String.prototype.toString),yr=J(String.prototype.match),br=J(String.prototype.replace),xr=J(String.prototype.indexOf),Sr=J(String.prototype.trim),Cr=J(Number.prototype.toString),wr=J(Boolean.prototype.toString),Tr=typeof BigInt>`u`?null:J(BigInt.prototype.toString),Er=typeof Symbol>`u`?null:J(Symbol.prototype.toString),K=J(Object.prototype.hasOwnProperty),Dr=J(Object.prototype.toString),q=J(RegExp.prototype.test),Or=kr(TypeError);function J(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return lr(e,t,n)}}function kr(e){return function(){return ur(e,[...arguments])}}function Y(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_r;if(rr&&rr(e,null),!gr(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ir(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ar(e){for(let t=0;t<e.length;t++)K(e,t)||(e[t]=null);return e}function X(e){let t=sr(null);for(let r of nr(e)){var n=er(r,2);let i=n[0],a=n[1];K(e,i)&&(gr(a)?t[i]=Ar(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=X(a):t[i]=a)}return t}function jr(e){switch(typeof e){case`string`:return e;case`number`:return Cr(e);case`boolean`:return wr(e);case`bigint`:return Tr?Tr(e):`0`;case`symbol`:return Er?Er(e):`Symbol()`;case`undefined`:return Dr(e);case`function`:case`object`:{if(e===null)return Dr(e);let t=e,n=Mr(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Dr(e)}return Dr(e)}default:return Dr(e)}}function Mr(e,t){for(;e!==null;){let n=or(e,t);if(n){if(n.get)return J(n.get);if(typeof n.value==`function`)return J(n.value)}e=ar(e)}function n(){return null}return n}function Nr(e){try{return q(e,``),!0}catch{return!1}}var Pr=W(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Fr=W(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ir=W([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Lr=W([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Rr=W(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),zr=W([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Br=W([`#text`]),Vr=W(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Hr=W(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Ur=W(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Wr=W([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Gr=G(/{{[\w\W]*|^[\w\W]*}}/g),Kr=G(/<%[\w\W]*|^[\w\W]*%>/g),qr=G(/\${[\w\W]*/g),Jr=G(/^data-[\-\w.\u00B7-\uFFFF]+$/),Yr=G(/^aria-[\-\w]+$/),Xr=G(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Zr=G(/^(?:\w+script|data):/i),Qr=G(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),$r=G(/^html$/i),ei=G(/^[a-z][.\w]*(-[.\w]+)+$/i),ti=G(/<[/\w!]/g),ni=G(/<[/\w]/g),ri=G(/<\/no(script|embed|frames)/i),ii=G(/\/>/i),ai={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},oi=function(){return typeof window>`u`?null:window},si=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},ci=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},li=function(e,t,n,r){return K(e,t)&&gr(e[t])?Y(r.base?X(r.base):{},e[t],r.transform):n};function ui(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:oi(),t=e=>ui(e);if(t.version=`3.4.11`,t.removed=[],!e||!e.document||e.document.nodeType!==ai.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Mr(d,`cloneNode`),p=Mr(d,`remove`),m=Mr(d,`nextSibling`),h=Mr(d,`childNodes`),g=Mr(d,`parentNode`),_=Mr(d,`shadowRoot`),v=Mr(d,`attributes`),y=o&&o.prototype?Mr(o.prototype,`nodeType`):null,b=o&&o.prototype?Mr(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,w=!1,T=0,E=function(){if(T>0)throw Or(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},D=function(e){E(),T++;try{return x.createHTML(e)}finally{T--}},O=function(e){E(),T++;try{return x.createScriptURL(e)}finally{T--}},k=function(){return w||=(C=si(u,i),!0),C},A=n,ee=A.implementation,te=A.createNodeIterator,j=A.createDocumentFragment,M=A.getElementsByTagName,ne=r.importNode,N=ci();t.isSupported=typeof nr==`function`&&typeof g==`function`&&ee&&ee.createHTMLDocument!==void 0;let re=Gr,P=Kr,ie=qr,ae=Jr,oe=Yr,se=Zr,ce=Qr,le=ei,ue=Xr,F=null,I=Y({},[...Pr,...Fr,...Ir,...Rr,...Br]),L=null,de=Y({},[...Vr,...Hr,...Ur,...Wr]),R=Object.seal(sr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),fe=null,pe=null,me=Object.seal(sr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),he=!0,ge=!0,_e=!1,z=!0,ve=!1,ye=!0,be=!1,xe=!1,Se=null,Ce=null,we=!1,Te=!1,Ee=!1,De=!1,Oe=!0,ke=!1,Ae=`user-content-`,je=!0,Me=!1,Ne={},B=null,Pe=Y({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Fe=null,Ie=Y({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Le=null,Re=Y({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),ze=`http://www.w3.org/1998/Math/MathML`,Be=`http://www.w3.org/2000/svg`,Ve=`http://www.w3.org/1999/xhtml`,He=Ve,Ue=!1,We=null,Ge=Y({},[ze,Be,Ve],vr),Ke=W([`mi`,`mo`,`mn`,`ms`,`mtext`]),qe=Y({},Ke),Je=W([`annotation-xml`]),Ye=Y({},Je),Xe=Y({},[`title`,`style`,`font`,`a`,`script`]),Ze=null,Qe=[`application/xhtml+xml`,`text/html`],V=null,$e=null,et=n.createElement(`form`),tt=function(e){return e instanceof RegExp||e instanceof Function},nt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if($e&&$e===e)return;(!e||typeof e!=`object`)&&(e={}),e=X(e),Ze=Qe.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,V=Ze===`application/xhtml+xml`?vr:_r,F=li(e,`ALLOWED_TAGS`,I,{transform:V}),L=li(e,`ALLOWED_ATTR`,de,{transform:V}),We=li(e,`ALLOWED_NAMESPACES`,Ge,{transform:vr}),Le=li(e,`ADD_URI_SAFE_ATTR`,Re,{transform:V,base:Re}),Fe=li(e,`ADD_DATA_URI_TAGS`,Ie,{transform:V,base:Ie}),B=li(e,`FORBID_CONTENTS`,Pe,{transform:V}),fe=li(e,`FORBID_TAGS`,X({}),{transform:V}),pe=li(e,`FORBID_ATTR`,X({}),{transform:V}),Ne=K(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?X(e.USE_PROFILES):e.USE_PROFILES:!1,he=e.ALLOW_ARIA_ATTR!==!1,ge=e.ALLOW_DATA_ATTR!==!1,_e=e.ALLOW_UNKNOWN_PROTOCOLS||!1,z=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ve=e.SAFE_FOR_TEMPLATES||!1,ye=e.SAFE_FOR_XML!==!1,be=e.WHOLE_DOCUMENT||!1,Te=e.RETURN_DOM||!1,Ee=e.RETURN_DOM_FRAGMENT||!1,De=e.RETURN_TRUSTED_TYPE||!1,we=e.FORCE_BODY||!1,Oe=e.SANITIZE_DOM!==!1,ke=e.SANITIZE_NAMED_PROPS||!1,je=e.KEEP_CONTENT!==!1,Me=e.IN_PLACE||!1,ue=Nr(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Xr,He=typeof e.NAMESPACE==`string`?e.NAMESPACE:Ve,qe=K(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?X(e.MATHML_TEXT_INTEGRATION_POINTS):Y({},Ke),Ye=K(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?X(e.HTML_INTEGRATION_POINTS):Y({},Je);let t=K(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?X(e.CUSTOM_ELEMENT_HANDLING):sr(null);if(R=sr(null),K(t,`tagNameCheck`)&&tt(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),K(t,`attributeNameCheck`)&&tt(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),K(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),G(R),ve&&(ge=!1),Ee&&(Te=!0),Ne&&(F=Y({},Br),L=sr(null),Ne.html===!0&&(Y(F,Pr),Y(L,Vr)),Ne.svg===!0&&(Y(F,Fr),Y(L,Hr),Y(L,Wr)),Ne.svgFilters===!0&&(Y(F,Ir),Y(L,Hr),Y(L,Wr)),Ne.mathMl===!0&&(Y(F,Rr),Y(L,Ur),Y(L,Wr))),me.tagCheck=null,me.attributeCheck=null,K(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?me.tagCheck=e.ADD_TAGS:gr(e.ADD_TAGS)&&(F===I&&(F=X(F)),Y(F,e.ADD_TAGS,V))),K(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?me.attributeCheck=e.ADD_ATTR:gr(e.ADD_ATTR)&&(L===de&&(L=X(L)),Y(L,e.ADD_ATTR,V))),K(e,`ADD_URI_SAFE_ATTR`)&&gr(e.ADD_URI_SAFE_ATTR)&&Y(Le,e.ADD_URI_SAFE_ATTR,V),K(e,`FORBID_CONTENTS`)&&gr(e.FORBID_CONTENTS)&&(B===Pe&&(B=X(B)),Y(B,e.FORBID_CONTENTS,V)),K(e,`ADD_FORBID_CONTENTS`)&&gr(e.ADD_FORBID_CONTENTS)&&(B===Pe&&(B=X(B)),Y(B,e.ADD_FORBID_CONTENTS,V)),je&&(F[`#text`]=!0),be&&Y(F,[`html`,`head`,`body`]),F.table&&(Y(F,[`tbody`]),delete fe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Or(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Or(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=D(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=k()),x&&typeof S==`string`&&(S=D(``)));W&&W(e),$e=e},rt=Y({},[...Fr,...Ir,...Lr]),it=Y({},[...Rr,...zr]),at=function(e,t,n){return t.namespaceURI===Ve?e===`svg`:t.namespaceURI===ze?e===`svg`&&(n===`annotation-xml`||qe[n]):!!rt[e]},ot=function(e,t,n){return t.namespaceURI===Ve?e===`math`:t.namespaceURI===Be?e===`math`&&Ye[n]:!!it[e]},st=function(e,t,n){return t.namespaceURI===Be&&!Ye[n]||t.namespaceURI===ze&&!qe[n]?!1:!it[e]&&(Xe[e]||!rt[e])},ct=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:He,tagName:`template`});let n=_r(e.tagName),r=_r(t.tagName);return We[e.namespaceURI]?e.namespaceURI===Be?at(n,t,r):e.namespaceURI===ze?ot(n,t,r):e.namespaceURI===Ve?st(n,t,r):!!(Ze===`application/xhtml+xml`&&We[e.namespaceURI]):!1},lt=function(e){mr(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Or(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},ut=function(e){let t=h(e);if(t){let e=[];dr(t,t=>{mr(e,t)}),dr(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},dt=function(e,n){try{mr(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{mr(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Te||Ee)try{lt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ft=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||L[V(i)]))try{e.removeAttribute(i)}catch{}}},pt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===ai.element&&ft(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},H=function(e){let t=null,r=null;if(we)e=`<remove></remove>`+e;else{let t=yr(e,/^[\r\n\t ]+/);r=t&&t[0]}Ze===`application/xhtml+xml`&&He===Ve&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?D(e):e;if(He===Ve)try{t=new l().parseFromString(i,Ze)}catch{}if(!t||!t.documentElement){t=ee.createDocument(He,`template`,null);try{t.documentElement.innerHTML=Ue?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),He===Ve?M.call(t,be?`html`:`body`)[0]:be?t.documentElement:a},mt=function(e){return te.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},ht=function(e){return e=br(e,re,` `),e=br(e,P,` `),e=br(e,ie,` `),e},gt=function(e){e.normalize();let t=te.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=ht(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&dr(r,e=>{_t(e.content)&>(e.content)})},U=function(e){let t=b?b(e):null;return typeof t!=`string`||V(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},_t=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===ai.documentFragment}catch{return!1}},vt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function yt(e,n,r){e.length!==0&&dr(e,e=>{e.call(t,n,r,$e)})}let bt=function(e,t){return!!(ye&&e.hasChildNodes()&&!vt(e.firstElementChild)&&q(ti,e.textContent)&&q(ti,e.innerHTML)||ye&&e.namespaceURI===Ve&&t===`style`&&vt(e.firstElementChild)||e.nodeType===ai.processingInstruction||ye&&e.nodeType===ai.comment&&q(ni,e.data))},xt=function(e,t){if(!fe[t]&&Tt(t)&&(R.tagNameCheck instanceof RegExp&&q(R.tagNameCheck,t)||R.tagNameCheck instanceof Function&&R.tagNameCheck(t)))return!1;if(je&&!B[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Me?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return lt(e),!0},St=function(e){if(yt(N.beforeSanitizeElements,e,null),U(e))return lt(e),!0;let n=V(b?b(e):e.nodeName);if(yt(N.uponSanitizeElement,e,{tagName:n,allowedTags:F}),bt(e,n))return lt(e),!0;if(fe[n]||!(me.tagCheck instanceof Function&&me.tagCheck(n))&&!F[n])return xt(e,n);if((y?y(e):e.nodeType)===ai.element&&!ct(e)||(n===`noscript`||n===`noembed`||n===`noframes`)&&q(ri,e.innerHTML))return lt(e),!0;if(ve&&e.nodeType===ai.text){let n=ht(e.textContent);e.textContent!==n&&(mr(t.removed,{element:e.cloneNode()}),e.textContent=n)}return yt(N.afterSanitizeElements,e,null),!1},Ct=function(e,t,r){if(pe[t]||Oe&&(t===`id`||t===`name`)&&(r in n||r in et))return!1;let i=L[t]||me.attributeCheck instanceof Function&&me.attributeCheck(t,e);if(!(ge&&q(ae,t))&&!(he&&q(oe,t))){if(!i){if(!(Tt(e)&&(R.tagNameCheck instanceof RegExp&&q(R.tagNameCheck,e)||R.tagNameCheck instanceof Function&&R.tagNameCheck(e))&&(R.attributeNameCheck instanceof RegExp&&q(R.attributeNameCheck,t)||R.attributeNameCheck instanceof Function&&R.attributeNameCheck(t,e))||t===`is`&&R.allowCustomizedBuiltInElements&&(R.tagNameCheck instanceof RegExp&&q(R.tagNameCheck,r)||R.tagNameCheck instanceof Function&&R.tagNameCheck(r))))return!1}else if(!Le[t]&&!q(ue,br(r,ce,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&xr(r,`data:`)===0&&Fe[e])&&!(_e&&!q(se,br(r,ce,``)))&&r)return!1}return!0},wt=Y({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Tt=function(e){return!wt[_r(e)]&&q(le,e)},Et=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return D(r);case`TrustedScriptURL`:return O(r)}return r},Dt=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),U(e)?lt(e):pr(t.removed)}catch{dt(n,e)}},Ot=function(e){yt(N.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||U(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:L,forceKeepAttr:void 0},r=t.length,i=V(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=V(o),u=c,d=o===`value`?u:Sr(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,yt(N.uponSanitizeAttribute,e,n),d=n.attrValue,ke&&(l===`id`||l===`name`)&&xr(d,Ae)!==0&&(dt(o,e),d=Ae+d),ye&&q(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){dt(o,e);continue}if(l===`attributename`&&yr(d,`href`)){dt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){dt(o,e);continue}if(!z&&q(ii,d)){dt(o,e);continue}if(ve&&(d=ht(d)),!Ct(i,l,d)){dt(o,e);continue}d=Et(i,l,s,d),d!==u&&Dt(e,o,s,d)}}yt(N.afterSanitizeAttributes,e,null)},kt=function(e){let t=null,n=mt(e);for(yt(N.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(yt(N.uponSanitizeShadowNode,t,null),St(t),Ot(t),_t(t.content)&&kt(t.content),(y?y(t):t.nodeType)===ai.element){let e=_(t);_t(e)&&(At(e),kt(e))}yt(N.afterSanitizeShadowDOM,e,null)},At=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){kt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===ai.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&V(e)===`template`){let e=n.content;_t(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);_t(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(Ue=!e,Ue&&(e=`<!-->`),typeof e!=`string`&&!vt(e)&&(e=jr(e),typeof e!=`string`))throw Or(`dirty is not a string, aborting`);if(!t.isSupported)return e;xe?(F=Se,L=Ce):nt(n),(N.uponSanitizeElement.length>0||N.uponSanitizeAttribute.length>0)&&(F=X(F)),N.uponSanitizeAttribute.length>0&&(L=X(L)),t.removed=[];let c=Me&&typeof e!=`string`&&vt(e);if(c){let t=b?b(e):e.nodeName;if(typeof t==`string`){let e=V(t);if(!F[e]||fe[e])throw Or(`root node is forbidden and cannot be sanitized in-place`)}if(U(e))throw Or(`root node is clobbered and cannot be sanitized in-place`);try{At(e)}catch(t){throw ut(e),t}}else if(vt(e))i=H(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===ai.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),At(a);else{if(!Te&&!ve&&!be&&e.indexOf(`<`)===-1)return x&&De?D(e):e;if(i=H(e),!i)return Te?null:De?S:``}i&&we&<(i.firstChild);let l=mt(c?e:i);try{for(;o=l.nextNode();)St(o),Ot(o),_t(o.content)&&kt(o.content)}catch(t){throw c&&ut(e),t}if(c)return dr(t.removed,e=>{e.element&&pt(e.element)}),ve&>(e),e;if(Te){if(ve&>(i),Ee)for(s=j.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(L.shadowroot||L.shadowrootmode)&&(s=ne.call(r,s,!0)),s}let u=be?i.outerHTML:i.innerHTML;return be&&F[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&q($r,i.ownerDocument.doctype.name)&&(u=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
7
|
+
`+u),ve&&(u=ht(u)),x&&De?D(u):u},t.setConfig=function(){nt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),xe=!0,Se=F,Ce=L},t.clearConfig=function(){$e=null,xe=!1,Se=null,Ce=null,x=C,S=``},t.isValidAttribute=function(e,t,n){return $e||nt({}),Ct(V(e),V(t),n)},t.addHook=function(e,t){typeof t==`function`&&K(N,e)&&mr(N[e],t)},t.removeHook=function(e,t){if(K(N,e)){if(t!==void 0){let n=fr(N[e],t);return n===-1?void 0:hr(N[e],n,1)[0]}return pr(N[e])}},t.removeHooks=function(e){K(N,e)&&(N[e]=[])},t.removeAllHooks=function(){N=ci()},t}var di=ui();function fi(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var pi=fi();function mi(e){pi=e}var hi={exec:()=>null};function gi(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function Z(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(Q.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var _i=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Q={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:gi(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:gi(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:gi(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:gi(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:gi(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:gi(e=>RegExp(`^ {0,${e}}>`))},vi=/^(?:[ \t]*(?:\n|$))+/,yi=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,bi=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,xi=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Si=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Ci=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,wi=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Ti=Z(wi).replace(/bull/g,Ci).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Ei=Z(wi).replace(/bull/g,Ci).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Di=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Oi=/^[^\n]+/,ki=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ai=Z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,ki).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),ji=Z(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Ci).getRegex(),Mi=`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|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Ni=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Pi=Z(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Ni).replace(`tag`,Mi).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Fi=Z(Di).replace(`hr`,xi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mi).getRegex(),Ii={blockquote:Z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Fi).getRegex(),code:yi,def:Ai,fences:bi,heading:Si,hr:xi,html:Pi,lheading:Ti,list:ji,newline:vi,paragraph:Fi,table:hi,text:Oi},Li=Z(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,xi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mi).getRegex(),Ri={...Ii,lheading:Ei,table:Li,paragraph:Z(Di).replace(`hr`,xi).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Li).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Mi).getRegex()},zi={...Ii,html:Z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Ni).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:hi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Z(Di).replace(`hr`,xi).replace(`heading`,` *#{1,6} *[^
|
|
8
|
+
]`).replace(`lheading`,Ti).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Bi=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Vi=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Hi=/^( {2,}|\\)\n(?!\s*$)/,Ui=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Wi=/[\p{P}\p{S}]/u,Gi=/[\s\p{P}\p{S}]/u,Ki=/[^\s\p{P}\p{S}]/u,qi=Z(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Gi).getRegex(),Ji=/(?!~)[\p{P}\p{S}]/u,Yi=/(?!~)[\s\p{P}\p{S}]/u,Xi=/(?:[^\s\p{P}\p{S}]|~)/u,Zi=Z(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,_i?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Qi=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,$i=Z(Qi,`u`).replace(/punct/g,Wi).getRegex(),ea=Z(Qi,`u`).replace(/punct/g,Ji).getRegex(),ta=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,na=Z(ta,`gu`).replace(/notPunctSpace/g,Ki).replace(/punctSpace/g,Gi).replace(/punct/g,Wi).getRegex(),ra=Z(ta,`gu`).replace(/notPunctSpace/g,Xi).replace(/punctSpace/g,Yi).replace(/punct/g,Ji).getRegex(),ia=Z(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Ki).replace(/punctSpace/g,Gi).replace(/punct/g,Wi).getRegex(),aa=Z(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Wi).getRegex(),oa=Z(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Ki).replace(/punctSpace/g,Gi).replace(/punct/g,Wi).getRegex(),sa=Z(/\\(punct)/,`gu`).replace(/punct/g,Wi).getRegex(),ca=Z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),la=Z(Ni).replace(`(?:-->|$)`,`-->`).getRegex(),ua=Z(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,la).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),da=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,fa=Z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,da).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),pa=Z(/^!?\[(label)\]\[(ref)\]/).replace(`label`,da).replace(`ref`,ki).getRegex(),ma=Z(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,ki).getRegex(),ha=Z(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,pa).replace(`nolink`,ma).getRegex(),ga=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,_a={_backpedal:hi,anyPunctuation:sa,autolink:ca,blockSkip:Zi,br:Hi,code:Vi,del:hi,delLDelim:hi,delRDelim:hi,emStrongLDelim:$i,emStrongRDelimAst:na,emStrongRDelimUnd:ia,escape:Bi,link:fa,nolink:ma,punctuation:qi,reflink:pa,reflinkSearch:ha,tag:ua,text:Ui,url:hi},va={..._a,link:Z(/^!?\[(label)\]\((.*?)\)/).replace(`label`,da).getRegex(),reflink:Z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,da).getRegex()},ya={..._a,emStrongRDelimAst:ra,emStrongLDelim:ea,delLDelim:aa,delRDelim:oa,url:Z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,ga).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:Z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,ga).getRegex()},ba={...ya,br:Z(Hi).replace(`{2,}`,`*`).getRegex(),text:Z(ya.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},xa={normal:Ii,gfm:Ri,pedantic:zi},Sa={normal:_a,gfm:ya,breaks:ba,pedantic:va},Ca={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},wa=e=>Ca[e];function Ta(e,t){if(t){if(Q.escapeTest.test(e))return e.replace(Q.escapeReplace,wa)}else if(Q.escapeTestNoEncode.test(e))return e.replace(Q.escapeReplaceNoEncode,wa);return e}function Ea(e){try{e=encodeURI(e).replace(Q.percentDecode,`%`)}catch{return null}return e}function Da(e,t){let n=e.replace(Q.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Q.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(Q.slashPipe,`|`);return n}function Oa(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function ka(e){let t=e.split(`
|
|
9
|
+
`),n=t.length-1;for(;n>=0&&Q.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
10
|
+
`)}function Aa(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function ja(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Ma(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function Na(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
11
|
+
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
|
|
12
|
+
`)}var Pa=class{options;rules;lexer;constructor(e){this.options=e||pi}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:ka(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Na(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Oa(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Oa(t[0],`
|
|
13
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:Oa(t[0],`
|
|
14
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Oa(t[0],`
|
|
15
|
+
`).split(`
|
|
16
|
+
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
17
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
18
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
19
|
+
${s}`:s,r=r?`${r}
|
|
20
|
+
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
|
|
21
|
+
`+e.join(`
|
|
22
|
+
`),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
|
|
23
|
+
`+e.join(`
|
|
24
|
+
`),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
|
|
25
|
+
`);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=ja(t[2].split(`
|
|
26
|
+
`,1)[0],t[1].length),l=e.split(`
|
|
27
|
+
`,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=c.search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
|
|
28
|
+
`,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d),f=this.rules.other.blockquoteBeginRegex(d);for(;e;){let p=e.split(`
|
|
29
|
+
`,1)[0],m;if(l=p,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),m=l):m=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||f.test(l)||t.test(l)||n.test(l))break;if(m.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
|
|
30
|
+
`+m.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
|
|
31
|
+
`+l}u=!l.trim(),r+=p+`
|
|
32
|
+
`,e=e.substring(p.length+1),c=m.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0)),i.items.push({type:`list_item`,raw:r,task:!!this.options.gfm&&this.rules.other.listIsTask.test(s),loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e of i.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,i.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.task&&=!1;if(!i.loose){let t=e.tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}}if(i.loose)for(let e of i.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return i}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=ka(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:Oa(t[0],`
|
|
33
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Da(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
34
|
+
`):[],a={type:`table`,raw:Oa(t[0],`
|
|
35
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Da(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:Oa(t[0],`
|
|
36
|
+
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
37
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Oa(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Aa(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Ma(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Ma(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim;for(s.lastIndex=0,t=t.slice(-1*e.length+n);(r=s.exec(t))!==null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},Fa=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pi,this.options.tokenizer=this.options.tokenizer||new Pa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Q,block:xa.normal,inline:Sa.normal};this.options.pedantic?(t.block=xa.pedantic,t.inline=Sa.pedantic):this.options.gfm&&(t.block=xa.gfm,this.options.breaks?t.inline=Sa.breaks:t.inline=Sa.gfm),this.tokenizer.rules=t}static get rules(){return{block:xa,inline:Sa}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Q.carriageReturn,`
|
|
38
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Q.tabCharGlobal,` `).replace(Q.spaceLine,``));let r=1/0;for(;e;){if(e.length<r)r=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}let i;if(this.options.extensions?.block?.some(n=>(i=n.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);i.raw.length===1&&n!==void 0?n.raw+=`
|
|
39
|
+
`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
40
|
+
`)?``:`
|
|
41
|
+
`)+i.raw,n.text+=`
|
|
42
|
+
`+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
43
|
+
`)?``:`
|
|
44
|
+
`)+i.raw,n.text+=`
|
|
45
|
+
`+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let a=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(a=e.substring(0,t+1))}if(this.state.top&&(i=this.tokenizer.paragraph(a))){let r=t.at(-1);n&&r?.type===`paragraph`?(r.raw+=(r.raw.endsWith(`
|
|
46
|
+
`)?``:`
|
|
47
|
+
`)+i.raw,r.text+=`
|
|
48
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=a.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
49
|
+
`)?``:`
|
|
50
|
+
`)+i.raw,n.text+=`
|
|
51
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!==null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!==null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!==null;)i=r[2]?r[2].length:0,n=n.slice(0,r.index+i)+`[`+`a`.repeat(r[0].length-i-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let a=!1,o=``,s=1/0;for(;e;){if(e.length<s)s=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}a||(o=``),a=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(i)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(o=r.raw.slice(-1)),a=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}},Ia=class{options;parser;constructor(e){this.options=e||pi}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(Q.notSpaceStart)?.[0],i=e.replace(Q.endingNewline,``)+`
|
|
52
|
+
`;return r?`<pre><code class="language-`+Ta(r)+`">`+(n?i:Ta(i,!0))+`</code></pre>
|
|
53
|
+
`:`<pre><code>`+(n?i:Ta(i,!0))+`</code></pre>
|
|
54
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
55
|
+
${this.parser.parse(e)}</blockquote>
|
|
56
|
+
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
57
|
+
`}hr(e){return`<hr>
|
|
58
|
+
`}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
|
|
59
|
+
`+r+`</`+i+`>
|
|
60
|
+
`}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
|
|
61
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox"> `}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
62
|
+
`}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
|
|
63
|
+
<thead>
|
|
64
|
+
`+t+`</thead>
|
|
65
|
+
`+r+`</table>
|
|
66
|
+
`}tablerow({text:e}){return`<tr>
|
|
67
|
+
${e}</tr>
|
|
68
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
69
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Ta(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Ea(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Ta(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Ea(e);if(i===null)return Ta(n);e=i;let a=`<img src="${e}" alt="${Ta(n)}"`;return t&&(a+=` title="${Ta(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Ta(e.text)}},La=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Ra=class e{options;renderer;textRenderer;constructor(e){this.options=e||pi,this.options.renderer=this.options.renderer||new Ia,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new La}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},za=class{options;block;constructor(e){this.options=e||pi}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Fa.lex:Fa.lexInline}provideParser(e=this.block){return e?Ra.parse:Ra.parseInline}},Ba=new class{defaults=fi();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Ra;Renderer=Ia;TextRenderer=La;Lexer=Fa;Tokenizer=Pa;Hooks=za;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Ia(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Pa(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new za;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];za.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&za.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Fa.lex(e,t??this.defaults)}parser(e,t){return Ra.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?Fa.lex:Fa.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?Ra.parse:Ra.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?Fa.lex:Fa.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?Ra.parse:Ra.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
70
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Ta(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return Ba.parse(e,t)}$.options=$.setOptions=function(e){return Ba.setOptions(e),$.defaults=Ba.defaults,mi($.defaults),$},$.getDefaults=fi,$.defaults=pi,$.use=function(...e){return Ba.use(...e),$.defaults=Ba.defaults,mi($.defaults),$},$.walkTokens=function(e,t){return Ba.walkTokens(e,t)},$.parseInline=Ba.parseInline,$.Parser=Ra,$.parser=Ra.parse,$.Renderer=Ia,$.TextRenderer=La,$.Lexer=Fa,$.lexer=Fa.lex,$.Tokenizer=Pa,$.Hooks=za,$.parse=$,$.options,$.setOptions,$.use,$.walkTokens,$.parseInline,Ra.parse,Fa.lex;var Va=!1;function Ha(){Va||=($.setOptions({breaks:!0,gfm:!0}),di.addHook(`afterSanitizeAttributes`,e=>{e.nodeName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}),!0)}function Ua(e,t){if(!e)return``;if(!t||typeof window>`u`)return Wa(e);try{Ha();let t=$.parse(e,{async:!1});return di.sanitize(t)}catch{return Wa(e)}}function Wa(e){return String(e).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`)}var Ga={pending:`Waiting for a decision.`,allowed:`Allowed once — the command may run for this tool call only.`,denied:`Denied — the command was not run.`,auto_denied:`Automatically denied — no interactive approval path was available.`,expired:`Expired — the command was not run.`,cancelled:`Cancelled — the command was not run.`};function Ka({approval:e,busy:t=!1,error:n,onDecision:r}){let i=e.status===`pending`;return(0,U.jsxs)(`section`,{className:`my-3 rounded-lg border border-danger/50 bg-danger/5 p-4 text-chocolate`,"aria-label":`Shell command approval`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`m-0 text-[0.72em] font-semibold uppercase tracking-wider text-danger`,children:`Shell command approval`}),(0,U.jsx)(`h2`,{className:`m-0 mt-1 font-body text-[0.95em] font-semibold`,children:i?`A risky command is waiting for you`:`Command decision recorded`})]}),(0,U.jsx)(`span`,{className:`rounded-full border border-danger/30 px-2 py-0.5 text-[0.75em] font-semibold uppercase tracking-wide text-danger`,children:e.status.replaceAll(`_`,` `)})]}),(0,U.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded-md border border-fawn bg-snow p-3 font-mono text-[0.82em] leading-[1.45] text-charcoal`,children:e.command}),(0,U.jsx)(`ul`,{className:`mt-3 space-y-1.5 pl-5 text-[0.84em] leading-[1.4] text-mocha`,children:e.risks.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`font-medium text-chocolate`,children:e.message}),` `,(0,U.jsx)(`code`,{className:`text-[0.9em]`,children:e.code})]},`${e.code}:${e.span.start}:${e.span.end}`))}),i?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`p`,{className:`mt-3 text-[0.78em] text-mocha-light`,children:[`This approval expires`,` `,(0,U.jsx)(`time`,{dateTime:new Date(e.expiresAt).toISOString(),children:new Date(e.expiresAt).toLocaleString()}),`. Deny blocks only this command; Stop ends the whole turn.`]}),n&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-2 rounded-md bg-danger/10 px-3 py-2 text-[0.82em] text-danger`,children:n}),r&&(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`primary`,disabled:t,onClick:()=>r(e,`deny`),children:`Deny`}),(0,U.jsx)(o,{variant:`danger`,disabled:t,onClick:()=>r(e,`allow`),children:`Allow once`})]})]}):(0,U.jsx)(`p`,{role:`status`,className:`mt-3 text-[0.84em] font-medium text-mocha`,children:Ga[e.status]})]})}var qa={terminal:dt,read:Xe,write:ct,search:Te,web:nt,message:f,file:et,image:rt,note:ut,question:Qe,tool:pt},Ja=6,Ya=40,Xa=6e3,Za=`rounded-md bg-frost px-1.5 py-px font-mono text-[0.86em] text-chocolate [overflow-wrap:anywhere]`;function Qa({items:e,dimmed:t=!1}){let n=Fn(e),r=n.filter(e=>e.name===`send_message`),i=n.filter(e=>e.name!==`send_message`),a=[...new Set(i.filter(e=>e.status===`done`&&(e.name===`write`||e.name===`edit`)).map(e=>ge(e.args)?.path).filter(e=>typeof e==`string`))];return(0,U.jsxs)(`div`,{className:t?`opacity-40`:void 0,children:[i.length>0&&(0,U.jsx)($a,{steps:i}),r.length>0&&(0,U.jsx)(ao,{steps:r}),a.length>0&&(0,U.jsx)(oo,{paths:a})]})}function $a({steps:e}){let t=e.some(e=>e.status===`running`),n=e.some(e=>e.status===`failed`),[r,i]=(0,H.useState)(null),a=r??(t||n||e.length<=Ja),o=e.map(e=>I(e.name,ge(e.args)));return(0,U.jsxs)(`div`,{className:`my-3 overflow-hidden rounded-[10px] border border-border bg-muted text-[0.86rem]`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":a,onClick:()=>i(!a),className:`unstyled flex min-h-9 w-full items-center gap-2 px-3 py-1.5 text-left text-mocha hover:bg-accent/50`,children:[(0,U.jsx)(at,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:[e.length,` step`,e.length===1?``:`s`]}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[_e(o.map(e=>e.kind)),t?` · running`:``]}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:a?`Hide`:`Show`})]}),a&&(0,U.jsx)(`ul`,{className:`m-0 list-none p-0`,children:e.map((e,t)=>(0,U.jsx)(eo,{step:e},t))})]})}function eo({step:e}){let[t,n]=(0,H.useState)(!1),r=ge(e.args),i=I(e.name,r),a=qa[i.icon],o=e.status===`done`?ke(e.name,r):null,s=e.status===`running`;return(0,U.jsxs)(`li`,{className:`border-t border-frost/70`,children:[(0,U.jsxs)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`unstyled flex min-h-8 w-full items-center gap-2.5 px-3 py-1 text-left hover:bg-accent/40`,children:[(0,U.jsx)(a,{className:`size-[15px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:[i.verb,i.target&&(0,U.jsxs)(U.Fragment,{children:[` `,(0,U.jsx)(`code`,{className:Za,children:i.target})]})]}),o&&o.added>0&&(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-success`,children:[`+`,o.added]}),o&&o.removed>0&&(0,U.jsxs)(`span`,{className:`shrink-0 font-mono text-xs font-medium text-danger`,children:[`−`,o.removed]}),s&&(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-success`,children:[(0,U.jsx)(`span`,{className:`size-[7px] animate-pulse rounded-full bg-success`,"aria-hidden":`true`}),`running`]}),e.status===`failed`&&(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-danger`,children:`failed`}),(0,U.jsx)(se,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform ${t?`rotate-90`:``}`,"aria-hidden":`true`})]}),s&&e.output&&!t&&(0,U.jsx)(io,{output:e.output}),t&&(0,U.jsx)(ro,{step:e,args:r})]})}function to(e,t=Ya){let n=e.replace(/\n$/,``).split(`
|
|
71
|
+
`);return{lines:n.slice(0,t),more:Math.max(0,n.length-t)}}function no({text:e,sign:t}){let{lines:n,more:r}=to(e),i=t===`+`?`bg-success/15`:`bg-danger/15`;return(0,U.jsxs)(U.Fragment,{children:[n.map((e,n)=>(0,U.jsxs)(`div`,{className:`whitespace-pre px-3 ${i}`,children:[t===`+`?`+`:`−`,e]},n)),r>0&&(0,U.jsxs)(`div`,{className:`px-3 text-mocha`,children:[` `,r,` more line`,r===1?``:`s`]})]})}function ro({step:e,args:t}){let n=e.output.length>Xa?`${e.output.slice(0,Xa)}\n…`:e.output,r=`overflow-x-auto border-t border-frost/70 bg-card font-mono text-xs leading-[1.55]`;if(e.status!==`failed`&&e.name===`write`&&typeof t?.content==`string`)return(0,U.jsx)(`div`,{className:r,children:(0,U.jsx)(no,{text:t.content,sign:`+`})});if(e.status!==`failed`&&e.name===`edit`&&Array.isArray(t?.edits))return(0,U.jsx)(`div`,{className:r,children:t.edits.map((e,t)=>(0,U.jsxs)(`div`,{className:t>0?`border-t border-frost/70`:void 0,children:[typeof e?.oldText==`string`&&(0,U.jsx)(no,{text:e.oldText,sign:`-`}),typeof e?.newText==`string`&&(0,U.jsx)(no,{text:e.newText,sign:`+`})]},t))});let i=e.name===`bash`&&typeof t?.command==`string`?t.command:t?JSON.stringify(t,null,2):e.args;return(0,U.jsxs)(`div`,{className:`${r} max-h-72 overflow-y-auto`,children:[i&&(0,U.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words px-3 py-1.5 text-mocha`,children:i}),n&&(0,U.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words border-t border-frost/70 px-3 py-1.5 ${e.status===`failed`?`text-danger`:`text-chocolate`}`,children:n})]})}function io({output:e}){let t=(0,H.useRef)(null);return(0,H.useLayoutEffect)(()=>{t.current&&(t.current.scrollTop=t.current.scrollHeight)},[e]),(0,U.jsx)(`pre`,{ref:t,className:`m-0 max-h-48 overflow-auto whitespace-pre-wrap break-words border-t border-frost/70 bg-card px-3 py-1.5 font-mono text-xs text-mocha`,children:e})}function ao({steps:e}){let t=E(),n=Ae();return(0,U.jsxs)(`div`,{className:`my-3 overflow-hidden rounded-[10px] border border-border bg-muted text-[0.86rem]`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-9 items-center gap-2 px-3 py-1.5 text-mocha`,children:[(0,U.jsx)(Je,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.length===1?`Handed off to a teammate`:`Handed off to ${e.length} teammates`}),t?.team&&(0,U.jsx)(i,{to:`/`,search:t.to({panel:`connections`}),className:`ml-auto text-xs font-semibold`,children:`See connections`})]}),e.map((e,r)=>{let a=ge(e.args),o=typeof a?.to==`string`?a.to:``,s=t?.agentById(o),c=typeof a?.text==`string`?a.text:``,l=s?n?.stateOf(s.id):void 0;return(0,U.jsxs)(`details`,{className:`group border-t border-frost/70`,children:[(0,U.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center gap-2.5 px-3 py-1.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(Fe,{identity:s?.identity,size:24}),(0,U.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:s?.name??(o?o.slice(0,8):`Teammate`)}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-mocha group-open:invisible`,children:c}),e.status===`failed`?(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-danger`,children:`not sent`}):e.status===`running`?(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:`sending…`}):l&&(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-mocha`,children:l.text}),t&&s&&(0,U.jsx)(i,{to:`/`,search:{agent:s.id,...t.search.panel?{panel:t.search.panel}:{}},className:`flex h-7 shrink-0 items-center rounded-[10px] border border-border bg-card px-2.5 text-xs font-semibold text-foreground hover:border-sapphire-light hover:text-sapphire`,children:`Open`})]}),(0,U.jsx)(`p`,{className:`m-0 whitespace-pre-wrap break-words px-3 pb-2.5 pl-[3.1rem] text-chocolate`,children:c}),e.status===`failed`&&(0,U.jsx)(`p`,{className:`m-0 break-words px-3 pb-2.5 pl-[3.1rem] text-xs text-danger`,children:e.output})]},r)})]})}function oo({paths:e}){let t=E(),n=`${e.length} file${e.length===1?``:`s`} written`,r=e.map(e=>e.split(`/`).pop()??e).join(`, `),a=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(h,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`shrink-0 font-semibold text-foreground`,children:n}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-mocha`,children:r})]}),o=`my-3 flex min-h-11 w-full items-center gap-2.5 rounded-[10px] border border-border bg-card px-3 py-2 text-[0.86rem]`;return t?.team?(0,U.jsxs)(i,{to:`/`,search:t.to({panel:`changes`,file:e[0]}),className:`${o} text-foreground hover:border-sapphire-light`,children:[a,(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 font-semibold text-accent-foreground`,children:[`Review changes`,(0,U.jsx)(P,{className:`size-3.5`,"aria-hidden":`true`})]})]}):(0,U.jsx)(`div`,{className:o,children:a})}var so=`[[bazilion:inbox-wake]]
|
|
72
|
+
`,co=`[conversation summary]`,lo=()=>()=>{};function uo(){return(0,H.useSyncExternalStore)(lo,()=>!0,()=>!1)}function fo({entry:e,markdownReady:t,onEdit:n,dropped:r=!1,approvals:i}){let a=r?`opacity-40 [&_.bubble-content]:line-through`:``;switch(e.type){case`user`:if(e.content.startsWith(so)){let t=e.content.slice(24);return(0,U.jsxs)(`details`,{className:`my-3 rounded-lg border border-fawn bg-ivory px-3 py-2 text-sm text-mocha ${a}`,"aria-label":`Teammate update`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer font-medium`,children:Yn(t)}),(0,U.jsx)(`p`,{className:`mt-2 text-xs`,children:`Original message and Agent instructions`}),(0,U.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto whitespace-pre-wrap break-words text-xs`,children:t})]})}return(0,U.jsxs)(`div`,{className:`group relative my-4 flex flex-col items-end ${a}`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:`you`}),e.images&&e.images.length>0&&(0,U.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.images.map((e,t)=>(0,U.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`attachment`,className:`max-h-48 rounded-lg border border-sapphire-light`},t))}),e.files&&e.files.length>0&&(0,U.jsx)(`div`,{className:`mb-1 flex max-w-[85%] flex-wrap justify-end gap-1`,children:e.files.map((e,t)=>(0,U.jsxs)(`span`,{className:`flex items-center gap-1 rounded-md border border-sapphire-light bg-sapphire-glow px-2 py-1 text-[0.8em] text-chocolate`,children:[(0,U.jsx)(et,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-[180px] truncate`,children:e.name})]},t))}),e.content&&(0,U.jsx)(go,{content:e.content}),n&&(0,U.jsx)(`button`,{type:`button`,onClick:n,title:`Edit and resend: replaces the last turn`,className:`absolute left-1 top-1 rounded-sm border border-fawn bg-ivory px-2 py-0.5 text-[0.78em] font-medium text-mocha opacity-65 transition hover:border-sapphire hover:bg-sapphire-glow hover:text-sapphire hover:opacity-100 group-hover:opacity-100 group-focus-within:opacity-100`,children:`edit`})]});case`assistant`:if(e.content.startsWith(co)){let n=e.content.slice(22).trim();return(0,U.jsx)(`div`,{className:`my-3 border-y border-dashed border-frost py-2 text-[0.85em] italic text-mocha-light ${a}`,children:(0,U.jsxs)(`details`,{children:[(0,U.jsx)(`summary`,{className:`cursor-pointer select-none text-center [&::-webkit-details-marker]:hidden`,children:`— conversation summary (click to expand) —`}),(0,U.jsx)(`div`,{className:`md-content mt-2 rounded-sm bg-frost/40 p-2 not-italic`,dangerouslySetInnerHTML:{__html:Ua(n,t)}})]})})}return(0,U.jsxs)(`div`,{className:`my-4 flex flex-col items-start ${a}`,children:[(0,U.jsx)(`span`,{className:`sr-only`,children:`agent`}),(0,U.jsx)(`div`,{className:`md-content bubble-content w-full leading-[1.55] text-chocolate`,dangerouslySetInnerHTML:{__html:Ua(e.content,t)}})]});case`images`:return(0,U.jsx)(`div`,{className:`my-2 space-y-2 ${a}`,children:e.images.map((e,t)=>(0,U.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:`screenshot`,className:`block max-w-full rounded-lg border border-fawn`},t))});case`command_approval`:return(0,U.jsx)(Ka,{approval:e.approval,busy:i?.busy[e.approval.id]??!1,error:i?.errors[e.approval.id],onDecision:i?.decide});case`system`:return(0,U.jsxs)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-sapphire bg-sapphire-glow px-3 py-1 font-mono text-[0.88em] text-sapphire-deep`,children:[(0,U.jsx)(`span`,{className:`mr-2 font-semibold uppercase tracking-wider opacity-80`,children:`system`}),(0,U.jsx)(`span`,{className:`whitespace-pre-wrap`,children:e.content})]});case`error`:return(0,U.jsx)(`div`,{className:`my-3 rounded-r-sm border-l-[3px] border-danger bg-danger/10 px-3 py-1 text-[0.92em] text-danger`,children:e.content})}}var po=14,mo=1400,ho=8;function go({content:e}){let[t,n]=(0,H.useState)(!1),r=e.split(`
|
|
73
|
+
`),i=r.length>po||e.length>mo;return(0,U.jsxs)(`div`,{className:`bubble-content max-w-[85%] rounded-[14px_14px_4px_14px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-chocolate`,children:[(0,U.jsxs)(`div`,{className:`whitespace-pre-wrap break-words`,children:[!i||t?e:r.slice(0,ho).join(`
|
|
74
|
+
`).slice(0,mo/2),i&&!t?`…`:``]}),i&&(0,U.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:()=>n(!t),className:`unstyled mt-1.5 text-[0.82em] font-semibold text-sapphire-deep hover:underline`,children:t?`Show less`:`Show the whole message (${r.length} lines)`})]})}function _o({block:e,dropped:t}){let n=E();return(0,U.jsxs)(U.Fragment,{children:[e.items.length>0&&(0,U.jsx)(Qa,{items:e.items,dimmed:t}),e.resultIds.length>0&&(0,U.jsx)(`div`,{className:`my-3 grid grid-cols-[repeat(auto-fit,minmax(min(15rem,100%),1fr))] gap-3 ${t?`opacity-40`:``}`,children:e.resultIds.map(e=>(0,U.jsx)(fn,{resultId:e,...n?.team?{open:n.to({view:`files`,result:e})}:{}},e))})]})}function vo({entries:e,notes:t=[],markdownReady:n,editableEntry:r=-1,replacedFrom:i=-1,onEdit:a,approvals:o}){let s=[],c=0,l=e=>{for(;c<t.length&&(t[c]?.afterIndex??0)<=e;){let e=t[c];s.push((0,U.jsx)(fo,{entry:{type:`system`,content:e.content},markdownReady:n},`note-${e.id}`)),c++}};for(let t of In(e)){l(t.index);let e=i>=0&&t.index>=i;s.push(t.type===`work`?(0,U.jsx)(_o,{block:t,dropped:e},t.index):(0,U.jsx)(fo,{entry:t.entry,markdownReady:n,dropped:e,onEdit:t.index===r?a:void 0,approvals:o},t.index))}return l(1/0),(0,U.jsx)(U.Fragment,{children:s})}function yo({messages:e}){let t=uo();return(0,U.jsx)(`section`,{"aria-label":`Conversation history`,children:(0,U.jsx)(vo,{entries:Pn(e),markdownReady:t})})}var bo=[`slash commands:`,` /context — context breakdown (system prompt, tools, skills, history)`,` /compact [N] — summarize the head; keep the last N messages verbatim (default 10)`,` /new — open the list of conversations to start a new one`,` /help — show this list`].join(`
|
|
75
|
+
`);function xo(e){let t=e.trim();if(!t.startsWith(`/`))return null;let[n=``,...r]=t.split(/\s+/);return{command:n.toLowerCase(),rest:r.join(` `)}}function So(e){let t=Number(e.trim());return e.trim()&&Number.isFinite(t)&&t>=0?Math.floor(t):void 0}function Co(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`}function wo(e){let t=(e,t)=>`${e.toLocaleString()} chars (~${t.toLocaleString()} tok)`,n=[`context for ${e.agentId}`,`model: ${e.model}`,``,`system prompt: ${t(e.systemPrompt.chars,e.systemPrompt.tokens)}`,...e.systemPrompt.files.map(e=>` - ${e.name}: ${e.chars.toLocaleString()} chars`),``,`tools: ${e.tools.count} (${e.tools.schemaChars.toLocaleString()} chars of schema)`,...e.tools.entries.slice(0,5).map(e=>` - ${e.name}: ${e.schemaChars.toLocaleString()} chars`)];if(e.skills.count>0){n.push(``,`skills: ${e.skills.count}`);for(let t of e.skills.entries.slice(0,10))n.push(` - ${t.name}: ${t.blockChars.toLocaleString()} chars`)}return n.push(``,`history: ${e.history.messageEntries} messages / ${e.history.compactionEntries} compactions`,` ${t(e.history.chars,e.history.tokensEstimate)}`,` bytes on disk: ${Co(e.history.bytes)}`,``,`TOTAL: ${t(e.totals.chars,e.totals.tokens)}`),n.join(`
|
|
76
|
+
`)}function To(e){return`/compact: ${e.before} → ${e.after} entries (${e.summarized} summarized, ${e.keptTail} kept verbatim; ~${e.tokensBefore.toLocaleString()} → ~${e.tokensAfter.toLocaleString()} tok). reloading…`}var Eo=1e4,Do=5e3,Oo={file:null,size:0,conversationId:null};function ko(e){return e?.items.filter(e=>e.status===`pending`||e.status===`running`).length??0}function Ao({agentId:e,initialMessages:t,initialSessionHead:n,onOpenLibrary:r,onConversation:i}){let a=`/api/agents/${encodeURIComponent(e)}`,[o,d]=(0,H.useState)(t),[f,p]=(0,H.useState)([]),[m,h]=(0,H.useState)([]),[g,_]=(0,H.useState)(!1),[v,y]=(0,H.useState)(!1),[b,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(!1),[E,D]=(0,H.useState)(n?.unavailable??!1),[O,k]=(0,H.useState)(null),[A,ee]=(0,H.useState)(0),[te,j]=(0,H.useState)({}),[M,ne]=(0,H.useState)({}),N=(0,H.useRef)(null),re=(0,H.useRef)(!1),P=(0,H.useRef)(n??Oo),ie=(0,H.useRef)(null),ae=(0,H.useRef)(0),oe=(0,H.useRef)(0),se=(0,H.useRef)(!1);se.current=v;let ce=v||b,le=ce||!!O?.turnActive,ue=O?.turnActive||O?.items.some(e=>e.status===`running`||e.status===`pending`&&!O.paused);function F(e){e.conversationId!==P.current.conversationId&&i?.(e.conversationId),P.current=e}function I(e){let t={id:ae.current++,content:e,afterIndex:oe.current};h(e=>[...e,t])}async function L(){if(!se.current)try{let e=await c(`${a}/sessions/messages`);D(e.head.unavailable??!1),d(e.messages),p([]),C(!1),F(e.head),T(!1)}catch{I(`Conversation history is unavailable. Your draft is preserved.`)}}async function de(){try{let e=await c(`${a}/sessions/head`),t=P.current.conversationId;if(t&&t!==e.conversationId){T(!0);return}D(e.unavailable??!1),F(e)}catch{}}async function R(){try{let e=await c(`${a}/queue`);ko(e)<ko(ie.current)&&!se.current&&L(),ie.current=e,k(e)}catch{}}(0,H.useEffect)(()=>()=>N.current?.abort(),[]),(0,H.useEffect)(()=>{R()},[]),(0,H.useEffect)(()=>{if(!ue)return;let e=setInterval(()=>{document.hidden||R()},Do);return()=>clearInterval(e)},[ue]),(0,H.useEffect)(()=>{if(!n||w)return;let e=setInterval(async()=>{if(!(document.hidden||se.current))try{let e=await c(`${a}/sessions/head`),t=P.current;(!!e.unavailable!=!!t.unavailable||e.file!==t.file||e.size!==t.size)&&(T(!0),R())}catch{}},Eo);return()=>clearInterval(e)},[a,n,w]),(0,H.useEffect)(()=>{let t=new AbortController;return c(Mn(e),{signal:t.signal}).then(({approvals:t})=>{let n=t.filter(t=>t.agentId===e&&t.status===`pending`);n.length!==0&&(re.current=!0,p(e=>n.reduce(Ln,e)),x(!0))}).catch(()=>{}),()=>t.abort()},[e]);async function fe(e){try{return await c(`${a}/queue`,{body:{message:e.text,attachments:e.attachments}}),R(),null}catch(t){return I(`The follow-up was not queued: ${s(t)}. Your draft is kept.`),e}}async function pe(e){if(o.length<2){I(`/compact: need ≥2 messages to compact`);return}C(!1),y(!0),_(!0);try{I(To(await c(`${a}/chat/compact`,{body:{keepTail:So(e)}}))),setTimeout(()=>window.location.reload(),400)}catch(e){I(`/compact failed: ${s(e)}`)}finally{_(!1),y(!1)}}async function me(e,t){switch(e){case`/help`:return I(bo),!0;case`/context`:try{I(wo(await c(`${a}/chat/context`)))}catch(e){I(`/context failed: ${s(e)}`)}return!0;case`/new`:return r(),!0;case`/compact`:return await pe(t),!0;default:return!1}}function he(){return o.findLastIndex(e=>e.role===`user`)}function ge(t){if(t.kind===`fatal`){re.current=!1,p(e=>[...Hn(e),{type:`error`,content:`[fatal] ${t.error}`}]),x(!1);return}if(t.kind===`done`){re.current=!1,d(t.messages),p([]),x(!1),j({}),ne({});return}let n=t.event;if(n.type===`command_approval`){if(n.approval.agentId!==e)return;re.current=!0,_(n.approval.status!==`pending`&&n.approval.status!==`cancelled`)}else n.type===`agent_question`?ee(e=>e+1):n.type===`assistant_delta`||n.type===`assistant_message`||n.type===`tool_call`?_(!1):(n.type===`tool_result`||n.type===`tool_error`)&&_(!0);p(e=>Vn(e,n))}async function _e(e){let t=xo(e.text);if(t&&await me(t.command,t.rest))return e.attachments.length>0?{text:``,attachments:e.attachments}:null;if(ce)return S?(I(`Wait for the current turn to finish before replacing the last message.`),e):fe(e);if(S){let t=he();try{await c(`${a}/chat/truncate`,{body:{keepCount:t,conversationId:P.current.conversationId??void 0}})}catch(t){return I(`Could not replace the last turn: ${s(t)}`),e}d(e=>e.slice(0,t)),C(!1)}let n=e.attachments.filter(e=>Nn(e.mimeType)),r=e.attachments.filter(e=>!Nn(e.mimeType)).map(e=>({name:e.name??`file`}));p([{type:`user`,content:e.text,...n.length>0?{images:n}:{},...r.length>0?{files:r}:{}}]),x(!1),j({}),ne({}),re.current=!1;let i=new AbortController;N.current=i,y(!0),_(!0);let o=!1,f=null;try{let t=await l(`${a}/chat`,{body:jn(e.text,e.attachments),signal:i.signal});if(!t.body)throw Error(`the chat response has no body`);for await(let e of Un(t.body))e.kind!==`event`&&(o=!0),ge(e);await de()}catch(t){t instanceof u?t.code===`agent_turn_active`?(p([]),f=await fe(e)):(p([{type:`error`,content:`[error] ${t.message}`}]),f=e):t.name!==`AbortError`&&p(e=>[...e,{type:`error`,content:`[network error] ${s(t)}`}])}finally{N.current===i&&(!o&&re.current&&x(!0),_(!1),y(!1),N.current=null,R(),ee(e=>e+1))}return f}async function z(){try{await c(`${a}/cancel`,{method:`POST`})}catch(e){e instanceof u&&e.status===409||I(`Stop was not confirmed; the response may still be running.`)}R()}async function ve(t){try{let{approvals:n}=await c(Mn(e)),r=n.find(n=>n.id===t&&n.agentId===e);return r&&p(e=>Ln(e,r)),r??null}catch{return null}}async function ye(t,n){if(!(t.agentId!==e||t.status!==`pending`)){j(e=>({...e,[t.id]:!0})),ne(({[t.id]:e,...n})=>n);try{let r=await c(`/api/shell-approvals/${encodeURIComponent(t.id)}`,{body:{decision:n}});r.approval.agentId===e&&p(e=>Ln(e,r.approval))}catch(e){let n=await ve(t.id);(!n||n.status===`pending`)&&ne(n=>({...n,[t.id]:s(e)}))}finally{j(e=>({...e,[t.id]:!1}))}}}function be(){if(f.length>0||ce)return null;let e=he();return e<0?null:(C(!0),o[e]?.content??null)}let xe=Pn(o),Se=[...xe,...f];oe.current=Se.length;let Ce=xe.findLastIndex(e=>e.type===`user`);return{entries:Se,notes:m,replacedFrom:S?Ce:-1,editableEntry:!S&&f.length===0&&!ce?Ce:-1,thinking:g,turnBusy:ce,agentBusy:le,editing:S,stale:w,recoveredTurn:b,historyUnavailable:E,queue:O,questionsKey:A,approvals:{busy:te,errors:M,decide:ye},send:_e,stop:z,startEdit:be,cancelEdit:()=>C(!1),refreshHistory:L,refreshQueue:R,dismissStale:()=>T(!1)}}var jo=40,Mo=`relative flex h-full flex-col overflow-hidden rounded-[16px] border border-frost bg-snow shadow-baziu-sm`;function No(e){return(0,U.jsx)(Po,{...e},e.agentId)}function Po({agentId:e,agentName:t,initialMessages:n,initialSessionHead:r,header:i,onViewConversation:a,onConversationChange:o}){let s=uo(),c=Ae(),[l,u]=(0,H.useState)(!1),d=Ao({agentId:e,initialMessages:n,initialSessionHead:r,onOpenLibrary:()=>u(!0),onConversation:o}),[f,p]=(0,H.useState)(``),[m,h]=(0,H.useState)([]),[g,_]=(0,H.useState)(!1),v=(0,H.useRef)(null),y=(0,H.useRef)(null),b=(0,H.useRef)(!0);(0,H.useLayoutEffect)(()=>{let e=y.current;e&&b.current&&(e.scrollTop=e.scrollHeight)});async function x(e){let t=await Kn(e);h(e=>[...e,...t].slice(0,16))}async function S(){let e={text:f,attachments:m};if(!e.text.trim()&&e.attachments.length===0)return;p(``),h([]);let t=await d.send(e);c?.refresh(),t&&(p(e=>e||t.text),h(e=>e.length>0?e:t.attachments))}function C(){let e=d.startEdit();e!==null&&(p(e),v.current?.focus())}let w=!d.historyUnavailable&&d.entries.length===0&&d.notes.length===0,T=d.agentBusy&&!d.turnBusy,E=c?.stateOf(e),D=E?.kind===`working`?E.text.replace(/^Working:?\s*/,``):``;return(0,U.jsxs)(`section`,{"aria-label":`Chat with ${t}`,className:Mo,onDragOver:e=>{Array.from(e.dataTransfer.types).includes(`Files`)&&(e.preventDefault(),_(!0))},onDragLeave:e=>{e.currentTarget===e.target&&_(!1)},onDrop:e=>{e.dataTransfer.files.length!==0&&(e.preventDefault(),_(!1),x(e.dataTransfer.files))},children:[g&&(0,U.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-[16px] border-2 border-dashed border-sapphire bg-sapphire-glow/80 text-[0.95em] font-medium text-sapphire-deep`,children:`drop images or files to attach`}),i?i({agentBusy:d.agentBusy,reload:d.refreshHistory,conversationsOpen:l,setConversationsOpen:u}):(0,U.jsx)(`div`,{className:`border-b border-frost px-4 py-2.5`,children:(0,U.jsx)(`h1`,{className:`m-0 truncate font-display text-[1.2rem] text-charcoal`,children:t})}),d.historyUnavailable&&(0,U.jsx)(`p`,{role:`alert`,className:`mx-5 mt-2 text-sm`,children:`This conversation's history is unavailable. Start a new conversation from the list above; earlier conversations and their files stay listed.`}),d.stale&&(0,U.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`mx-5 mt-2 flex items-center gap-2 rounded-[10px] border border-sapphire-light bg-sapphire-glow px-3 py-2 text-[0.86em] text-sapphire-deep`,children:[(0,U.jsx)(`span`,{className:`h-2 w-2 flex-none rounded-full bg-sapphire`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`flex-1`,children:d.recoveredTurn?`The recovered turn has new activity.`:`There is new activity from another source (a follow-up, Telegram or a schedule).`}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void d.refreshHistory(),className:`unstyled rounded-md bg-sapphire px-3 py-1 text-[0.92em] font-semibold text-snow hover:bg-sapphire-deep`,children:`Show it`}),(0,U.jsx)(`button`,{type:`button`,onClick:d.dismissStale,className:`unstyled px-1 text-sapphire-deep hover:opacity-70`,"aria-label":`Dismiss`,children:`×`})]}),(0,U.jsx)(`div`,{ref:y,onScroll:e=>{let t=e.currentTarget;b.current=t.scrollHeight-t.scrollTop-t.clientHeight<jo},role:`log`,"aria-label":`Conversation with ${t}`,"aria-live":`polite`,"aria-relevant":`additions`,"aria-busy":d.turnBusy,className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[50rem]`,children:[w&&(0,U.jsxs)(`p`,{className:`py-12 text-center italic text-mocha-light`,children:[`Say what you need. `,t,` keeps this conversation between turns.`]}),(0,U.jsx)(vo,{entries:d.entries,notes:d.notes,markdownReady:s,editableEntry:d.editableEntry,replacedFrom:d.replacedFrom,onEdit:C,approvals:d.approvals}),(d.thinking||T)&&(0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 px-1 py-1.5 text-[0.85em] text-success`,children:[(0,U.jsx)(`span`,{className:`size-[7px] animate-pulse rounded-full bg-success`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{children:[t,` is working`,D?`: ${D}`:``]})]})]})}),(0,U.jsx)(`p`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:d.turnBusy?`${t} is responding.`:`Conversation ready.`}),(0,U.jsx)(Jn,{agentId:e,queue:d.queue,onChanged:()=>void d.refreshQueue(),onViewConversation:e=>a?.(e)}),(0,U.jsx)(kn,{agentId:e,agentName:t,refreshKey:d.questionsKey}),(0,U.jsx)(qn,{agentName:t,value:f,onChange:p,onSubmit:()=>void S(),attachments:m,onAddFiles:e=>void x(e),onRemoveAttachment:e=>h(t=>t.filter((t,n)=>n!==e)),editing:d.editing,onCancelEdit:d.cancelEdit,agentBusy:d.agentBusy,onStop:()=>void d.stop(),inputRef:v})]})}var Fo=[{id:`all`,label:`All`},{id:`pictures`,label:`Pictures`},{id:`documents`,label:`Documents`}],Io=e=>e.mimeType.startsWith(`image/`);function Lo({team:e}){let{agents:t,agentById:n,search:a,to:s}=k(),l=r(),d=S(),[p,m]=(0,H.useState)(``),[h,g]=(0,H.useState)(`all`),[_,v]=(0,H.useState)(!1),[y,x]=(0,H.useState)(null),[w,T]=(0,H.useState)(null),E=t.filter(t=>t.teamId===e.id),D=mn(e.id,p?{agentId:p}:{},48),O=D.results.filter(e=>h===`all`||h===`pictures`===Io(e)),A=a.result??null,ee=D.results.find(e=>e.id===A),te=M(async e=>{if(!A||ee)return null;try{return(await c(un(A),{signal:e})).result}catch(e){if(e instanceof u&&e.status===404)return null;throw e}},[A,!!ee]),j=ee??te.data??null,ne=D.results.find(e=>e.id===y)??null,N=e=>void l.navigate({to:`/`,search:s({result:e}),replace:!0}),re=()=>{v(!1),x(null)};(0,H.useEffect)(re,[A]);let P=e=>n(e.agentId)?.name,ie=p?{agentId:p}:{};return(0,U.jsxs)(b,{view:`files`,actions:D.total>0&&(0,U.jsxs)(`a`,{href:dn({teamId:e.id,...ie}),download:!0,className:`ghost-btn min-h-8 px-3 py-1 text-xs`,children:[(0,U.jsx)($e,{className:`size-3.5`,"aria-hidden":`true`}),`Download `,p?`these`:`all`,` `,D.total,` (.zip)`]}),children:[(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 ${j?`lg:grid-cols-[minmax(0,1fr)_minmax(20rem,26rem)]`:``}`,children:[j&&ne?(0,U.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-3 sm:p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(V,{className:`size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,U.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 font-body text-sm font-semibold text-foreground`,children:`Side by side`}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:re,children:`Stop comparing`})]}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[j,ne].map(e=>(0,U.jsxs)(`figure`,{className:`m-0 min-w-0`,children:[(0,U.jsx)(Ro,{result:e}),(0,U.jsxs)(`figcaption`,{className:`mt-1.5 flex items-center gap-2 text-xs text-mocha`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:e.name,children:[(0,U.jsx)(`strong`,{className:`text-foreground`,children:e.name}),` ·`,` `,cn(e.byteLength),P(e)?` · ${P(e)}`:``]}),(0,U.jsx)(`a`,{href:un(e.id,`download`),download:e.name,className:`shrink-0 font-semibold`,children:`Download`})]})]},e.id))})]}):(0,U.jsxs)(`div`,{className:`min-h-0 overflow-y-auto p-3 sm:p-4 ${j?`hidden lg:block`:``}`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(C,{label:`Kind of file`,value:h,options:Fo,onChange:g}),(0,U.jsxs)(`select`,{"aria-label":`Delivered by`,value:p,onChange:e=>m(e.target.value),className:`min-h-8 w-auto min-w-40 py-1 text-xs`,children:[(0,U.jsxs)(`option`,{value:``,children:[`Everyone in `,e.name]}),E.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,U.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D.loading&&D.results.length===0?`Loading…`:h===`all`?`${D.total} file${D.total===1?``:`s`}`:`${O.length} of the ${D.results.length} loaded`})]}),_&&(0,U.jsxs)(`p`,{role:`status`,className:`mb-3 flex flex-wrap items-center gap-2 rounded-[10px] border border-primary/30 bg-accent/40 px-3 py-2 text-sm text-foreground`,children:[(0,U.jsx)(V,{className:`size-4 shrink-0 text-accent-foreground`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Choose the file to put beside `,(0,U.jsx)(`strong`,{children:j?.name}),`.`]}),(0,U.jsx)(o,{variant:`ghost`,className:`min-h-8 px-3 py-1 text-xs`,onClick:re,children:`Stop comparing`})]}),D.error&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:D.error}),!D.loading&&!D.error&&O.length===0&&(0,U.jsx)(`p`,{className:`m-0 rounded-2xl border border-dashed border-border bg-muted/40 px-4 py-10 text-center text-sm text-muted-foreground`,children:D.total===0?`Nothing saved yet. Files an Agent delivers and pictures it generates are kept here with their original contents.`:`No file of this kind among the ones loaded.`}),(0,U.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(14rem,1fr))] gap-3`,children:O.map(e=>(0,U.jsx)(fn,{resultId:e.id,result:e,compact:!0,selected:e.id===A||e.id===y,detail:[P(e),d?fe(e.createdAt):null].filter(Boolean).join(` · `),open:s({result:e.id}),..._&&e.id!==A?{onPick:()=>x(e.id)}:{}},e.id))}),D.hasMore&&(0,U.jsx)(`div`,{className:`mt-4 text-center`,children:(0,U.jsx)(o,{variant:`ghost`,disabled:D.loading,onClick:D.more,children:D.loading?`Loading…`:`Show more (${D.total-D.results.length} left)`})})]}),j&&(0,U.jsxs)(`aside`,{"aria-label":`Details of ${j.name}`,className:`min-h-0 overflow-y-auto border-border p-3 sm:p-4 lg:border-l`,children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-start gap-2`,children:[(0,U.jsx)(`h2`,{className:`m-0 min-w-0 flex-1 break-words font-body text-base font-semibold leading-snug text-foreground`,children:j.name}),(0,U.jsx)(`button`,{type:`button`,"aria-label":`Close the details`,onClick:()=>N(void 0),className:`unstyled flex size-8 shrink-0 items-center justify-center rounded-[10px] text-mocha hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(ce,{className:`size-4`,"aria-hidden":`true`})})]}),(0,U.jsx)(Ro,{result:j}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsxs)(`a`,{href:un(j.id,`download`),download:j.name,className:`btn-primary min-h-9 px-3 py-1.5 text-sm no-underline`,children:[(0,U.jsx)($e,{className:`size-4`,"aria-hidden":`true`}),`Download`]}),ne?(0,U.jsx)(o,{variant:`ghost`,className:`min-h-9`,onClick:re,children:`Stop comparing`}):(0,U.jsxs)(o,{variant:`ghost`,className:`min-h-9`,disabled:D.results.length<2,onClick:()=>v(!0),children:[(0,U.jsx)(V,{className:`size-4`,"aria-hidden":`true`}),`Compare`]}),(0,U.jsxs)(o,{variant:`danger`,className:`min-h-9`,onClick:()=>T(j),children:[(0,U.jsx)(ft,{className:`size-4`,"aria-hidden":`true`}),`Delete`]})]}),(0,U.jsxs)(`dl`,{className:`m-0 mt-4 grid grid-cols-[max-content_minmax(0,1fr)] gap-x-3 gap-y-2 text-sm`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Delivered by`}),(0,U.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(Fe,{identity:n(j.agentId)?.identity,size:18}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:P(j)??`An Agent that was deleted`})]}),(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Saved`}),(0,U.jsx)(`dd`,{className:`m-0`,children:d?new Date(j.createdAt).toLocaleString():``}),(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Kind`}),(0,U.jsxs)(`dd`,{className:`m-0`,children:[ln(j.mimeType,j.name),` · `,cn(j.byteLength)]}),j.imageModel&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`Made with`}),(0,U.jsx)(`dd`,{className:`m-0 break-all font-mono text-xs`,children:j.imageModel})]}),(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:`SHA-256`}),(0,U.jsxs)(`dd`,{className:`m-0 flex min-w-0 items-center gap-1`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate font-mono text-xs text-mocha`,children:j.sha256}),(0,U.jsx)(Qt,{value:j.sha256,ariaLabel:`Copy the checksum`,title:`Copy`})]})]}),P(j)&&(0,U.jsxs)(i,{to:`/`,search:{agent:j.agentId,conversation:j.sessionId,panel:`files`},className:`ghost-btn mt-4 min-h-9 w-full text-sm`,children:[(0,U.jsx)(f,{className:`size-4`,"aria-hidden":`true`}),`Open the conversation it came from`]})]}),A&&!j&&!te.loading&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 p-4 text-sm text-muted-foreground`,children:`That saved file is not available any more.`})]}),(0,U.jsx)(F,{open:w!==null,title:`Delete ${w?.name??`this file`}?`,description:(0,U.jsx)(`p`,{children:`The saved copy is removed for good, and the conversation shows it as unavailable. A file of the same name in the Team's workspace, if there is one, is not touched.`}),confirmLabel:`Delete saved file`,onOpenChange:e=>{e||T(null)},onConfirm:async()=>{w&&(await c(un(w.id),{method:`DELETE`}),N(void 0),await D.reload())}})]})}function Ro({result:e}){let t=M(async t=>sn(e)?(await l(un(e.id,`preview`),{signal:t})).text():null,[e.id]);return on(e)?(0,U.jsx)(`a`,{href:un(e.id,`preview`),target:`_blank`,rel:`noreferrer`,title:`Open at full size`,children:(0,U.jsx)(`img`,{src:un(e.id,`preview`),alt:e.name,className:`block max-h-[60vh] w-full rounded-[10px] border border-border bg-muted object-contain`})}):sn(e)?(0,U.jsx)(`pre`,{className:`m-0 max-h-[60vh] overflow-auto whitespace-pre-wrap break-words rounded-[10px] border border-border bg-muted p-3 font-mono text-xs leading-relaxed`,children:t.error?s(t.error):t.data??`Loading…`}):(0,U.jsxs)(`p`,{className:`m-0 rounded-[10px] border border-dashed border-border bg-muted/50 px-3 py-8 text-center text-sm text-muted-foreground`,children:[`No preview for `,ln(e.mimeType,e.name),` files. Download it to open it.`]})}var zo=`inline-flex h-[26px] shrink-0 items-center gap-1 rounded-full border border-border bg-muted px-2.5 text-xs font-semibold text-mocha hover:border-sapphire-light hover:text-sapphire`,Bo=`flex min-h-10 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-sm text-foreground outline-none data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;function Vo(e){let t=e.indexOf(`:`);return t>0?e.slice(t+1):e}function Ho({agent:e,chat:t,panel:n,lastPanel:r}){let{to:a}=k();return(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2.5 gap-y-2 border-b border-frost px-3 py-2.5 sm:px-4`,children:[(0,U.jsx)(i,{to:`/`,search:{},"aria-label":`Back to the list of agents`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border border-border text-mocha lg:hidden`,children:(0,U.jsx)(p,{className:`size-4`,"aria-hidden":`true`})}),(0,U.jsx)(Fe,{identity:e.agent.identity,size:32}),(0,U.jsx)(`h1`,{className:`m-0 min-w-0 truncate font-display text-[1.2rem] leading-tight text-charcoal`,children:e.agent.name}),(0,U.jsx)(i,{to:`/`,search:a({panel:`team`,section:void 0}),className:zo,children:e.team.name}),(0,U.jsxs)(i,{to:`/`,search:a({panel:`agent`,section:void 0}),title:`Model: ${e.model}`,className:Pe(zo,`hidden font-mono font-normal sm:inline-flex`),children:[Vo(e.model),(0,U.jsx)(ye,{className:`size-[11px]`,"aria-hidden":`true`})]}),(0,U.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1.5`,children:[(0,U.jsx)(Uo,{agentId:e.agent.id,chat:t}),(0,U.jsx)(i,{to:`/`,search:a({panel:n===`none`?r:`none`,section:void 0}),"aria-label":n===`none`?`Show the side panel`:`Hide the side panel`,title:n===`none`?`Show the side panel`:`Hide the side panel`,"aria-pressed":n!==`none`,className:`flex size-8 shrink-0 items-center justify-center rounded-[10px] border ${n===`none`?`border-border bg-card text-mocha hover:text-sapphire`:`border-primary/25 bg-accent text-accent-foreground`}`,children:(0,U.jsx)(N,{className:`size-4`,"aria-hidden":`true`})})]})]})}function Uo({agentId:e,chat:t}){let{search:n,to:a}=k(),{turnsEnded:o}=z(),l=r(),u=S(),d=`/api/agents/${encodeURIComponent(e)}/conversations`,[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),[_,y]=(0,H.useState)(``),b=M(e=>c(`${d}?limit=20`,{signal:e}),[d,o]),x=t?t.conversationsOpen:p,C=t?t.setConversationsOpen:m,w=b.data?.conversations??[],T=b.data?.selectedId??null,E=n.conversation??T,D=w.find(e=>e.id===E);async function O(){y(``);try{await c(d,{body:{}}),t?await t.reload():(await l.invalidate({sync:!0}),await l.navigate({to:`/`,search:a({conversation:void 0})})),await b.reload()}catch(e){y(s(e)),C(!0)}}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(be,{open:x,onOpenChange:e=>{C(e),e&&b.reload()},children:[(0,U.jsx)(L,{asChild:!0,children:(0,U.jsxs)(`button`,{type:`button`,"aria-label":`Conversations`,className:`unstyled inline-flex h-8 min-w-0 max-w-[15rem] items-center gap-1.5 rounded-[10px] border border-border bg-card px-2.5 text-[0.82rem] font-semibold text-foreground hover:border-sapphire-light`,children:[(0,U.jsx)(f,{className:`size-[15px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:D?.title??`Conversations`}),(0,U.jsx)(ye,{className:`size-3 shrink-0 text-mocha`,"aria-hidden":`true`})]})}),(0,U.jsx)(he,{children:(0,U.jsxs)(ve,{align:`end`,sideOffset:6,collisionPadding:12,className:`z-50 max-h-[70vh] w-[min(22rem,calc(100vw-1.5rem))] overflow-y-auto rounded-xl border border-border bg-popover p-1.5 text-popover-foreground shadow-baziu-lg outline-none`,children:[(0,U.jsx)(me,{className:`px-2.5 pb-1 pt-1.5 text-[0.7rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`,children:`Conversations`}),b.error&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 px-2.5 py-1.5 text-xs text-danger`,children:b.error}),_&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 px-2.5 py-1.5 text-xs text-danger`,children:_}),!b.data&&!b.error&&(0,U.jsx)(`p`,{role:`status`,className:`m-0 px-2.5 py-2 text-sm text-muted-foreground`,children:`Loading…`}),b.data&&w.length===0&&(0,U.jsx)(`p`,{className:`m-0 px-2.5 py-2 text-sm text-muted-foreground`,children:`The first message starts the first conversation.`}),w.map(e=>{let t=e.id===T,n=e.id===E;return(0,U.jsx)(pe,{asChild:!0,className:Bo,children:(0,U.jsxs)(i,{to:`/`,search:a({conversation:t?void 0:e.id}),"aria-current":n?`true`:void 0,className:n?`bg-accent/70 text-accent-foreground`:``,children:[(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.title}),t?(0,U.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-xs font-semibold text-success`,children:[(0,U.jsx)(ae,{className:`size-3`,"aria-hidden":`true`}),`Active`]}):u&&(0,U.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:fe(e.createdAt)})]})},e.id)}),b.data&&b.data.total>w.length&&(0,U.jsxs)(`p`,{className:`m-0 px-2.5 py-1.5 text-xs text-muted-foreground`,children:[`The newest `,w.length,` of `,b.data.total,`.`,` `,(0,U.jsx)(`code`,{children:`bazilion conversation list`}),` shows them all.`]}),(0,U.jsx)(Re,{className:`my-1.5 h-px bg-border`}),(0,U.jsxs)(pe,{className:`${Bo} font-semibold`,disabled:t?.agentBusy??!1,onSelect:()=>void O(),children:[(0,U.jsx)(ie,{className:`size-3.5`,"aria-hidden":`true`}),`New conversation`,t?.agentBusy&&(0,U.jsx)(`span`,{className:`ml-auto text-xs font-normal`,children:`after this turn`})]}),D&&(0,U.jsxs)(pe,{className:Bo,onSelect:()=>g(D),children:[(0,U.jsx)(v,{className:`size-3.5`,"aria-hidden":`true`}),`Rename “`,D.title.length>24?`${D.title.slice(0,24)}…`:D.title,`”`]})]})})]}),h&&(0,U.jsx)(Wo,{base:d,conversation:h,onClose:()=>g(null),onRenamed:()=>b.reload()})]})}function Wo({base:e,conversation:t,onClose:n,onRenamed:r}){let[i,a]=(0,H.useState)(t.title),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(``),p=!i.trim()||i.trim()===t.title;async function m(a){if(a.preventDefault(),!p){u(!0),f(``);try{await c(`${e}/${encodeURIComponent(t.id)}`,{method:`PATCH`,body:{title:i.trim()}}),await r(),n()}catch(e){f(s(e)),u(!1)}}}return(0,U.jsx)(le,{title:`Rename the conversation`,busy:l,onClose:n,className:`max-w-md`,children:(0,U.jsxs)(`form`,{onSubmit:e=>void m(e),children:[(0,U.jsxs)(`label`,{children:[`Title`,(0,U.jsx)(`input`,{autoFocus:!0,value:i,maxLength:200,onChange:e=>a(e.target.value)})]}),d&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:d}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsxs)(ue,{children:[(0,U.jsx)(o,{variant:`ghost`,disabled:l,onClick:n,children:`Cancel`}),(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:l||p,children:l?`Renaming…`:`Rename`})]})})]})})}function Go({agentId:e,agentName:t,conversationId:n,header:a}){let{to:l}=k(),d=r(),f=`/api/agents/${encodeURIComponent(e)}/conversations/${encodeURIComponent(n)}`,[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(``),_=M(async e=>{try{return await c(f,{signal:e})}catch(e){if(e instanceof u&&e.status===409)return{conversation:e.body.conversation??null,messages:null};throw e}},[f]);async function v(){m(!0),g(``);try{await c(`${f}/select`,{method:`POST`}),await d.invalidate({sync:!0}),await d.navigate({to:`/`,search:l({conversation:void 0})})}catch(e){g(s(e)),m(!1)}}let y=_.data?.conversation?.title;return(0,U.jsxs)(`section`,{"aria-label":`An earlier conversation with ${t}`,className:Mo,children:[a,(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-frost bg-muted px-4 py-2 text-sm`,children:[(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 basis-56 text-mocha`,children:[`You are reading`,` `,y?(0,U.jsx)(`strong`,{className:`text-foreground`,children:y}):`an earlier conversation`,`. New messages go to the active conversation.`]}),(0,U.jsx)(o,{variant:`primary`,className:`min-h-9`,disabled:p||!_.data?.messages,onClick:()=>void v(),children:p?`Switching…`:`Continue this conversation`}),(0,U.jsx)(i,{to:`/`,search:l({conversation:void 0}),className:`ghost-btn min-h-9`,children:`Back to the active one`})]}),h&&(0,U.jsx)(`p`,{role:`alert`,className:`m-0 px-5 pt-3 text-sm text-danger`,children:h}),(0,U.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,U.jsxs)(`div`,{className:`mx-auto max-w-[50rem]`,children:[_.error&&(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_.error}),!_.data&&!_.error&&(0,U.jsx)(`p`,{role:`status`,className:`text-sm text-mocha`,children:`Loading the conversation…`}),_.data&&(_.data.messages===null?(0,U.jsx)(`p`,{role:`alert`,className:`text-sm`,children:`This conversation's history is unavailable, so it cannot be read or continued.`}):_.data.messages.length>0?(0,U.jsx)(yo,{messages:_.data.messages}):(0,U.jsx)(`p`,{className:`py-12 text-center italic text-mocha-light`,children:`This conversation is empty.`}))]})})]})}function Ko({status:e}){return(0,U.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-1 gap-x-4 gap-y-2 text-sm sm:grid-cols-[max-content_minmax(0,1fr)]`,children:[(0,U.jsx)(`dt`,{className:`font-medium text-mocha`,children:`Browser tools`}),(0,U.jsx)(`dd`,{children:e.enabled?`Enabled`:`Disabled`}),(0,U.jsx)(`dt`,{className:`font-medium text-mocha`,children:`Session`}),(0,U.jsx)(`dd`,{children:e.running?`Running`:`Stopped`}),(0,U.jsx)(`dt`,{className:`font-medium text-mocha`,children:`Profile`}),(0,U.jsx)(`dd`,{children:e.profilePresent?`Saved (cookies and logins)`:`None yet`}),(0,U.jsx)(`dt`,{className:`font-medium text-mocha`,children:`Browser`}),(0,U.jsx)(`dd`,{className:`break-words`,children:e.browser?`${e.browser.name} · ${e.browser.mode}`:`None found`})]})}function qo({agentId:e}){let t=`/api/agents/${encodeURIComponent(e)}/browser`,[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(!0),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(!1),h=(0,H.useCallback)(async()=>{a(!0);try{r(await c(t))}catch(e){f(s(e))}finally{a(!1)}},[t]),g=(0,H.useCallback)(()=>{f(null),h()},[h]);(0,H.useEffect)(()=>{g()},[g]);async function _(e){u(e),f(null);try{e===`stop`?await c(`${t}/stop`,{method:`POST`}):await c(`${t}/profile`,{method:`DELETE`})}catch(e){f(s(e))}finally{await h(),u(null)}}let v=l!==null||i;return(0,U.jsxs)(B,{title:`Managed browser`,description:`This Agent's own persistent browser, used by its browser_* tools.`,actions:(0,U.jsx)(o,{variant:`ghost`,disabled:v,onClick:g,children:i?`Refreshing…`:`Refresh status`}),children:[(0,U.jsxs)(`div`,{className:`space-y-4`,children:[i&&!n&&(0,U.jsx)(`p`,{role:`status`,children:`Loading browser status…`}),n&&(0,U.jsx)(Ko,{status:n}),n?.error&&(0,U.jsx)(`p`,{className:`whitespace-pre-wrap break-words rounded-md bg-fawn/35 p-3 text-sm text-chocolate`,children:n.error}),d&&(0,U.jsx)(`p`,{role:`alert`,className:`err break-words`,children:d}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`ghost`,disabled:v||!n?.running,onClick:()=>void _(`stop`),children:l===`stop`?`Stopping…`:`Stop session`}),(0,U.jsx)(o,{variant:`danger`,disabled:v||!n?.profilePresent&&!n?.running,onClick:()=>m(!0),children:`Reset profile`})]}),(0,U.jsx)(`p`,{className:`text-xs leading-5 text-mocha-light`,children:`Stopping, archiving and moving the Agent to another Team keep the profile; Reset and deleting the Agent remove it. Browser profiles are not included in backups.`})]}),(0,U.jsx)(F,{open:p,onOpenChange:m,title:`Reset this Agent's browser profile?`,description:(0,U.jsx)(`p`,{children:`This stops the browser and permanently deletes this Agent's profile, including cookies and logins.`}),confirmLabel:`Delete profile`,onConfirm:()=>_(`reset`)})]})}function Jo({agentId:e,attached:t,all:n}){let i=r(),[a,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(null),g=`/api/agents/${encodeURIComponent(e)}/skills`;async function _(e,t){l(e),d(null);try{await t(),await i.invalidate()}catch(e){throw d(s(e)),e}finally{l(null)}}let v=e=>_(e.name,()=>c(g,{body:{skill:e.name,allowFindings:(e.scanFindings??[]).length>0}})),y=e=>_(e,()=>c(`${g}/${encodeURIComponent(e)}`,{method:`DELETE`}));return n.length===0?(0,U.jsx)(`p`,{className:`text-[0.9em] text-mocha-light`,children:`No skills installed.`}):(0,U.jsxs)(U.Fragment,{children:[u&&(0,U.jsx)(`p`,{role:`alert`,className:`mb-2 text-[0.85em] text-danger`,children:u}),(0,U.jsx)(Ne,{children:n.map(e=>{let n=t.has(e.name),r=a===e.name,i=e.scanFindings??[];return(0,U.jsx)(Oe,{title:(0,U.jsx)(`code`,{children:e.name}),meta:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(je,{variant:n?`success`:`neutral`,children:n?`Attached`:`Available`}),(0,U.jsx)(`span`,{children:e.description||`No description.`}),(0,U.jsx)(Ke,{findings:i})]}),actions:n?(0,U.jsx)(o,{variant:`ghost`,disabled:r,onClick:()=>h(e.name),children:r?`Detaching…`:`Detach`}):(0,U.jsx)(o,{variant:`ghost`,disabled:r,onClick:()=>i.length>0?p(e):void v(e).catch(()=>{}),children:r?`Attaching…`:`Attach`})},e.name)})}),(0,U.jsx)(F,{open:f!==null,onOpenChange:e=>{e||p(null)},title:`Attach ${f?.name??`skill`} despite scan findings?`,description:(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsxs)(`p`,{children:[`Static scanning found `,f?.scanFindings?.length??0,` potentially unsafe instruction`,f?.scanFindings?.length===1?``:`s`,`. Review them before allowing this skill into the Agent's prompt.`]}),(0,U.jsx)(qe,{findings:f?.scanFindings??[]})]}),confirmLabel:`Attach despite findings`,onConfirm:async()=>{f&&await v(f)}}),(0,U.jsx)(F,{open:m!==null,onOpenChange:e=>{e||h(null)},title:`Detach ${m??`skill`}?`,description:(0,U.jsx)(`p`,{children:`This removes the skill's instructions from this Agent's future turns. It does not uninstall the skill, and you can attach it again later.`}),confirmLabel:`Detach skill`,onConfirm:async()=>{m&&await y(m)}})]})}function Yo({agent:e}){let t=r(),[n,i]=(0,H.useState)(!1),[a,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(e.telegramMirrorMode),[f,p]=(0,H.useState)(e.telegramIconEmoji??``),[m,h]=(0,H.useState)(!1),g=`/api/agents/${encodeURIComponent(e.id)}`,_=e.telegramTopicId!==null;async function v(e){i(!0),l(null);try{await e(),await t.invalidate()}catch(e){throw l(s(e)),e}finally{i(!1)}}async function y(){await v(async()=>{let{deepLink:e}=await c(`${g}/telegram/bind`,{method:`POST`});window.open(e,`_blank`,`noopener`)}).catch(()=>{})}async function b(t){d(t),await v(()=>c(g,{method:`PATCH`,body:{telegramMirrorMode:t}})).catch(()=>d(e.telegramMirrorMode))}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`text-[0.9em]`,children:[(0,U.jsx)(`div`,{className:`mb-3 flex flex-wrap items-center gap-3`,children:_?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`rounded-full bg-success/10 px-2 py-0.5 text-xs font-semibold text-success`,children:`bound`}),(0,U.jsxs)(`span`,{className:`font-mono text-mocha`,children:[`topic #`,e.telegramTopicId]}),(0,U.jsx)(o,{variant:`ghost`,onClick:()=>void y(),disabled:n,children:`Open in Telegram`}),(0,U.jsx)(o,{variant:`danger`,onClick:()=>h(!0),disabled:n,children:`Unbind`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`rounded-full bg-warning/10 px-2 py-0.5 text-xs font-semibold text-warning`,children:`unbound`}),(0,U.jsx)(o,{variant:`ghost`,onClick:()=>void y(),disabled:n,children:n?`Binding…`:`Bind a topic`})]})}),(0,U.jsxs)(`label`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[(0,U.jsx)(`span`,{className:`text-mocha-light`,children:`Mirror mode`}),(0,U.jsxs)(`select`,{value:u,onChange:e=>void b(e.target.value),className:`sm:max-w-sm`,disabled:n,children:[(0,U.jsx)(`option`,{value:`minimal`,children:`minimal — assistant messages only`}),(0,U.jsx)(`option`,{value:`verbose`,children:`verbose — also tool calls`})]})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,U.jsxs)(`label`,{className:`m-0`,children:[`Topic icon`,(0,U.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),placeholder:`(template default)`,maxLength:8,className:`w-40 font-mono`,disabled:n})]}),(0,U.jsx)(o,{variant:`ghost`,onClick:()=>void v(()=>c(g,{method:`PATCH`,body:{telegramIconEmoji:f.trim()||null}})).catch(()=>{}),disabled:n||f===(e.telegramIconEmoji??``),children:`Save icon`})]}),a&&(0,U.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:a}),(0,U.jsx)(`p`,{className:`mt-3 text-[0.85em] text-mocha-light`,children:`While bound, every assistant turn of this Agent is mirrored to the topic, and a message in the topic starts a turn. On iOS, Telegram opens the topic list instead of the topic.`})]}),(0,U.jsx)(F,{open:m,onOpenChange:h,title:`Unbind ${e.name} from Telegram?`,description:(0,U.jsx)(`p`,{children:`Telegram ingress and mirroring stop for this Agent. The forum topic stays in Telegram until you remove it there.`}),confirmLabel:`Unbind Telegram topic`,onConfirm:()=>v(()=>c(`${g}/telegram/binding`,{method:`DELETE`}))})]})}function Xo({agent:e}){let t=`/api/agents/${encodeURIComponent(e.id)}`,n=M(async e=>{let[n,r,i]=await Promise.all([c(`${t}/review-config`,{signal:e}),c(`${t}/reviews`,{signal:e}),c(`${t}/lesson-proposals`,{signal:e})]);return{config:n,reviews:r.reviews,proposals:i.proposals}},[t]),[r,i]=(0,H.useState)(null),[a,l]=(0,H.useState)(!1),u=async(e,t)=>{i(null),l(!0);try{await c(e,t),await n.reload()}catch(e){throw i(s(e)),e}finally{l(!1)}};if(!n.data)return n.error?(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:n.error}):(0,U.jsx)(`p`,{role:`status`,className:`muted`,children:`Loading reviewed learning…`});let{config:d,reviews:f,proposals:p}=n.data;return(0,U.jsxs)(`div`,{className:`space-y-6`,children:[r&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:r}),(0,U.jsxs)(B,{title:`Reviewed learning`,description:(0,U.jsxs)(U.Fragment,{children:[`A review reads at most 8 successful user turns and 40,000 characters with`,` `,d.model??`the Agent model`,` at `,d.reasoningLevel,` reasoning and proposes at most five lessons. Nothing is applied until you approve it.`]}),children:[(0,U.jsx)(Zo,{config:d,disabled:a,onSave:e=>u(`${t}/review-config`,{method:`PATCH`,body:e})}),(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,disabled:a||e.status===`archived`,onClick:()=>void u(`${t}/reviews`,{method:`POST`}).catch(()=>{}),children:`Review now`}),!d.enabled&&(0,U.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Periodic review is off; Review now still works.`})]})]}),(0,U.jsx)(B,{title:`Lesson proposals`,children:p.length===0?(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:`No proposals yet. A successful review may also produce none.`}):(0,U.jsx)(`div`,{className:`grid gap-3`,children:p.map(e=>(0,U.jsx)(Qo,{proposal:e,base:`${t}/lesson-proposals/${encodeURIComponent(e.id)}`,busy:a,act:u},e.id))})}),(0,U.jsx)(B,{title:`Review history`,children:f.length===0?(0,U.jsx)(`p`,{className:`text-muted-foreground`,children:`No reviews have been queued.`}):(0,U.jsx)(Ne,{children:f.map(e=>(0,U.jsx)(Oe,{title:new Date(e.createdAt).toLocaleString(),meta:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`code`,{children:e.status}),(0,U.jsx)(`span`,{children:e.trigger}),(0,U.jsxs)(`span`,{children:[e.turnsReviewed,` turns`]}),(0,U.jsxs)(`span`,{children:[e.proposalCount,` proposals`]})]}),children:e.lastError&&(0,U.jsx)(`p`,{className:`mb-0 mt-1 break-words text-sm text-danger`,children:e.lastError})},e.id))})})]})}function Zo({config:e,disabled:t,onSave:n}){let[r,i]=(0,H.useState)(e.enabled),[a,s]=(0,H.useState)(e.everyNTurns),[c,l]=(0,H.useState)(e.model??``),[u,d]=(0,H.useState)(e.reasoningLevel);return(0,U.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n({enabled:r,everyNTurns:a,model:c.trim()||null,reasoningLevel:u}).catch(()=>{})},className:`grid items-end gap-x-3 md:grid-cols-4`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked)}),`Periodic review`]}),(0,U.jsxs)(`label`,{children:[`Every N turns`,(0,U.jsx)(`input`,{type:`number`,min:1,max:100,value:a,onChange:e=>s(Number(e.target.value))})]}),(0,U.jsxs)(`label`,{children:[`Model override`,(0,U.jsx)(`input`,{value:c,placeholder:`the Agent model`,onChange:e=>l(e.target.value)})]}),(0,U.jsxs)(`label`,{children:[`Reasoning`,(0,U.jsx)(`select`,{value:u,onChange:e=>d(e.target.value),children:ze.map(e=>(0,U.jsx)(`option`,{children:e},e))})]}),(0,U.jsx)(`div`,{className:`md:col-span-4`,children:(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:t,children:`Save learning settings`})})]})}function Qo({proposal:e,base:t,busy:n,act:r}){let[i,a]=(0,H.useState)(e.text),[s,c]=(0,H.useState)(e.scope),[l,u]=(0,H.useState)(null),d={version:e.version},f=e.text.length>54?`${e.text.slice(0,51)}…`:e.text;return(0,U.jsxs)(`article`,{className:`rounded-lg border bg-card p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex justify-between gap-2`,children:[(0,U.jsx)(`code`,{children:e.status}),(0,U.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`v`,e.version]})]}),e.status===`pending`?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`label`,{children:[`Proposed lesson`,(0,U.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value)})]}),(0,U.jsxs)(`label`,{children:[`Apply the approved lesson to`,(0,U.jsxs)(`select`,{value:s,onChange:e=>c(e.target.value),children:[(0,U.jsx)(`option`,{value:`private`,children:`private Agent behavior`}),(0,U.jsx)(`option`,{value:`shared`,children:`shared Team knowledge`})]})]}),s===`shared`&&(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Shared lessons become searchable Team memory. Stable facts about you belong in the Team's USER.md instead.`}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,U.jsx)(o,{variant:`ghost`,disabled:n,onClick:()=>void r(t,{method:`PATCH`,body:{...d,text:i,scope:s}}).catch(()=>{}),children:`Save edit`}),(0,U.jsx)(o,{variant:`primary`,disabled:n,onClick:()=>void r(`${t}/approve`,{body:d}).catch(()=>{}),children:`Approve`}),(0,U.jsx)(o,{variant:`danger`,disabled:n,onClick:()=>u(`reject`),children:`Reject`})]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{children:e.text}),e.status===`approved`&&(0,U.jsx)(`div`,{className:`mt-3`,children:(0,U.jsx)(o,{variant:`danger`,disabled:n,onClick:()=>u(`revoke`),children:`Revoke`})})]}),(0,U.jsxs)(`div`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Evidence:`,` `,e.evidence.length===0?`none`:(0,U.jsx)(`ul`,{className:`mt-1 list-disc pl-5`,children:e.evidence.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsxs)(`code`,{children:[e.sessionId,`:`,e.entryOrdinal]}),e.excerpt?` — ${e.excerpt}`:` — excerpt unavailable`]},`${e.sessionId}:${e.entryOrdinal}`))})]}),l&&(0,U.jsx)(F,{open:!0,title:l===`reject`?`Reject “${f}”?`:`Revoke “${f}”?`,description:l===`reject`?(0,U.jsx)(`p`,{children:`The proposal is marked rejected and never changes the Agent's prompts or Team memory; unsaved edits are discarded. A rejected proposal cannot be edited or approved later.`}):e.scope===`shared`?(0,U.jsx)(`p`,{children:`The lesson note is removed from Team memory, so Team-memory search no longer finds it. The proposal stays in the review history.`}):(0,U.jsx)(`p`,{children:`The lesson is removed from the Agent's future prompts; past conversations are not rewritten. The proposal stays in the review history.`}),confirmLabel:l===`reject`?`Reject proposal`:`Revoke lesson`,onOpenChange:e=>{e||u(null)},onConfirm:()=>r(`${t}/${l}`,{body:d})})]})}function $o({agent:e,agents:t}){let n=`/api/agents/${encodeURIComponent(e.id)}`,r=M(async e=>{let[t,r]=await Promise.all([c(`${n}/messages`,{signal:e}),c(`${n}/loop-breaks?limit=10`,{signal:e})]);return{messages:[...t.messages].reverse(),loopBreaks:r.events}},[n]);return r.data?(0,U.jsx)(es,{agent:e,agents:t,...r.data,onChanged:r.reload}):r.error?(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:r.error}):(0,U.jsx)(`p`,{role:`status`,className:`muted`,children:`Loading the mailbox…`})}function es({agent:e,agents:t,messages:n,loopBreaks:r,onChanged:i}){let[a,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(()=>n.find(e=>e.readAt===null)?.id??null),[f,p]=(0,H.useState)(null),m=n.filter(e=>e.readAt===null).length,h=a?n.filter(e=>e.readAt===null):n,g=n.find(e=>e.id===u)??null,_=Object.fromEntries(t.map(e=>[e.id,e.name])),v=t.filter(t=>t.status!==`archived`&&t.id!==e.id).map(e=>({id:e.id,name:e.name})),y=e=>_[e]?`${_[e]} (${e.slice(0,8)})`:e.slice(0,8),b=e=>`unstyled -mb-px border-b-2 px-3 py-1.5 text-sm ${e?`border-primary font-semibold text-primary`:`border-transparent text-muted-foreground`}`;return(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-[360px_1fr]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`mb-3 flex items-center gap-1 border-b`,children:[(0,U.jsx)(`button`,{type:`button`,"aria-pressed":!a,onClick:()=>l(!1),className:b(!a),children:`All`}),(0,U.jsx)(`button`,{type:`button`,"aria-pressed":a,onClick:()=>l(!0),className:b(a),children:`Unread`}),(0,U.jsxs)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:[m,` unread`]})]}),(0,U.jsx)(`div`,{className:`max-h-[60dvh] overflow-y-auto rounded-lg border bg-card`,children:h.length===0?(0,U.jsx)(`div`,{className:`p-6 text-center italic text-muted-foreground`,children:a?`Nothing unread.`:`No messages yet.`}):h.map(e=>{let t=A(e.payload),n=e.readAt===null;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{p(null),d(e.id)},className:`unstyled block w-full border-b px-3 py-2 text-left text-sm last:border-0 hover:bg-accent/30 ${g?.id===e.id?`bg-accent/40`:``} ${n?`font-medium`:``}`,children:[(0,U.jsxs)(`div`,{className:`flex justify-between text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{className:`font-mono`,children:[n&&(0,U.jsx)(`span`,{className:`mr-1.5 inline-block h-1.5 w-1.5 rounded-full bg-primary align-middle`}),`from `,y(e.fromAgentId)]}),(0,U.jsx)(`span`,{className:`font-mono`,children:new Date(e.createdAt).toLocaleString()})]}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate text-foreground`,children:t.length>80?`${t.slice(0,80)}…`:t})]},e.id)})})]}),(0,U.jsxs)(`div`,{children:[g&&(0,U.jsxs)(`div`,{className:`mb-4 rounded-lg border bg-card p-5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 space-y-0.5 font-mono text-xs text-muted-foreground`,children:[(0,U.jsxs)(`div`,{children:[`id: `,(0,U.jsx)(`code`,{children:g.id})]}),(0,U.jsxs)(`div`,{children:[`from: `,(0,U.jsx)(`code`,{children:y(g.fromAgentId)})]}),(0,U.jsxs)(`div`,{children:[`received: `,new Date(g.createdAt).toLocaleString()]}),(0,U.jsxs)(`div`,{children:[`read: `,g.readAt?new Date(g.readAt).toLocaleString():`(unread)`,!g.readAt&&(0,U.jsx)(o,{variant:`ghost`,className:`ml-2`,onClick:async()=>{p(null);try{await c(`/api/messages/${encodeURIComponent(g.id)}`,{method:`PATCH`,body:{read:!0}}),await i()}catch(e){p(s(e))}},children:`Mark read`}),f&&(0,U.jsx)(`span`,{role:`alert`,className:`ml-2 text-danger`,children:f})]}),g.replyTo&&(0,U.jsxs)(`div`,{children:[`reply to: `,(0,U.jsx)(`code`,{children:g.replyTo})]})]}),(0,U.jsx)(`div`,{className:`whitespace-pre-wrap break-words border-t pt-3 font-mono text-sm`,children:A(g.payload)})]}),(0,U.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Agents exchange messages with their `,(0,U.jsx)(`code`,{className:`font-mono`,children:`send_message`}),` tool; an idle recipient picks up unread mail on the next scheduler tick.`]}),(0,U.jsx)(ts,{agentId:e.id,senders:v,onSent:()=>void i()}),(0,U.jsxs)(`div`,{className:`mt-6 rounded-lg border bg-card p-4`,children:[(0,U.jsx)(`h2`,{className:`mb-2 font-serif text-lg text-foreground`,children:`Loop circuit breaker`}),r.length===0?(0,U.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No agent-message chains stopped.`}):(0,U.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,U.jsxs)(`div`,{className:`border-t pt-3 text-xs first:border-0 first:pt-0`,children:[(0,U.jsxs)(`div`,{className:`font-mono text-foreground`,children:[y(e.fromAgentId),` → `,y(e.toAgentId)]}),(0,U.jsxs)(`div`,{className:`mt-1 text-muted-foreground`,children:[`stopped hop `,e.attemptedHop,` at limit `,e.maxHops,` · chain`,` `,(0,U.jsx)(`code`,{children:e.causalChainId.slice(0,8)}),` ·`,` `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]})]})}function ts({agentId:e,senders:t,onSent:n}){let[r,i]=(0,H.useState)(t[0]?.id??``),[a,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(!1);if(t.length===0)return null;async function m(t){t.preventDefault(),d(null),p(!0);try{let t={from:r,payload:{text:a}};await c(`/api/agents/${encodeURIComponent(e)}/messages`,{body:t}),l(``),n()}catch(e){d(s(e))}finally{p(!1)}}return(0,U.jsxs)(`form`,{onSubmit:e=>void m(e),className:`mt-6 rounded-lg border bg-card p-4`,children:[(0,U.jsx)(`h2`,{className:`mb-2 font-serif text-lg text-foreground`,children:`Send a message to this Agent`}),(0,U.jsxs)(`label`,{children:[`From`,(0,U.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:t.map(e=>(0,U.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id.slice(0,8),`)`]},e.id))})]}),(0,U.jsxs)(`label`,{children:[`Message`,(0,U.jsx)(`textarea`,{required:!0,value:a,onChange:e=>l(e.target.value),className:`min-h-[80px] font-mono text-[0.9em]`})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:f,children:f?`Sending…`:`Send`}),u&&(0,U.jsx)(`span`,{role:`alert`,className:`text-[0.85em] text-danger`,children:u})]})]})}function ns({agent:e}){let t=`/api/agents/${encodeURIComponent(e.id)}/triggers`,n=M(e=>c(t,{signal:e}),[t]);return n.data?(0,U.jsx)(rs,{agentId:e.id,...n.data,onChanged:n.reload}):n.error?(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:n.error}):(0,U.jsx)(`p`,{role:`status`,className:`muted`,children:`Loading the schedules…`})}function rs({agentId:e,triggers:t,dispatches:n,onChanged:r}){let[i,a]=(0,H.useState)(null),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null);async function p(e){f(e.id),u(null);try{await c(`/api/triggers/${encodeURIComponent(e.id)}`,{method:`PATCH`,body:{enabled:!e.enabled}}),await r()}catch(e){u(s(e))}finally{f(null)}}return(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsx)(is,{agentId:e,onAdded:()=>void r()}),l&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:l}),(0,U.jsx)(B,{title:`Triggers`,children:t.length===0?(0,U.jsx)(`p`,{className:`muted`,children:`No triggers yet; add one above.`}):(0,U.jsx)(Ne,{children:t.map(e=>(0,U.jsx)(Oe,{className:e.enabled?``:`opacity-60`,title:(0,U.jsx)(`code`,{children:e.kind===`interval`?`every ${e.intervalSec}s`:e.cronExpr}),meta:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{children:e.kind}),(0,U.jsxs)(`span`,{children:[`last fired`,` `,e.lastFiredAt?new Date(e.lastFiredAt).toLocaleString():`never`]}),(0,U.jsx)(`code`,{className:`break-all`,children:e.id})]}),actions:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(o,{variant:`ghost`,disabled:d===e.id,onClick:()=>void p(e),children:d===e.id?`Working…`:e.enabled?`Disable`:`Enable`}),(0,U.jsx)(o,{variant:`danger`,disabled:d===e.id,onClick:()=>a(e),children:`Delete`})]}),children:(0,U.jsx)(`p`,{className:`mb-0 mt-2 whitespace-pre-wrap break-words text-sm`,children:e.message})},e.id))})}),(0,U.jsx)(B,{title:`Recent runs`,children:n.length===0?(0,U.jsx)(`p`,{className:`muted`,children:`No scheduled occurrences yet.`}):(0,U.jsx)(Ne,{children:n.map(e=>(0,U.jsx)(Oe,{title:new Date(e.scheduledAt).toLocaleString(),meta:(0,U.jsx)(`code`,{children:e.status}),children:e.error&&(0,U.jsx)(`p`,{className:`mb-0 mt-1 break-words text-sm text-danger`,children:e.error})},e.id))})}),(0,U.jsx)(F,{open:i!==null,title:`Delete ${i?.kind??``} trigger?`,description:(0,U.jsxs)(`p`,{children:[`This permanently removes trigger `,(0,U.jsx)(`code`,{className:`font-mono`,children:i?.id}),`, its run history, and every future scheduled occurrence. The Agent itself is not deleted.`]}),confirmLabel:`Delete trigger and history`,onConfirm:async()=>{i&&(await c(`/api/triggers/${encodeURIComponent(i.id)}`,{method:`DELETE`}),await r())},onOpenChange:e=>{e||a(null)}})]})}function is({agentId:e,onAdded:t}){let[n,r]=(0,H.useState)(`interval`),[i,a]=(0,H.useState)(300),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(``),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(!1);async function _(r){r.preventDefault(),m(null),g(!0);try{let r=n===`interval`?{kind:n,intervalSec:i,message:d.trim()}:{kind:n,cronExpr:l.trim(),message:d.trim()};await c(`/api/agents/${encodeURIComponent(e)}/triggers`,{body:r}),f(``),u(``),a(300),t()}catch(e){m(s(e))}finally{g(!1)}}return(0,U.jsx)(B,{title:`Add trigger`,children:(0,U.jsxs)(`form`,{onSubmit:e=>void _(e),children:[(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap gap-4`,children:[(0,U.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,U.jsx)(`input`,{type:`radio`,checked:n===`interval`,onChange:()=>r(`interval`)}),`interval (every N seconds)`]}),(0,U.jsxs)(`label`,{className:`m-0 inline-flex cursor-pointer items-center gap-1`,children:[(0,U.jsx)(`input`,{type:`radio`,checked:n===`cron`,onChange:()=>r(`cron`)}),`cron (5-field)`]})]}),n===`interval`?(0,U.jsxs)(`label`,{children:[`Interval (seconds)`,(0,U.jsx)(`input`,{type:`number`,min:1,required:!0,value:i,onChange:e=>a(Number(e.target.value))})]}):(0,U.jsxs)(`label`,{children:[`Cron expression (minute hour day-of-month month day-of-week)`,(0,U.jsx)(`input`,{type:`text`,required:!0,placeholder:`*/15 * * * *`,value:l,onChange:e=>u(e.target.value)})]}),(0,U.jsxs)(`label`,{children:[`Message`,(0,U.jsx)(`textarea`,{required:!0,placeholder:`e.g. check your inbox and act on anything new`,value:d,onChange:e=>f(e.target.value),className:`min-h-[80px] font-mono text-[0.9em]`})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,type:`submit`,disabled:h,children:h?`Adding…`:`Add trigger`}),p&&(0,U.jsx)(`span`,{role:`alert`,className:`text-[0.85em] text-danger`,children:p})]})]})})}var as=e=>({key:e.key,preview:e.content.slice(0,80)});function os({team:e,openKey:t}){let n=`/api/teams/${encodeURIComponent(e.id)}/memory`,r=e=>`${n}/${e.split(`/`).map(encodeURIComponent).join(`/`)}`,[i,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(``),[m,h]=(0,H.useState)(null),[g,_]=(0,H.useState)(`none`),[v,y]=(0,H.useState)(``),[b,x]=(0,H.useState)(``),[S,C]=(0,H.useState)({key:``,content:``}),[w,T]=(0,H.useState)(null),[E,D]=(0,H.useState)(null),O=g!==`none`&&(v!==S.key||b!==S.content);async function k(e){try{e.trim()?(l((await c(`${n}/search?q=${encodeURIComponent(e)}&limit=50`)).map(e=>({key:e.key,preview:e.snippet,score:e.score}))),d(!0)):(l((await c(n)).map(as)),d(!1))}catch(e){T({message:s(e),error:!0})}}(0,H.useEffect)(()=>{let e=setTimeout(()=>void k(f),200);return()=>clearTimeout(e)},[f]),(0,H.useEffect)(()=>{t&&ee(t)},[t]);function A(e,t,n){_(e),h(e===`edit`?t:null),y(t),x(n),C({key:t,content:n})}async function ee(e){T({message:`Loading…`,error:!1});try{let t=await c(r(e));A(`edit`,t.key,t.content??``),T(null)}catch(e){T({message:s(e),error:!0})}}function te(e,t){if(!O){e();return}D({title:`Discard unsaved memory changes?`,description:(0,U.jsxs)(`p`,{children:[`Your changes to`,` `,(0,U.jsx)(`code`,{className:`font-mono`,children:m??(v||`the new entry`)}),` will be lost.`]}),confirmLabel:t,onConfirm:e})}async function j(){let e=v.trim();try{await c(r(e),{method:`PUT`,body:{content:b}}),A(`edit`,e,b),T({message:`Saved`,error:!1}),await k(f)}catch(e){T({message:s(e),error:!0})}}async function M(e){await c(r(e),{method:`DELETE`}),A(`none`,``,``),T({message:`${e} deleted`,error:!1}),await k(f)}return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(a,{when:O,subject:`Team memory draft`}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-[320px_1fr]`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-[16px] border border-frost bg-snow`,children:[(0,U.jsx)(`div`,{className:`border-b border-frost p-2`,children:(0,U.jsx)(`input`,{"aria-label":`Search Team memory`,type:`search`,placeholder:`Search the notes`,autoComplete:`off`,value:f,onChange:e=>p(e.target.value)})}),(0,U.jsx)(`div`,{className:`max-h-[46dvh] overflow-y-auto`,children:i.length===0?(0,U.jsx)(`div`,{className:`p-8 text-center text-mocha-light`,children:u?`No note matches.`:`No notes yet.`}):i.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{(g!==`edit`||e.key!==m)&&te(()=>ee(e.key),`Discard and open`)},className:`unstyled block w-full cursor-pointer border-b border-frost/50 px-3.5 py-2 text-left font-mono text-[0.84em] transition-colors last:border-b-0 hover:bg-sapphire-glow ${e.key===m?`bg-sapphire-glow font-medium text-sapphire-deep`:``}`,children:[u&&e.score!==void 0&&(0,U.jsx)(`span`,{className:`float-right text-[0.75em] text-sapphire`,children:e.score.toFixed(2)}),e.key,e.preview&&(0,U.jsx)(`span`,{className:`mt-1 block text-[0.9em] font-normal text-mocha-light`,children:e.preview})]},e.key))})]}),(0,U.jsx)(o,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>te(()=>{A(`new`,``,``),T({message:`New entry: type a key and content, then save.`,error:!1})},`Discard and create new`),children:`New note`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`input`,{"aria-label":`Memory entry key`,type:`text`,placeholder:`key (e.g. prefs/hiking.md)`,value:v,onChange:e=>y(e.target.value),disabled:g!==`new`,className:`mb-3 font-mono`}),(0,U.jsx)(`textarea`,{"aria-label":`Memory entry content`,placeholder:`Select an entry on the left, or create a new one.`,value:b,onChange:e=>x(e.target.value),disabled:g===`none`,className:`min-h-[40dvh] font-mono text-[0.9em] leading-[1.55]`}),(0,U.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,U.jsx)(o,{variant:`primary`,onClick:()=>void j(),disabled:g===`none`||!v.trim()||!O,children:`Save`}),(0,U.jsx)(o,{variant:`danger`,disabled:g!==`edit`||m===null,onClick:()=>{let e=m;e&&D({title:`Delete ${e}?`,description:(0,U.jsxs)(`p`,{children:[`This permanently deletes `,(0,U.jsx)(`code`,{className:`font-mono`,children:e}),` from the Team's shared memory and its search results.`]}),confirmLabel:`Delete memory entry`,onConfirm:()=>M(e)})},children:`Delete`})]}),w&&(0,U.jsx)(`p`,{role:w.error?`alert`:`status`,className:`mt-2 text-[0.9em] ${w.error?`text-danger`:`text-mocha-light`}`,children:w.message})]})]}),(0,U.jsx)(F,{open:E!==null,title:E?.title??``,description:E?.description??null,confirmLabel:E?.confirmLabel??`Continue`,onConfirm:()=>E?.onConfirm(),onOpenChange:e=>{e||D(null)}})]})}function ss(e,t){return{image:e.trim()||null,cwd:t.trim()||`.`}}function cs({teamId:e}){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(``),[a,l]=(0,H.useState)(`.`),[u,d]=(0,H.useState)(``),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(!1),g=`/api/teams/${encodeURIComponent(e)}/coding-environment`;function _(e){n(e),i(e.image??``),l(e.cwd)}(0,H.useEffect)(()=>{let e=new AbortController;return c(g,{signal:e.signal}).then(_).catch(t=>{e.signal.aborted||d(s(t))}),()=>e.abort()},[g]);async function v(e){e.preventDefault(),h(!0),d(``),p(!1);try{_(await c(g,{method:`PUT`,body:ss(r,a)})),p(!0)}catch(e){d(s(e))}finally{h(!1)}}return(0,U.jsxs)(`details`,{children:[(0,U.jsx)(`summary`,{className:`cursor-pointer text-sm`,children:`Docker sandbox defaults`}),(0,U.jsxs)(`p`,{className:`my-3 text-sm text-muted-foreground`,children:[`Image and working directory for this Team's bash commands when BAZILION_BASH_SANDBOX is docker`,t?` (currently ${t.sandboxMode})`:``,`. The image must already exist locally; Bazilion never pulls it.`]}),u&&(0,U.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:u}),t&&(0,U.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>void v(e),children:[(0,U.jsxs)(`label`,{children:[`Local Docker image`,(0,U.jsx)(`input`,{value:r,placeholder:`${t.defaultImage} (installation default)`,onChange:e=>i(e.target.value)})]}),(0,U.jsxs)(`label`,{children:[`Working directory inside the Team`,(0,U.jsx)(`input`,{required:!0,value:a,onChange:e=>l(e.target.value)})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(o,{type:`submit`,variant:`primary`,disabled:m,children:m?`Saving…`:`Save defaults`}),f&&(0,U.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`})]})]})]})}function ls({team:e,sampleAgent:t}){return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(B,{title:`Workspace`,description:`Where this Team's Agents read and write files.`,children:[(0,U.jsxs)(`p`,{className:`m-0 flex min-w-0 items-center gap-1.5 text-sm`,children:[(0,U.jsx)(`code`,{className:`min-w-0 break-all`,children:e.path}),(0,U.jsx)(Qt,{value:e.path,ariaLabel:`Copy the workspace path`,title:`Copy the path`})]}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsx)(cs,{teamId:e.id})})]}),(0,U.jsx)(us,{team:e,sampleAgent:t}),(0,U.jsx)(ds,{teamId:e.id})]})}function us({team:e,sampleAgent:t}){let n=r(),[i,l]=(0,H.useState)(e.telegramTopicNameFormat??``),[u,d]=(0,H.useState)(!1),[f,p]=(0,H.useState)(null),[m,h]=(0,H.useState)(!1),g=i.trim(),_=(e.telegramTopicNameFormat??``)!==i,v=g?g.replaceAll(`{agent.name}`,t).replaceAll(`{team.name}`,e.name).replaceAll(`{team.slug}`,e.id):e.id==="default"?t:`${e.id} › ${t}`;async function y(t){d(!0),p(null);try{await c(`/api/teams/${encodeURIComponent(e.id)}/topic-format`,{method:`PUT`,body:{format:t?null:i}}),t&&l(``),await n.invalidate({sync:!0}),h(!0)}catch(e){p(s(e))}finally{d(!1)}}return(0,U.jsxs)(B,{title:`Telegram topic names`,description:(0,U.jsxs)(U.Fragment,{children:[`The title of each member's Telegram forum topic; leave empty for the built-in naming. Tokens: `,(0,U.jsx)(`code`,{children:`{agent.name}`}),` (required), `,(0,U.jsx)(`code`,{children:`{team.name}`}),`,`,` `,(0,U.jsx)(`code`,{children:`{team.slug}`}),`. Saving renames the existing topics you have not renamed in Telegram.`]}),children:[(0,U.jsx)(a,{when:_,subject:`topic name changes`}),(0,U.jsx)(`input`,{"aria-label":`Telegram topic name format`,value:i,onChange:e=>{l(e.target.value),h(!1)},placeholder:`{team.name} / {agent.name}`,className:`font-mono text-sm`}),(0,U.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[`Preview: `,(0,U.jsx)(`span`,{className:`font-mono text-foreground`,children:v})]}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,onClick:()=>void y(!1),disabled:u||!_||g.length===0,children:u?`Saving…`:`Save`}),e.telegramTopicNameFormat&&(0,U.jsx)(o,{variant:`ghost`,onClick:()=>void y(!0),disabled:u,children:`Clear`}),m&&!_&&(0,U.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved`}),f&&(0,U.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:f})]})]})}function ds({teamId:e}){let[t,n]=(0,H.useState)(`${e}-template`),[r,i]=(0,H.useState)(`${e} template`),[a,l]=(0,H.useState)(!1),[u,d]=(0,H.useState)(null);async function f(){l(!0),d(null);try{let n=await c(`/api/teams/${encodeURIComponent(e)}/policy/save-as-template`,{body:{id:t.trim(),name:r.trim()}});window.location.assign(`/templates/teams/${encodeURIComponent(n.id)}`)}catch(e){d(s(e)),l(!1)}}return(0,U.jsxs)(B,{title:`Save as Team template`,description:`Copies the members, their connections, the mode and USER.md into a reusable template.`,children:[(0,U.jsxs)(`div`,{className:`grid items-end gap-x-3 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,U.jsxs)(`label`,{children:[`Template ID`,(0,U.jsx)(`input`,{value:t,onChange:e=>n(e.target.value)})]}),(0,U.jsxs)(`label`,{children:[`Template name`,(0,U.jsx)(`input`,{value:r,onChange:e=>i(e.target.value)})]}),(0,U.jsxs)(o,{variant:`primary`,className:`mb-[0.6rem]`,disabled:a||!t.trim()||!r.trim(),onClick:()=>void f(),children:[(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":`true`}),`Save template`]})]}),u&&(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:u})]})}var fs=12e3;function ps({team:e}){let t=r(),[n,i]=(0,H.useState)(e.userMd),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(null),[p,m]=(0,H.useState)(!1),h=n!==e.userMd;async function g(){u(!0),f(null);try{await c(`/api/teams/${encodeURIComponent(e.id)}/user-md`,{method:`PUT`,body:{userMd:n}}),await t.invalidate({sync:!0}),m(!0)}catch(e){f(s(e))}finally{u(!1)}}return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(a,{when:h,subject:`USER.md changes`}),(0,U.jsx)(`textarea`,{"aria-label":`USER.md`,value:n,onChange:e=>{i(e.target.value),m(!1)},className:`min-h-[52dvh] font-mono text-sm leading-[1.55]`,placeholder:`What the Agents should know about you in this Team…`}),(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3`,children:[(0,U.jsx)(o,{variant:`primary`,onClick:()=>void g(),disabled:l||!h||n.length>fs,children:l?`Saving…`:`Save`}),(0,U.jsxs)(`span`,{className:`text-xs ${n.length>fs?`font-semibold text-danger`:`text-muted-foreground`}`,children:[n.length.toLocaleString(),` of `,fs.toLocaleString(),` characters`]}),p&&!h&&(0,U.jsx)(`span`,{role:`status`,className:`text-xs text-success`,children:`Saved. Members read it from their next turn.`}),d&&(0,U.jsx)(`span`,{role:`alert`,className:`text-xs text-danger`,children:d})]})]})}function ms({title:e,description:t,onClose:n,busy:r=!1,children:i}){return(0,U.jsx)(le,{title:e,description:t,onClose:n,busy:r,className:`top-[4dvh] max-h-[92dvh] max-w-5xl translate-y-0 content-start`,children:(0,U.jsx)(`div`,{className:`min-w-0`,children:i})})}function hs(){let{agent:e,team:t,agents:n,search:i,to:a}=k(),o=r(),s=i.section;if(!s)return null;let c=()=>void o.navigate({to:`/`,search:a({section:void 0,note:void 0})}),l,u,d;if(xe(s)){if(!e)return null;let{name:t,id:r}=e.agent;switch(s){case`schedules`:l=`${t}'s schedules`,u=`A schedule sends this Agent a message on an interval or a cron expression, as if you had written it.`,d=(0,U.jsx)(ns,{agent:e.agent},r);break;case`learning`:l=`What ${t} has learned`,u=`A review reads recent turns and proposes lessons. Nothing changes until you approve a lesson.`,d=(0,U.jsx)(Xo,{agent:e.agent},r);break;case`mailbox`:l=`${t}'s mailbox`,u=`Messages other Agents sent it. An idle Agent picks up unread mail on the next scheduler tick.`,d=(0,U.jsx)($o,{agent:e.agent,agents:n},r);break;case`skills`:l=`${t}'s skills`,u=`Attach or detach the installed prompt skills for this Agent.`,d=(0,U.jsx)(gs,{agentId:r,attached:e.skills},r);break;case`telegram`:l=`${t} on Telegram`,u=`Bind this Agent to its forum topic and choose what is mirrored there.`,d=(0,U.jsx)(Yo,{agent:e.agent},r);break;case`browser`:l=`${t}'s browser`,u=`The browser this Agent drives: its session and its saved profile.`,d=(0,U.jsx)(qo,{agentId:r},r);break}}else if(de(s)){if(!t)return null;switch(s){case`user-md`:l=`USER.md of ${t.name}`,u=`What every member of this Team is told about you, on every turn. Only you can edit it; Agents cannot.`,d=(0,U.jsx)(ps,{team:t},t.id);break;case`memory`:l=`Shared memory of ${t.name}`,u=(0,U.jsxs)(U.Fragment,{children:[`Notes every Agent of this Team reads, writes and searches. Notes about one Agent belong in its own `,(0,U.jsx)(`code`,{children:`IDENTITY.md`}),`.`]}),d=(0,U.jsx)(os,{team:t,openKey:i.note},t.id);break;case`settings`:l=`Settings of ${t.name}`,d=(0,U.jsx)(ls,{team:t,sampleAgent:n.find(e=>e.teamId===t.id)?.name??`researcher`},t.id);break}}else return null;return(0,U.jsx)(ms,{title:l,description:u,onClose:c,children:d})}function gs({agentId:e,attached:t}){let n=M(e=>c(`/api/skills`,{signal:e}),[]);return n.error?(0,U.jsx)(`p`,{role:`alert`,className:`err`,children:n.error}):n.data?n.data.length===0?(0,U.jsxs)(`p`,{className:`muted`,children:[`No skills are installed yet. Add some under `,(0,U.jsx)(`a`,{href:`/skills`,children:`Skills`}),`.`]}):(0,U.jsx)(Jo,{agentId:e,attached:new Set(t),all:n.data}):(0,U.jsx)(`p`,{role:`status`,className:`muted`,children:`Loading the skills…`})}var _s=[{view:`connections`,label:`Connections`,icon:m},{view:`changes`,label:`Changes`,icon:h},{view:`files`,label:`Files`,icon:ne}],vs=`m-0 mb-2 mt-7 font-body text-[0.72rem] font-bold uppercase tracking-[0.08em] text-muted-foreground`;function ys({team:e}){let{agents:t,profiles:n,teams:r,search:a}=k(),s=z(),[c,l]=(0,H.useState)(!1),u=t.filter(t=>t.teamId===e.id),d=R(u.map(e=>s.stateOf(e.id))),f=Xt(e.id),m=mn(e.id,{},4),h=D(e.id,50);return(0,U.jsxs)(`section`,{"aria-label":e.name,className:`flex h-full flex-col overflow-y-auto rounded-[16px] border border-border bg-card px-4 py-5 shadow-baziu-sm sm:px-8 sm:py-8`,children:[(0,U.jsxs)(`div`,{className:`mx-auto w-full max-w-2xl`,children:[(0,U.jsxs)(i,{to:`/`,search:{},className:`mb-4 inline-flex items-center gap-1.5 text-sm font-semibold lg:hidden`,children:[(0,U.jsx)(p,{className:`size-3.5`,"aria-hidden":`true`}),`All teams`]}),(0,U.jsx)(`h1`,{className:`m-0 font-display text-[1.9rem] leading-tight text-charcoal`,children:e.name}),(0,U.jsxs)(`p`,{className:`m-0 mt-1 text-sm text-mocha`,children:[u.length,` member`,u.length===1?``:`s`,d?` · ${d}`:``]}),u.length===0?(0,U.jsxs)(`div`,{className:`mt-6 rounded-2xl border border-dashed border-border bg-muted/40 px-5 py-8 text-center`,children:[(0,U.jsx)(`p`,{className:`m-0 text-sm font-semibold text-foreground`,children:`No Agents in this Team yet`}),(0,U.jsx)(`p`,{className:`m-0 mt-1 text-sm text-muted-foreground`,children:`Add the first one to start a conversation.`}),(0,U.jsxs)(o,{variant:`primary`,className:`mt-4`,onClick:()=>l(!0),children:[(0,U.jsx)(ie,{className:`size-4`,"aria-hidden":`true`}),`Add an agent`]})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{className:`m-0 mt-5 list-none space-y-2 p-0`,children:u.map(e=>{let t=s.stateOf(e.id);return(0,U.jsx)(`li`,{children:(0,U.jsxs)(i,{to:`/`,search:{agent:e.id,...a.panel?{panel:a.panel}:{}},className:`flex min-h-16 items-center gap-3 rounded-2xl border border-border bg-card px-3.5 py-2.5 text-foreground shadow-baziu-sm hover:border-sapphire-light hover:bg-accent/30`,children:[(0,U.jsx)(Fe,{identity:e.identity,size:40}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[0.95rem] font-semibold`,children:e.name}),(0,U.jsxs)(`span`,{className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-xs text-mocha`,children:[(0,U.jsx)(`span`,{className:`size-[7px] shrink-0 rounded-full ${y[t.kind]}`,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:t.text})]})]}),(0,U.jsx)(`span`,{className:`shrink-0 text-xs font-semibold text-accent-foreground`,children:`Open`})]})},e.id)})}),(0,U.jsx)(`div`,{className:`mt-4`,children:(0,U.jsxs)(o,{variant:`ghost`,onClick:()=>l(!0),children:[(0,U.jsx)(ie,{className:`size-4`,"aria-hidden":`true`}),`Add an agent`]})})]}),(0,U.jsx)(`div`,{className:`mt-8 grid grid-cols-1 gap-2 sm:grid-cols-3`,children:_s.map(({view:t,label:n,icon:r})=>(0,U.jsxs)(i,{to:`/`,search:{team:e.id,view:t},className:`flex min-h-16 items-center gap-2.5 rounded-2xl border border-border bg-muted/50 px-3 py-2.5 text-foreground hover:border-sapphire-light hover:bg-accent/30`,children:[(0,U.jsx)(r,{className:`size-[18px] shrink-0 text-mocha`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0`,children:[(0,U.jsx)(`span`,{className:`block text-sm font-semibold`,children:n}),(0,U.jsx)(`span`,{className:`block truncate text-xs text-mocha`,children:t===`connections`?`${e.policyMode===`open`?`Open`:`Restricted`} · ${h.data?.length?`${h.data.length} message${h.data.length===1?``:`s`}`:`no messages yet`}`:t===`changes`?f.changes===null?`Not a Git repository`:`${f.changes} changed file${f.changes===1?``:`s`}`:`${f.files??0} saved file${f.files===1?``:`s`}`})]})]},t))}),m.results.length>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:vs,children:`Latest files`}),(0,U.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5 sm:grid-cols-4`,children:m.results.map(n=>(0,U.jsx)(fn,{resultId:n.id,result:n,compact:!0,detail:t.find(e=>e.id===n.agentId)?.name,open:{team:e.id,view:`files`,result:n.id}},n.id))})]}),(h.data?.length??0)>0&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`h2`,{className:vs,children:`Lately between its Agents`}),(0,U.jsx)(te,{messages:h.data??[],limit:4})]})]}),c&&(0,U.jsx)(Ue,{profiles:n,teams:r,teamId:e.id,onClose:()=>l(!1)})]})}var bs=(0,H.lazy)(()=>De(()=>import(`./ConnectionsView-BZHJysCa.js`).then(e=>({default:e.ConnectionsView})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18])));function xs(){let e=Me.useLoaderData(),t=Me.useSearch(),n=r(),{agents:a,teams:o,selected:s}=e,c=s?.resolved??null,l=c?.team??o.find(e=>e.id===t.team)??null,u=l?t.view:void 0,d=(0,H.useMemo)(()=>new Map(a.map(e=>[e.id,e.name])),[a]),[f,p]=(0,H.useState)(e.panel);(0,H.useEffect)(()=>{t.panel&&p(e=>{let n=t.panel===`none`?{open:!1,tab:e.tab}:{open:!0,tab:t.panel};return n.open===e.open&&n.tab===e.tab?e:(Ie(n),n)})},[t.panel]);let m=t.panel??(f.open?f.tab:`none`),h=t.panel!==void 0&&t.panel!==`none`,[g,_]=(0,H.useState)(null),v=s?.head.conversationId??null,y=c&&g?.agentId===c.agent.id&&g.loaded===v?g.id:v,S=c&&t.conversation&&t.conversation!==y?t.conversation:null,C=c?S??y:null,w=(0,H.useMemo)(()=>({agents:a,teams:o,profiles:e.profiles,teamTemplates:e.teamTemplates,agent:c,team:l,conversationId:C,search:t}),[a,o,e.profiles,e.teamTemplates,c,l,C,t]),E=e=>c&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ho,{agent:c,chat:e,panel:m,lastPanel:f.tab}),c.agent.status===`archived`&&(0,U.jsxs)(`p`,{className:`m-0 flex flex-wrap items-center gap-2 border-b border-frost bg-warning/[0.07] px-4 py-2 text-sm text-chocolate`,children:[(0,U.jsx)(je,{variant:`warning`,children:`Archived`}),`This Agent receives no work. Restore it from its settings to talk to it again.`,(0,U.jsx)(i,{to:`/`,search:{...t,panel:`agent`},className:`font-semibold`,children:`Agent settings`})]})]});return(0,U.jsx)(Se,{initial:e.activity,openAgentId:u?null:c?.agent.id??null,names:d,children:(0,U.jsx)(x,{value:w,children:(0,U.jsxs)(It,{children:[u&&l?(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 sm:grid-cols-[4rem_minmax(0,1fr)]`,children:[(0,U.jsx)(`div`,{className:`hidden min-h-0 sm:block`,children:(0,U.jsx)(T,{})}),(0,U.jsx)(`div`,{className:`min-h-0 min-w-0`,children:u===`connections`?(0,U.jsx)(H.Suspense,{fallback:(0,U.jsx)(b,{view:`connections`,children:(0,U.jsx)(`p`,{role:`status`,className:`m-4 text-sm text-muted-foreground`,children:`Loading the map…`})}),children:(0,U.jsx)(bs,{team:l},l.id)}):u===`changes`?(0,U.jsx)(On,{team:l},l.id):(0,U.jsx)(Lo,{team:l},l.id)})]}):(0,U.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 gap-3 py-3 lg:grid-cols-[18rem_minmax(0,1fr)] ${m===`none`?``:`xl:grid-cols-[18rem_minmax(0,1fr)_minmax(22rem,27rem)]`}`,children:[(0,U.jsx)(`div`,{className:`min-h-0 ${c||l?`hidden lg:block`:``}`,children:(0,U.jsx)(O,{initialOpenGroups:e.openGroups})}),(0,U.jsx)(`div`,{className:`min-h-0 min-w-0 ${c||l?``:`hidden lg:block`}`,children:c&&s?S?(0,U.jsx)(Go,{agentId:c.agent.id,agentName:c.agent.name,conversationId:S,header:E()},`${c.agent.id}:${S}`):(0,U.jsx)(No,{agentId:c.agent.id,agentName:c.agent.name,initialMessages:s.messages,initialSessionHead:s.head,header:E,onViewConversation:e=>void n.navigate({to:`/`,search:{...t,conversation:e}}),onConversationChange:e=>_({agentId:c.agent.id,loaded:v,id:e})}):l?(0,U.jsx)(ys,{team:l}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center rounded-2xl border border-dashed bg-card px-6 text-center text-muted-foreground`,children:(0,U.jsxs)(`div`,{className:`max-w-sm`,children:[(0,U.jsx)(`h1`,{className:`m-0 font-body text-lg font-semibold text-foreground`,children:a.length===0?`Start your first conversation`:`Choose an agent`}),(0,U.jsx)(`p`,{className:`mt-2 text-sm leading-6`,children:a.length===0?`Your default Team and Agent template are ready. Use “Spawn first agent” on the left to create a working member.`:`Pick an agent on the left to open its conversation. “Jump to” at the top finds any Agent or Team by name.`})]})})}),m!==`none`&&(0,U.jsxs)(U.Fragment,{children:[h&&(0,U.jsx)(i,{to:`/`,search:{...t,panel:`none`,section:void 0},"aria-label":`Close the side panel`,className:`fixed inset-0 z-30 bg-chocolate/30 xl:hidden`}),(0,U.jsx)(`div`,{className:h?`fixed inset-y-0 right-0 z-40 w-[min(27rem,100vw)] p-2 xl:static xl:z-auto xl:min-h-0 xl:w-auto xl:min-w-0 xl:p-0`:`hidden min-h-0 min-w-0 xl:block`,children:(0,U.jsx)(xn,{tab:m})})]})]}),(0,U.jsx)(hs,{})]})})})}export{xs as component};
|