adam-agent-server 1.8.0 → 1.9.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/README.md +8 -0
- package/dist/App-5QZKMPRM.js +13 -0
- package/dist/adam-tools-FSI5XKDL.js +1 -0
- package/dist/{approval-handler-PB7PSLUS.js → approval-handler-JYCGXQUE.js} +1 -1
- package/dist/audit-manager-CLKTJPLM.js +1 -0
- package/dist/bree-engine-XJR5TKVC.js +1 -0
- package/dist/channels-DY2OW7YQ.js +1 -0
- package/dist/{channels-ULFUCUUZ.js → channels-ZNMTMMCY.js} +1 -1
- package/dist/{chunk-BQ3ZAYHC.js → chunk-3HZE5DQZ.js} +1 -1
- package/dist/chunk-3IQADR6L.js +144 -0
- package/dist/{chunk-NASJH4NT.js → chunk-3N7MGASP.js} +1 -1
- package/dist/{chunk-TAF2DBBC.js → chunk-56QP5ZHF.js} +7 -7
- package/dist/{chunk-PG6LMSX6.js → chunk-5AUQIK3Q.js} +1 -1
- package/dist/{chunk-NUITL62I.js → chunk-6M2QCKAS.js} +1 -1
- package/dist/{chunk-WMB7P64J.js → chunk-6XVWIRR2.js} +1 -1
- package/dist/{chunk-5EPG2US5.js → chunk-7F4SZXI2.js} +39 -10
- package/dist/{chunk-JJH2RCVC.js → chunk-7WJF65TQ.js} +1 -1
- package/dist/{chunk-RZ7LCZVK.js → chunk-ARQF52V6.js} +1 -1
- package/dist/{chunk-NWMOV23A.js → chunk-C2SD2NMZ.js} +1 -1
- package/dist/{chunk-2L2347UQ.js → chunk-DKMF4B33.js} +1 -1
- package/dist/{chunk-EQZFOBAJ.js → chunk-EJBGJLA2.js} +1 -1
- package/dist/{chunk-T33BLZV2.js → chunk-HSEP6LNQ.js} +1 -1
- package/dist/{chunk-GSFLLRS7.js → chunk-IZ3WZHCM.js} +1 -1
- package/dist/chunk-J4Y54LIC.js +50 -0
- package/dist/{chunk-AQ3ASS4B.js → chunk-KO7XBNPV.js} +1 -1
- package/dist/{chunk-RI3V72RP.js → chunk-KUJFQDT5.js} +2 -2
- package/dist/{chunk-DVN3BFPP.js → chunk-LV4XLPCD.js} +1 -1
- package/dist/chunk-MYVYH4PQ.js +77 -0
- package/dist/chunk-OFTIPZTH.js +1 -0
- package/dist/{chunk-K4C43YDD.js → chunk-OY2KVSIX.js} +1 -1
- package/dist/{chunk-IKPYPZ64.js → chunk-PFYYS7CI.js} +1 -1
- package/dist/chunk-QMW7VEPC.js +0 -0
- package/dist/{chunk-A5OCDYTW.js → chunk-QPIWPQWM.js} +1 -1
- package/dist/chunk-S6OV7Z6K.js +1 -0
- package/dist/{chunk-2YTDCR6A.js → chunk-TTP7QRAQ.js} +1 -1
- package/dist/{chunk-B6LOT5CG.js → chunk-UQDC3X6O.js} +1 -1
- package/dist/{chunk-M4YI4WVX.js → chunk-UYOLAFUR.js} +1 -1
- package/dist/chunk-VPZSOYE5.js +6 -0
- package/dist/{chunk-5QZXYKMS.js → chunk-W7U3ASGR.js} +1 -1
- package/dist/chunk-XIQVXRZH.js +27 -0
- package/dist/{chunk-FPZEZYUB.js → chunk-XTOOD44S.js} +1 -1
- package/dist/{chunk-6KF7OO2B.js → chunk-YKMWAVUH.js} +1 -1
- package/dist/{chunk-UQJZU3R5.js → chunk-YVVKUPGL.js} +1 -1
- package/dist/{chunk-HQRUJQN7.js → chunk-YWUX3ZTO.js} +4 -4
- package/dist/cli.js +2 -2
- package/dist/{config-HBQPBIWL.js → config-CILWJYZB.js} +1 -1
- package/dist/config-W2OD7PXZ.js +1 -0
- package/dist/{db-QEWTZGU3.js → db-JO24ZLIN.js} +1 -1
- package/dist/{delivery-log-AC476GX7.js → delivery-log-QPQM5YU7.js} +1 -1
- package/dist/engine-ZAPYG7G4.js +1 -0
- package/dist/{evolution-audit-XMBDUN3T.js → evolution-audit-ZLYQ3ZYV.js} +1 -1
- package/dist/{external-api-V74YTLBY.js → external-api-QKRNGSYS.js} +1 -1
- package/dist/index.js +20 -16
- package/dist/{learner-VCS3Q7BR.js → learner-ACHENH6R.js} +1 -1
- package/dist/{memories-VMOGFVPU.js → memories-LXH4VHCH.js} +1 -1
- package/dist/{memory-extractor-4WJNHYWR.js → memory-extractor-URH4YHK3.js} +2 -2
- package/dist/memory-service-23P6VNKZ.js +1 -0
- package/dist/outbound-gateway-Y3P3T3VH.js +1 -0
- package/dist/presets-XR2OBXUP.js +1 -0
- package/dist/role-presets-DYWDEQYU.js +1 -0
- package/dist/role-workspace-LHW7AWPF.js +1 -0
- package/dist/{roles-ZYCFQMAY.js → roles-DRPLO4LY.js} +1 -1
- package/dist/{runtime-VDBZZ4KG.js → runtime-YPBWWMXW.js} +1 -1
- package/dist/session-manager-Z6K4U5X7.js +1 -0
- package/dist/{task-templates-4KCZOUN5.js → task-templates-4DWXHLFZ.js} +1 -1
- package/dist/workflow-executor-6ZMNL34C.js +1 -0
- package/package.json +2 -1
- package/web/dist/assets/{AlertDialog-B1zj0Qs3.js → AlertDialog-DhA65f_0.js} +1 -1
- package/web/dist/assets/{Button-BehrGSvy.js → Button-CYDgoTTo.js} +1 -1
- package/web/dist/assets/{Card-B5E56u94.js → Card-DDGXsHus.js} +1 -1
- package/web/dist/assets/{ChannelDetail-BaSlX2yb.js → ChannelDetail-Bb8P8It_.js} +1 -1
- package/web/dist/assets/{Channels-CLhgGEmS.js → Channels-8j28oydE.js} +2 -2
- package/web/dist/assets/{Chat-BZpf1DSF.js → Chat-BZwLDoYO.js} +2 -2
- package/web/dist/assets/{Dashboard-HR4Qmdwg.js → Dashboard-Cv0AtO-o.js} +1 -1
- package/web/dist/assets/{EmptyState-tTclFq_B.js → EmptyState-EuQHAv5Y.js} +1 -1
- package/web/dist/assets/{EnvVarEditor-BzJNsDt0.js → EnvVarEditor-r-l-u4V7.js} +1 -1
- package/web/dist/assets/{EventDefDetail-CjoqsH0e.js → EventDefDetail-asUFrbQE.js} +1 -1
- package/web/dist/assets/Events-DtkHL-r2.js +1 -0
- package/web/dist/assets/{Evolution-CUn8g34X.js → Evolution-DIqYOSb8.js} +1 -1
- package/web/dist/assets/FeatureRequests-BxPqLR1x.js +1 -0
- package/web/dist/assets/{GoalDetail-DgPvXb6z.js → GoalDetail-Bkvgg6uI.js} +1 -1
- package/web/dist/assets/Goals-CkKJDCiU.js +1 -0
- package/web/dist/assets/{Logs-CvFC-GbD.js → Logs-DnaaHV0Y.js} +1 -1
- package/web/dist/assets/{Memories-B5pvI6Oj.js → Memories-Dq9S-Tsi.js} +1 -1
- package/web/dist/assets/Mistakes-D5lW31Co.js +1 -0
- package/web/dist/assets/{NotFound-D-OII_Lp.js → NotFound-gJVrOtER.js} +1 -1
- package/web/dist/assets/{PageHeader-B2CgcZ-t.js → PageHeader-CugYeCci.js} +1 -1
- package/web/dist/assets/Plugins-CoRmK2UG.js +1 -0
- package/web/dist/assets/{RoleDetail-BBJxaZip.js → RoleDetail-BHJA_PAn.js} +2 -2
- package/web/dist/assets/Roles-EBUueS_P.js +1 -0
- package/web/dist/assets/{SectionHeader-CmXz6PM3.js → SectionHeader-DihC0CnO.js} +1 -1
- package/web/dist/assets/Settings-DZHAGazz.js +1 -0
- package/web/dist/assets/{Strategies-Ddb5HiUS.js → Strategies-3IV9eueQ.js} +1 -1
- package/web/dist/assets/{Switch-yrTepsdl.js → Switch-B3w5KMMc.js} +1 -1
- package/web/dist/assets/{Table-CXAcZ8Ru.js → Table-Cf6m8zLu.js} +1 -1
- package/web/dist/assets/{TaskDetail-CHwHgfZq.js → TaskDetail-BmXaH3sx.js} +2 -2
- package/web/dist/assets/Work-CvQrOKtL.js +1 -0
- package/web/dist/assets/api-D-UzHSDq.js +1 -0
- package/web/dist/assets/index-BsKlGx3x.js +2 -0
- package/web/dist/assets/index-EqsPGp9a.css +2 -0
- package/web/dist/assets/{useIsMobileLayout-dYzXP1EC.js → useIsMobileLayout-2GbB90oO.js} +1 -1
- package/web/dist/assets/{vendor-icons-Dk0hMuJz.js → vendor-icons-PF9RcPJx.js} +1 -1
- package/web/dist/assets/{vendor-react-C6faO6LO.js → vendor-react-Cxy4EVtR.js} +1 -1
- package/web/dist/assets/{vendor-state-DahK0J-G.js → vendor-state-aQJ7d4tA.js} +1 -1
- package/web/dist/index.html +8 -8
- package/dist/App-ZRCRM7WR.js +0 -13
- package/dist/adam-automator-skills-EZGBICHT.js +0 -18
- package/dist/adam-tools-V5LPU47X.js +0 -1
- package/dist/audit-manager-BSBBDUER.js +0 -1
- package/dist/bree-engine-7S33CWS7.js +0 -1
- package/dist/channels-SITUUC4J.js +0 -1
- package/dist/chunk-4PQHGLZH.js +0 -99
- package/dist/chunk-5XOTPEAK.js +0 -6
- package/dist/chunk-BCH2HAIM.js +0 -23
- package/dist/chunk-GSMC3VUM.js +0 -1
- package/dist/chunk-IZNEOYRP.js +0 -1
- package/dist/chunk-QGYDGZSC.js +0 -49
- package/dist/chunk-ULTK7RD6.js +0 -27
- package/dist/config-ZBNGRASI.js +0 -1
- package/dist/engine-6K4RG644.js +0 -1
- package/dist/memory-service-ZS6MBUIC.js +0 -1
- package/dist/outbound-gateway-H7RFG6D2.js +0 -1
- package/dist/role-presets-XAEOYEAW.js +0 -1
- package/dist/role-workspace-NKGAH6J6.js +0 -1
- package/dist/session-manager-COLCNIB7.js +0 -1
- package/dist/workflow-executor-Z7JFMR56.js +0 -1
- package/web/dist/assets/Events-IeznRpCj.js +0 -1
- package/web/dist/assets/Goals-DYrggK-M.js +0 -1
- package/web/dist/assets/Plugins-BuE7GImW.js +0 -1
- package/web/dist/assets/Roles-C5eVA6LM.js +0 -1
- package/web/dist/assets/Settings-BblOdOih.js +0 -1
- package/web/dist/assets/Work-Corw0ITh.js +0 -1
- package/web/dist/assets/api-Bux34u4-.js +0 -1
- package/web/dist/assets/index-B3_4_qY6.js +0 -2
- package/web/dist/assets/index-Cu5neZGw.css +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,b as n,lt as r,n as i}from"./vendor-icons-PF9RcPJx.js";import{r as a,t as o}from"./vendor-react-Cxy4EVtR.js";import{t as s}from"./Button-CYDgoTTo.js";import{i as c,r as l,t as u}from"./index-BsKlGx3x.js";import{t as d}from"./Card-DDGXsHus.js";import{t as f}from"./PageHeader-CugYeCci.js";import{t as p}from"./SectionHeader-DihC0CnO.js";import{a as m}from"./format-BUYXZqDw.js";import{t as h}from"./EmptyState-EuQHAv5Y.js";import{t as g}from"./useIsMobileLayout-2GbB90oO.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./Table-Cf6m8zLu.js";var C=e(r(),1),w=o();function T(){let e=l(e=>e.roles),r=l(e=>e.fetchRoles),o=l(e=>e.createRole),[T,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(!1),[k,A]=(0,C.useState)(``),[j,M]=(0,C.useState)(``),[N,P]=(0,C.useState)(!1),[F,I]=(0,C.useState)(null),L=g(),R=(0,C.useCallback)(async()=>{E(!0),await r(),E(!1)},[r]),z=()=>{A(``),M(``),I(null),P(!1)},B=async()=>{let e=k.trim();if(!e){I(`Name is required.`);return}P(!0),I(null);try{await o({name:e,cagPrompt:j.trim()}),await r(),O(!1),z(),c.success(`Role created`)}catch(e){I(e instanceof Error?e.message:`Failed to create role`)}finally{P(!1)}};(0,C.useEffect)(()=>{R()},[R]);let V=e=>e===`active`?`success`:e===`inactive`?`secondary`:e===`retired`?`destructive`:e===`probation`?`warning`:`secondary`,H=e.filter(e=>e.status===`active`).length,U=e.filter(e=>e.status===`probation`).length,W=e.filter(e=>e.memoryStreamId).length;return(0,w.jsxs)(`div`,{className:`space-y-5`,children:[(0,w.jsx)(f,{eyebrow:`Identities`,title:`Roles`,description:`Registry for role status, memory linkage, and edit actions.`,metrics:[{label:`Active`,value:H},{label:`Probation`,value:U},{label:`Linked Memory`,value:W}],compact:!0,actions:(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>void R(),disabled:T,children:(0,w.jsx)(n,{size:14,className:T?`animate-spin`:``})}),(0,w.jsxs)(s,{size:`sm`,onClick:()=>O(!0),children:[(0,w.jsx)(t,{size:14}),`New Role`]})]})}),(0,w.jsx)(p,{title:`Registry`,description:`Open a role to inspect prompts, performance, and bindings.`,compact:!0,action:(0,w.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.length,` role`,e.length===1?``:`s`]})}),e.length===0&&!T?(0,w.jsx)(d,{children:(0,w.jsx)(h,{title:`No roles yet`,description:`Create a role to define agent behavior and bind plugins.`})}):L?(0,w.jsx)(`div`,{className:`space-y-3`,children:e.map(e=>(0,w.jsxs)(d,{children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`}),(0,w.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]}),(0,w.jsx)(u,{variant:V(e.status),children:e.status})]}),(0,w.jsxs)(`div`,{className:`mt-4 grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Score`}),(0,w.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.performanceScore==null?`—`:`${(e.performanceScore*100).toFixed(0)}%`})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Memory`}),(0,w.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})]})]})]},e.id))}):(0,w.jsx)(d,{padding:!1,children:(0,w.jsxs)(S,{children:[(0,w.jsx)(_,{children:(0,w.jsxs)(b,{children:[(0,w.jsx)(v,{children:`Name`}),(0,w.jsx)(v,{children:`Status`}),(0,w.jsx)(v,{children:`Score`}),(0,w.jsx)(v,{children:`Memories`}),(0,w.jsx)(v,{children:`Created`})]})}),(0,w.jsx)(y,{children:e.map(e=>(0,w.jsxs)(b,{children:[(0,w.jsx)(x,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(a,{to:`/roles/${e.id}`,className:`font-medium text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.name}),e.presetId&&(0,w.jsx)(u,{variant:`info`,children:`Preset`})]})}),(0,w.jsx)(x,{children:(0,w.jsx)(u,{variant:V(e.status),children:e.status})}),(0,w.jsx)(x,{children:e.performanceScore==null?(0,w.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`—`}):(0,w.jsxs)(`span`,{className:`font-mono text-xs text-[var(--app-text)]`,children:[(e.performanceScore*100).toFixed(0),`%`]})}),(0,w.jsx)(x,{children:(0,w.jsx)(`span`,{className:`text-sm text-[var(--app-text-muted)]`,children:e.memoryStreamId?e.memoryStreamId.slice(0,8):`—`})}),(0,w.jsx)(x,{className:`text-xs text-[var(--app-text-subtle)]`,children:m(e.createdAt)})]},e.id))})]})}),D&&(0,w.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60`,onClick:e=>{e.target===e.currentTarget&&(O(!1),z())},children:(0,w.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-panel)] p-6 shadow-lg`,children:[(0,w.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,w.jsx)(`h2`,{className:`text-lg font-semibold text-[var(--app-text)]`,children:`Create Role`}),(0,w.jsx)(`button`,{className:`text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,onClick:()=>{O(!1),z()},children:(0,w.jsx)(i,{size:16})})]}),(0,w.jsxs)(`div`,{className:`space-y-4`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-name`,children:[`Name `,(0,w.jsx)(`span`,{className:`text-[var(--app-danger)]`,children:`*`})]}),(0,w.jsx)(`input`,{id:`role-name`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. Engineer, Reviewer`,value:k,onChange:e=>A(e.target.value),onKeyDown:e=>{e.key===`Enter`&&B()},autoFocus:!0})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-[var(--app-text)]`,htmlFor:`role-cag-prompt`,children:`CAG Prompt`}),(0,w.jsx)(`textarea`,{id:`role-cag-prompt`,className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-2 text-sm text-[var(--app-text)] placeholder-slate-500 focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Character and Guidance prompt for this role...`,rows:5,value:j,onChange:e=>M(e.target.value)})]}),F&&(0,w.jsx)(`p`,{className:`text-sm text-[var(--app-danger)]`,children:F}),(0,w.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>{O(!1),z()},children:`Cancel`}),(0,w.jsx)(s,{size:`sm`,onClick:()=>void B(),disabled:N,children:N?`Creating...`:`Create`})]})]})]})})]})}export{T as Roles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-
|
|
1
|
+
import{t as e}from"./vendor-react-Cxy4EVtR.js";import{n as t}from"./dist-CgGno8kE.js";var n=e();function r({title:e,description:r,action:i,compact:a=!1,className:o}){return(0,n.jsxs)(`div`,{className:t(`flex flex-col sm:flex-row sm:justify-between`,a?`gap-2 sm:items-start`:`gap-3 sm:items-end`,o),children:[(0,n.jsxs)(`div`,{className:t(a?`space-y-0.5`:`space-y-1`),children:[(0,n.jsx)(`p`,{className:`text-section-label`,children:e}),r?(0,n.jsx)(`p`,{className:t(`text-sm text-[var(--app-text-muted)]`,a?`leading-5`:`leading-6`),children:r}):null]}),i?(0,n.jsx)(`div`,{className:`flex items-center gap-2`,children:i}):null]})}export{r as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{M as t,b as n,h as r,lt as i,n as a,v as o}from"./vendor-icons-PF9RcPJx.js";import{l as s,t as c}from"./vendor-react-Cxy4EVtR.js";import{a as l,c as u,i as d,n as f,o as p,r as m,s as h,t as g}from"./AlertDialog-DhA65f_0.js";import{t as _}from"./Button-CYDgoTTo.js";import{a as v,c as y,d as b,l as x,r as S,s as C,t as w}from"./api-D-UzHSDq.js";import{r as T}from"./index-BsKlGx3x.js";import{t as E}from"./Card-DDGXsHus.js";import{t as D}from"./PageHeader-CugYeCci.js";import{t as O}from"./SectionHeader-DihC0CnO.js";import{i as k}from"./format-BUYXZqDw.js";import{t as A}from"./EmptyState-EuQHAv5Y.js";import{t as j}from"./ui-CerQw0jA.js";import{t as M}from"./EnvVarEditor-r-l-u4V7.js";var N=e(i(),1),P=c(),ee={anthropic:{label:`Anthropic`,paths:[`anthropic.apiKey`,`anthropic.baseUrl`,`anthropic.model`,`anthropic.defaultOpusModel`,`anthropic.defaultSonnetModel`,`anthropic.defaultHaikuModel`,`anthropic.smallFastModel`]},defaults:{label:`Defaults`,paths:[`defaults.model`,`defaults.effort`,`defaults.maxTurns`,`defaults.maxBudgetUsd`,`defaults.timeout`,`defaults.approvalTimeout`]},server:{label:`Server`,paths:[`server.port`,`server.host`],mutablePaths:[`server.timezone`]},logging:{label:`Logging`,paths:[`logging.level`]},evolution:{label:`Evolution`,paths:[`roles.evolution.triggerEvery`,`roles.evolution.reflectionThreshold`]},chat:{label:`Chat`,paths:[`chat.sessionTimeoutMinutes`,`chat.maxSessionTurns`,`chat.autoTitle`,`chat.archiveExtractMemory`]},workflow:{label:`Workflow`,paths:[`watchdog.rules.artifactCleanup.enabled`,`watchdog.rules.artifactCleanup.ttlDays`,`watchdog.rules.artifactCleanup.orphanGcMinAgeHours`]}},te={anthropic:`Model endpoints and provider-specific defaults.`,defaults:`Global execution defaults applied when a role does not override them.`,server:`Network surface and host-level configuration.`,logging:`Verbosity and runtime observability controls.`,evolution:`Thresholds that govern role adaptation over time.`,chat:`Session lifecycle and archive behavior for chat mode.`,workflow:`Cleanup rules and artifact retention for background work.`},ne=[`defaults.deniedReadPaths`,`defaults.approvalRequired`],F=new Set([`anthropic.apiKey`,`server.apiKey`]),I={"anthropic.apiKey":`API Key`,"anthropic.baseUrl":`Base URL`,"anthropic.model":`Model`,"anthropic.defaultOpusModel":`Default Opus Model`,"anthropic.defaultSonnetModel":`Default Sonnet Model`,"anthropic.defaultHaikuModel":`Default Haiku Model`,"anthropic.smallFastModel":`Small Fast Model`,"defaults.model":`Default Model`,"defaults.effort":`Effort Level`,"defaults.maxTurns":`Max Turns`,"defaults.maxBudgetUsd":`Max Budget (USD)`,"defaults.timeout":`Timeout (seconds)`,"defaults.approvalTimeout":`Approval Timeout (seconds)`,"server.port":`Port`,"server.host":`Host`,"server.apiKey":`API Key (server auth)`,"server.timezone":`Timezone`,"logging.level":`Log Level`,"roles.evolution.triggerEvery":`Evolution Trigger Every (tasks)`,"roles.evolution.reflectionThreshold":`Reflection Threshold (tokens)`,"chat.sessionTimeoutMinutes":`Session Timeout (minutes)`,"chat.maxSessionTurns":`Max Session Turns`,"chat.autoTitle":`Auto-generate Session Title`,"chat.archiveExtractMemory":`Extract Memory on Archive`,"watchdog.rules.artifactCleanup.enabled":`Workflow Artifact Cleanup Enabled`,"watchdog.rules.artifactCleanup.ttlDays":`Artifact Retention (days)`,"watchdog.rules.artifactCleanup.orphanGcMinAgeHours":`Orphan File GC Min Age (hours)`},L={"defaults.effort":[`low`,`medium`,`high`,`max`],"logging.level":[`debug`,`info`,`warn`,`error`],"server.timezone":[`system`,`Asia/Shanghai`,`Asia/Tokyo`,`Asia/Singapore`,`America/New_York`,`America/Los_Angeles`,`America/Chicago`,`Europe/London`,`Europe/Berlin`,`Europe/Paris`,`UTC`]};function R(){let[e,i]=(0,N.useState)({}),[a,c]=(0,N.useState)([]),[v,y]=(0,N.useState)({}),[b,x]=(0,N.useState)(new Set),[S,C]=(0,N.useState)(!1),[j,R]=(0,N.useState)(null),[H,U]=(0,N.useState)(!0),[W,G]=(0,N.useState)(null),[K,q]=(0,N.useState)({}),[J,Y]=(0,N.useState)(new Set),[re,ie]=(0,N.useState)({}),X=T(e=>e.configVersion);(0,N.useEffect)(()=>{if(b.size===0)return;let e=e=>{e.preventDefault()};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[b.size]);let Z=s(({currentLocation:e,nextLocation:t})=>b.size>0&&e.pathname!==t.pathname),Q=(0,N.useCallback)(async()=>{try{let e=await w(`/config`);i(e.config),c(e.mutable);let t={};for(let[n,r]of Object.entries(e.config))t[n]=String(r.value??``);y(t),x(new Set);let n=e.config[`server.timezone`]?.value;n&&k(n);let r={};for(let t of ne){let n=e.config[t];n&&(r[t]=Array.isArray(n.value)?n.value:[])}q(r),Y(new Set),G(await w(`/config/env-diff`)),ie((await w(`/config/env`)).env)}catch(e){R({type:`error`,text:e instanceof Error?e.message:`Failed to load config`})}finally{U(!1)}},[]);(0,N.useEffect)(()=>{Q()},[Q]),(0,N.useEffect)(()=>{X>0&&Q()},[X,Q]);let ae=async()=>{await w(`/config/sync-to-env`,{method:`POST`}),R({type:`success`,text:`Synced DB values to .env`}),G(null)},oe=async()=>{await w(`/config/load-from-env`,{method:`POST`}),R({type:`success`,text:`Loaded .env values to DB`}),Q()},$=(e,t)=>{y(n=>({...n,[e]:t})),x(t=>new Set(t).add(e)),R(null)},se=async()=>{if(b.size!==0){C(!0),R(null);try{let t={};for(let n of b){let r=e[n],i=v[n];if(r&&typeof r.value==`number`&&(i=Number(i),isNaN(i))){R({type:`error`,text:`"${I[n]??n}" must be a number`}),C(!1);return}t[n]=i}let n=await w(`/config`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...Object.fromEntries(Array.from(J).map(e=>[e,K[e]??[]]))})});if(n.updated.length>0&&(R({type:`success`,text:`Updated ${n.updated.length} setting(s)`}),n.updated.includes(`server.timezone`))){let e=v[`server.timezone`];k(e)}n.errors.length>0&&R({type:`error`,text:n.errors.join(`; `)}),x(new Set),Q()}catch(e){R({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{C(!1)}}};return H?(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,P.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})}):Object.keys(e).length===0?(0,P.jsx)(A,{icon:(0,P.jsx)(r,{size:32}),title:`No configuration`,description:`Config API not available`}):(0,P.jsxs)(`div`,{className:`space-y-5`,children:[(0,P.jsx)(D,{eyebrow:`Configuration`,title:`Settings`,compact:!0,description:`Mutable fields, pending edits, and environment drift.`,metrics:[{label:`Editable`,value:a.length},{label:`Pending`,value:b.size+J.size},{label:`Env Drift`,value:W?.diffs.length??0}],actions:(0,P.jsxs)(`div`,{className:`flex w-full justify-end gap-2`,children:[(0,P.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>void Q(),children:(0,P.jsx)(n,{size:14})}),b.size>0&&(0,P.jsxs)(_,{size:`sm`,onClick:()=>void se(),disabled:S,children:[(0,P.jsx)(o,{size:14}),S?`Saving...`:`Save (${b.size})`]})]})}),(0,P.jsx)(O,{title:`Configuration Groups`,compact:!0,description:`Fields stay in place while changeable, restart-required, and pending state are clarified.`}),j&&(0,P.jsx)(`div`,{className:`rounded-lg border px-4 py-3 text-sm ${j.type===`success`?`border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:j.text}),W&&W.diffs.length>0&&(0,P.jsx)(E,{className:`surface-accent`,children:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 md:flex-row md:items-start md:justify-between`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`p`,{className:`text-sm font-medium text-[var(--app-text)]`,children:[`.env and DB have `,W.diffs.length,` different value(s)`]}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:W.diffs.map(e=>e.envKey).join(`, `)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2 md:justify-end`,children:[(0,P.jsx)(_,{variant:`ghost`,size:`sm`,onClick:ae,children:`Sync DB → .env`}),(0,P.jsx)(_,{variant:`ghost`,size:`sm`,onClick:oe,children:`Load .env → DB`})]})]})}),Object.entries(ee).map(([n,{label:r,paths:i,mutablePaths:o}])=>{let s=[...i,...o??[]],c=s.filter(e=>a.includes(e)).length;return(0,P.jsxs)(E,{children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r}),(0,P.jsx)(`p`,{className:`mt-1 text-sm text-[var(--app-text-muted)]`,children:te[n]??`Configuration values for this system area.`})]}),(0,P.jsxs)(`div`,{className:`rounded-full border border-[var(--app-border)] bg-black/10 px-3 py-1.5 text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:[c,`/`,s.length,` editable`]})]}),(0,P.jsx)(`div`,{className:`space-y-3`,children:s.map(n=>{let r=e[n];if(!r)return null;let i=a.includes(n),o=I[n]??n,s=v[n]??String(r.value??``),c=b.has(n),l=L[n];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-[var(--app-border)] bg-black/10 px-3 py-3 md:flex-row md:items-center md:gap-3`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 md:w-56 md:shrink-0`,children:[!i&&(0,P.jsx)(t,{size:12,className:`text-[var(--app-text-subtle)]`}),(0,P.jsx)(`label`,{className:`text-sm text-[var(--app-text-muted)]`,children:o}),!i&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`restart required`})]}),(0,P.jsx)(`div`,{className:`min-w-0 flex-1`,children:l?(0,P.jsx)(`select`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,value:s,onChange:e=>$(n,e.target.value),disabled:!i,children:l.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))}):(0,P.jsx)(`input`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none disabled:opacity-50`,type:F.has(n)?`password`:`text`,value:s,onChange:e=>$(n,e.target.value),disabled:!i,placeholder:F.has(n)?`Enter to update`:void 0})}),(0,P.jsx)(`div`,{className:`text-left md:w-16 md:text-right`,children:c&&i&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`modified`})})]},n)})})]},n)}),(0,P.jsx)(M,{envVars:re,onSave:()=>void Q(),mode:`global`,title:`Environment Variables`}),(0,P.jsx)(V,{}),(0,P.jsx)(z,{mutablePaths:a,listValues:K,listDirty:J,setListValues:q,setListDirty:e=>Y(e),dirty:b}),(0,P.jsx)(B,{}),(0,P.jsx)(g,{open:Z.state===`blocked`,children:(0,P.jsxs)(d,{children:[(0,P.jsxs)(h,{children:[(0,P.jsx)(u,{children:`Unsaved Changes`}),(0,P.jsxs)(l,{children:[`You have `,b.size+J.size,` unsaved change(s). Discard and leave?`]})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(m,{onClick:()=>Z.reset?.(),children:`Stay`}),(0,P.jsx)(f,{onClick:()=>Z.proceed?.(),children:`Discard`})]})]})})]})}function z({mutablePaths:e,listValues:n,listDirty:r,setListValues:i,setListDirty:o,dirty:s}){let[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(``),f=e.includes(`defaults.deniedReadPaths`),p=e.includes(`defaults.approvalRequired`),m=n[`defaults.deniedReadPaths`]??[],h=n[`defaults.approvalRequired`]??[],g=[`~/.ssh`,`~/.aws`,`~/.gnupg`,`/etc/shadow`],v=[`rm -rf *`,`git push*`,`git reset*`,`curl * -X POST*`,`curl * --request POST*`],y=e=>g.some(t=>e===(t.startsWith(`~/`),t)||e===t),b=e=>v.includes(e),x=()=>{let e=c.trim();!e||m.includes(e)||(i(t=>({...t,"defaults.deniedReadPaths":[...m,e]})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)),l(``))},S=e=>{y(e)||(i(t=>({...t,"defaults.deniedReadPaths":m.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.deniedReadPaths`)))},C=()=>{let e=u.trim();!e||h.includes(e)||(i(t=>({...t,"defaults.approvalRequired":[...h,e]})),o(e=>new Set(e).add(`defaults.approvalRequired`)),d(``))},w=e=>{b(e)||(i(t=>({...t,"defaults.approvalRequired":h.filter(t=>t!==e)})),o(e=>new Set(e).add(`defaults.approvalRequired`)))},T=s.size+r.size;return(0,P.jsxs)(E,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Advanced`}),T>0&&(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:[r.size,` modified`]})]}),(0,P.jsxs)(`div`,{className:`mb-6`,children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Denied Read Paths`}),!f&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,P.jsx)(t,{size:j.xs}),` restart required`]})]}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Paths blocked at both the SDK and OS layer for all roles. System defaults (locked) cannot be removed. Uses `,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` as wildcard.`]}),(0,P.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:m.map(e=>{let n=y(e);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${n?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:[n&&(0,P.jsx)(t,{size:j.xs}),e,!n&&f&&(0,P.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>S(e),children:(0,P.jsx)(a,{size:j.xs})})]},e)})}),f&&(0,P.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,P.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`/absolute/path or ~/path`,value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())}}),(0,P.jsx)(_,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>x(),children:`Add`})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Approval Required Patterns`}),!p&&(0,P.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[(0,P.jsx)(t,{size:j.xs}),` restart required`]})]}),(0,P.jsxs)(`p`,{className:`mb-2 text-xs text-[var(--app-text-subtle)]`,children:[`Operations matching these glob patterns require user approval before execution. Uses SDK Permission Rule glob syntax (`,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`*`}),` = wildcard, e.g.,`,` `,(0,P.jsx)(`code`,{className:`text-[var(--app-text-muted)]`,children:`rm -rf *`}),`).`]}),(0,P.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:h.map(e=>{let n=b(e);return(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border px-2 py-0.5 text-xs ${n?`border-[var(--app-border)] bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`:`border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] text-[var(--app-warning-soft-text)]`}`,children:[n&&(0,P.jsx)(t,{size:j.xs}),e,!n&&p&&(0,P.jsx)(`button`,{type:`button`,className:`ml-0.5 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:()=>w(e),children:(0,P.jsx)(a,{size:j.xs})})]},e)})}),p&&(0,P.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,P.jsx)(`input`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1 text-xs text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`e.g. "curl * --request POST *"`,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),C())}}),(0,P.jsx)(_,{variant:`ghost`,size:`sm`,className:`scale-75`,onClick:()=>C(),children:`Add`})]})]})]})}function B(){let[e,t]=(0,N.useState)([]),[n,r]=(0,N.useState)(!0),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(15),[u,d]=(0,N.useState)(30),[f,p]=(0,N.useState)(500),[m,h]=(0,N.useState)(!1),g=2e3,v=e.find(e=>e.presetId===`feature-mining`)?.id;(0,N.useEffect)(()=>{(async()=>{try{let e=(await w(`/task-templates`)).templates.find(e=>e.presetId===`feature-mining`);e&&(t([e]),l(e.config?.max_sessions??15),d(e.config?.max_messages_per_session??30),p(e.config?.message_char_cap??500))}catch{}finally{r(!1)}})()},[]);let y=async()=>{if(v){a(!0),s(null);try{await b(v,{max_sessions:c,max_messages_per_session:u,message_char_cap:f}),s({type:`success`,text:`Feature Miner limits saved`}),h(!1)}catch(e){s({type:`error`,text:e instanceof Error?e.message:`Save failed`})}finally{a(!1)}}};if(n||!v)return null;let x=c*u*Math.min(f,100)/4,S=`~${Math.round(x).toLocaleString()} tokens (worst case)`;return(0,P.jsxs)(E,{children:[(0,P.jsxs)(`div`,{className:`mb-3 flex items-start justify-between gap-3`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Feature Miner Pre-fetch Limits`}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:`Controls how many chat sessions and messages the Feature Miner scans per run. Hard ceilings prevent prompt size from exceeding the model's context window.`})]}),m&&(0,P.jsx)(_,{size:`sm`,onClick:()=>void y(),disabled:i,children:i?`Saving...`:`Save`})]}),o&&(0,P.jsx)(`div`,{className:`mb-3 rounded px-3 py-2 text-xs ${o.type===`success`?`border border-[var(--app-success-soft-border)] bg-[var(--app-success-soft-bg)] text-[var(--app-success-soft-text)]`:`border border-[var(--app-danger-soft-border)] bg-[var(--app-danger-soft-bg)] text-[var(--app-danger-soft-text)]`}`,children:o.text}),(0,P.jsxs)(`div`,{className:`space-y-4`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-sessions`,children:`Max Sessions`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,50]})]}),(0,P.jsx)(`input`,{id:`fm-max-sessions`,type:`number`,min:1,max:50,value:c,onChange:e=>{l(Math.min(50,Math.max(1,parseInt(e.target.value)||1))),h(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Sessions to scan (most recent first). Default: 15.`})]}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-max-messages`,children:`Max Messages / Session`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,100]})]}),(0,P.jsx)(`input`,{id:`fm-max-messages`,type:`number`,min:1,max:100,value:u,onChange:e=>{d(Math.min(100,Math.max(1,parseInt(e.target.value)||1))),h(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Most recent messages per session. Default: 30.`})]}),(0,P.jsxs)(`div`,{className:`space-y-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`label`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,htmlFor:`fm-char-cap`,children:`Message Char Cap`}),(0,P.jsxs)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:[`ceiling: `,g]})]}),(0,P.jsx)(`input`,{id:`fm-char-cap`,type:`number`,min:10,max:g,value:f,onChange:e=>{p(Math.min(g,Math.max(10,parseInt(e.target.value)||10))),h(!0)},className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-2 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`}),(0,P.jsx)(`p`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`Max characters per message. Default: 500.`})]})]}),(0,P.jsxs)(`div`,{className:`flex items-center justify-between rounded border border-[var(--app-border)] bg-[var(--app-panel)] px-3 py-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-xs font-medium text-[var(--app-text-muted)]`,children:`Estimated worst-case prompt size`}),(0,P.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:S})]}),x>15e4&&(0,P.jsx)(`span`,{className:`text-[10px] text-[var(--app-warning)]`,children:`Near context window limit`})]})]})]})}function V(){let e=v()??``,[t,r]=(0,N.useState)(!1),[i,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(!1),[b,w]=(0,N.useState)(null),[T,D]=(0,N.useState)(null),k=e.length>12?e.slice(0,4)+`****`+e.slice(-4):`(no key in localStorage)`;async function A(){o(!0),D(null);try{let e=await y();x(e),w(e),c(!1)}catch(e){D(e instanceof Error?e.message:String(e)),c(!1)}finally{o(!1)}}function M(){S(),C()}return(0,P.jsxs)(E,{children:[(0,P.jsx)(O,{title:`Adam API Key`,description:`Rotate or sign out`}),(0,P.jsxs)(`div`,{className:`mt-3 space-y-3`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(`code`,{className:`flex-1 rounded bg-[var(--app-bg)] px-3 py-2 font-mono text-sm`,children:t?e||`(no key)`:k}),(0,P.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>r(e=>!e),children:t?`Hide`:`Show`})]}),(0,P.jsxs)(`div`,{className:`flex gap-2`,children:[(0,P.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>c(!0),disabled:i,children:[(0,P.jsx)(n,{size:j.xs,className:`mr-1`}),`Rotate key`]}),(0,P.jsxs)(_,{variant:`ghost`,size:`sm`,onClick:M,children:[(0,P.jsx)(a,{size:j.xs,className:`mr-1`}),`Log out`]})]}),T&&(0,P.jsx)(`div`,{className:`rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400`,children:T}),(0,P.jsxs)(`p`,{className:`text-xs text-[var(--app-muted)]`,children:[`Rotating generates a new key, writes it to `,(0,P.jsx)(`code`,{children:`~/.adam/adam.key`}),`, and invalidates the old key on every device that uses the Adam API (Web UI, TUI, other browsers). Channel adapters (WeChat, Telegram, Discord) keep their own credentials and are NOT affected. Only external callers of your `,(0,P.jsx)(`code`,{children:`/webhooks/:name`}),` endpoints need the new key.`]})]}),(0,P.jsx)(g,{open:s,children:(0,P.jsxs)(d,{children:[(0,P.jsxs)(h,{children:[(0,P.jsx)(u,{children:`Rotate API key?`}),(0,P.jsxs)(l,{children:[`The old key stops working immediately. Other browsers/TUI sessions and any external callers of `,(0,P.jsx)(`code`,{children:`/webhooks/:name`}),` will return 401 until updated. Channel adapters (WeChat, Telegram, Discord) use their own credentials and are not affected.`]})]}),(0,P.jsxs)(p,{children:[(0,P.jsx)(m,{onClick:()=>c(!1),children:`Cancel`}),(0,P.jsx)(f,{onClick:A,disabled:i,children:i?`Rotating...`:`Rotate`})]})]})}),(0,P.jsx)(g,{open:!!b,children:(0,P.jsxs)(d,{children:[(0,P.jsxs)(h,{children:[(0,P.jsx)(u,{children:`New API key`}),(0,P.jsx)(l,{children:`Save this somewhere safe. Other devices and channels need to be updated with this key.`})]}),(0,P.jsx)(`code`,{className:`mt-2 block break-all rounded bg-[var(--app-bg)] p-3 font-mono text-xs`,children:b}),(0,P.jsxs)(p,{children:[(0,P.jsx)(f,{onClick:()=>{b&&navigator.clipboard.writeText(b)},children:`Copy`}),(0,P.jsx)(f,{onClick:()=>w(null),children:`Done`})]})]})})]})}export{R as Settings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{F as t,b as n,lt as r}from"./vendor-icons-PF9RcPJx.js";import{t as i}from"./vendor-react-Cxy4EVtR.js";import{t as a}from"./Button-CYDgoTTo.js";import{r as o,t as s}from"./index-BsKlGx3x.js";import{t as c}from"./Card-DDGXsHus.js";import{t as l}from"./PageHeader-CugYeCci.js";import{a as u}from"./format-BUYXZqDw.js";import{t as d}from"./EmptyState-EuQHAv5Y.js";import{a as f,i as p,n as m,o as h,r as g,t as _}from"./Table-Cf6m8zLu.js";var v=e(r(),1),y=i(),b={engineer:`info`,analyst:`warning`,content_creator:`success`,reviewer:`muted`};function x(){let e=o(e=>e.strategies),r=o(e=>e.fetchStrategies);(0,v.useEffect)(()=>{r()},[r]);let i=new Map;for(let t of e){let e=i.get(t.roleId)??[];e.push(t),i.set(t.roleId,e)}return(0,y.jsxs)(`div`,{className:`space-y-5`,children:[(0,y.jsx)(l,{compact:!0,title:`Strategies`,description:`Bandit strategies grouped by role.`,metrics:[{label:`Catalog`,value:e.length},{label:`Roles`,value:i.size},{label:`Mature`,value:e.filter(e=>e.totalTrials>=10).length}],className:`px-4 py-3 lg:px-4 lg:py-3`,actions:(0,y.jsx)(a,{variant:`ghost`,size:`sm`,onClick:()=>void r(),children:(0,y.jsx)(n,{size:14})})}),e.length===0?(0,y.jsx)(c,{className:`p-4`,children:(0,y.jsx)(d,{icon:(0,y.jsx)(t,{size:32}),title:`No strategies`,description:`Strategies are created by the Thompson Sampling engine as agents process tasks.`,compact:!0})}):Array.from(i.entries()).map(([e,t])=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(s,{variant:b[e]??`muted`,children:e}),(0,y.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[t.length,` strategies`]})]}),(0,y.jsx)(c,{padding:!1,children:(0,y.jsxs)(_,{children:[(0,y.jsx)(f,{children:(0,y.jsxs)(h,{children:[(0,y.jsx)(p,{children:`Name`}),(0,y.jsx)(p,{children:`Task Type`}),(0,y.jsx)(p,{children:`Alpha`}),(0,y.jsx)(p,{children:`Beta`}),(0,y.jsx)(p,{children:`Trials`}),(0,y.jsx)(p,{children:`Avg Reward`}),(0,y.jsx)(p,{children:`Created`})]})}),(0,y.jsx)(m,{children:t.map(e=>(0,y.jsxs)(h,{children:[(0,y.jsx)(g,{className:`font-medium text-[var(--app-text)]`,children:e.name}),(0,y.jsx)(g,{children:(0,y.jsx)(`span`,{className:`rounded bg-[var(--app-panel-elevated)] px-1.5 py-0.5 font-mono text-[10px] text-[var(--app-text-muted)]`,children:e.taskType})}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.alpha.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.beta.toFixed(2)}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.totalTrials}),(0,y.jsx)(g,{className:`font-mono text-xs`,children:e.avgReward==null?`—`:e.avgReward.toFixed(3)}),(0,y.jsx)(g,{className:`text-xs text-[var(--app-text-subtle)]`,children:u(e.createdAt)})]},e.id))})]})})]},e))]})}export{x as Strategies};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-PF9RcPJx.js";import{t as n}from"./vendor-react-Cxy4EVtR.js";import{n as r}from"./dist-CgGno8kE.js";import{_ as i,b as a,u as o,x as s}from"./AlertDialog-DhA65f_0.js";import{i as c}from"./Button-CYDgoTTo.js";import{a as l}from"./index-BsKlGx3x.js";var u=e(t(),1);function d(e){let t=u.useRef({value:e,previous:e});return u.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var f=n(),p=`Switch`,[m,h]=a(p),[g,_]=m(p),v=u.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:a,defaultChecked:l,required:d,disabled:m,value:h=`on`,onCheckedChange:_,form:v,...y}=e,[b,x]=u.useState(null),w=c(t,e=>x(e)),T=u.useRef(!1),E=b?v||!!b.closest(`form`):!0,[D,O]=o({prop:a,defaultProp:l??!1,onChange:_,caller:p});return(0,f.jsxs)(g,{scope:n,checked:D,disabled:m,children:[(0,f.jsx)(i.button,{type:`button`,role:`switch`,"aria-checked":D,"aria-required":d,"data-state":C(D),"data-disabled":m?``:void 0,disabled:m,value:h,...y,ref:w,onClick:s(e.onClick,e=>{O(e=>!e),E&&(T.current=e.isPropagationStopped(),T.current||e.stopPropagation())})}),E&&(0,f.jsx)(S,{control:b,bubbles:!T.current,name:r,value:h,checked:D,required:d,disabled:m,form:v,style:{transform:`translateX(-100%)`}})]})});v.displayName=p;var y=`SwitchThumb`,b=u.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,a=_(y,n);return(0,f.jsx)(i.span,{"data-state":C(a.checked),"data-disabled":a.disabled?``:void 0,...r,ref:t})});b.displayName=y;var x=`SwitchBubbleInput`,S=u.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=u.useRef(null),s=c(o,a),p=d(n),m=l(t);return u.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(p!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[p,n,r]),(0,f.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...m,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});S.displayName=x;function C(e){return e?`checked`:`unchecked`}var w=v,T=b,E=u.forwardRef(({className:e,...t},n)=>(0,f.jsx)(w,{className:r(`peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-[var(--app-accent)] data-[state=unchecked]:bg-[var(--app-panel-muted)]`,e),...t,ref:n,children:(0,f.jsx)(T,{className:r(`pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0`)})}));E.displayName=w.displayName;export{E as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{lt as t}from"./vendor-icons-PF9RcPJx.js";import{t as n}from"./vendor-react-Cxy4EVtR.js";import{n as r}from"./dist-CgGno8kE.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{className:`overflow-x-auto`,children:(0,a.jsx)(`table`,{ref:n,className:r(`w-full text-sm`,e),...t})}));o.displayName=`Table`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`thead`,{ref:n,className:r(`border-b border-[var(--app-border)]`,e),...t}));s.displayName=`TableHeader`;var c=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`tbody`,{ref:n,className:r(`divide-y divide-[var(--app-border)]`,e),...t}));c.displayName=`TableBody`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`tr`,{ref:n,className:r(`transition-colors hover:bg-white/[0.04]`,e),...t}));l.displayName=`TableRow`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`th`,{ref:n,className:r(`px-3 py-2.5 text-left text-[11px] font-semibold uppercase tracking-[var(--app-tracking-micro)] text-[var(--app-text-subtle)]`,e),...t}));u.displayName=`TableHead`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`td`,{ref:n,className:r(`px-3 py-2.5 align-top text-[var(--app-text)]`,e),...t}));d.displayName=`TableCell`;var f=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`caption`,{ref:n,className:r(`mt-2 text-xs text-[var(--app-text-subtle)]`,e),...t}));f.displayName=`TableCaption`;var p=s,m=c,h=l,g=u,_=d;export{p as a,g as i,m as n,h as o,_ as r,o as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{B as t,I as n,K as r,L as i,Y as a,a as o,at as s,ct as c,it as l,p as u,q as d}from"./vendor-icons-Dk0hMuJz.js";import{f,r as p,t as m}from"./vendor-react-C6faO6LO.js";import{t as h}from"./Button-BehrGSvy.js";import{i as g,t as _}from"./api-Bux34u4-.js";import{n as v,t as y}from"./index-B3_4_qY6.js";import{i as b,n as x,r as S,t as C}from"./Card-B5E56u94.js";import{t as w}from"./PageHeader-B2CgcZ-t.js";import{t as T}from"./SectionHeader-CmXz6PM3.js";import{a as E,n as D,r as O,t as k}from"./format-BUYXZqDw.js";import{t as A}from"./ui-CerQw0jA.js";var j=e(c(),1),M=m(),N={reasoning:`text-[var(--app-accent)]`,tool_call:`text-[var(--app-accent-strong)]`,tool_result:`text-[var(--app-success)]`,approval_request:`text-[var(--app-warning)]`,approval_response:`text-[var(--app-warning-strong)]`,permission_denied:`text-[var(--app-indicator-alert)]`,error:`text-[var(--app-danger)]`,plugin_error:`text-[var(--app-danger)]`};function P({logs:e}){let[t,n]=(0,j.useState)(new Set);return e.length===0?(0,M.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No execution steps yet.`}):(0,M.jsx)(`div`,{className:`space-y-0`,children:e.map((r,i)=>{let o=i>0?e[i-1].timestamp:null,s=o?r.timestamp-o:null,c=r.type===`plugin_error`,l=t.has(i)?r.content:r.content.length>200?r.content.slice(0,200)+`...`:r.content;return(0,M.jsxs)(`div`,{className:`flex gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,M.jsx)(a,{size:10,className:`mt-1.5 flex-shrink-0 fill-current ${N[r.type]??`text-[var(--app-text-subtle)]`} ${c?`rounded-full ring-2 ring-[var(--app-danger)]`:``}`}),i<e.length-1&&(0,M.jsx)(`div`,{className:`mt-0.5 w-0.5 flex-1 bg-[var(--app-border)]`})]}),(0,M.jsxs)(`div`,{className:`flex-1 pb-4 ${c?`rounded-lg border border-[var(--app-danger)]/40 bg-[var(--app-danger-soft-bg-subtle)] p-3`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,r.index]}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r.toolName??r.type}),c&&(0,M.jsx)(y,{variant:`destructive`,children:`Plugin Error`}),(0,M.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:E(r.timestamp)}),s!=null&&s>0&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,s,`ms`]}),r.truncated&&(0,M.jsx)(y,{variant:`outline`,children:`truncated`})]}),l&&(0,M.jsx)(`button`,{className:`mt-2 w-full rounded-lg border border-[var(--app-border)] bg-white/[0.03] px-3 py-3 text-left font-mono text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,onClick:()=>{n(e=>{let t=new Set(e);return t.has(i)?t.delete(i):t.add(i),t})},children:l})]})]},r.id)})})}function F(){let{id:e}=f(),[a,c]=(0,j.useState)(null),[m,E]=(0,j.useState)([]),[N,F]=(0,j.useState)([]),[R,z]=(0,j.useState)([]),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(!1),[J,Y]=(0,j.useState)(!1),[X,Z]=(0,j.useState)(!1),Q=(0,j.useMemo)(()=>{if(!a)return`No diagnostics yet`;let e=[];return a.error&&e.push(`error`),N.length>0&&e.push(`${N.length} steps`),R.length>0&&e.push(`${R.length} delivery events`),e.length>0?e.join(` · `):`No diagnostics yet`},[R.length,N.length,a]);(0,j.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{if(!t)try{let n=await _(`/tasks/${e}`);if(t)return;c(n.task),U(null)}catch(e){if(t)return;U(e instanceof Error?e.message:`Failed to load task`)}};n(),_(`/tasks/${e}/plan`).then(e=>{t||E(e.plans)}).catch(()=>{t||E([])}),_(`/tasks/${e}/logs?limit=200`).then(e=>{t||F(e.logs)}).catch(()=>{t||F([])}),g(e).then(e=>{t||z(e)}).catch(()=>{t||z([])});let r=setInterval(n,3e3);return()=>{t=!0,clearInterval(r)}},[e]),(0,j.useEffect)(()=>{if(!a?.roleId||!e)return;let t=!1;return _(`/roles/${a.roleId}/scores?limit=100`).then(n=>{t||V(n.scores.find(t=>t.taskId===e)??null)}).catch(()=>{t||V(null)}),()=>{t=!0}},[a?.roleId,e]);let $=async()=>{if(e){G(!0);try{await _(`/tasks/${e}/cancel`,{method:`POST`}),c(e=>e&&{...e,status:`cancelled`})}finally{G(!1)}}};if(H)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-danger)]`,children:H})]});if(!a)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let ee=[`running`,`queued`,`pending`,`paused`].includes(a.status);return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(w,{eyebrow:`Task`,title:`Task Detail`,compact:!0,description:`Summary, execution, result, and diagnostics.`,metrics:[{label:`Status`,value:(0,M.jsx)(y,{variant:v(a.status),children:a.status})},{label:`Task`,value:a.id.slice(0,8)},{label:`Elapsed`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`},{label:`Spend`,value:a.costUsd==null?`—`:k(a.costUsd)}],actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(p,{to:`/work`,className:`inline-flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(s,{size:A.sm}),` Back to Tasks`]}),ee&&(0,M.jsxs)(h,{variant:`destructive`,size:`sm`,onClick:()=>void $(),disabled:W,children:[(0,M.jsx)(l,{size:A.sm}),W?`Cancelling...`:`Cancel Task`]})]})}),(0,M.jsx)(C,{className:`surface-accent text-white`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`text-kicker text-white/70`,children:`Summary`}),(0,M.jsx)(`p`,{className:`mt-2 text-base leading-7 text-white`,children:a.prompt.length>220&&!K?`${a.prompt.slice(0,220)}…`:a.prompt})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a.prompt.length>220?(0,M.jsxs)(h,{variant:`secondary`,size:`sm`,onClick:()=>q(e=>!e),children:[(0,M.jsx)(t,{size:A.sm}),K?`Collapse prompt`:`Show full prompt`]}):null,(0,M.jsxs)(h,{variant:`secondary`,size:`sm`,onClick:()=>Z(e=>!e),children:[(0,M.jsx)(u,{size:A.sm}),X?`Hide diagnostics`:`Show diagnostics`]})]})]})}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:d,label:`Created`,value:D(a.createdAt)}),(0,M.jsx)(L,{icon:d,label:`Duration`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`}),(0,M.jsx)(L,{icon:r,label:`Cost`,value:a.costUsd==null?`—`:k(a.costUsd)}),(0,M.jsx)(L,{icon:i,label:`Turns`,value:String(a.numTurns??`—`)})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:o,label:`Role`,value:a.roleId??`—`,mono:!0}),(0,M.jsx)(L,{icon:n,label:`Parent`,value:a.parentId??`—`,mono:!0}),a.templateId?(0,M.jsxs)(p,{to:`/work`,className:`block`,children:[(0,M.jsx)(L,{icon:n,label:`Template`,value:a.templateId,mono:!0}),(0,M.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:`View in Automations →`})]}):(0,M.jsx)(L,{icon:n,label:`Template`,value:`—`,mono:!0}),a.sourceSessionId&&(0,M.jsx)(L,{icon:i,label:`Source Session`,value:a.sourceSessionId.slice(0,8),mono:!0})]}),(a.deliverTo||a.reportTo)&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Delivery Targets`}),(0,M.jsx)(x,{children:`Where results and status updates are sent after execution.`})]})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[a.deliverTo&&a.deliverTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Output`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.deliverTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`d-${t}`))})]}),a.reportTo&&a.reportTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Status Reports`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.reportTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`r-${t}`))})]})]})]}),B&&(a.status===`completed`||a.status===`failed`)&&(0,M.jsx)(I,{score:B}),a.tokenUsage&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Token Usage`}),(0,M.jsx)(x,{children:`Input and output token totals for this execution.`})]})}),(0,M.jsxs)(`div`,{className:`flex gap-6 text-sm`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Input:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.input.toLocaleString()})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Output:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.output.toLocaleString()})]})]})]}),m.length>0&&(()=>{let e=m[0],t=e.plan.overallRisk===`high`?`destructive`:e.plan.overallRisk===`medium`?`warning`:`secondary`;return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Execution Plan`}),(0,M.jsx)(x,{children:`Expected steps, risk, and permissions before execution.`})]}),(0,M.jsxs)(y,{variant:t,children:[e.plan.overallRisk.toUpperCase(),` RISK`]}),(0,M.jsx)(y,{variant:`outline`,children:e.status})]})}),(0,M.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,e.plan.steps.length,`)`]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:e.plan.steps.map(e=>(0,M.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,M.jsx)(y,{variant:e.riskLevel===`high`?`destructive`:e.riskLevel===`medium`?`warning`:`secondary`,children:e.riskLevel})]}),(0,M.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]}),e.expectedOutput&&(0,M.jsxs)(`div`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`Expected: `,e.expectedOutput]})]},e.index))}),Object.keys(e.plan.requiredPermissions).length>0&&(0,M.jsxs)(`div`,{className:`mt-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(e.plan.requiredPermissions).map(e=>(0,M.jsx)(y,{variant:`secondary`,children:e},e))})]}),e.deviationReport&&(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg-subtle)] p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-warning)] mb-2`,children:`Deviation Report`}),(0,M.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2`,children:[`Planned: `,e.deviationReport.stepsPlanned,` | Executed: `,e.deviationReport.stepsExecuted,` | Accuracy: `,(e.deviationReport.overallAccuracy*100).toFixed(0),`%`]}),e.deviationReport.deviations.length>0&&(0,M.jsx)(`div`,{className:`space-y-1`,children:e.deviationReport.deviations.map((e,t)=>(0,M.jsxs)(`div`,{className:`text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-warning)] font-mono`,children:[`[`,e.deviationType,`]`]}),(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[` Step `,e.stepIndex,`: `]}),(0,M.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.actual})]},t))})]}),e.learnedRules&&e.learnedRules.length>0&&(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:`Learned Rules`}),(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.learnedRules.map((e,t)=>(0,M.jsxs)(`li`,{className:`text-xs text-[var(--app-text-muted)] flex items-start gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-[var(--app-accent)] mt-0.5`,children:`*`}),e]},t))})]})]})})(),N.length>0&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(b,{children:[`Execution Timeline (`,N.length,` steps)`]}),(0,M.jsx)(x,{children:`Ordered execution events, tool calls, and error markers.`})]})}),(0,M.jsx)(P,{logs:N})]}),a.result&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Result`}),(0,M.jsx)(x,{children:`The final task output. Raw text stays collapsed until needed.`})]}),a.result.length>360?(0,M.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>Y(e=>!e),children:J?`Collapse`:`Expand`}):null]})}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:a.result.length>360&&!J?`${a.result.slice(0,360)}…`:a.result})]}),a.error&&(()=>{let e=[`plugin`,`--plugin-dir`,`failed to load plugin`],t=a.error.toLowerCase(),n=e.some(e=>t.includes(e)),r=n?a.error.split(`
|
|
2
|
-
`).find(t=>e.some(e=>t.toLowerCase().includes(e))):null;return(0,M.jsxs)(C,{className:n?`border-[var(--app-danger)]`:``,children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Error`}),(0,M.jsx)(x,{children:`Execution failed or returned an error condition.`})]}),n&&(0,M.jsx)(y,{variant:`warning`,children:`Plugin Issue`})]})}),n&&r&&(0,M.jsx)(`div`,{className:`mb-2 rounded bg-[var(--app-warning-soft-bg-subtle)] px-2 py-1 text-xs text-[var(--app-warning)]`,children:r}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-danger-soft-bg-subtle)] p-3 font-mono text-xs text-[var(--app-danger)]`,children:a.error})]})})(),(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Diagnostics`}),(0,M.jsx)(x,{children:Q})]})}),X?R.length>0?(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(T,{title:`Delivery Log`,description:`Recent delivery attempts and outcomes.`}),(0,M.jsx)(`div`,{className:`space-y-2`,children:R.map(e=>{let t=e.status===`delivered`?`success`:e.status===`pending`?`secondary`:`destructive`,n=e.target.type===`webhook`?e.target.webhookUrl:e.target.type===`channel`?`channel ${e.target.channelId.slice(0,8)}`:`session ${e.target.sessionId?.slice(0,8)}`;return(0,M.jsxs)(`div`,{className:`surface-panel-muted rounded-lg px-3 py-3 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(y,{variant:t,children:e.status}),(0,M.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:n}),e.messageType?(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`(`,e.messageType,`)`]}):null]}),e.error?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-[var(--app-danger-soft-text)]`,children:e.error}):null,(0,M.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:[D(e.createdAt),e.deliveredAt&&` \u2192 ${D(e.deliveredAt)}`]})]},e.id)})})]}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`No delivery events recorded yet.`}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`Diagnostics are hidden by default because this section can contain raw execution details and operational data.`})]})]})}function I({score:e}){let t=[{label:`Task Success`,value:e.scores.taskSuccess,weight:`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{J as t,L as n,R as r,V as i,X as a,a as o,at as s,lt as c,m as l,ot as u,q as d}from"./vendor-icons-PF9RcPJx.js";import{f,r as p,t as m}from"./vendor-react-Cxy4EVtR.js";import{t as h}from"./Button-CYDgoTTo.js";import{i as g,t as _}from"./api-D-UzHSDq.js";import{n as v,t as y}from"./index-BsKlGx3x.js";import{i as b,n as x,r as S,t as C}from"./Card-DDGXsHus.js";import{t as w}from"./PageHeader-CugYeCci.js";import{t as T}from"./SectionHeader-DihC0CnO.js";import{a as E,n as D,r as O,t as k}from"./format-BUYXZqDw.js";import{t as A}from"./ui-CerQw0jA.js";var j=e(c(),1),M=m(),N={reasoning:`text-[var(--app-accent)]`,tool_call:`text-[var(--app-accent-strong)]`,tool_result:`text-[var(--app-success)]`,approval_request:`text-[var(--app-warning)]`,approval_response:`text-[var(--app-warning-strong)]`,permission_denied:`text-[var(--app-indicator-alert)]`,error:`text-[var(--app-danger)]`,plugin_error:`text-[var(--app-danger)]`};function P({logs:e}){let[t,n]=(0,j.useState)(new Set);return e.length===0?(0,M.jsx)(`p`,{className:`text-sm text-[var(--app-text-subtle)]`,children:`No execution steps yet.`}):(0,M.jsx)(`div`,{className:`space-y-0`,children:e.map((r,i)=>{let o=i>0?e[i-1].timestamp:null,s=o?r.timestamp-o:null,c=r.type===`plugin_error`,l=t.has(i)?r.content:r.content.length>200?r.content.slice(0,200)+`...`:r.content;return(0,M.jsxs)(`div`,{className:`flex gap-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,M.jsx)(a,{size:10,className:`mt-1.5 flex-shrink-0 fill-current ${N[r.type]??`text-[var(--app-text-subtle)]`} ${c?`rounded-full ring-2 ring-[var(--app-danger)]`:``}`}),i<e.length-1&&(0,M.jsx)(`div`,{className:`mt-0.5 w-0.5 flex-1 bg-[var(--app-border)]`})]}),(0,M.jsxs)(`div`,{className:`flex-1 pb-4 ${c?`rounded-lg border border-[var(--app-danger)]/40 bg-[var(--app-danger-soft-bg-subtle)] p-3`:``}`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,r.index]}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:r.toolName??r.type}),c&&(0,M.jsx)(y,{variant:`destructive`,children:`Plugin Error`}),(0,M.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:E(r.timestamp)}),s!=null&&s>0&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`+`,s,`ms`]}),r.truncated&&(0,M.jsx)(y,{variant:`outline`,children:`truncated`})]}),l&&(0,M.jsx)(`button`,{className:`mt-2 w-full rounded-lg border border-[var(--app-border)] bg-white/[0.03] px-3 py-3 text-left font-mono text-xs text-[var(--app-text-muted)] transition-colors hover:border-[var(--app-border-strong)] hover:text-[var(--app-text)]`,onClick:()=>{n(e=>{let t=new Set(e);return t.has(i)?t.delete(i):t.add(i),t})},children:l})]})]},r.id)})})}function F(){let{id:e}=f(),[a,c]=(0,j.useState)(null),[m,E]=(0,j.useState)([]),[N,F]=(0,j.useState)([]),[R,z]=(0,j.useState)([]),[B,V]=(0,j.useState)(null),[H,U]=(0,j.useState)(null),[W,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(!1),[J,Y]=(0,j.useState)(!1),[X,Z]=(0,j.useState)(!1),Q=(0,j.useMemo)(()=>{if(!a)return`No diagnostics yet`;let e=[];return a.error&&e.push(`error`),N.length>0&&e.push(`${N.length} steps`),R.length>0&&e.push(`${R.length} delivery events`),e.length>0?e.join(` · `):`No diagnostics yet`},[R.length,N.length,a]);(0,j.useEffect)(()=>{if(!e)return;let t=!1,n=async()=>{if(!t)try{let n=await _(`/tasks/${e}`);if(t)return;c(n.task),U(null)}catch(e){if(t)return;U(e instanceof Error?e.message:`Failed to load task`)}};n(),_(`/tasks/${e}/plan`).then(e=>{t||E(e.plans)}).catch(()=>{t||E([])}),_(`/tasks/${e}/logs?limit=200`).then(e=>{t||F(e.logs)}).catch(()=>{t||F([])}),g(e).then(e=>{t||z(e)}).catch(()=>{t||z([])});let r=setInterval(n,3e3);return()=>{t=!0,clearInterval(r)}},[e]),(0,j.useEffect)(()=>{if(!a?.roleId||!e)return;let t=!1;return _(`/roles/${a.roleId}/scores?limit=100`).then(n=>{t||V(n.scores.find(t=>t.taskId===e)??null)}).catch(()=>{t||V(null)}),()=>{t=!0}},[a?.roleId,e]);let $=async()=>{if(e){G(!0);try{await _(`/tasks/${e}/cancel`,{method:`POST`}),c(e=>e&&{...e,status:`cancelled`})}finally{G(!1)}}};if(H)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(u,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-danger)]`,children:H})]});if(!a)return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(p,{to:`/work`,className:`flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(u,{size:A.sm}),` Back to Tasks`]}),(0,M.jsx)(C,{className:`text-center text-[var(--app-text-subtle)]`,children:`Loading...`})]});let ee=[`running`,`queued`,`pending`,`paused`].includes(a.status);return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(w,{eyebrow:`Task`,title:`Task Detail`,compact:!0,description:`Summary, execution, result, and diagnostics.`,metrics:[{label:`Status`,value:(0,M.jsx)(y,{variant:v(a.status),children:a.status})},{label:`Task`,value:a.id.slice(0,8)},{label:`Elapsed`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`},{label:`Spend`,value:a.costUsd==null?`—`:k(a.costUsd)}],actions:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(p,{to:`/work`,className:`inline-flex items-center gap-1.5 text-sm text-[var(--app-text-muted)] hover:text-[var(--app-text)]`,children:[(0,M.jsx)(u,{size:A.sm}),` Back to Tasks`]}),ee&&(0,M.jsxs)(h,{variant:`destructive`,size:`sm`,onClick:()=>void $(),disabled:W,children:[(0,M.jsx)(s,{size:A.sm}),W?`Cancelling...`:`Cancel Task`]})]})}),(0,M.jsx)(C,{className:`surface-accent text-white`,children:(0,M.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-start lg:justify-between`,children:[(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`text-kicker text-white/70`,children:`Summary`}),(0,M.jsx)(`p`,{className:`mt-2 text-base leading-7 text-white`,children:a.prompt.length>220&&!K?`${a.prompt.slice(0,220)}…`:a.prompt})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a.prompt.length>220?(0,M.jsxs)(h,{variant:`secondary`,size:`sm`,onClick:()=>q(e=>!e),children:[(0,M.jsx)(i,{size:A.sm}),K?`Collapse prompt`:`Show full prompt`]}):null,(0,M.jsxs)(h,{variant:`secondary`,size:`sm`,onClick:()=>Z(e=>!e),children:[(0,M.jsx)(l,{size:A.sm}),X?`Hide diagnostics`:`Show diagnostics`]})]})]})}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:t,label:`Created`,value:D(a.createdAt)}),(0,M.jsx)(L,{icon:t,label:`Duration`,value:a.totalDurationMs?O(a.totalDurationMs):a.startedAt?O(Date.now()-a.startedAt):`—`}),(0,M.jsx)(L,{icon:d,label:`Cost`,value:a.costUsd==null?`—`:k(a.costUsd)}),(0,M.jsx)(L,{icon:r,label:`Turns`,value:String(a.numTurns??`—`)})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,M.jsx)(L,{icon:o,label:`Role`,value:a.roleId??`—`,mono:!0}),(0,M.jsx)(L,{icon:n,label:`Parent`,value:a.parentId??`—`,mono:!0}),a.templateId?(0,M.jsxs)(p,{to:`/work`,className:`block`,children:[(0,M.jsx)(L,{icon:n,label:`Template`,value:a.templateId,mono:!0}),(0,M.jsx)(`span`,{className:`mt-0.5 block text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:`View in Automations →`})]}):(0,M.jsx)(L,{icon:n,label:`Template`,value:`—`,mono:!0}),a.sourceSessionId&&(0,M.jsx)(L,{icon:r,label:`Source Session`,value:a.sourceSessionId.slice(0,8),mono:!0})]}),(a.deliverTo||a.reportTo)&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Delivery Targets`}),(0,M.jsx)(x,{children:`Where results and status updates are sent after execution.`})]})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[a.deliverTo&&a.deliverTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Output`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.deliverTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`d-${t}`))})]}),a.reportTo&&a.reportTo.length>0&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)] mb-1`,children:`Status Reports`}),(0,M.jsx)(`div`,{className:`space-y-1`,children:a.reportTo.map((e,t)=>(0,M.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-[var(--app-text)]`,children:[(0,M.jsx)(y,{variant:`outline`,children:e.type===`channel`?`Channel`:`Session`}),e.type===`channel`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`font-mono text-xs`,children:e.channelId.slice(0,8)}),e.chatId&&(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`chat: `,e.chatId.slice(0,8)]})]}):(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:[`session `,e.sessionId?.slice(0,8)]})]},`r-${t}`))})]})]})]}),B&&(a.status===`completed`||a.status===`failed`)&&(0,M.jsx)(I,{score:B}),a.tokenUsage&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Token Usage`}),(0,M.jsx)(x,{children:`Input and output token totals for this execution.`})]})}),(0,M.jsxs)(`div`,{className:`flex gap-6 text-sm`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Input:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.input.toLocaleString()})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:`Output:`}),` `,(0,M.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:a.tokenUsage.output.toLocaleString()})]})]})]}),m.length>0&&(()=>{let e=m[0],t=e.plan.overallRisk===`high`?`destructive`:e.plan.overallRisk===`medium`?`warning`:`secondary`;return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Execution Plan`}),(0,M.jsx)(x,{children:`Expected steps, risk, and permissions before execution.`})]}),(0,M.jsxs)(y,{variant:t,children:[e.plan.overallRisk.toUpperCase(),` RISK`]}),(0,M.jsx)(y,{variant:`outline`,children:e.status})]})}),(0,M.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,e.plan.steps.length,`)`]}),(0,M.jsx)(`div`,{className:`space-y-2`,children:e.plan.steps.map(e=>(0,M.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,M.jsx)(y,{variant:e.riskLevel===`high`?`destructive`:e.riskLevel===`medium`?`warning`:`secondary`,children:e.riskLevel})]}),(0,M.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]}),e.expectedOutput&&(0,M.jsxs)(`div`,{className:`mt-0.5 text-xs text-[var(--app-text-subtle)]`,children:[`Expected: `,e.expectedOutput]})]},e.index))}),Object.keys(e.plan.requiredPermissions).length>0&&(0,M.jsxs)(`div`,{className:`mt-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(e.plan.requiredPermissions).map(e=>(0,M.jsx)(y,{variant:`secondary`,children:e},e))})]}),e.deviationReport&&(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg-subtle)] p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-warning)] mb-2`,children:`Deviation Report`}),(0,M.jsxs)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2`,children:[`Planned: `,e.deviationReport.stepsPlanned,` | Executed: `,e.deviationReport.stepsExecuted,` | Accuracy: `,(e.deviationReport.overallAccuracy*100).toFixed(0),`%`]}),e.deviationReport.deviations.length>0&&(0,M.jsx)(`div`,{className:`space-y-1`,children:e.deviationReport.deviations.map((e,t)=>(0,M.jsxs)(`div`,{className:`text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-warning)] font-mono`,children:[`[`,e.deviationType,`]`]}),(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[` Step `,e.stepIndex,`: `]}),(0,M.jsx)(`span`,{className:`text-[var(--app-text)]`,children:e.actual})]},t))})]}),e.learnedRules&&e.learnedRules.length>0&&(0,M.jsxs)(`div`,{className:`mt-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:`Learned Rules`}),(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.learnedRules.map((e,t)=>(0,M.jsxs)(`li`,{className:`text-xs text-[var(--app-text-muted)] flex items-start gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-[var(--app-accent)] mt-0.5`,children:`*`}),e]},t))})]})]})})(),N.length>0&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(b,{children:[`Execution Timeline (`,N.length,` steps)`]}),(0,M.jsx)(x,{children:`Ordered execution events, tool calls, and error markers.`})]})}),(0,M.jsx)(P,{logs:N})]}),a.result&&(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Result`}),(0,M.jsx)(x,{children:`The final task output. Raw text stays collapsed until needed.`})]}),a.result.length>360?(0,M.jsx)(h,{variant:`ghost`,size:`sm`,onClick:()=>Y(e=>!e),children:J?`Collapse`:`Expand`}):null]})}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-panel-elevated)] p-3 font-mono text-xs text-[var(--app-text)]`,children:a.result.length>360&&!J?`${a.result.slice(0,360)}…`:a.result})]}),a.error&&(()=>{let e=[`plugin`,`--plugin-dir`,`failed to load plugin`],t=a.error.toLowerCase(),n=e.some(e=>t.includes(e)),r=n?a.error.split(`
|
|
2
|
+
`).find(t=>e.some(e=>t.toLowerCase().includes(e))):null;return(0,M.jsxs)(C,{className:n?`border-[var(--app-danger)]`:``,children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Error`}),(0,M.jsx)(x,{children:`Execution failed or returned an error condition.`})]}),n&&(0,M.jsx)(y,{variant:`warning`,children:`Plugin Issue`})]})}),n&&r&&(0,M.jsx)(`div`,{className:`mb-2 rounded bg-[var(--app-warning-soft-bg-subtle)] px-2 py-1 text-xs text-[var(--app-warning)]`,children:r}),(0,M.jsx)(`pre`,{className:`max-h-96 overflow-auto whitespace-pre-wrap rounded-md bg-[var(--app-danger-soft-bg-subtle)] p-3 font-mono text-xs text-[var(--app-danger)]`,children:a.error})]})})(),(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(b,{children:`Diagnostics`}),(0,M.jsx)(x,{children:Q})]})}),X?R.length>0?(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsx)(T,{title:`Delivery Log`,description:`Recent delivery attempts and outcomes.`}),(0,M.jsx)(`div`,{className:`space-y-2`,children:R.map(e=>{let t=e.status===`delivered`?`success`:e.status===`pending`?`secondary`:`destructive`,n=e.target.type===`webhook`?e.target.webhookUrl:e.target.type===`channel`?`channel ${e.target.channelId.slice(0,8)}`:`session ${e.target.sessionId?.slice(0,8)}`;return(0,M.jsxs)(`div`,{className:`surface-panel-muted rounded-lg px-3 py-3 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(y,{variant:t,children:e.status}),(0,M.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:n}),e.messageType?(0,M.jsxs)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`(`,e.messageType,`)`]}):null]}),e.error?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-[var(--app-danger-soft-text)]`,children:e.error}):null,(0,M.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--app-text-subtle)]`,children:[D(e.createdAt),e.deliveredAt&&` \u2192 ${D(e.deliveredAt)}`]})]},e.id)})})]}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`No delivery events recorded yet.`}):(0,M.jsx)(`div`,{className:`surface-panel-muted rounded-lg px-4 py-4 text-sm text-[var(--app-text-subtle)]`,children:`Diagnostics are hidden by default because this section can contain raw execution details and operational data.`})]})]})}function I({score:e}){let t=[{label:`Task Success`,value:e.scores.taskSuccess,weight:`25%`},{label:`Plan Accuracy`,value:e.scores.planAccuracy,weight:`20%`},{label:`Permission Compliance`,value:e.scores.permissionCompliance,weight:`20%`},{label:`Efficiency`,value:e.scores.efficiency,weight:`15%`},{label:`Intent Fulfillment`,value:e.scores.intentFulfillment,weight:`20%`,pending:e.scores.intentFulfillment==null}];return(0,M.jsxs)(C,{children:[(0,M.jsx)(S,{children:(0,M.jsx)(b,{children:`Quality Score`})}),(0,M.jsxs)(`div`,{className:`space-y-3`,children:[t.map(e=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`mb-1 flex items-center justify-between text-xs`,children:[(0,M.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[e.label,` `,(0,M.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`(`,e.weight,`)`]})]}),e.pending?(0,M.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,title:`Intent eval pending or failed`,children:`—`}):(0,M.jsxs)(`span`,{className:`font-mono text-[var(--app-text)]`,children:[((e.value??0)*100).toFixed(0),`%`]})]}),!e.pending&&e.value!=null&&(0,M.jsx)(`div`,{className:`h-1.5 w-full rounded-full bg-[var(--app-panel-elevated)]`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full ${e.value<.4?`bg-[var(--app-danger)]`:`bg-[var(--app-accent)]`}`,style:{width:`${e.value*100}%`}})})]},e.label)),(0,M.jsxs)(`div`,{className:`mt-2 flex items-center justify-between border-t border-[var(--app-border)] pt-2`,children:[(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`Weighted Score`}),(0,M.jsxs)(`span`,{className:`font-mono text-sm font-semibold text-[var(--app-text)]`,children:[(e.scores.weighted*100).toFixed(0),`%`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:`EMA (after this task)`}),(0,M.jsxs)(`span`,{className:`font-mono text-sm font-semibold ${e.emaScore<.4?`text-[var(--app-danger)]`:`text-[var(--app-success)]`}`,children:[(e.emaScore*100).toFixed(0),`%`]})]})]})]})}function L({icon:e,label:t,value:n,mono:r}){return(0,M.jsxs)(C,{className:`flex flex-col gap-1`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[var(--app-text-subtle)]`,children:[(0,M.jsx)(e,{size:12}),(0,M.jsx)(`span`,{className:`text-xs`,children:t})]}),(0,M.jsx)(`span`,{className:`text-sm text-[var(--app-text)] truncate ${r?`font-mono text-xs`:``}`,children:n})]})}export{F as TaskDetail};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{C as t,D as n,E as r,H as i,P as a,at as o,b as s,et as c,lt as l,nt as u,s as d,tt as f}from"./vendor-icons-PF9RcPJx.js";import{r as p,t as m}from"./vendor-react-Cxy4EVtR.js";import{n as h}from"./dist-CgGno8kE.js";import{_ as g,a as _,b as v,c as y,d as b,g as ee,i as te,n as x,o as ne,p as S,r as re,s as ie,t as ae,u as oe,v as se,x as C}from"./AlertDialog-DhA65f_0.js";import{i as w,t as T}from"./Button-CYDgoTTo.js";import{t as ce}from"./vendor-state-aQJ7d4tA.js";import{t as E}from"./api-D-UzHSDq.js";import{i as D,n as O,r as k,t as A}from"./index-BsKlGx3x.js";import{t as j}from"./Card-DDGXsHus.js";import{t as M}from"./PageHeader-CugYeCci.js";import{t as le}from"./SectionHeader-DihC0CnO.js";import{a as ue,o as de,t as fe}from"./format-BUYXZqDw.js";import{t as pe}from"./EmptyState-EuQHAv5Y.js";import{t as me}from"./ui-CerQw0jA.js";import{t as he}from"./useIsMobileLayout-2GbB90oO.js";import{a as ge,i as N,n as _e,o as ve,r as P,t as ye}from"./Table-Cf6m8zLu.js";import{t as be}from"./Switch-B3w5KMMc.js";import{Goals as xe,t as Se}from"./Goals-CkKJDCiU.js";var F=e(l(),1),I=m();function Ce(e){let t=e+`CollectionProvider`,[n,r]=v(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=F.useRef(null),a=F.useRef(new Map).current;return(0,I.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=se(s),l=F.forwardRef((e,t)=>{let{scope:n,children:r}=e;return(0,I.jsx)(c,{ref:w(t,a(s,n).collectionRef),children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=se(u),p=F.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=F.useRef(null),s=w(t,o),c=a(u,n);return F.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,I.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return F.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var L=F.createContext(void 0);function R(e){let t=F.useContext(L);return e||t||`ltr`}var z=`rovingFocusGroup.onEntryFocus`,we={bubbles:!1,cancelable:!0},B=`RovingFocusGroup`,[V,Te,H]=Ce(B),[Ee,De]=v(B,[H]),[U,Oe]=Ee(B),W=F.forwardRef((e,t)=>(0,I.jsx)(V.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(V.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,I.jsx)(ke,{...e,ref:t})})}));W.displayName=B;var ke=F.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=F.useRef(null),p=w(t,f),m=R(a),[h,_]=oe({prop:o,defaultProp:s??null,onChange:c,caller:B}),[v,y]=F.useState(!1),b=ee(l),te=Te(n),x=F.useRef(!1),[ne,S]=F.useState(0);return F.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(z,b),()=>e.removeEventListener(z,b)},[b]),(0,I.jsx)(U,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:F.useCallback(e=>_(e),[_]),onItemShiftTab:F.useCallback(()=>y(!0),[]),onFocusableItemAdd:F.useCallback(()=>S(e=>e+1),[]),onFocusableItemRemove:F.useCallback(()=>S(e=>e-1),[]),children:(0,I.jsx)(g.div,{tabIndex:v||ne===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:C(e.onMouseDown,()=>{x.current=!0}),onFocus:C(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!v){let t=new CustomEvent(z,we);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=te().filter(e=>e.focusable);Pe([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:C(e.onBlur,()=>y(!1))})})}),G=`RovingFocusGroupItem`,Ae=F.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=S(),l=a||c,u=Oe(G,n),d=u.currentTabStopId===l,f=Te(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return F.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,I.jsx)(V.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,I.jsx)(g.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:C(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:C(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:C(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Ne(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Fe(n,r+1):n.slice(r+1)}setTimeout(()=>Pe(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});Ae.displayName=G;var je={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Me(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function Ne(e,t,n){let r=Me(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return je[r]}function Pe(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function Fe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var Ie=W,Le=Ae,K=`Tabs`,[Re,ze]=v(K,[De]),Be=De(),[Ve,q]=Re(K),J=F.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=R(s),[d,f]=oe({prop:r,onChange:i,defaultProp:a??``,caller:K});return(0,I.jsx)(Ve,{scope:n,baseId:S(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,I.jsx)(g.div,{dir:u,"data-orientation":o,...l,ref:t})})});J.displayName=K;var He=`TabsList`,Ue=F.forwardRef((e,t)=>{let{__scopeTabs:n,loop:r=!0,...i}=e,a=q(He,n),o=Be(n);return(0,I.jsx)(Ie,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,I.jsx)(g.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})});Ue.displayName=He;var We=`TabsTrigger`,Ge=F.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=q(We,n),s=Be(n),c=X(o.baseId,r),l=qe(o.baseId,r),u=r===o.value;return(0,I.jsx)(Le,{asChild:!0,...s,focusable:!i,active:u,children:(0,I.jsx)(g.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:C(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:C(e.onKeyDown,e=>{[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:C(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})});Ge.displayName=We;var Y=`TabsContent`,Ke=F.forwardRef((e,t)=>{let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=q(Y,n),c=X(s.baseId,r),l=qe(s.baseId,r),u=r===s.value,d=F.useRef(u);return F.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,I.jsx)(b,{present:i||u,children:({present:n})=>(0,I.jsx)(g.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})});Ke.displayName=Y;function X(e,t){return`${e}-trigger-${t}`}function qe(e,t){return`${e}-content-${t}`}var Je=J,Ye=Ue,Xe=Ge,Ze=Ke,Qe=Je,$e=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ye,{ref:n,className:h(`surface-panel-muted inline-flex min-h-11 items-center justify-center gap-1 rounded-full p-1 text-[var(--app-text-muted)]`,e),...t}));$e.displayName=Ye.displayName;var Z=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Xe,{ref:n,className:h(`inline-flex items-center justify-center whitespace-nowrap rounded-full px-4 py-2 text-sm font-medium ring-offset-[var(--app-canvas)] transition-[background-color,color,box-shadow] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:surface-panel data-[state=active]:text-[var(--app-text)] data-[state=active]:shadow-[var(--app-shadow-sm)]`,e),...t}));Z.displayName=Xe.displayName;var Q=F.forwardRef(({className:e,...t},n)=>(0,I.jsx)(Ze,{ref:n,className:h(`mt-4 ring-offset-[var(--app-canvas)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`,e),...t}));Q.displayName=Ze.displayName;var et=[{label:`All`,value:`all`},{label:`Running`,value:`running`},{label:`Pending`,value:`pending`},{label:`Completed`,value:`completed`},{label:`Failed`,value:`failed`},{label:`Cancelled`,value:`cancelled`},{label:`Blocked`,value:`blocked`}],$=new Set([`pending`,`queued`,`running`,`paused`]);function tt(){let e=k(e=>e.tasks),n=k(e=>e.fetchTasks),[r,i]=(0,F.useState)(`all`),[c,l]=(0,F.useState)(!1),[d,f]=(0,F.useState)(``),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(new Set),[v,y]=(0,F.useState)(!1),b=he();(0,F.useEffect)(()=>{let e=r===`all`?void 0:r;n(e);let t=setInterval(()=>void n(e),5e3);return()=>clearInterval(t)},[n,r]),(0,F.useEffect)(()=>{_(new Set)},[r]);let ee=async()=>{if(d.trim()){h(!0);try{await E(`/tasks`,{method:`POST`,body:JSON.stringify({prompt:d.trim()})}),f(``),l(!1),n(r===`all`?void 0:r)}finally{h(!1)}}},te=e=>{_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},x=()=>{let e=S.filter(e=>$.has(e.status)).map(e=>e.id);_(new Set(e))},ne=async()=>{if(g.size!==0){y(!0);try{await E(`/tasks/batch-cancel`,{method:`POST`,body:JSON.stringify({taskIds:Array.from(g)})}),_(new Set),n(r===`all`?void 0:r)}finally{y(!1)}}},S=[...e].sort((e,t)=>t.createdAt-e.createdAt),re=Array.from(g).filter(t=>{let n=e.find(e=>e.id===t);return n&&$.has(n.status)});return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(le,{title:`Tasks`,description:`Review active execution, cancel work, or create the next task.`,compact:!0,action:(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[g.size>0&&(0,I.jsxs)(T,{variant:`destructive`,size:`sm`,onClick:()=>void ne(),disabled:v||re.length===0,children:[(0,I.jsx)(o,{size:me.sm}),v?`Cancelling...`:`Cancel ${re.length} task${re.length===1?``:`s`}`]}),(0,I.jsx)(T,{variant:`ghost`,size:`sm`,onClick:()=>void n(r===`all`?void 0:r),children:(0,I.jsx)(s,{size:me.sm})}),(0,I.jsxs)(T,{size:`sm`,onClick:()=>l(!c),children:[(0,I.jsx)(t,{size:me.sm}),`New Task`]})]})}),c&&(0,I.jsxs)(j,{className:`flex gap-2`,children:[(0,I.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Enter task prompt...`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ee()}}),(0,I.jsx)(T,{onClick:()=>void ee(),disabled:m||!d.trim(),children:m?`Creating...`:`Create`}),(0,I.jsx)(T,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 md:flex-row md:items-center md:justify-between`,children:[(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:et.map(e=>(0,I.jsx)(`button`,{onClick:()=>i(e.value),className:`rounded-md px-2.5 py-1 text-xs font-medium transition-colors ${r===e.value?`bg-[var(--app-panel-elevated)] text-[var(--app-text)]`:`text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:e.label},e.value))}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[S.some(e=>$.has(e.status))&&(0,I.jsx)(`button`,{onClick:x,className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:`Select all cancellable`}),g.size>0&&(0,I.jsxs)(`button`,{onClick:()=>_(new Set),className:`text-xs text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`,children:[`Clear selection (`,g.size,`)`]})]})]}),S.length===0?(0,I.jsx)(j,{padding:!1,children:(0,I.jsx)(pe,{icon:(0,I.jsx)(a,{size:32}),title:`No tasks found`,description:r===`all`?`Create a task to get started`:`No tasks with status "${r}"`})}):b?(0,I.jsx)(`div`,{className:`space-y-3`,children:S.map(e=>(0,I.jsx)(j,{className:g.has(e.id)?`border-[var(--app-accent)]/40 bg-[var(--app-accent)]/8`:``,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,I.jsx)(`div`,{className:`pt-1`,children:$.has(e.status)?(0,I.jsx)(`button`,{onClick:()=>te(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${g.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:g.has(e.id)&&(0,I.jsx)(u,{size:12})}):(0,I.jsx)(`span`,{className:`inline-block h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,I.jsx)(p,{to:`/tasks/${e.id}`,className:`break-all font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)}),(0,I.jsx)(`p`,{className:`break-words text-sm font-medium leading-6 text-[var(--app-text)]`,children:de(e.prompt,140)})]}),(0,I.jsx)(A,{variant:O(e.status),children:e.status})]}),(0,I.jsxs)(`div`,{className:`grid gap-2 text-xs text-[var(--app-text-subtle)] sm:grid-cols-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Role`}),(0,I.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.roleId?e.roleId.slice(0,12):`—`})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Cost`}),(0,I.jsx)(`div`,{className:`mt-1 font-mono text-[var(--app-text)]`,children:e.costUsd==null?`—`:fe(e.costUsd)})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`span`,{className:`text-[10px] uppercase tracking-[0.14em] text-[var(--app-text-subtle)]`,children:`Created`}),(0,I.jsx)(`div`,{className:`mt-1 text-[var(--app-text)]`,children:ue(e.createdAt)})]})]})]})]})},e.id))}):(0,I.jsx)(j,{padding:!1,children:(0,I.jsxs)(ye,{children:[(0,I.jsx)(ge,{children:(0,I.jsxs)(ve,{children:[(0,I.jsx)(N,{className:`w-8`,children:(0,I.jsx)(`button`,{onClick:()=>{g.size>0&&g.size===S.filter(e=>$.has(e.status)).length?_(new Set):x()},className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${g.size>0&&g.size===S.filter(e=>$.has(e.status)).length?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:g.size>0&&g.size===S.filter(e=>$.has(e.status)).length&&(0,I.jsx)(u,{size:12})})}),(0,I.jsx)(N,{children:`ID`}),(0,I.jsx)(N,{children:`Prompt`}),(0,I.jsx)(N,{children:`Status`}),(0,I.jsx)(N,{children:`Role`}),(0,I.jsx)(N,{children:`Cost`}),(0,I.jsx)(N,{children:`Created`})]})}),(0,I.jsx)(_e,{children:S.map(e=>(0,I.jsxs)(ve,{className:g.has(e.id)?`bg-[var(--app-panel-elevated)]/50`:``,children:[(0,I.jsx)(P,{children:$.has(e.status)?(0,I.jsx)(`button`,{onClick:()=>te(e.id),className:`flex h-4 w-4 items-center justify-center rounded border transition-colors ${g.has(e.id)?`border-[var(--app-accent-strong)] bg-[var(--app-accent)] text-white`:`border-[var(--app-border-strong)] bg-transparent hover:border-[var(--app-text-muted)]`}`,children:g.has(e.id)&&(0,I.jsx)(u,{size:12})}):(0,I.jsx)(`span`,{className:`inline-block w-4`})}),(0,I.jsx)(P,{children:(0,I.jsx)(p,{to:`/tasks/${e.id}`,className:`font-mono text-xs text-[var(--app-accent)] hover:text-[var(--app-accent)]`,children:e.id.slice(0,8)})}),(0,I.jsx)(P,{children:(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`div`,{className:`break-words font-medium text-[var(--app-text)]`,children:de(e.prompt,120)}),(0,I.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[e.totalDurationMs?fe(e.costUsd??0):`Awaiting completion`,` · `,ue(e.createdAt)]})]})}),(0,I.jsx)(P,{children:(0,I.jsx)(A,{variant:O(e.status),children:e.status})}),(0,I.jsx)(P,{children:(0,I.jsx)(`span`,{className:`font-mono text-xs text-[var(--app-text-subtle)]`,children:e.roleId?e.roleId.slice(0,12):`—`})}),(0,I.jsx)(P,{className:`font-mono text-xs`,children:e.costUsd==null?`—`:fe(e.costUsd)}),(0,I.jsx)(P,{className:`text-xs text-[var(--app-text-subtle)]`,children:ue(e.createdAt)})]},e.id))})]})})]})}function nt(e){return`step-${e+1}`}function rt(){let e=k(e=>e.templates),a=k(e=>e.fetchTemplates),o=k(e=>e.goals),l=k(e=>e.fetchGoals),u=k(e=>e.roles),p=k(e=>e.fetchRoles),[m,h]=(0,F.useState)(!1),[g,v]=(0,F.useState)(``),[b,ee]=(0,F.useState)(`manual`),[S,oe]=(0,F.useState)(``),[se,C]=(0,F.useState)(``),[w,ce]=(0,F.useState)(``),[O,M]=(0,F.useState)([{id:`step-1`,prompt:``}]),[de,fe]=(0,F.useState)(!1),[me,he]=(0,F.useState)(!1),[xe,Ce]=(0,F.useState)(null),[L,R]=(0,F.useState)(null),[z,we]=(0,F.useState)(null),[B,V]=(0,F.useState)(null),[Te,H]=(0,F.useState)(`template_only`),[Ee,De]=(0,F.useState)(!1),[U,Oe]=(0,F.useState)(null),[W,ke]=(0,F.useState)(``),[G,Ae]=(0,F.useState)(`manual`),[je,Me]=(0,F.useState)(``),[Ne,Pe]=(0,F.useState)(``),[Fe,Ie]=(0,F.useState)(``),[Le,K]=(0,F.useState)(``),[Re,ze]=(0,F.useState)(``),[Be,Ve]=(0,F.useState)([]),[q,J]=(0,F.useState)([]),[He,Ue]=(0,F.useState)(!1),[We,Ge]=(0,F.useState)(!1),[Y,Ke]=(0,F.useState)(`prompt`),[X,qe]=(0,F.useState)([]),[Je,Ye]=(0,F.useState)([]),[Xe,Ze]=(0,F.useState)([]),[Qe,$e]=(0,F.useState)(null),[Z,Q]=(0,F.useState)([]),[et,$]=(0,F.useState)(!1),tt=(0,F.useCallback)(async e=>{$(!0);try{let t=await E(`/workflow-executions?templateId=${e}&limit=5`);Q(await Promise.all(t.executions.map(async e=>{try{let t=await E(`/workflow-executions/${e.id}`);return{...t.execution,stepTasks:t.stepTasks}}catch{return{...e,stepTasks:[]}}})))}catch{Q([])}finally{$(!1)}},[]),rt=(0,F.useCallback)(e=>{Qe===e?($e(null),Q([])):($e(e),tt(e))},[Qe,tt]),it=(0,F.useMemo)(()=>Object.fromEntries(e.map(e=>[e.id,e.name])),[e]),at=e=>e.type===`cron`?`Cron: ${e.cron??`—`}`:e.type===`once`?`Once at ${e.runAt?new Date(e.runAt).toLocaleString():`—`}`:e.type===`template_complete`?`When template '${it[e.event?.split(`:`)[1]??``]??`[deleted template]`}' completes`:e.type===`event`?`On event '${Be.find(t=>t.id===e.eventDefId)?.name??`[deleted event]`}'`:e.type;(0,F.useEffect)(()=>{a(),l(),p(),(async()=>{try{Ve(await E(`/event-defs`))}catch{}})()},[a,l,p]);let ot=async()=>{if(g.trim()&&!(Y===`prompt`&&O.every(e=>!e.prompt.trim()))&&!(Y===`goal`&&X.length===0)){he(!0);try{let e={name:g.trim(),trigger:{type:b,...b===`cron`&&se?{cron:se}:{},...b===`once`&&w?{runAt:new Date(w).toISOString()}:{},...b===`template_complete`&&S?{event:`template_complete:${S}`}:{},...b===`event`&&Le?{eventDefId:Le}:{}},enabled:!0,...Je.length>0?{deliverTo:Je}:{},...de?{config:{continueOnError:!0}}:{}};Y===`prompt`?e.steps=O.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||nt(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{}})):(e.goalIds=X,e.steps=[]),await E(`/task-templates`,{method:`POST`,body:JSON.stringify(e)}),v(``),M([{id:`step-1`,prompt:``}]),C(``),ce(``),oe(``),K(``),qe([]),Ye([]),h(!1),a()}finally{he(!1)}}},st=async t=>{let n=e.find(e=>e.id===t);Ce(t);try{await E(`/task-templates/${t}/run`,{method:`POST`}),D.success(`Triggered: ${n?.name??t}`)}catch(e){let t=e instanceof Error?e.message:`Failed to trigger template`;D.error(`Trigger failed: ${t}`)}finally{Ce(null)}},ct=async e=>{we(e),H(`template_only`),V(null);try{V((await E(`/task-templates/${e}/dependents`)).dependents)}catch{V({executionCount:0,taskCount:0})}},lt=async(t,n)=>{let r=e.find(e=>e.id===t);De(!0);try{let e=await E(`/task-templates/${t}?mode=${n}`,{method:`DELETE`}),i=[];e.deletedCounts.workflowExecutions>0&&i.push(`${e.deletedCounts.workflowExecutions} execution${e.deletedCounts.workflowExecutions===1?``:`s`}`),e.deletedCounts.tasks>0&&i.push(`${e.deletedCounts.tasks} task${e.deletedCounts.tasks===1?``:`s`}`);let o=i.length?` (+ ${i.join(`, `)})`:``;D.success(`Deleted: ${r?.name??t}${o}`),a()}catch(e){let t=e instanceof Error?e.message:`Failed to delete template`;D.error(`Delete failed: ${t}`)}finally{De(!1)}},ut=async t=>{let n=e.find(e=>e.id===t);if(!n)return;if(![`cron`,`once`,`template_complete`].includes(n.trigger.type)){D.error(`Toggle not applicable for manual triggers`);return}let r=!n.enabled;try{await E(`/task-templates/${t}`,{method:`PATCH`,body:JSON.stringify({enabled:r})}),D.success(`${n.name} ${r?`enabled`:`disabled`}`),a()}catch(e){let t=e instanceof Error?e.message:`Failed to toggle template`;D.error(`Toggle failed: ${t}`)}},dt=e=>{Oe(e.id),ke(e.name),Ae(e.trigger.type===`workflow_complete`?`template_complete`:e.trigger.type),Me(e.trigger.cron??``),Pe(e.trigger.runAt?new Date(e.trigger.runAt).toISOString().slice(0,16):``),J(e.steps.map(e=>({id:e.id,prompt:e.prompt,roleId:e.roleId,dependsOn:e.dependsOn,config:e.config}))),Ue(e.config?.continueOnError??!1),Ze(e.deliverTo??[]),Ie(e.trigger.type===`template_complete`||e.trigger.type===`workflow_complete`?e.trigger.event?.split(`:`)[1]??``:``),ze(e.trigger.eventDefId??``)},ft=async()=>{if(!(!U||!W.trim()||q.every(e=>!e.prompt.trim()))){Ge(!0);try{await E(`/task-templates/${U}`,{method:`PATCH`,body:JSON.stringify({name:W.trim(),trigger:{type:G,...G===`cron`&&je?{cron:je}:{},...G===`once`&&Ne?{runAt:new Date(Ne).toISOString()}:{},...G===`template_complete`&&Fe?{event:`template_complete:${Fe}`}:{},...G===`event`&&Re?{eventDefId:Re}:{}},steps:q.filter(e=>e.prompt.trim()).map((e,t)=>({id:e.id||nt(t),prompt:e.prompt.trim(),...e.roleId?{roleId:e.roleId}:{},...e.dependsOn&&e.dependsOn.length>0?{dependsOn:e.dependsOn}:{},...e.config&&(e.config.timeout!==void 0||e.config.maxTurns!==void 0)?{config:e.config}:{}})),enabled:e.find(e=>e.id===U)?.enabled??!0,...He?{config:{continueOnError:!0}}:{config:{}},deliverTo:Xe.length>0?Xe:void 0})}),Oe(null),a(),D.success(`Template updated`)}catch(e){let t=e instanceof Error?e.message:`Failed to update template`;D.error(t)}finally{Ge(!1)}}},pt=e.find(e=>e.id===L),mt=e.find(e=>e.id===z);return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(le,{title:`Automations`,description:`Reusable workflows, manual triggers, and recent workflow runs.`,compact:!0,action:(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(T,{variant:`ghost`,size:`sm`,onClick:()=>void a(),children:(0,I.jsx)(s,{size:14})}),(0,I.jsxs)(T,{size:`sm`,onClick:()=>h(!m),children:[(0,I.jsx)(t,{size:14}),`New Automation`]})]})}),m&&(0,I.jsxs)(j,{className:`space-y-3`,children:[(0,I.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:g,onChange:e=>v(e.target.value)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:b,onChange:e=>ee(e.target.value),children:[(0,I.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,I.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,I.jsx)(`option`,{value:`once`,children:`One-time`}),(0,I.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,I.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),b===`template_complete`&&(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:S,onChange:e=>oe(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==U).map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),b===`event`&&(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Le,onChange:e=>K(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),b===`cron`&&(0,I.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression (e.g. */5 * * * *)`,value:se,onChange:e=>C(e.target.value)}),b===`once`&&(0,I.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:w,onChange:e=>ce(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Action type:`}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>Ke(`prompt`),className:`rounded px-2 py-1 text-xs ${Y===`prompt`?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Custom Prompt`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>Ke(`goal`),className:`rounded px-2 py-1 text-xs ${Y===`goal`?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)] hover:text-[var(--app-text)]`}`,children:`Goal Reference`})]})]}),Y===`prompt`?(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,I.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:()=>M([...O,{id:nt(O.length),prompt:``}]),children:[(0,I.jsx)(t,{size:12}),` Add Step`]})]}),O.map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,I.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...O];r[t]={...e,roleId:n.target.value||void 0},M(r)},children:[(0,I.jsx)(`option`,{value:``,children:`Role (template default)`}),u.filter(e=>e.source!==`system`).map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),O.length>1&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>M(O.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,I.jsx)(d,{size:12})})]}),(0,I.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt${t>0?` (use {{`+O[t-1].id+`.result}} for prev output)`:``}`,rows:2,value:e.prompt,onChange:n=>{let r=[...O];r[t]={...e,prompt:n.target.value},M(r)}}),t>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),O.slice(0,t).map(n=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...O];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},M(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,I.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...O],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},M(r)}})]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,I.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...O],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},M(r)}})]})]})]},e.id))]}):(0,I.jsx)(`div`,{className:`space-y-1`,children:o.length===0?(0,I.jsx)(`p`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No goals available`}):o.map(e=>(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] hover:text-[var(--app-text)] cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:X.includes(e.id),onChange:t=>{t.target.checked?qe([...X,e.id]):qe(X.filter(t=>t!==e.id))},className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),(0,I.jsx)(`span`,{className:`truncate`,children:e.name}),(0,I.jsx)(A,{variant:`muted`,className:`text-[10px]`,children:e.status})]},e.id))}),O.length>1&&(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:de,onChange:e=>fe(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error (skip failed step dependents, run independent steps)`]}),(0,I.jsx)(Se,{value:Je,onChange:Ye}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(T,{onClick:()=>void ot(),disabled:me||!g.trim()||Y===`prompt`&&O.every(e=>!e.prompt.trim())||Y===`goal`&&X.length===0||b===`template_complete`&&!S,children:me?`Creating...`:`Create`}),(0,I.jsx)(T,{variant:`ghost`,onClick:()=>h(!1),children:`Cancel`})]})]}),U!==null&&(0,I.jsxs)(j,{className:`space-y-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-[var(--app-text)]`,children:`Edit Automation`}),(0,I.jsx)(`input`,{className:`w-full rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Template name`,value:W,onChange:e=>ke(e.target.value)}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Triggered by:`}),(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:G,onChange:e=>Ae(e.target.value),children:[(0,I.jsx)(`option`,{value:`manual`,children:`Manual`}),(0,I.jsx)(`option`,{value:`cron`,children:`Schedule (Cron)`}),(0,I.jsx)(`option`,{value:`once`,children:`One-time`}),(0,I.jsx)(`option`,{value:`template_complete`,children:`Template completion`}),(0,I.jsx)(`option`,{value:`event`,children:`Event (definition)`})]}),G===`template_complete`&&(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Fe,onChange:e=>Ie(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`-- Select target template --`}),e.filter(e=>e.id!==U).map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`event`&&(0,I.jsxs)(`select`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Re,onChange:e=>ze(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:`-- Select event --`}),Be.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),G===`cron`&&(0,I.jsx)(`input`,{className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Cron expression`,value:je,onChange:e=>Me(e.target.value)}),G===`once`&&(0,I.jsx)(`input`,{type:`datetime-local`,className:`flex-1 rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-3 py-1.5 text-sm text-[var(--app-text)] focus:border-[var(--app-accent)] focus:outline-none`,value:Ne,onChange:e=>Pe(e.target.value)})]}),(0,I.jsxs)(`div`,{className:`space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-muted)]`,children:`Steps`}),(0,I.jsxs)(T,{variant:`ghost`,size:`sm`,onClick:()=>J([...q,{id:nt(q.length),prompt:``}]),children:[(0,I.jsx)(t,{size:12}),` Add Step`]})]}),q.map((e,t)=>(0,I.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] p-2 space-y-1.5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-[10px] font-mono text-[var(--app-text-subtle)]`,children:e.id}),(0,I.jsxs)(`select`,{className:`flex-1 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1 text-xs text-[var(--app-text)]`,value:e.roleId??``,onChange:n=>{let r=[...q];r[t]={...e,roleId:n.target.value||void 0},J(r)},children:[(0,I.jsx)(`option`,{value:``,children:`Role (template default)`}),u.filter(e=>e.source!==`system`).map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),q.length>1&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>J(q.filter((e,n)=>n!==t)),className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,children:(0,I.jsx)(d,{size:12})})]}),(0,I.jsx)(`textarea`,{className:`w-full rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-2 py-1.5 text-sm text-[var(--app-text)] placeholder:text-[var(--app-text-subtle)] focus:border-[var(--app-accent)] focus:outline-none`,placeholder:`Step ${t+1} prompt`,rows:2,value:e.prompt,onChange:n=>{let r=[...q];r[t]={...e,prompt:n.target.value},J(r)}}),t>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`text-[10px] text-[var(--app-text-subtle)]`,children:`depends on:`}),q.slice(0,t).map(n=>(0,I.jsx)(`button`,{type:`button`,onClick:()=>{let r=e.dependsOn??[],i=[...q];i[t]={...e,dependsOn:r.includes(n.id)?r.filter(e=>e!==n.id):[...r,n.id]},J(i)},className:`rounded px-1.5 py-0.5 text-[10px] ${(e.dependsOn??[]).includes(n.id)?`bg-[var(--app-accent)] text-white`:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)] hover:text-[var(--app-text)]`}`,children:n.id},n.id))]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`timeout(s):`,(0,I.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.timeout??``,onChange:n=>{let r=[...q],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,timeout:i}},J(r)}})]}),(0,I.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px] text-[var(--app-text-subtle)]`,children:[`max turns:`,(0,I.jsx)(`input`,{type:`number`,min:0,placeholder:`default`,className:`w-20 rounded border border-[var(--app-border)] bg-[var(--app-panel-elevated)] px-1.5 py-0.5 text-xs text-[var(--app-text)]`,value:e.config?.maxTurns??``,onChange:n=>{let r=[...q],i=n.target.value===``?void 0:Number(n.target.value);r[t]={...e,config:{...e.config,maxTurns:i}},J(r)}})]})]})]},e.id))]}),q.length>1&&(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-[var(--app-text)] cursor-pointer`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:He,onChange:e=>Ue(e.target.checked),className:`rounded border-[var(--app-border-strong)] bg-[var(--app-panel-elevated)]`}),`Continue on error`]}),(0,I.jsx)(Se,{value:Xe,onChange:Ze}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(T,{onClick:()=>void ft(),disabled:We||!W.trim()||q.every(e=>!e.prompt.trim()),children:We?`Saving...`:`Save`}),(0,I.jsx)(T,{variant:`ghost`,onClick:()=>Oe(null),children:`Cancel`})]})]}),(0,I.jsx)(j,{padding:!1,children:e.length===0?(0,I.jsx)(pe,{icon:(0,I.jsx)(i,{size:32}),title:`No automations`,description:`Create an automation to run recurring tasks`}):(0,I.jsxs)(ye,{children:[(0,I.jsx)(ge,{children:(0,I.jsxs)(ve,{children:[(0,I.jsx)(N,{children:`Name`}),(0,I.jsx)(N,{children:`Trigger`}),(0,I.jsx)(N,{children:`Schedule`}),(0,I.jsx)(N,{children:`Steps`}),(0,I.jsx)(N,{children:`Enabled`}),(0,I.jsx)(N,{children:`Created`}),(0,I.jsx)(N,{children:`Webhook URL`}),(0,I.jsx)(N,{children:`Actions`})]})}),(0,I.jsx)(_e,{children:e.map(e=>(0,I.jsxs)(F.Fragment,{children:[(0,I.jsxs)(ve,{children:[(0,I.jsxs)(P,{className:`font-medium text-[var(--app-text)]`,children:[(0,I.jsxs)(`button`,{type:`button`,onClick:()=>rt(e.id),className:`flex items-center gap-1 hover:text-[var(--app-accent)] transition-colors`,children:[Qe===e.id?(0,I.jsx)(f,{size:12}):(0,I.jsx)(c,{size:12}),e.name]}),(e.isPreset||e.presetId)&&(0,I.jsx)(A,{variant:`info`,className:`ml-2`,children:`Preset`})]}),(0,I.jsx)(P,{children:(0,I.jsx)(A,{variant:e.trigger.type===`cron`?`info`:(e.trigger.type,`muted`),children:at(e.trigger)})}),(0,I.jsx)(P,{className:`font-mono text-xs`,children:e.trigger.type===`once`&&e.trigger.runAt?new Date(e.trigger.runAt).toLocaleString():e.trigger.cron??`—`}),(0,I.jsx)(P,{className:`font-mono text-xs`,children:e.goalIds&&e.goalIds.length>0?`Goals: ${e.goalIds.length}`:(()=>{let t=new Set(e.steps.filter(e=>e.roleId).map(e=>e.roleId));return t.size>0?`${e.steps.length} steps / ${t.size} roles`:String(e.steps.length)})()}),(0,I.jsx)(P,{children:[`cron`,`once`,`template_complete`].every(t=>e.trigger.type!==t)?(0,I.jsx)(`span`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`—`}):(0,I.jsx)(be,{checked:e.enabled,onCheckedChange:()=>void ut(e.id),"aria-label":`Toggle ${e.name}`})}),(0,I.jsx)(P,{className:`text-xs text-[var(--app-text-subtle)]`,children:e.createdAt?ue(e.createdAt):`—`}),(0,I.jsx)(P,{className:`font-mono text-xs text-[var(--app-text-muted)]`,children:e.enabled?`POST /webhooks/${e.id}`:`—`}),(0,I.jsx)(P,{children:(0,I.jsxs)(`div`,{className:`flex gap-1`,children:[(0,I.jsx)(T,{variant:`ghost`,size:`sm`,onClick:()=>dt(e),title:`Edit`,children:(0,I.jsx)(n,{size:12})}),(0,I.jsx)(T,{variant:`ghost`,size:`sm`,onClick:()=>R(e.id),disabled:xe===e.id,title:`Run now`,children:(0,I.jsx)(r,{size:12})}),(0,I.jsx)(T,{variant:`ghost`,size:`sm`,className:`text-[var(--app-danger)] hover:text-[var(--app-danger-soft-text)]`,onClick:()=>{ct(e.id)},title:`Delete`,children:(0,I.jsx)(d,{size:12})})]})})]}),Qe===e.id&&(0,I.jsx)(ve,{children:(0,I.jsxs)(P,{colSpan:8,className:`bg-[var(--app-panel)]/50 p-3`,children:[(0,I.jsx)(`div`,{className:`text-xs text-[var(--app-text-muted)] mb-2 font-medium`,children:`Recent Executions`}),et?(0,I.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Loading...`}):Z.length===0?(0,I.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`No executions yet`}):(0,I.jsx)(`div`,{className:`space-y-1.5`,children:Z.map(t=>{let n=Object.entries(t.stepStatuses),r=n.filter(([,e])=>e.status===`completed`).length,i=n.filter(([,e])=>e.status===`failed`).length,a=n.filter(([,e])=>e.status===`skipped`).length,o=n.filter(([,e])=>e.status===`cancelled`).length,s=n.length,c=new Map(t.stepTasks.filter(e=>e.stepId).map(e=>[e.stepId,e])),l=[...e.steps.map(e=>e.id),...Object.keys(t.stepStatuses).filter(t=>!e.steps.some(e=>e.id===t))];return(0,I.jsxs)(`div`,{className:`rounded border border-[var(--app-border)] bg-[var(--app-canvas)]/50 p-2.5 space-y-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,I.jsx)(A,{variant:t.status===`completed`?`success`:t.status===`failed`?`destructive`:t.status===`partial`?`warning`:t.status===`cancelled`?`secondary`:`muted`,children:t.status}),(0,I.jsx)(`span`,{className:`text-[var(--app-text-subtle)]`,children:new Date(t.startedAt).toLocaleString()}),s>0&&(0,I.jsxs)(`span`,{className:`text-[var(--app-text-muted)]`,children:[r,`/`,s,` steps`,(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[i>0&&(0,I.jsxs)(`span`,{className:`text-[var(--app-danger)]`,children:[i,` failed`]}),a>0&&(0,I.jsxs)(`span`,{className:`text-[var(--app-warning)]`,children:[a,` skipped`]}),o>0&&(0,I.jsxs)(`span`,{className:`text-[var(--app-text)]`,children:[o,` cancelled`]})]})]}),t.completedAt&&(0,I.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[Math.round((t.completedAt-t.startedAt)/1e3),`s`]}),(0,I.jsx)(`span`,{className:`font-mono text-[var(--app-text-subtle)] truncate max-w-[120px]`,children:t.id.slice(0,8)})]}),(0,I.jsx)(`div`,{className:`space-y-1.5`,children:l.map(n=>{let r=t.stepStatuses[n];if(!r)return null;let i=e.steps.find(e=>e.id===n),a=c.get(n),o=a?.roleId??r.roleId??i?.roleId,s=u.find(e=>e.id===o)?.name??o,l=a?.error??r.error??a?.result??r.result;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto_auto] gap-2 rounded bg-[var(--app-panel)]/60 px-2 py-1.5 text-xs`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[var(--app-text)]`,children:n}),s&&(0,I.jsxs)(`span`,{className:`text-[var(--app-warning-soft-text)]`,children:[`@`,s]}),i?.dependsOn&&i.dependsOn.length>0&&(0,I.jsxs)(`span`,{className:`text-[var(--app-text-subtle)]`,children:[`after `,i.dependsOn.join(`, `)]})]}),l&&(0,I.jsx)(`div`,{className:`mt-1 truncate ${r.status===`failed`?`text-[var(--app-danger-soft-text)]`:r.status===`skipped`?`text-[var(--app-warning-soft-text)]`:r.status===`cancelled`?`text-[var(--app-text)]`:`text-[var(--app-text-muted)]`}`,children:l})]}),(0,I.jsx)(A,{variant:r.status===`completed`?`success`:r.status===`failed`?`destructive`:r.status===`skipped`?`warning`:r.status===`cancelled`?`secondary`:`muted`,children:r.status}),(0,I.jsxs)(`div`,{className:`text-right text-[var(--app-text-subtle)]`,children:[a?.completedAt&&(0,I.jsxs)(`div`,{children:[Math.max(0,Math.round((a.completedAt-a.createdAt)/1e3)),`s`]}),a?.id&&(0,I.jsx)(`div`,{className:`font-mono`,children:a.id.slice(0,8)})]})]},`${t.id}-${n}`)})})]},t.id)})})]})})]},e.id))})]})}),(0,I.jsx)(ae,{open:L!==null,onOpenChange:e=>{e||R(null)},children:(0,I.jsxs)(te,{children:[(0,I.jsxs)(ie,{children:[(0,I.jsx)(y,{children:`Run Template`}),(0,I.jsxs)(_,{children:[`Run “`,pt?.name,`” now? This will execute the template immediately.`]})]}),(0,I.jsxs)(ne,{children:[(0,I.jsx)(re,{children:`Cancel`}),(0,I.jsx)(x,{onClick:()=>{L&&st(L),R(null)},children:`Run Now`})]})]})}),(0,I.jsx)(ae,{open:z!==null,onOpenChange:e=>{e||(we(null),V(null),H(`template_only`))},children:(0,I.jsxs)(te,{children:[(0,I.jsxs)(ie,{children:[(0,I.jsx)(y,{children:`Delete Template`}),(0,I.jsx)(_,{children:B===null?(0,I.jsx)(I.Fragment,{children:`Loading…`}):B.taskCount===0&&B.executionCount===0?(0,I.jsxs)(I.Fragment,{children:[`Delete “`,mt?.name,`”? This action cannot be undone.`]}):B.taskCount===0?(0,I.jsxs)(I.Fragment,{children:[`“`,mt?.name,`” has `,B.executionCount,` execution`,B.executionCount===1?``:`s`,` which will be removed. Delete?`]}):(0,I.jsxs)(I.Fragment,{children:[`“`,mt?.name,`” has`,` `,B.executionCount>0&&(0,I.jsxs)(I.Fragment,{children:[B.executionCount,` execution`,B.executionCount===1?``:`s`]}),B.executionCount>0&&B.taskCount>0&&` and `,B.taskCount,` task`,B.taskCount===1?``:`s`,`. Choose what to delete:`]})})]}),B!==null&&B.taskCount>0&&(0,I.jsxs)(`div`,{className:`space-y-2 px-1`,children:[(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`template_only`,checked:Te===`template_only`,onChange:()=>H(`template_only`),className:`mt-1`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:`Template only`}),(0,I.jsx)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:`Removes the automation. Tasks remain under the Tasks tab as history.`})]})]}),(0,I.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[(0,I.jsx)(`input`,{type:`radio`,name:`deleteMode`,value:`with_tasks`,checked:Te===`with_tasks`,onChange:()=>H(`with_tasks`),className:`mt-1`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`text-sm font-medium`,children:`Template and its tasks`}),(0,I.jsxs)(`div`,{className:`text-xs text-[var(--app-text-subtle)]`,children:[`Also deletes `,B.taskCount,` task`,B.taskCount===1?``:`s`,` and their score history. Cannot be undone.`]})]})]})]}),(0,I.jsxs)(ne,{children:[(0,I.jsx)(re,{disabled:Ee,children:`Cancel`}),(0,I.jsx)(x,{className:`bg-[var(--app-danger)] hover:bg-[var(--app-danger)]`,disabled:Ee||B===null,onClick:()=>{z&<(z,B&&B.taskCount>0?Te:`template_only`),we(null),V(null),H(`template_only`)},children:`Delete`})]})]})})]})}function it(){let{tasks:e,templates:t,goals:n}=k(ce(e=>({tasks:e.tasks,templates:e.templates,goals:e.goals}))),r=k(e=>e.fetchTasks),i=k(e=>e.fetchTemplates),a=k(e=>e.fetchGoals);return(0,F.useEffect)(()=>{r(),i(),a()},[r,i,a]),(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsx)(M,{eyebrow:`Operations`,title:`Work`,description:`Tasks, automations, and goals in one place.`,metrics:[{label:`Running`,value:e.filter(e=>e.status===`running`).length},{label:`Automations`,value:t.length},{label:`Goals`,value:n.length}],compact:!0}),(0,I.jsxs)(Qe,{defaultValue:`tasks`,children:[(0,I.jsxs)($e,{children:[(0,I.jsx)(Z,{value:`tasks`,children:`Tasks`}),(0,I.jsx)(Z,{value:`automations`,children:`Automations`}),(0,I.jsx)(Z,{value:`goals`,children:`Goals`})]}),(0,I.jsx)(Q,{value:`tasks`,children:(0,I.jsx)(tt,{})}),(0,I.jsx)(Q,{value:`automations`,children:(0,I.jsx)(rt,{})}),(0,I.jsx)(Q,{value:`goals`,children:(0,I.jsx)(xe,{})})]})]})}export{it as Work};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-Dw2cE7zH.js";var t=e({AUTH_STORAGE_KEY:()=>r,ApiError:()=>n,api:()=>c,clearStoredApiKey:()=>o,fetchDeliveryLog:()=>l,getStoredApiKey:()=>i,listMistakePatterns:()=>f,redirectToLogin:()=>s,rotateApiKey:()=>d,setStoredApiKey:()=>a,updateMistakePattern:()=>p,updateTaskTemplateConfig:()=>m,verifyApiKey:()=>u}),n=class extends Error{status;code;constructor(e,t,n){super(n),this.name=`ApiError`,this.status=e,this.code=t}},r=`adam_api_key`;function i(){return typeof localStorage<`u`?localStorage.getItem(r):null}function a(e){localStorage.setItem(r,e)}function o(){localStorage.removeItem(r)}function s(){if(typeof window>`u`||window.location.pathname===`/ui/login`)return;let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href=`/ui/login?returnTo=${e}`}async function c(e,t){let r=i(),a={...t?.headers,...r?{"x-api-key":r}:{}};t?.body&&(a[`Content-Type`]??=`application/json`);let c=await fetch(e,{...t,headers:a});if(!c.ok){let e=`UNKNOWN_ERROR`,t=c.statusText;try{let n=await c.json();e=n.code??e,t=n.message??t}catch{}throw c.status===401&&(o(),s()),new n(c.status,e,t)}if(c.status!==204)return c.json()}async function l(e,t=50){return(await c(`/tasks/${e}/delivery-log?limit=${t}`)).logs}async function u(e){return(await fetch(`/auth/verify`,{headers:{"x-api-key":e}})).ok}async function d(){return(await c(`/auth/rotate`,{method:`POST`})).apiKey}async function f(e){let t=new URLSearchParams;e&&t.set(`status`,e);let n=t.toString();return(await c(`/mistake-patterns${n?`?${n}`:``}`)).mistakePatterns}async function p(e,t){await c(`/mistake-patterns/${e}`,{method:`PATCH`,body:JSON.stringify({status:t})})}async function m(e,t){return c(`/task-templates/${e}`,{method:`PATCH`,body:JSON.stringify({config:t})})}export{i as a,d as c,m as d,u as f,l as i,a as l,t as n,f as o,o as r,s,c as t,p as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Dashboard-Cv0AtO-o.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/vendor-react-Cxy4EVtR.js","assets/vendor-icons-PF9RcPJx.js","assets/vendor-state-aQJ7d4tA.js","assets/PageHeader-CugYeCci.js","assets/dist-CgGno8kE.js","assets/SectionHeader-DihC0CnO.js","assets/Card-DDGXsHus.js","assets/format-BUYXZqDw.js","assets/Chat-BZwLDoYO.js","assets/Button-CYDgoTTo.js","assets/EmptyState-EuQHAv5Y.js","assets/api-D-UzHSDq.js","assets/ui-CerQw0jA.js","assets/useIsMobileLayout-2GbB90oO.js","assets/Work-CvQrOKtL.js","assets/AlertDialog-DhA65f_0.js","assets/Switch-B3w5KMMc.js","assets/Goals-CkKJDCiU.js","assets/Table-Cf6m8zLu.js","assets/TaskDetail-BmXaH3sx.js","assets/Plugins-CoRmK2UG.js","assets/Strategies-3IV9eueQ.js","assets/Logs-DnaaHV0Y.js","assets/Settings-DZHAGazz.js","assets/EnvVarEditor-r-l-u4V7.js","assets/Memories-Dq9S-Tsi.js","assets/Evolution-DIqYOSb8.js","assets/Channels-8j28oydE.js","assets/GoalDetail-Bkvgg6uI.js","assets/ChannelDetail-Bb8P8It_.js","assets/Roles-EBUueS_P.js","assets/RoleDetail-BHJA_PAn.js","assets/FeatureRequests-BxPqLR1x.js","assets/Mistakes-D5lW31Co.js","assets/NotFound-gJVrOtER.js","assets/Events-DtkHL-r2.js","assets/EventDefDetail-asUFrbQE.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{A as t,B as n,F as r,I as i,P as a,S as o,Z as s,c,d as l,h as u,i as d,it as f,j as p,l as m,lt as h,n as g,o as _,r as v,t as y,x as b}from"./vendor-icons-PF9RcPJx.js";import{a as x,c as S,h as C,i as w,m as T,n as E,o as D,p as O,s as k,t as A,u as j}from"./vendor-react-Cxy4EVtR.js";import{n as M,r as N,t as ee}from"./dist-CgGno8kE.js";import{_ as P,a as F,b as te,c as ne,d as re,f as ie,g as ae,h as oe,i as se,m as ce,o as le,p as I,s as ue,t as de,u as L,x as R,y as fe}from"./AlertDialog-DhA65f_0.js";import{i as pe,t as me}from"./Button-CYDgoTTo.js";import{n as he}from"./vendor-state-aQJ7d4tA.js";import{a as ge,f as _e,l as ve,r as ye,s as be,t as z}from"./api-D-UzHSDq.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var xe=T(),B=e(h(),1),V=A(),Se=class extends B.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary] Uncaught error:`,e,t.componentStack)}render(){return this.state.hasError?(0,V.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-[var(--app-canvas)] p-6`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-panel)] p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-[var(--app-danger)]/10`,children:(0,V.jsx)(`svg`,{className:`h-6 w-6 text-[var(--app-danger)]`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`})})}),(0,V.jsx)(`h1`,{className:`mb-2 text-lg font-semibold text-[var(--app-text)]`,children:`Something went wrong`}),(0,V.jsx)(`p`,{className:`mb-6 text-sm text-[var(--app-text-muted)]`,children:`An unexpected error occurred. Try reloading the page.`}),this.state.error&&(0,V.jsx)(`pre`,{className:`mb-6 max-h-32 overflow-auto rounded bg-[var(--app-canvas)] p-3 text-left text-xs text-[var(--app-danger)]`,children:this.state.error.message}),(0,V.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-md bg-[var(--app-accent)] px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-[var(--app-accent)] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-[var(--app-canvas)]`,children:`Reload`})]})}):this.props.children}},Ce=[{to:`/`,icon:i,label:`Dashboard`,description:`Live system overview and operational focus.`},{to:`/chat`,icon:t,label:`Chat`,description:`Start a session, monitor execution, and review responses.`},{to:`/work`,icon:a,label:`Work`,description:`Tasks, automations, and goals in one work surface.`},{to:`/roles`,icon:s,label:`Roles`,description:`Role definitions, prompts, permissions, and health.`},{to:`/events`,icon:y,label:`Events`,description:`Event definitions that trigger automations.`},{to:`/strategies`,icon:r,label:`Strategies`,description:`Evaluate and adjust strategy records.`},{to:`/channels`,icon:b,label:`Channels`,description:`Delivery targets, sessions, and routing rules.`},{to:`/goals`,icon:m,label:`Goals`,description:`Long-running outcomes, budgets, and delivery targets.`},{to:`/feature-requests`,icon:l,label:`Feature Requests`,description:`Unmet needs extracted from chat sessions.`},{to:`/mistakes`,icon:_,label:`Mistakes`,description:`Cross-role failure patterns extracted from audit data.`},{to:`/memories`,icon:f,label:`Memories`,description:`Query memory records and retention patterns.`},{to:`/evolution`,icon:n,label:`Evolution`,description:`Review learning history and rule updates.`},{to:`/plugins`,icon:o,label:`Plugins`,description:`Installed plugins, scope, and activation state.`},{to:`/logs`,icon:c,label:`Logs`,description:`Observe runtime events and system diagnostics.`},{to:`/settings`,icon:u,label:`Settings`,description:`Server, model, and environment configuration.`}],we=[{test:e=>/^\/tasks\/[^/]+$/.test(e),meta:{title:`Task Detail`,description:`Summary, execution, results, and diagnostics for a single task.`,section:`Work`}},{test:e=>/^\/roles\/[^/]+$/.test(e),meta:{title:`Role Detail`,description:`Role configuration, memory, scores, and activity history.`,section:`Identities`}},{test:e=>/^\/channels\/[^/]+$/.test(e),meta:{title:`Channel Detail`,description:`Channel delivery rules, bindings, and recent activity.`,section:`Delivery`}},{test:e=>/^\/goals\/[^/]+$/.test(e),meta:{title:`Goal Detail`,description:`Goal progress, budgets, and related orchestration state.`,section:`Operations`}}];function H(e){let t=Ce.find(t=>t.to===e);if(t)return{title:t.label,description:t.description,section:{"/":`Overview`,"/chat":`Sessions`,"/work":`Operations`,"/roles":`Identities`,"/events":`Control Plane`,"/strategies":`Decision Engine`,"/channels":`Delivery`,"/goals":`Operations`,"/feature-requests":`Intelligence`,"/mistakes":`Intelligence`,"/memories":`Knowledge`,"/evolution":`Learning`,"/plugins":`Capabilities`,"/logs":`Diagnostics`,"/settings":`Configuration`}[e]??`Control Plane`};let n=we.find(t=>t.test(e));return n?n.meta:{title:`Adam`,description:`Control plane for tasks, roles, channels, and delivery.`,section:`Control Plane`}}var Te=[`top`,`right`,`bottom`,`left`],Ee=Math.min,U=Math.max,De=Math.round,Oe=Math.floor,W=e=>({x:e,y:e}),ke={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function Ae(e,t,n){return U(e,Ee(t,n))}function je(e,t){return typeof e==`function`?e(t):e}function Me(e){return e.split(`-`)[0]}function Ne(e){return e.split(`-`)[1]}function Pe(e){return e===`x`?`y`:`x`}function Fe(e){return e===`y`?`height`:`width`}function G(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function Ie(e){return Pe(G(e))}function Le(e,t,n){n===void 0&&(n=!1);let r=Ne(e),i=Ie(e),a=Fe(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Ke(o)),[o,Ke(o)]}function Re(e){let t=Ke(e);return[ze(e),t,ze(t)]}function ze(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Be=[`left`,`right`],Ve=[`right`,`left`],He=[`top`,`bottom`],Ue=[`bottom`,`top`];function We(e,t,n){switch(e){case`top`:case`bottom`:return n?t?Ve:Be:t?Be:Ve;case`left`:case`right`:return t?He:Ue;default:return[]}}function Ge(e,t,n,r){let i=Ne(e),a=We(Me(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ze)))),a}function Ke(e){let t=Me(e);return ke[t]+e.slice(t.length)}function qe(e){return{top:0,right:0,bottom:0,left:0,...e}}function Je(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:qe(e)}function Ye(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Xe(e,t,n){let{reference:r,floating:i}=e,a=G(t),o=Ie(t),s=Fe(o),c=Me(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(Ne(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function Ze(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=je(t,e),p=Je(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ye(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ye(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Qe=50,$e=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ze},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Xe(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Qe&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Xe(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},et=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=je(e,t)||{};if(l==null)return{};let d=Je(u),f={x:n,y:r},p=Ie(i),m=Fe(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Ee(d[_],T),D=Ee(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=Ae(O,A,k),M=!c.arrow&&Ne(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),tt=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=je(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Me(r),_=G(o),v=Me(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Ke(o)]:Re(o)),x=p!==`none`;!d&&x&&b.push(...Ge(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=Le(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==G(t))||T.every(e=>G(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=G(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function nt(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function rt(e){return Te.some(t=>e[t]>=0)}var it=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=je(e,t);switch(i){case`referenceHidden`:{let e=nt(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:rt(e)}}}case`escaped`:{let e=nt(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:rt(e)}}}default:return{}}}}},at=new Set([`left`,`top`]);async function ot(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Me(n),s=Ne(n),c=G(n)===`y`,l=at.has(o)?-1:1,u=a&&c?-1:1,d=je(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var st=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ot(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ct=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=je(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=G(Me(i)),p=Pe(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=Ae(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=Ae(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},lt=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=je(e,t),u={x:n,y:r},d=G(i),f=Pe(d),p=u[f],m=u[d],h=je(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=at.has(Me(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ut=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=je(e,t),u=await o.detectOverflow(t,l),d=Me(i),f=Ne(i),p=G(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=Ee(h-u[g],v),x=Ee(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=U(u.left,0),t=U(u.right,0),n=U(u.top,0),r=U(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:U(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:U(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function dt(){return typeof window<`u`}function ft(e){return pt(e)?(e.nodeName||``).toLowerCase():`#document`}function K(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function q(e){return((pt(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function pt(e){return dt()?e instanceof Node||e instanceof K(e).Node:!1}function J(e){return dt()?e instanceof Element||e instanceof K(e).Element:!1}function mt(e){return dt()?e instanceof HTMLElement||e instanceof K(e).HTMLElement:!1}function ht(e){return!dt()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof K(e).ShadowRoot}function gt(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Y(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function _t(e){return/^(table|td|th)$/.test(ft(e))}function vt(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var yt=/transform|translate|scale|rotate|perspective|filter/,bt=/paint|layout|strict|content/,xt=e=>!!e&&e!==`none`,St;function Ct(e){let t=J(e)?Y(e):e;return xt(t.transform)||xt(t.translate)||xt(t.scale)||xt(t.rotate)||xt(t.perspective)||!Tt()&&(xt(t.backdropFilter)||xt(t.filter))||yt.test(t.willChange||``)||bt.test(t.contain||``)}function wt(e){let t=Ot(e);for(;mt(t)&&!Et(t);){if(Ct(t))return t;if(vt(t))return null;t=Ot(t)}return null}function Tt(){return St??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),St}function Et(e){return/^(html|body|#document)$/.test(ft(e))}function Y(e){return K(e).getComputedStyle(e)}function Dt(e){return J(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ot(e){if(ft(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ht(e)&&e.host||q(e);return ht(t)?t.host:t}function kt(e){let t=Ot(e);return Et(t)?e.ownerDocument?e.ownerDocument.body:e.body:mt(t)&>(t)?t:kt(t)}function At(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=kt(e),i=r===e.ownerDocument?.body,a=K(r);if(i){let e=jt(a);return t.concat(a,a.visualViewport||[],gt(r)?r:[],e&&n?At(e):[])}else return t.concat(r,At(r,[],n))}function jt(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Mt(e){let t=Y(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=mt(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=De(n)!==a||De(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Nt(e){return J(e)?e:e.contextElement}function Pt(e){let t=Nt(e);if(!mt(t))return W(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Mt(t),o=(a?De(n.width):n.width)/r,s=(a?De(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ft=W(0);function It(e){let t=K(e);return!Tt()||!t.visualViewport?Ft:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Lt(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==K(e)?!1:t}function Rt(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Nt(e),o=W(1);t&&(r?J(r)&&(o=Pt(r)):o=Pt(e));let s=Lt(a,n,r)?It(a):W(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=K(a),t=r&&J(r)?K(r):r,n=e,i=jt(n);for(;i&&r&&t!==n;){let e=Pt(i),t=i.getBoundingClientRect(),r=Y(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=K(i),i=jt(n)}}return Ye({width:u,height:d,x:c,y:l})}function zt(e,t){let n=Dt(e).scrollLeft;return t?t.left+n:Rt(q(e)).left+n}function Bt(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-zt(e,n),y:n.top+t.scrollTop}}function Vt(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=q(r),s=t?vt(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=W(1),u=W(0),d=mt(r);if((d||!d&&!a)&&((ft(r)!==`body`||gt(o))&&(c=Dt(r)),d)){let e=Rt(r);l=Pt(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Bt(o,c):W(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ht(e){return Array.from(e.getClientRects())}function Ut(e){let t=q(e),n=Dt(e),r=e.ownerDocument.body,i=U(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=U(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+zt(e),s=-n.scrollTop;return Y(r).direction===`rtl`&&(o+=U(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Wt=25;function Gt(e,t){let n=K(e),r=q(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Tt();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=zt(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Wt&&(a-=o)}else l<=Wt&&(a+=l);return{width:a,height:o,x:s,y:c}}function Kt(e,t){let n=Rt(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=mt(e)?Pt(e):W(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function qt(e,t,n){let r;if(t===`viewport`)r=Gt(e,n);else if(t===`document`)r=Ut(q(e));else if(J(t))r=Kt(t,n);else{let n=It(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ye(r)}function Jt(e,t){let n=Ot(e);return n===t||!J(n)||Et(n)?!1:Y(n).position===`fixed`||Jt(n,t)}function Yt(e,t){let n=t.get(e);if(n)return n;let r=At(e,[],!1).filter(e=>J(e)&&ft(e)!==`body`),i=null,a=Y(e).position===`fixed`,o=a?Ot(e):e;for(;J(o)&&!Et(o);){let t=Y(o),n=Ct(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||gt(o)&&!n&&Jt(e,o))?r=r.filter(e=>e!==o):i=t,o=Ot(o)}return t.set(e,r),r}function Xt(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?vt(t)?[]:Yt(t,this._c):[].concat(n),r],o=qt(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=qt(t,a[e],i);s=U(n.top,s),c=Ee(n.right,c),l=Ee(n.bottom,l),u=U(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Zt(e){let{width:t,height:n}=Mt(e);return{width:t,height:n}}function Qt(e,t,n){let r=mt(t),i=q(t),a=n===`fixed`,o=Rt(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=W(0);function l(){c.x=zt(i)}if(r||!r&&!a)if((ft(t)!==`body`||gt(i))&&(s=Dt(t)),r){let e=Rt(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Bt(i,s):W(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function $t(e){return Y(e).position===`static`}function en(e,t){if(!mt(e)||Y(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return q(e)===n&&(n=n.ownerDocument.body),n}function tn(e,t){let n=K(e);if(vt(e))return n;if(!mt(e)){let t=Ot(e);for(;t&&!Et(t);){if(J(t)&&!$t(t))return t;t=Ot(t)}return n}let r=en(e,t);for(;r&&_t(r)&&$t(r);)r=en(r,t);return r&&Et(r)&&$t(r)&&!Ct(r)?n:r||wt(e)||n}var nn=async function(e){let t=this.getOffsetParent||tn,n=this.getDimensions,r=await n(e.floating);return{reference:Qt(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function rn(e){return Y(e).direction===`rtl`}var an={convertOffsetParentRelativeRectToViewportRelativeRect:Vt,getDocumentElement:q,getClippingRect:Xt,getOffsetParent:tn,getElementRects:nn,getClientRects:Ht,getDimensions:Zt,getScale:Pt,isElement:J,isRTL:rn};function on(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function sn(e,t){let n=null,r,i=q(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=Oe(d),h=Oe(i.clientWidth-(u+f)),g=Oe(i.clientHeight-(d+p)),_=Oe(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:U(0,Ee(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!on(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function cn(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Nt(e),u=i||a?[...l?At(l):[],...t?At(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?sn(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Rt(e):null;c&&g();function g(){let t=Rt(e);h&&!on(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ln=st,un=ct,dn=tt,fn=ut,pn=it,mn=et,hn=lt,gn=(e,t,n)=>{let r=new Map,i={platform:an,...n},a={...i.platform,_c:r};return $e(e,t,{...i,platform:a})},_n=e(C(),1),vn=typeof document<`u`?B.useLayoutEffect:function(){};function yn(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!yn(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!yn(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function bn(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function xn(e,t){let n=bn(e);return Math.round(t*n)/n}function Sn(e){let t=B.useRef(e);return vn(()=>{t.current=e}),t}function Cn(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=B.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=B.useState(r);yn(f,r)||p(r);let[m,h]=B.useState(null),[g,_]=B.useState(null),v=B.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=B.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=B.useRef(null),C=B.useRef(null),w=B.useRef(u),T=c!=null,E=Sn(c),D=Sn(i),O=Sn(l),k=B.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),gn(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!yn(w.current,t)&&(w.current=t,_n.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);vn(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=B.useRef(!1);vn(()=>(A.current=!0,()=>{A.current=!1}),[]),vn(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=B.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=B.useMemo(()=>({reference:b,floating:x}),[b,x]),N=B.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=xn(M.floating,u.x),r=xn(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...bn(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return B.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var wn=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:mn({element:r.current,padding:i}).fn(n):r?mn({element:r,padding:i}).fn(n):{}}}},Tn=(e,t)=>{let n=ln(e);return{name:n.name,fn:n.fn,options:[e,t]}},En=(e,t)=>{let n=un(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dn=(e,t)=>({fn:hn(e).fn,options:[e,t]}),On=(e,t)=>{let n=dn(e);return{name:n.name,fn:n.fn,options:[e,t]}},kn=(e,t)=>{let n=fn(e);return{name:n.name,fn:n.fn,options:[e,t]}},An=(e,t)=>{let n=pn(e);return{name:n.name,fn:n.fn,options:[e,t]}},jn=(e,t)=>{let n=wn(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mn=`Arrow`,Nn=B.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,V.jsx)(P.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,V.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Nn.displayName=Mn;var Pn=Nn;function Fn(e){let[t,n]=B.useState(void 0);return ce(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var In=`Popper`,[Ln,Rn]=te(In),[zn,Bn]=Ln(In),Vn=e=>{let{__scopePopper:t,children:n}=e,[r,i]=B.useState(null);return(0,V.jsx)(zn,{scope:t,anchor:r,onAnchorChange:i,children:n})};Vn.displayName=In;var Hn=`PopperAnchor`,Un=B.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Bn(Hn,n),o=B.useRef(null),s=pe(t,o),c=B.useRef(null);return B.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,V.jsx)(P.div,{...i,ref:s})});Un.displayName=Hn;var Wn=`PopperContent`,[Gn,Kn]=Ln(Wn),qn=B.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=Bn(Wn,n),[_,v]=B.useState(null),y=pe(t,e=>v(e)),[b,x]=B.useState(null),S=Fn(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(Zn),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:ee}=Cn({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>cn(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Tn({mainAxis:i+w,alignmentAxis:o}),c&&En({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Dn():void 0,...k}),c&&On({...k}),kn({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&jn({element:b,padding:s}),Qn({arrowWidth:C,arrowHeight:w}),f&&An({strategy:`referenceHidden`,...k})]}),[F,te]=$n(M),ne=ae(m);ce(()=>{N&&ne?.()},[N,ne]);let re=ee.arrow?.x,ie=ee.arrow?.y,oe=ee.arrow?.centerOffset!==0,[se,le]=B.useState();return ce(()=>{_&&le(window.getComputedStyle(_).zIndex)},[_]),(0,V.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[ee.transformOrigin?.x,ee.transformOrigin?.y].join(` `),...ee.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,V.jsx)(Gn,{scope:n,placedSide:F,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:oe,children:(0,V.jsx)(P.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});qn.displayName=Wn;var Jn=`PopperArrow`,Yn={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Xn=B.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Kn(Jn,n),a=Yn[i.placedSide];return(0,V.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,V.jsx)(Pn,{...r,ref:t,style:{...r.style,display:`block`}})})});Xn.displayName=Jn;function Zn(e){return e!==null}var Qn=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=$n(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function $n(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var er=Vn,tr=Un,nr=qn,rr=Xn,ir=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),ar=`VisuallyHidden`,or=B.forwardRef((e,t)=>(0,V.jsx)(P.span,{...e,ref:t,style:{...ir,...e.style}}));or.displayName=ar;var sr=or,[cr,lr]=te(`Tooltip`,[Rn]),ur=Rn(),dr=`TooltipProvider`,fr=700,pr=`tooltip.open`,[mr,hr]=cr(dr),gr=e=>{let{__scopeTooltip:t,delayDuration:n=fr,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=B.useRef(!0),s=B.useRef(!1),c=B.useRef(0);return B.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,V.jsx)(mr,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:B.useCallback(()=>{window.clearTimeout(c.current),o.current=!1},[]),onClose:B.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:s,onPointerInTransitChange:B.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};gr.displayName=dr;var _r=`Tooltip`,[vr,yr]=cr(_r),br=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=hr(_r,e.__scopeTooltip),l=ur(t),[u,d]=B.useState(null),f=I(),p=B.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=B.useRef(!1),[_,v]=L({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(pr))):c.onClose(),a?.(e)},caller:_r}),y=B.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=B.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=B.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return B.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,V.jsx)(er,{...l,children:(0,V.jsx)(vr,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:B.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:B.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};br.displayName=_r;var xr=`TooltipTrigger`,Sr=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=yr(xr,n),a=hr(xr,n),o=ur(n),s=pe(t,B.useRef(null),i.onTriggerChange),c=B.useRef(!1),l=B.useRef(!1),u=B.useCallback(()=>c.current=!1,[]);return B.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,V.jsx)(tr,{asChild:!0,...o,children:(0,V.jsx)(P.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:R(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:R(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:R(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:R(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:R(e.onBlur,i.onClose),onClick:R(e.onClick,i.onClose)})})});Sr.displayName=xr;var Cr=`TooltipPortal`,[wr,Tr]=cr(Cr,{forceMount:void 0}),Er=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=yr(Cr,t);return(0,V.jsx)(wr,{scope:t,forceMount:n,children:(0,V.jsx)(re,{present:n||a.open,children:(0,V.jsx)(ie,{asChild:!0,container:i,children:r})})})};Er.displayName=Cr;var Dr=`TooltipContent`,Or=B.forwardRef((e,t)=>{let n=Tr(Dr,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=yr(Dr,e.__scopeTooltip);return(0,V.jsx)(re,{present:r||o.open,children:o.disableHoverableContent?(0,V.jsx)(Nr,{side:i,...a,ref:t}):(0,V.jsx)(kr,{side:i,...a,ref:t})})}),kr=B.forwardRef((e,t)=>{let n=yr(Dr,e.__scopeTooltip),r=hr(Dr,e.__scopeTooltip),i=B.useRef(null),a=pe(t,i),[o,s]=B.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=B.useCallback(()=>{s(null),d(!1)},[d]),p=B.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Lr(r,Ir(r,n.getBoundingClientRect())),a=Rr(t.getBoundingClientRect());s(Br([...i,...a])),d(!0)},[d]);return B.useEffect(()=>()=>f(),[f]),B.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),B.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!zr(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,V.jsx)(Nr,{...e,ref:a})}),[Ar,jr]=cr(_r,{isInside:!1}),Mr=fe(`TooltipContent`),Nr=B.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=yr(Dr,n),l=ur(n),{onClose:u}=c;return B.useEffect(()=>(document.addEventListener(pr,u),()=>document.removeEventListener(pr,u)),[u]),B.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,V.jsx)(oe,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,V.jsxs)(nr,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,V.jsx)(Mr,{children:r}),(0,V.jsx)(Ar,{scope:n,isInside:!0,children:(0,V.jsx)(sr,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Or.displayName=Dr;var Pr=`TooltipArrow`,Fr=B.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=ur(n);return jr(Pr,n).isInside?null:(0,V.jsx)(rr,{...i,...r,ref:t})});Fr.displayName=Pr;function Ir(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Lr(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Rr(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function zr(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Br(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),Vr(t)}function Vr(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Hr=gr,Ur=br,Wr=Sr,Gr=Er,Kr=Or,qr=Hr,Jr=Ur,Yr=Wr,Xr=B.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,V.jsx)(Gr,{children:(0,V.jsx)(Kr,{ref:r,sideOffset:t,className:M(`surface-panel z-50 max-w-xs overflow-hidden rounded-md px-3 py-1.5 text-xs text-[var(--app-text)] shadow-[var(--app-shadow-md)] animate-in fade-in-0 zoom-in-95`,e),...n})}));Xr.displayName=Kr.displayName;function Zr({onNavigate:e}){return(0,V.jsxs)(`aside`,{className:`flex h-full w-64 flex-col border-r border-[var(--app-border)] bg-[var(--app-sidebar-bg)]`,children:[(0,V.jsxs)(`div`,{className:`flex h-16 items-center gap-3 border-b border-[var(--app-border)] px-5`,children:[(0,V.jsx)(`div`,{className:`surface-accent flex h-10 w-10 items-center justify-center rounded-lg text-sm font-bold text-white`,children:`A`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold tracking-wide text-[var(--app-text)]`,children:`Adam`}),(0,V.jsx)(`div`,{className:`text-[11px] text-[var(--app-text-subtle)]`,children:`Operator workspace`})]}),(0,V.jsx)(`span`,{className:`ml-auto rounded-full border border-[var(--app-border)] bg-white/[0.04] px-2 py-0.5 font-mono text-[10px] text-[var(--app-text-subtle)]`,children:`v2.0`})]}),(0,V.jsx)(qr,{delayDuration:300,children:(0,V.jsx)(`nav`,{role:`navigation`,"aria-label":`Main navigation`,className:`flex-1 space-y-1 px-3 py-4`,children:Ce.map(({to:t,icon:n,label:r,description:i})=>(0,V.jsxs)(Jr,{children:[(0,V.jsx)(Yr,{asChild:!0,children:(0,V.jsx)(w,{to:t,end:t===`/`,onClick:e,className:({isActive:e})=>N(`group flex items-center gap-3 rounded-lg px-3 py-2 transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--app-canvas)]`,e?`surface-panel-elevated text-[var(--app-text)]`:`text-[var(--app-text-muted)] hover:bg-white/[0.04] hover:text-[var(--app-text)]`),children:({isActive:e})=>(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(n,{size:16,className:`flex-shrink-0`}),(0,V.jsx)(`span`,{className:`text-sm font-medium`,children:r}),e&&(0,V.jsx)(`span`,{className:`sr-only`,children:`(current page)`})]})})}),(0,V.jsx)(Xr,{side:`right`,children:(0,V.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,V.jsx)(`div`,{className:`font-medium text-[var(--app-text)]`,children:r}),(0,V.jsx)(`div`,{className:`text-[var(--app-text-muted)]`,children:i})]})})]},t))})})]})}function Qr(e){if(!e||typeof document>`u`)return;let t=document.head||document.getElementsByTagName(`head`)[0],n=document.createElement(`style`);n.type=`text/css`,t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var $r=e=>{switch(e){case`success`:return ni;case`info`:return ii;case`warning`:return ri;case`error`:return ai;default:return null}},ei=Array(12).fill(0),ti=({visible:e,className:t})=>B.createElement(`div`,{className:[`sonner-loading-wrapper`,t].filter(Boolean).join(` `),"data-visible":e},B.createElement(`div`,{className:`sonner-spinner`},ei.map((e,t)=>B.createElement(`div`,{className:`sonner-loading-bar`,key:`spinner-bar-${t}`})))),ni=B.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},B.createElement(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z`,clipRule:`evenodd`})),ri=B.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`currentColor`,height:`20`,width:`20`},B.createElement(`path`,{fillRule:`evenodd`,d:`M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z`,clipRule:`evenodd`})),ii=B.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},B.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z`,clipRule:`evenodd`})),ai=B.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 20 20`,fill:`currentColor`,height:`20`,width:`20`},B.createElement(`path`,{fillRule:`evenodd`,d:`M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z`,clipRule:`evenodd`})),oi=B.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`},B.createElement(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),B.createElement(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})),si=()=>{let[e,t]=B.useState(document.hidden);return B.useEffect(()=>{let e=()=>{t(document.hidden)};return document.addEventListener(`visibilitychange`,e),()=>window.removeEventListener(`visibilitychange`,e)},[]),e},ci=1,X=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id?.length>0?e.id:ci++,i=this.toasts.find(e=>e.id===r),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(r)&&this.dismissedToasts.delete(r),i?this.toasts=this.toasts.map(n=>n.id===r?(this.publish({...n,...e,id:r,title:t}),{...n,...e,id:r,dismissible:a,title:t}):n):this.addToast({title:t,...n,dismissible:a,id:r}),r},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:`error`}),this.success=(e,t)=>this.create({...t,type:`success`,message:e}),this.info=(e,t)=>this.create({...t,type:`info`,message:e}),this.warning=(e,t)=>this.create({...t,type:`warning`,message:e}),this.loading=(e,t)=>this.create({...t,type:`loading`,message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:t.loading,description:typeof t.description==`function`?void 0:t.description}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,a,o=r.then(async e=>{if(a=[`resolve`,e],B.isValidElement(e))i=!1,this.create({id:n,type:`default`,message:e});else if(ui(e)&&!e.ok){i=!1;let r=typeof t.error==`function`?await t.error(`HTTP error! status: ${e.status}`):t.error,a=typeof t.description==`function`?await t.description(`HTTP error! status: ${e.status}`):t.description,o=typeof r==`object`&&!B.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(e instanceof Error){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!B.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?await t.success(e):t.success,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!B.isValidElement(r)?r:{message:r};this.create({id:n,type:`success`,description:a,...o})}}).catch(async e=>{if(a=[`reject`,e],t.error!==void 0){i=!1;let r=typeof t.error==`function`?await t.error(e):t.error,a=typeof t.description==`function`?await t.description(e):t.description,o=typeof r==`object`&&!B.isValidElement(r)?r:{message:r};this.create({id:n,type:`error`,description:a,...o})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),s=()=>new Promise((e,t)=>o.then(()=>a[0]===`reject`?t(a[1]):e(a[1])).catch(t));return typeof n!=`string`&&typeof n!=`number`?{unwrap:s}:Object.assign(n,{unwrap:s})},this.custom=(e,t)=>{let n=t?.id||ci++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},li=(e,t)=>{let n=t?.id||ci++;return X.addToast({title:e,...t,id:n}),n},ui=e=>e&&typeof e==`object`&&`ok`in e&&typeof e.ok==`boolean`&&`status`in e&&typeof e.status==`number`,di=Object.assign(li,{success:X.success,info:X.info,warning:X.warning,error:X.error,custom:X.custom,message:X.message,promise:X.promise,dismiss:X.dismiss,loading:X.loading},{getHistory:()=>X.toasts,getToasts:()=>X.getActiveToasts()});Qr(`[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}`);function fi(e){return e.label!==void 0}var pi=3,mi=`24px`,hi=`16px`,gi=4e3,_i=356,vi=14,yi=45,bi=200;function Z(...e){return e.filter(Boolean).join(` `)}function xi(e){let[t,n]=e.split(`-`),r=[];return t&&r.push(t),n&&r.push(n),r}var Si=e=>{let{invert:t,toast:n,unstyled:r,interacting:i,setHeights:a,visibleToasts:o,heights:s,index:c,toasts:l,expanded:u,removeToast:d,defaultRichColors:f,closeButton:p,style:m,cancelButtonStyle:h,actionButtonStyle:g,className:_=``,descriptionClassName:v=``,duration:y,position:b,gap:x,expandByDefault:S,classNames:C,icons:w,closeButtonAriaLabel:T=`Close toast`}=e,[E,D]=B.useState(null),[O,k]=B.useState(null),[A,j]=B.useState(!1),[M,N]=B.useState(!1),[ee,P]=B.useState(!1),[F,te]=B.useState(!1),[ne,re]=B.useState(!1),[ie,ae]=B.useState(0),[oe,se]=B.useState(0),ce=B.useRef(n.duration||y||gi),le=B.useRef(null),I=B.useRef(null),ue=c===0,de=c+1<=o,L=n.type,R=n.dismissible!==!1,fe=n.className||``,pe=n.descriptionClassName||``,me=B.useMemo(()=>s.findIndex(e=>e.toastId===n.id)||0,[s,n.id]),he=B.useMemo(()=>n.closeButton??p,[n.closeButton,p]),ge=B.useMemo(()=>n.duration||y||gi,[n.duration,y]),_e=B.useRef(0),ve=B.useRef(0),ye=B.useRef(0),be=B.useRef(null),[z,xe]=b.split(`-`),V=B.useMemo(()=>s.reduce((e,t,n)=>n>=me?e:e+t.height,0),[s,me]),Se=si(),Ce=n.invert||t,we=L===`loading`;ve.current=B.useMemo(()=>me*x+V,[me,V]),B.useEffect(()=>{ce.current=ge},[ge]),B.useEffect(()=>{j(!0)},[]),B.useEffect(()=>{let e=I.current;if(e){let t=e.getBoundingClientRect().height;return se(t),a(e=>[{toastId:n.id,height:t,position:n.position},...e]),()=>a(e=>e.filter(e=>e.toastId!==n.id))}},[a,n.id]),B.useLayoutEffect(()=>{if(!A)return;let e=I.current,t=e.style.height;e.style.height=`auto`;let r=e.getBoundingClientRect().height;e.style.height=t,se(r),a(e=>e.find(e=>e.toastId===n.id)?e.map(e=>e.toastId===n.id?{...e,height:r}:e):[{toastId:n.id,height:r,position:n.position},...e])},[A,n.title,n.description,a,n.id,n.jsx,n.action,n.cancel]);let H=B.useCallback(()=>{N(!0),ae(ve.current),a(e=>e.filter(e=>e.toastId!==n.id)),setTimeout(()=>{d(n)},bi)},[n,d,a,ve]);B.useEffect(()=>{if(n.promise&&L===`loading`||n.duration===1/0||n.type===`loading`)return;let e;return u||i||Se?(()=>{if(ye.current<_e.current){let e=new Date().getTime()-_e.current;ce.current-=e}ye.current=new Date().getTime()})():ce.current!==1/0&&(_e.current=new Date().getTime(),e=setTimeout(()=>{n.onAutoClose==null||n.onAutoClose.call(n,n),H()},ce.current)),()=>clearTimeout(e)},[u,i,n,L,Se,H]),B.useEffect(()=>{n.delete&&(H(),n.onDismiss==null||n.onDismiss.call(n,n))},[H,n.delete]);function Te(){return w?.loading?B.createElement(`div`,{className:Z(C?.loader,n?.classNames?.loader,`sonner-loader`),"data-visible":L===`loading`},w.loading):B.createElement(ti,{className:Z(C?.loader,n?.classNames?.loader),visible:L===`loading`})}let Ee=n.icon||w?.[L]||$r(L);return B.createElement(`li`,{tabIndex:0,ref:I,className:Z(_,fe,C?.toast,n?.classNames?.toast,C?.default,C?.[L],n?.classNames?.[L]),"data-sonner-toast":``,"data-rich-colors":n.richColors??f,"data-styled":!(n.jsx||n.unstyled||r),"data-mounted":A,"data-promise":!!n.promise,"data-swiped":ne,"data-removed":M,"data-visible":de,"data-y-position":z,"data-x-position":xe,"data-index":c,"data-front":ue,"data-swiping":ee,"data-dismissible":R,"data-type":L,"data-invert":Ce,"data-swipe-out":F,"data-swipe-direction":O,"data-expanded":!!(u||S&&A),"data-testid":n.testId,style:{"--index":c,"--toasts-before":c,"--z-index":l.length-c,"--offset":`${M?ie:ve.current}px`,"--initial-height":S?`auto`:`${oe}px`,...m,...n.style},onDragEnd:()=>{P(!1),D(null),be.current=null},onPointerDown:e=>{e.button!==2&&(we||!R||(le.current=new Date,ae(ve.current),e.target.setPointerCapture(e.pointerId),e.target.tagName!==`BUTTON`&&(P(!0),be.current={x:e.clientX,y:e.clientY})))},onPointerUp:()=>{if(F||!R)return;be.current=null;let e=Number(I.current?.style.getPropertyValue(`--swipe-amount-x`).replace(`px`,``)||0),t=Number(I.current?.style.getPropertyValue(`--swipe-amount-y`).replace(`px`,``)||0),r=new Date().getTime()-le.current?.getTime(),i=E===`x`?e:t,a=Math.abs(i)/r;if(Math.abs(i)>=yi||a>.11){ae(ve.current),n.onDismiss==null||n.onDismiss.call(n,n),k(E===`x`?e>0?`right`:`left`:t>0?`down`:`up`),H(),te(!0);return}else{var o,s;(o=I.current)==null||o.style.setProperty(`--swipe-amount-x`,`0px`),(s=I.current)==null||s.style.setProperty(`--swipe-amount-y`,`0px`)}re(!1),P(!1),D(null)},onPointerMove:t=>{var n,r;if(!be.current||!R||window.getSelection()?.toString().length>0)return;let i=t.clientY-be.current.y,a=t.clientX-be.current.x,o=e.swipeDirections??xi(b);!E&&(Math.abs(a)>1||Math.abs(i)>1)&&D(Math.abs(a)>Math.abs(i)?`x`:`y`);let s={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if(E===`y`){if(o.includes(`top`)||o.includes(`bottom`))if(o.includes(`top`)&&i<0||o.includes(`bottom`)&&i>0)s.y=i;else{let e=i*c(i);s.y=Math.abs(e)<Math.abs(i)?e:i}}else if(E===`x`&&(o.includes(`left`)||o.includes(`right`)))if(o.includes(`left`)&&a<0||o.includes(`right`)&&a>0)s.x=a;else{let e=a*c(a);s.x=Math.abs(e)<Math.abs(a)?e:a}(Math.abs(s.x)>0||Math.abs(s.y)>0)&&re(!0),(n=I.current)==null||n.style.setProperty(`--swipe-amount-x`,`${s.x}px`),(r=I.current)==null||r.style.setProperty(`--swipe-amount-y`,`${s.y}px`)}},he&&!n.jsx&&L!==`loading`?B.createElement(`button`,{"aria-label":T,"data-disabled":we,"data-close-button":!0,onClick:we||!R?()=>{}:()=>{H(),n.onDismiss==null||n.onDismiss.call(n,n)},className:Z(C?.closeButton,n?.classNames?.closeButton)},w?.close??oi):null,(L||n.icon||n.promise)&&n.icon!==null&&(w?.[L]!==null||n.icon)?B.createElement(`div`,{"data-icon":``,className:Z(C?.icon,n?.classNames?.icon)},n.promise||n.type===`loading`&&!n.icon?n.icon||Te():null,n.type===`loading`?null:Ee):null,B.createElement(`div`,{"data-content":``,className:Z(C?.content,n?.classNames?.content)},B.createElement(`div`,{"data-title":``,className:Z(C?.title,n?.classNames?.title)},n.jsx?n.jsx:typeof n.title==`function`?n.title():n.title),n.description?B.createElement(`div`,{"data-description":``,className:Z(v,pe,C?.description,n?.classNames?.description)},typeof n.description==`function`?n.description():n.description):null),B.isValidElement(n.cancel)?n.cancel:n.cancel&&fi(n.cancel)?B.createElement(`button`,{"data-button":!0,"data-cancel":!0,style:n.cancelButtonStyle||h,onClick:e=>{fi(n.cancel)&&R&&(n.cancel.onClick==null||n.cancel.onClick.call(n.cancel,e),H())},className:Z(C?.cancelButton,n?.classNames?.cancelButton)},n.cancel.label):null,B.isValidElement(n.action)?n.action:n.action&&fi(n.action)?B.createElement(`button`,{"data-button":!0,"data-action":!0,style:n.actionButtonStyle||g,onClick:e=>{fi(n.action)&&(n.action.onClick==null||n.action.onClick.call(n.action,e),!e.defaultPrevented&&H())},className:Z(C?.actionButton,n?.classNames?.actionButton)},n.action.label):null)};function Ci(){if(typeof window>`u`||typeof document>`u`)return`ltr`;let e=document.documentElement.getAttribute(`dir`);return e===`auto`||!e?window.getComputedStyle(document.documentElement).direction:e}function wi(e,t){let n={};return[e,t].forEach((e,t)=>{let r=t===1,i=r?`--mobile-offset`:`--offset`,a=r?hi:mi;function o(e){[`top`,`right`,`bottom`,`left`].forEach(t=>{n[`${i}-${t}`]=typeof e==`number`?`${e}px`:e})}typeof e==`number`||typeof e==`string`?o(e):typeof e==`object`?[`top`,`right`,`bottom`,`left`].forEach(t=>{e[t]===void 0?n[`${i}-${t}`]=a:n[`${i}-${t}`]=typeof e[t]==`number`?`${e[t]}px`:e[t]}):o(a)}),n}var Ti=B.forwardRef(function(e,t){let{id:n,invert:r,position:i=`bottom-right`,hotkey:a=[`altKey`,`KeyT`],expand:o,closeButton:s,className:c,offset:l,mobileOffset:u,theme:d=`light`,richColors:f,duration:p,style:m,visibleToasts:h=pi,toastOptions:g,dir:_=Ci(),gap:v=vi,icons:y,containerAriaLabel:b=`Notifications`}=e,[x,S]=B.useState([]),C=B.useMemo(()=>n?x.filter(e=>e.toasterId===n):x.filter(e=>!e.toasterId),[x,n]),w=B.useMemo(()=>Array.from(new Set([i].concat(C.filter(e=>e.position).map(e=>e.position)))),[C,i]),[T,E]=B.useState([]),[D,O]=B.useState(!1),[k,A]=B.useState(!1),[j,M]=B.useState(d===`system`?typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:d),N=B.useRef(null),ee=a.join(`+`).replace(/Key/g,``).replace(/Digit/g,``),P=B.useRef(null),F=B.useRef(!1),te=B.useCallback(e=>{S(t=>(t.find(t=>t.id===e.id)?.delete||X.dismiss(e.id),t.filter(({id:t})=>t!==e.id)))},[]);return B.useEffect(()=>X.subscribe(e=>{if(e.dismiss){requestAnimationFrame(()=>{S(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))});return}setTimeout(()=>{_n.flushSync(()=>{S(t=>{let n=t.findIndex(t=>t.id===e.id);return n===-1?[e,...t]:[...t.slice(0,n),{...t[n],...e},...t.slice(n+1)]})})})}),[x]),B.useEffect(()=>{if(d!==`system`){M(d);return}if(d===`system`&&(window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`).matches?M(`dark`):M(`light`)),typeof window>`u`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`);try{e.addEventListener(`change`,({matches:e})=>{M(e?`dark`:`light`)})}catch{e.addListener(({matches:e})=>{try{M(e?`dark`:`light`)}catch(e){console.error(e)}})}},[d]),B.useEffect(()=>{x.length<=1&&O(!1)},[x]),B.useEffect(()=>{let e=e=>{if(a.every(t=>e[t]||e.code===t)){var t;O(!0),(t=N.current)==null||t.focus()}e.code===`Escape`&&(document.activeElement===N.current||N.current?.contains(document.activeElement))&&O(!1)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]),B.useEffect(()=>{if(N.current)return()=>{P.current&&(P.current.focus({preventScroll:!0}),P.current=null,F.current=!1)}},[N.current]),B.createElement(`section`,{ref:t,"aria-label":`${b} ${ee}`,tabIndex:-1,"aria-live":`polite`,"aria-relevant":`additions text`,"aria-atomic":`false`,suppressHydrationWarning:!0},w.map((t,n)=>{let[i,a]=t.split(`-`);return C.length?B.createElement(`ol`,{key:t,dir:_===`auto`?Ci():_,tabIndex:-1,ref:N,className:c,"data-sonner-toaster":!0,"data-sonner-theme":j,"data-y-position":i,"data-x-position":a,style:{"--front-toast-height":`${T[0]?.height||0}px`,"--width":`${_i}px`,"--gap":`${v}px`,...m,...wi(l,u)},onBlur:e=>{F.current&&!e.currentTarget.contains(e.relatedTarget)&&(F.current=!1,P.current&&=(P.current.focus({preventScroll:!0}),null))},onFocus:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||F.current||(F.current=!0,P.current=e.relatedTarget)},onMouseEnter:()=>O(!0),onMouseMove:()=>O(!0),onMouseLeave:()=>{k||O(!1)},onDragEnd:()=>O(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&e.target.dataset.dismissible===`false`||A(!0)},onPointerUp:()=>A(!1)},C.filter(e=>!e.position&&n===0||e.position===t).map((n,i)=>B.createElement(Si,{key:n.id,icons:y,index:i,toast:n,defaultRichColors:f,duration:g?.duration??p,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:h,closeButton:g?.closeButton??s,interacting:k,position:t,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:te,toasts:C.filter(e=>e.position==n.position),heights:T.filter(e=>e.position==n.position),setHeights:E,expandByDefault:o,gap:v,expanded:D,swipeDirections:e.swipeDirections}))):null}))}),Ei=({...e})=>(0,V.jsx)(Ti,{theme:`dark`,className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-[var(--app-panel)] group-[.toaster]:text-[var(--app-text)] group-[.toaster]:border-[var(--app-border)] group-[.toaster]:shadow-lg`,description:`group-[.toast]:text-[var(--app-text-muted)]`,actionButton:`group-[.toast]:bg-[var(--app-accent)] group-[.toast]:text-white`,cancelButton:`group-[.toast]:bg-[var(--app-panel-elevated)] group-[.toast]:text-[var(--app-text)]`}},...e}),Di=500,Q=he((e,t)=>({tasks:[],goals:[],strategies:[],templates:[],readiness:null,stats:{activeTasks:0,queuedTasks:0,totalCostToday:0},logs:[],configVersion:0,pendingPlanApproval:null,planTimeoutNotice:null,roles:[],executionPool:{active:0,max:5,queued:0},deliveryLog:[],wsConnected:!1,_ws:null,_wsReconnectDelay:1e3,fetchTasks:async t=>{let n=new URLSearchParams({limit:`100`});t&&n.set(`status`,t),e({tasks:(await z(`/tasks?${n}`)).tasks})},fetchGoals:async()=>{e({goals:(await z(`/goals`)).goals})},updateGoal:async(t,n)=>{let r=await z(`/goals/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return e(e=>({goals:e.goals.map(e=>e.id===t?r.goal:e)})),r.goal},deleteGoal:async t=>{await z(`/goals/${t}`,{method:`DELETE`}),e(e=>({goals:e.goals.filter(e=>e.id!==t)}))},fetchStrategies:async()=>{e({strategies:(await z(`/strategies`)).strategies})},fetchTemplates:async()=>{e({templates:(await z(`/task-templates`)).templates})},fetchExecutionPool:async()=>{try{e({executionPool:(await z(`/stats`)).executionPool})}catch{}},fetchReadiness:async()=>{try{e({readiness:await(await fetch(`/readyz`)).json()})}catch{e({readiness:{status:`not_ready`,checks:{database:!1,config:!1}}})}},connectWebSocket:()=>{let n=t()._ws;if(n&&n.readyState<=1)return;let r=window.location.protocol===`https:`?`wss:`:`ws:`,i=ge(),a=new URL(`${r}//${window.location.host}/events`);i&&a.searchParams.set(`api_key`,i);let o=new WebSocket(a.toString()),s=!1;o.onopen=()=>{s=!0,e({wsConnected:!0,_ws:o,_wsReconnectDelay:1e3})},o.onclose=async()=>{if(!s&&i&&!await _e(i).catch(()=>!0)){ye(),be();return}let n=t()._wsReconnectDelay;e({wsConnected:!1,_ws:null,_wsReconnectDelay:Math.min(n*2,1e4)}),setTimeout(()=>{t().connectWebSocket()},n)},o.onerror=()=>{o.close()},o.onmessage=n=>{try{Oi(JSON.parse(n.data),e,t)}catch{}},e({_ws:o})},disconnectWebSocket:()=>{let n=t()._ws;n&&(n.close(),e({_ws:null,wsConnected:!1}))},addLog:t=>{e(e=>({logs:[...e.logs.slice(-(Di-1)),t]}))},addDeliveryLogEntry:t=>{e(e=>({deliveryLog:[t,...e.deliveryLog].slice(0,100)}))},approvePlan:async(t,n,r)=>{await z(`/tasks/${t}/approve-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({planId:n,decision:`allow`,approvalType:r})}),e({pendingPlanApproval:null})},denyPlan:async(t,n,r)=>{await z(`/tasks/${t}/approve-plan`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({planId:n,decision:`deny`,reason:r??`rejected by user`})}),e({pendingPlanApproval:null})},clearPlanTimeoutNotice:()=>{e({planTimeoutNotice:null})},fetchRoles:async()=>{let{roles:t}=await z(`/roles`);e({roles:t})},createRole:async t=>{let n=await z(`/roles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});return e(e=>({roles:[...e.roles,n.role]})),n.role},updateRole:async(t,n)=>{let r=await z(`/roles/${t}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return e(e=>({roles:e.roles.map(e=>e.id===t?{...e,...r.role}:e)})),r.role},deleteRole:async t=>{await z(`/roles/${t}`,{method:`DELETE`}),e(e=>({roles:e.roles.filter(e=>e.id!==t)}))}}));function Oi(e,t,n){switch(e.type){case`task_status_change`:t(t=>({tasks:t.tasks.map(t=>t.id===e.taskId?{...t,status:e.newStatus}:t)}));break;case`stats_update`:t(()=>({stats:{activeTasks:e.activeTasks,queuedTasks:e.queuedTasks,totalCostToday:e.totalCostToday}}));break;case`log_event`:n().addLog(e);break;case`goal_status_change`:t(t=>({goals:t.goals.map(t=>t.id===e.goalId?{...t,status:e.newStatus}:t)}));break;case`config_changed`:t(e=>({configVersion:e.configVersion+1}));break;case`execution_slot_change`:t(()=>({executionPool:{active:e.active,max:e.max,queued:e.queued}}));break;case`plan_approval_request`:t(()=>({pendingPlanApproval:{taskId:e.taskId,planId:e.planId,plan:e.plan}}));break;case`plan_approval_decision`:n().pendingPlanApproval?.planId===e.planId&&t(()=>({pendingPlanApproval:null}));break;case`delivery_status_change`:n().addDeliveryLogEntry(e);break}}function ki(){let[e,t]=(0,B.useState)(!1),n=j(),r=Q(e=>e.wsConnected),i=Q(e=>e.connectWebSocket),a=Q(e=>e.fetchReadiness),o=H(n.pathname);(0,B.useEffect)(()=>{i(),a();let e=setInterval(a,3e4);return()=>clearInterval(e)},[i,a]);let s=(0,B.useCallback)(()=>t(!1),[]);return(0,V.jsxs)(`div`,{className:`flex h-screen overflow-hidden`,children:[(0,V.jsx)(`a`,{href:`#main-content`,className:`sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-50 focus:rounded-md focus:bg-[var(--app-accent)] focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:text-white focus:outline-none`,children:`Skip to content`}),(0,V.jsx)(`div`,{className:`hidden lg:block`,children:(0,V.jsx)(Zr,{})}),e&&(0,V.jsxs)(`div`,{className:`fixed inset-0 z-40 lg:hidden`,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 bg-black/60`,onClick:s}),(0,V.jsx)(`div`,{className:`relative z-50 h-full w-60`,children:(0,V.jsx)(Zr,{onNavigate:s})})]}),(0,V.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,children:[(0,V.jsx)(`header`,{className:`border-b border-[var(--app-border)] bg-[var(--app-header-bg)] px-4 py-2.5 lg:px-6`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`button`,{className:`text-[var(--app-text-subtle)] transition-colors hover:text-[var(--app-text)] lg:hidden`,onClick:()=>t(!e),"aria-label":e?`Close menu`:`Open menu`,children:e?(0,V.jsx)(g,{size:20}):(0,V.jsx)(p,{size:20})}),(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,V.jsxs)(`p`,{className:`text-sm text-[var(--app-text-muted)]`,children:[(0,V.jsx)(`span`,{className:`text-[var(--app-text)]`,children:o.section}),(0,V.jsx)(`span`,{className:`mx-1.5 text-[var(--app-text-subtle)]`,children:`/`}),(0,V.jsx)(`span`,{className:`font-medium text-[var(--app-text)]`,children:o.title})]})}),(0,V.jsx)(`div`,{className:`surface-panel-muted flex items-center gap-2 rounded-full px-3 py-1 text-xs`,"aria-live":`polite`,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(v,{size:14,className:`text-[var(--app-success)]`}),(0,V.jsx)(`span`,{className:`text-[var(--app-text)]`,children:`Connected`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(d,{size:14,className:`text-[var(--app-danger)]`}),(0,V.jsx)(`span`,{className:`text-[var(--app-text)]`,children:`Disconnected`})]})})]})}),(0,V.jsx)(`main`,{id:`main-content`,role:`main`,className:`flex-1 overflow-y-auto p-4 lg:p-5`,children:(0,V.jsx)(x,{})})]}),(0,V.jsx)(Ei,{position:`bottom-center`})]})}var Ai=ee(`inline-flex items-center rounded-md px-2 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`,{variants:{variant:{default:`bg-[var(--app-panel-muted)] text-[var(--app-text)]`,secondary:`bg-[var(--app-panel-elevated)] text-[var(--app-text-muted)]`,destructive:`bg-[var(--app-danger-soft-bg)] text-[var(--app-danger)] border border-[var(--app-danger-soft-border)]`,outline:`border border-[var(--app-border)] text-[var(--app-text)]`,success:`bg-[var(--app-success-soft-bg)] text-[var(--app-success)] border border-[var(--app-success-soft-border)]`,warning:`bg-[var(--app-warning-soft-bg)] text-[var(--app-warning)] border border-[var(--app-warning-soft-border)]`,info:`bg-[var(--app-accent-soft-bg)] text-[var(--app-accent)] border border-[var(--app-accent-soft-border)]`,muted:`bg-[var(--app-panel-elevated)] text-[var(--app-text-subtle)]`}},defaultVariants:{variant:`default`}});function ji({className:e,variant:t=`default`,...n}){return(0,V.jsx)(`span`,{className:M(Ai({variant:t}),e),...n})}function Mi(e){switch(e){case`blocked`:return`warning`;case`completed`:case`ready`:case`idle`:return`success`;case`running`:case`busy`:case`executing`:case`planning`:case`evaluating`:case`replanning`:return`info`;case`pending`:case`queued`:case`paused`:case`degraded`:return`warning`;case`failed`:case`cancelled`:case`dead`:case`not_ready`:return`destructive`;default:return`muted`}}var Ni=300;function Pi(e){return e===`high`?`destructive`:e===`medium`?`outline`:`secondary`}function Fi(){let e=Q(e=>e.pendingPlanApproval),t=Q(e=>e.approvePlan),n=Q(e=>e.denyPlan),r=Q(e=>e.planTimeoutNotice),i=Q(e=>e.clearPlanTimeoutNotice),[a,o]=(0,B.useState)(Ni),[s,c]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!e){o(Ni),c(!1);return}let t=setInterval(()=>{o(e=>e<=1?(clearInterval(t),0):e-1)},1e3);return()=>clearInterval(t)},[e?.planId]),(0,B.useEffect)(()=>{a===0&&e&&!s&&(c(!0),n(e.taskId,e.planId,`timeout`).catch(()=>{}))},[a,e,s,n]);let l=async n=>{if(e){c(!0);try{await t(e.taskId,e.planId,n)}catch{c(!1)}}},u=async()=>{if(e){c(!0);try{await n(e.taskId,e.planId)}catch{c(!1)}}},d=e?.plan;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(de,{open:!!e,children:(0,V.jsxs)(se,{className:`max-w-2xl max-h-[80vh] overflow-y-auto`,children:[(0,V.jsxs)(ue,{children:[(0,V.jsxs)(ne,{className:`flex items-center gap-2`,children:[`Execution Plan — Approval Required`,d&&(0,V.jsxs)(ji,{variant:Pi(d.overallRisk),children:[d.overallRisk.toUpperCase(),` RISK`]})]}),(0,V.jsxs)(F,{className:`text-xs text-[var(--app-text-muted)]`,children:[`Plan `,e?.planId,` | Task `,e?.taskId,` | `,a,`s remaining`]})]}),d&&(0,V.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-2`,children:[`Plan Steps (`,d.steps.length,`)`]}),(0,V.jsx)(`div`,{className:`space-y-2`,children:d.steps.map(e=>(0,V.jsxs)(`div`,{className:`rounded-md border border-[var(--app-border)] bg-[var(--app-panel-elevated)]/50 p-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`text-xs font-mono text-[var(--app-text-subtle)]`,children:[`#`,e.index]}),(0,V.jsx)(`span`,{className:`text-sm text-[var(--app-text)]`,children:e.description})]}),(0,V.jsx)(ji,{variant:Pi(e.riskLevel),children:e.riskLevel})]}),(0,V.jsxs)(`div`,{className:`mt-1 text-xs text-[var(--app-text-muted)]`,children:[`Tools: `,e.toolsNeeded.join(`, `)||`none`]})]},e.index))})]}),Object.keys(d.requiredPermissions).length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-[var(--app-text)] mb-1`,children:`Required Permissions`}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Object.keys(d.requiredPermissions).map(e=>(0,V.jsx)(ji,{variant:`secondary`,children:e},e))})]})]}),(0,V.jsxs)(le,{children:[(0,V.jsx)(me,{variant:`destructive`,onClick:u,disabled:s,children:`Deny`}),(0,V.jsx)(me,{variant:`outline`,onClick:()=>l(`permanent`),disabled:s,children:`Allow Permanent`}),(0,V.jsx)(me,{onClick:()=>l(`once`),disabled:s,children:`Allow Once`})]})]})}),r&&(0,V.jsxs)(`div`,{className:`fixed bottom-4 right-4 z-50 rounded-md border border-[var(--app-warning-soft-border)] bg-[var(--app-warning-soft-bg)] px-4 py-2 text-sm text-[var(--app-warning-soft-text)] shadow-[var(--app-shadow-lg)]`,children:[r,(0,V.jsx)(`button`,{className:`ml-3 text-[var(--app-warning)] hover:text-[var(--app-warning-soft-text)]`,onClick:i,children:`Dismiss`})]})]})}function $(e){return(0,B.lazy)(()=>e().catch(e=>{let t=`chunk-reload-`+window.location.pathname;if(!sessionStorage.getItem(t))return sessionStorage.setItem(t,`1`),window.location.reload(),new Promise(()=>{});throw sessionStorage.removeItem(t),e}))}function Ii(){let[e,t]=(0,B.useState)(``),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1),o=new URLSearchParams(window.location.search).get(`returnTo`)??`/ui`;async function s(t){t.preventDefault();let n=e.trim();if(!n){r(`API key is required`);return}r(null),a(!0);try{if(!await _e(n)){r(`Invalid API key`),a(!1);return}ve(n),window.location.href=o}catch(e){r(e instanceof Error?e.message:`Verification failed`),a(!1)}}return(0,V.jsx)(`div`,{className:`flex h-screen items-center justify-center bg-[var(--app-bg)] text-[var(--app-fg)]`,children:(0,V.jsxs)(`form`,{onSubmit:s,className:`w-full max-w-md rounded-lg border border-[var(--app-border)] bg-[var(--app-panel)] p-8 shadow-lg`,children:[(0,V.jsx)(`h1`,{className:`mb-2 text-2xl font-semibold`,children:`Adam — Sign in`}),(0,V.jsx)(`p`,{className:`mb-6 text-sm text-[var(--app-muted)]`,children:`Paste your API key to continue.`}),(0,V.jsx)(`label`,{className:`mb-1 block text-sm font-medium`,children:`API key`}),(0,V.jsx)(`input`,{type:`password`,value:e,onChange:e=>t(e.target.value),placeholder:`64-character hex string`,className:`mb-4 w-full rounded border border-[var(--app-border)] bg-[var(--app-bg)] px-3 py-2 font-mono text-sm outline-none focus:border-[var(--app-accent)]`,autoFocus:!0,disabled:i}),n&&(0,V.jsx)(`div`,{className:`mb-4 rounded border border-red-500/30 bg-red-500/10 px-3 py-2 text-sm text-red-400`,children:n}),(0,V.jsx)(`button`,{type:`submit`,disabled:i,className:`w-full rounded bg-[var(--app-accent)] px-4 py-2 font-medium text-[var(--app-accent-fg)] transition hover:opacity-90 disabled:opacity-50`,children:i?`Verifying...`:`Sign in`}),(0,V.jsxs)(`details`,{className:`mt-6 text-xs text-[var(--app-muted)]`,children:[(0,V.jsx)(`summary`,{className:`cursor-pointer select-none`,children:`Where do I find my API key?`}),(0,V.jsxs)(`div`,{className:`mt-2 space-y-1 leading-relaxed`,children:[(0,V.jsxs)(`p`,{children:[`Adam generates a random API key on first boot and stores it at`,` `,(0,V.jsx)(`code`,{className:`rounded bg-[var(--app-bg)] px-1`,children:`~/.adam/adam.key`}),`.`]}),(0,V.jsxs)(`p`,{children:[`Local: `,(0,V.jsx)(`code`,{className:`rounded bg-[var(--app-bg)] px-1`,children:`cat ~/.adam/adam.key`})]}),(0,V.jsxs)(`p`,{children:[`Remote (VPS): `,(0,V.jsx)(`code`,{className:`rounded bg-[var(--app-bg)] px-1`,children:`ssh <host> cat ~/.adam/adam.key`})]}),(0,V.jsx)(`p`,{children:`Rotation resets all logged-in sessions. Do it from Settings → API Key.`})]})]})]})})}var Li=$(()=>O(()=>import(`./Dashboard-Cv0AtO-o.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),Ri=$(()=>O(()=>import(`./Chat-BZwLDoYO.js`).then(e=>({default:e.Chat})),__vite__mapDeps([10,1,2,3,11,6,4,5,12,13,9,14,15]))),zi=$(()=>O(()=>import(`./Work-CvQrOKtL.js`).then(e=>({default:e.Work})),__vite__mapDeps([16,1,2,3,17,11,6,18,4,5,7,8,12,19,13,9,20,14,15]))),Bi=$(()=>O(()=>import(`./TaskDetail-BmXaH3sx.js`).then(e=>({default:e.TaskDetail})),__vite__mapDeps([21,1,2,3,11,6,5,7,8,13,9,14]))),Vi=$(()=>O(()=>import(`./Plugins-CoRmK2UG.js`).then(e=>({default:e.Plugins})),__vite__mapDeps([22,1,2,3,11,6,5,7,8,12,20,13,9,14,15]))),Hi=$(()=>O(()=>import(`./Strategies-3IV9eueQ.js`).then(e=>({default:e.Strategies})),__vite__mapDeps([23,1,2,3,11,6,5,8,12,20,9]))),Ui=$(()=>O(()=>import(`./Goals-CkKJDCiU.js`).then(e=>({default:e.Goals})),__vite__mapDeps([19,1,2,3,17,11,6,5,8,12,13,9]))),Wi=$(()=>O(()=>import(`./Logs-DnaaHV0Y.js`).then(e=>({default:e.Logs})),__vite__mapDeps([24,1,2,3,11,6,5,8,12,14]))),Gi=$(()=>O(()=>import(`./Settings-DZHAGazz.js`).then(e=>({default:e.Settings})),__vite__mapDeps([25,1,2,3,17,11,6,26,8,13,14,5,7,12,9]))),Ki=$(()=>O(()=>import(`./Memories-Dq9S-Tsi.js`).then(e=>({default:e.Memories})),__vite__mapDeps([27,1,2,3,11,6,5,7,8,12,13,9]))),qi=$(()=>O(()=>import(`./Evolution-DIqYOSb8.js`).then(e=>({default:e.Evolution})),__vite__mapDeps([28,1,2,3,11,6,5,8,12,13,9]))),Ji=$(()=>O(()=>import(`./Channels-8j28oydE.js`).then(e=>({default:e.Channels})),__vite__mapDeps([29,1,2,3,11,6,5,7,8,12,13,14]))),Yi=$(()=>O(()=>import(`./GoalDetail-Bkvgg6uI.js`).then(e=>({default:e.GoalDetail})),__vite__mapDeps([30,1,2,3,5,6,7,8,13,9]))),Xi=$(()=>O(()=>import(`./ChannelDetail-Bb8P8It_.js`).then(e=>({default:e.ChannelDetail})),__vite__mapDeps([31,1,2,3,5,6,7,8,13,9]))),Zi=$(()=>O(()=>import(`./Roles-EBUueS_P.js`).then(e=>({default:e.Roles})),__vite__mapDeps([32,1,2,3,11,6,5,7,8,12,20,9,15]))),Qi=$(()=>O(()=>import(`./RoleDetail-BHJA_PAn.js`).then(e=>({default:e.RoleDetail})),__vite__mapDeps([33,1,2,3,17,11,6,18,26,8,13,14,5,7,20,9,15]))),$i=$(()=>O(()=>import(`./FeatureRequests-BxPqLR1x.js`).then(e=>({default:e.FeatureRequests})),__vite__mapDeps([34,1,2,3,11,6,7,8,12,13]))),ea=$(()=>O(()=>import(`./Mistakes-D5lW31Co.js`).then(e=>({default:e.Mistakes})),__vite__mapDeps([35,1,2,3,11,6,7,8,12,13]))),ta=$(()=>O(()=>import(`./NotFound-gJVrOtER.js`),__vite__mapDeps([36,2,1,3]))),na=$(()=>O(()=>import(`./Events-DtkHL-r2.js`).then(e=>({default:e.Events})),__vite__mapDeps([37,1,2,3,17,11,6,18,7,8,12,20,13,9]))),ra=$(()=>O(()=>import(`./EventDefDetail-asUFrbQE.js`).then(e=>({default:e.EventDefDetail})),__vite__mapDeps([38,1,2,3,11,6,7,8,12,20,13])));function ia(){return(0,V.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,V.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-[var(--app-border)] border-t-[var(--app-accent)]`})})}function aa(){let e=window.location.pathname,t=ge();return e===`/ui/login`||!t?(0,V.jsx)(Ii,{}):(0,V.jsxs)(B.Suspense,{fallback:(0,V.jsx)(ia,{}),children:[(0,V.jsxs)(k,{children:[(0,V.jsx)(D,{path:`login`,element:(0,V.jsx)(Ii,{})}),(0,V.jsxs)(D,{element:(0,V.jsx)(ki,{}),children:[(0,V.jsx)(D,{index:!0,element:(0,V.jsx)(Li,{})}),(0,V.jsx)(D,{path:`chat`,element:(0,V.jsx)(Ri,{})}),(0,V.jsx)(D,{path:`work`,element:(0,V.jsx)(zi,{})}),(0,V.jsx)(D,{path:`tasks/:id`,element:(0,V.jsx)(Bi,{})}),(0,V.jsx)(D,{path:`plugins`,element:(0,V.jsx)(Vi,{})}),(0,V.jsx)(D,{path:`roles`,element:(0,V.jsx)(Zi,{})}),(0,V.jsx)(D,{path:`roles/:id`,element:(0,V.jsx)(Qi,{})}),(0,V.jsx)(D,{path:`feature-requests`,element:(0,V.jsx)($i,{})}),(0,V.jsx)(D,{path:`mistakes`,element:(0,V.jsx)(ea,{})}),(0,V.jsx)(D,{path:`events`,element:(0,V.jsx)(na,{})}),(0,V.jsx)(D,{path:`events/:id`,element:(0,V.jsx)(ra,{})}),(0,V.jsx)(D,{path:`channels`,element:(0,V.jsx)(Ji,{})}),(0,V.jsx)(D,{path:`channels/:id`,element:(0,V.jsx)(Xi,{})}),(0,V.jsx)(D,{path:`strategies`,element:(0,V.jsx)(Hi,{})}),(0,V.jsx)(D,{path:`goals`,element:(0,V.jsx)(Ui,{})}),(0,V.jsx)(D,{path:`goals/:id`,element:(0,V.jsx)(Yi,{})}),(0,V.jsx)(D,{path:`logs`,element:(0,V.jsx)(Wi,{})}),(0,V.jsx)(D,{path:`settings`,element:(0,V.jsx)(Gi,{})}),(0,V.jsx)(D,{path:`memories`,element:(0,V.jsx)(Ki,{})}),(0,V.jsx)(D,{path:`evolution`,element:(0,V.jsx)(qi,{})}),(0,V.jsx)(D,{path:`*`,element:(0,V.jsx)(ta,{})})]})]}),(0,V.jsx)(Fi,{})]})}var oa=S([{path:`*`,element:(0,V.jsx)(aa,{})}],{basename:`/ui`});(0,xe.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(Se,{children:(0,V.jsx)(E,{router:oa})})}));export{Fn as a,di as i,Mi as n,Q as r,ji as t};
|