@cuongtran001/kanna 1.112.2 → 1.112.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{BoardsPage-C4ENzt64.js → BoardsPage-C-XPAU3h.js} +1 -1
- package/dist/client/assets/{BoardsRoutePage-C5PTbi6Z.js → BoardsRoutePage-gPPjLYFJ.js} +1 -1
- package/dist/client/assets/{ChatPage-BHMfe4hl.js → ChatPage-BTvroV45.js} +4 -4
- package/dist/client/assets/{CronJobsPage-Bh091yEI.js → CronJobsPage-DWhHYDPy.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-C2s7k36v.js → FilePreviewSheet-DcMdV7hW.js} +1 -1
- package/dist/client/assets/{FlowSurface-jNQcFMOA.js → FlowSurface-DVqwtykb.js} +1 -1
- package/dist/client/assets/{GenUIBlock-hkkM4P_r.js → GenUIBlock-DAGKgmn9.js} +2 -2
- package/dist/client/assets/{InboundHandlerFields-CHcSqbMB.js → InboundHandlerFields-B-Oaf00T.js} +1 -1
- package/dist/client/assets/{InboxPage-BpqjwtXn.js → InboxPage-D974XFxa.js} +1 -1
- package/dist/client/assets/{LocalProjectsPage-lyxhfFS2.js → LocalProjectsPage-DoqYQOk_.js} +1 -1
- package/dist/client/assets/{PluginPage-CEmCB38q.js → PluginPage-DHzi5YJm.js} +1 -1
- package/dist/client/assets/{SettingsPage-BsQiWj_w.js → SettingsPage-CuZzlqsG.js} +1 -1
- package/dist/client/assets/{StackBoardsRoutePage-Dj88KTce.js → StackBoardsRoutePage-DeaUCg6R.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-I5nT0rPg.js → ToolCallMessage-C7QI45cs.js} +1 -1
- package/dist/client/assets/{VChartSurface-DezqqT8Y.js → VChartSurface-RVaL5qrl.js} +1 -1
- package/dist/client/assets/{WebhooksPage-BCMse54G.js → WebhooksPage-heTo8A5m.js} +1 -1
- package/dist/client/assets/{WorkflowsPage-vWjQy33o.js → WorkflowsPage-YY8NQXiF.js} +1 -1
- package/dist/client/assets/{beacon-alias-DU-hx8ux.js → beacon-alias-CcevdUfB.js} +3 -3
- package/dist/client/assets/{contextWindow-D6tuokPX.js → contextWindow-BVVtk5Al.js} +1 -1
- package/dist/client/assets/{copyFeedbackStore-DHN0d0wY.js → copyFeedbackStore-B4X215_R.js} +1 -1
- package/dist/client/assets/{errors-W4jQ4RJU.js → errors-ewkwYZz5.js} +1 -1
- package/dist/client/assets/{inboxAutonomy-C7kYrLi-.js → inboxAutonomy-B8WAm9lN.js} +1 -1
- package/dist/client/assets/{index-DBSVTFCP.js → index-Bk7A56Tb.js} +18 -18
- package/dist/client/assets/{keybindings-CMDgT5Fr.js → keybindings-CqgNeQvJ.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-BgvURrXK.js → pendingActionsStore-Bw87-8u6.js} +1 -1
- package/dist/client/assets/runDetached-Dt8QjzWN.js +1 -0
- package/dist/client/assets/{searchable-select-BdWimkUA.js → searchable-select-C5ZlaFYL.js} +1 -1
- package/dist/client/assets/{select-BzVGFhmQ.js → select-DNgFvwVk.js} +1 -1
- package/dist/client/assets/{settings-header-button-GQg0n1x9.js → settings-header-button-F_g1XSLK.js} +1 -1
- package/dist/client/assets/{textarea-DlZ4tGyx.js → textarea-DCKnXsZI.js} +1 -1
- package/dist/client/assets/{timer.adapter-DWVGc3wb.js → timer.adapter-t-ql2eaa.js} +1 -1
- package/dist/client/assets/{tools-CryRpKwA.js → tools-BFWoj5em.js} +1 -1
- package/dist/client/assets/{useAppGlobalState-BruhC_so.js → useAppGlobalState-Cs47JwWq.js} +1 -1
- package/dist/client/assets/{useProviderCatalog-Bi14KFxt.js → useProviderCatalog-DJqnDuQQ.js} +1 -1
- package/dist/client/index.html +15 -15
- package/package.json +1 -1
- package/src/server/agent.test.ts +1 -246
- package/src/server/claude-session-start.ts +1 -8
- package/src/server/claude-spawn-helpers.test.ts +0 -70
- package/src/server/claude-spawn-helpers.ts +0 -26
- package/src/server/kanna-mcp.test.ts +0 -30
- package/src/server/kanna-mcp.ts +0 -41
- package/src/server/permission-gate.test.ts +0 -30
- package/src/server/permission-gate.ts +0 -6
- package/dist/client/assets/runDetached-BkBQfi5b.js +0 -1
- package/src/server/kanna-mcp-tools/bash.adapter.ts +0 -53
- package/src/server/kanna-mcp-tools/bash.test.ts +0 -53
- package/src/server/kanna-mcp-tools/edit.adapter.ts +0 -47
- package/src/server/kanna-mcp-tools/edit.test.ts +0 -92
- package/src/server/kanna-mcp-tools/glob.adapter.ts +0 -35
- package/src/server/kanna-mcp-tools/glob.test.ts +0 -60
- package/src/server/kanna-mcp-tools/grep.adapter.ts +0 -71
- package/src/server/kanna-mcp-tools/grep.test.ts +0 -60
- package/src/server/kanna-mcp-tools/read.adapter.ts +0 -26
- package/src/server/kanna-mcp-tools/read.test.ts +0 -62
- package/src/server/kanna-mcp-tools/tool-callback-shim.ts +0 -64
- package/src/server/kanna-mcp-tools/walk-files.adapter.ts +0 -18
- package/src/server/kanna-mcp-tools/webfetch.test.ts +0 -81
- package/src/server/kanna-mcp-tools/webfetch.ts +0 -49
- package/src/server/kanna-mcp-tools/write.adapter.ts +0 -31
- package/src/server/kanna-mcp-tools/write.test.ts +0 -52
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{Ct as a,E as o,M as s,T as c,Y as l,_ as u,a as d,c as f,d as p,g as m,gt as h,h as g,j as _,k as v,l as y,m as b,n as x,o as S,s as ee,u as te,wt as ne,xt as C}from"./useAppGlobalState-BruhC_so.js";import{i as w,t as T}from"./utils-gw0dpHSZ.js";import{a as re,l as ie,n as E,o as ae}from"./beacon-alias-DU-hx8ux.js";import{a as D,i as oe,n as se,o as ce,t as le}from"./copyFeedbackStore-DHN0d0wY.js";import{a as O,i as k,n as ue,o as de,r as fe,t as pe}from"./select-BzVGFhmQ.js";import{t as me}from"./info-DRKK3Ev3.js";import{c as he,r as ge,s as _e}from"./contextWindow-D6tuokPX.js";import{a as ve,d as A,f as j,i as ye,l as M,n as N,o as be,r as P,t as F,u as xe}from"./pendingActionsStore-BgvURrXK.js";import{t as Se}from"./monitor-B1cxkbAV.js";import{t as Ce}from"./pencil-BnnPP0sI.js";import{t as we}from"./plus-k8ypzgh4.js";import{t as Te}from"./refresh-cw-BnSFXoQI.js";import{t as Ee}from"./search-DaMiMFjO.js";import{S as De,a as Oe,c as ke,i as Ae,o as je,r as Me,s as Ne,t as Pe}from"./useProviderCatalog-Bi14KFxt.js";import{t as Fe}from"./triangle-alert-BlEPrBcS.js";import{g as Ie,i as Le,n as Re,o as ze,r as Be,t as Ve,u as He}from"./timer.adapter-DWVGc3wb.js";import{a as Ue,c as We,o as Ge,s as Ke,t as I}from"./segmented-control-CthWIFFX.js";import{n as L}from"./log-8K5PdGJC.js";import{t as R}from"./input-Bkp2JE9C.js";import{n as qe,o as Je,r as Ye,t as Xe,u as Ze}from"./errors-W4jQ4RJU.js";import{f as Qe,i as $e,o as et,u as tt}from"./core-types-BWpRMPSe.js";import{$ as nt,A as rt,C as it,D as at,E as ot,G as st,H as ct,J as lt,K as ut,L as dt,M as ft,N as pt,O as mt,U as ht,V as gt,W as _t,X as vt,Y as yt,Z as bt,_ as xt,a as St,at as Ct,b as wt,c as Tt,ct as Et,d as Dt,dt as Ot,et as kt,f as At,g as jt,h as Mt,i as Nt,it as Pt,j as Ft,k as It,l as Lt,lt as Rt,m as zt,n as Bt,nt as Vt,o as Ht,p as Ut,q as Wt,r as Gt,rt as Kt,s as qt,u as Jt,v as z,w as Yt}from"./tool-call-types-CoEzmgyY.js";import{M as Xt,N as Zt,iu as Qt,j as $t,r as en,ru as tn}from"./useTheme-Cb3XmN93.js";import{a as nn,n as rn}from"./state-mark-p6veyUZZ.js";import{f as B,n as an,o as on,r as sn,t as cn,u as ln}from"./textarea-DlZ4tGyx.js";import{t as un}from"./runDetached-BkBQfi5b.js";import{C as dn,S as fn,T as pn,a as mn,b as hn,d as gn,g as _n,h as vn,i as yn,l as bn,m as xn,n as Sn,o as Cn,p as wn,r as Tn,s as En,t as Dn,v as On,x as kn,y as An}from"./types-tbL38EdO.js";import{t as jn}from"./dom.adapter-C26vNdMA.js";import{d as Mn,f as Nn,l as Pn,t as Fn}from"./keybindings-CMDgT5Fr.js";import{n as In,t as Ln}from"./formatDuration-BbWTR_M_.js";import{En as Rn,On as zn,Sn as Bn,_t as Vn,it as Hn,rn as Un,vt as Wn,yt as Gn}from"./index-DBSVTFCP.js";import{S as Kn,T as qn,b as Jn,d as Yn,f as Xn,l as Zn,m as Qn,u as $n,x as er,y as tr}from"./ChatPage-BHMfe4hl.js";import{a as nr,c as rr,d as ir,f as ar,i as or,l as sr,o as cr,p as lr,s as ur,t as dr,u as fr}from"./searchable-select-BdWimkUA.js";import{f as pr,l as mr,t as hr,u as gr}from"./inboxAutonomy-C7kYrLi-.js";import{t as _r}from"./settings-header-button-GQg0n1x9.js";import{t as vr}from"./InboundHandlerFields-CHcSqbMB.js";var yr={name:`antenna`,size:24,node:[[`path`,{d:`M2 12 7 2`,key:`117k30`}],[`path`,{d:`m7 12 5-10`,key:`1tvx22`}],[`path`,{d:`m12 12 5-10`,key:`ev1o1a`}],[`path`,{d:`m17 12 5-10`,key:`1e4ti3`}],[`path`,{d:`M4.5 7h15`,key:`vlsxkz`}],[`path`,{d:`M12 16v6`,key:`c8a4gj`}]]};yr.node;var br=w(yr),xr={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};xr.node;var Sr=w(xr),Cr={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Cr.node;var wr=w(Cr),Tr={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Tr.node;var Er=w(Tr),Dr={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};Dr.node;var Or=w(Dr),kr={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};kr.node;var Ar=w(kr),jr={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};jr.node;var Mr=w(jr),Nr={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Nr.node;var Pr=w(Nr),Fr={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Fr.node;var Ir=w(Fr),Lr={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Lr.node;var Rr=w(Lr),zr={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};zr.node;var Br=w(zr),Vr={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Vr.node;var Hr=w(Vr),Ur={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};Ur.node;var Wr=w(Ur),Gr={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Gr.node;var Kr=w(Gr),qr={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};qr.node;var Jr=w(qr),Yr={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Yr.node;var Xr=w(Yr),Zr={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Zr.node;var Qr=w(Zr),$r={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};$r.node;var ei=w($r),ti={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},V=e(t(),1),H=e(i(),1);function ni(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var ri={maxFileSizeMb:2048},ii={path:`uploads.maxFileSizeMb`,min:1,max:51200,integer:!1},ai=L()(e=>({authEnabled:!1,setAuthEnabled:t=>e({authEnabled:t})}));function U({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,H.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,H.jsxs)(`div`,{className:T(`flex flex-col gap-4 py-5 md:flex-row md:justify-between md:gap-8`,i?`md:items-start`:`md:items-center`),children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,H.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function oi({icon:e,message:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,H.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function si({children:e}){return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function ci({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,H.jsx)(Ce,{className:`h-4 w-4`})}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,H.jsx)(De,{className:`h-4 w-4`})})]})}var li=new Set([`checking`,`downloading`,`installing`,`restarting`]);function ui(e){return e!==null&&li.has(e.state)}function di(e){switch(e.state){case`checking`:return`Checking ${e.version}…`;case`downloading`:return`Downloading ${e.version}…`;case`installing`:return`Installing ${e.version}…`;case`restarting`:return`Restarting…`;case`current`:return`Up to date`;case`failed`:return e.message===void 0?`Update failed`:`Update failed: ${e.message}`}}function fi(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var pi={},mi={},hi={},gi={};function _i(e,t){return`${e}:${t}`}function vi(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));return Object.keys(r).length>0?r:n}var W=L()(e=>({pairing:null,expandedId:null,drafts:pi,updateErrors:mi,aliasErrors:hi,openExplanations:gi,setPairing:t=>e({pairing:t}),toggleExpanded:t=>e(e=>({expandedId:e.expandedId===t?null:t})),setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),clearDraft:t=>e(e=>({drafts:vi(e.drafts,t,pi)})),setUpdateError:(t,n)=>e(e=>n===null?{updateErrors:vi(e.updateErrors,t,mi)}:{updateErrors:{...e.updateErrors,[t]:n}}),beginAliasEdit:(t,n)=>e(e=>({drafts:{...e.drafts,[_i(t,`alias`)]:n}})),endAliasEdit:t=>e(e=>({drafts:vi(e.drafts,_i(t,`alias`),pi),aliasErrors:vi(e.aliasErrors,t,hi)})),setAliasError:(t,n)=>e(e=>n===null?{aliasErrors:vi(e.aliasErrors,t,hi)}:{aliasErrors:{...e.aliasErrors,[t]:n}}),toggleExplanation:t=>e(e=>({openExplanations:t in e.openExplanations?vi(e.openExplanations,t,gi):{...e.openExplanations,[t]:!0}}))})),yi=`kanna-beacon`,bi=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,xi=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${bi}]{8}$`);function Si(e){return`${yi}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function Ci(e){return`kanna-beacon pair ${e.kannaUrl} ${e.code}`}function wi(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function Ti(e,t){if(e===t)return!1;let n=wi(e),r=wi(t),i=Math.max(n.length,r.length);for(let a=0;a<i;a+=1){let i=n[a]??0,o=r[a]??0;if(Number.isNaN(i)||Number.isNaN(o))return e<t;if(i!==o)return i<o}return!1}var Ei={outdated:`border-warning/40 text-warning-text bg-warning/10`,partial:`border-warning/40 text-warning-text bg-warning/10`,unknown:`border-border text-muted-foreground bg-muted/40`};function Di({beaconId:e,alias:t,displayName:n}){let r=W(e=>e.beginAliasEdit),i=(0,V.useCallback)(()=>{r(e,t??``)},[t,e,r]);return(0,H.jsx)(an,{label:`Set a short name`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`Set a short name for ${n}`,children:(0,H.jsx)(Ce,{className:`h-3.5 w-3.5`})})})}function Oi({beaconId:e,alias:t,displayName:n,onSetAlias:r}){let i=_i(e,`alias`),a=W(e=>e.drafts[i]),o=W(t=>t.aliasErrors[e]??null),s=W(e=>e.setDraft),c=W(e=>e.setAliasError),l=W(e=>e.endAliasEdit),u=F(`beacons.setAlias`,e),d=P(u),f=a??``,p=f.length===0?null:re(f),m=f.length>0&&p===null&&f!==t,h=p??o,g=(0,V.useCallback)(t=>{s(i,t.target.value.toLowerCase()),c(e,null)},[e,i,c,s]),_=(0,V.useCallback)(t=>{N(u,async()=>{try{await r(e,t),l(e)}catch(t){c(e,Xe(t))}})},[e,l,r,u,c]),v=(0,V.useCallback)(()=>{_(f)},[_,f]),y=(0,V.useCallback)(()=>{_(null)},[_]),b=(0,V.useCallback)(()=>{l(e)},[e,l]);return a===void 0?null:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(R,{value:f,onChange:g,placeholder:`office-mac`,disabled:d,"aria-label":`Short name for ${n}`,"aria-invalid":h!==null||void 0,className:`w-48`}),(0,H.jsx)(M,{size:`sm`,onClick:v,pending:d,disabled:!m,children:`Save`}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:b,disabled:d,children:`Cancel`}),t!==null&&(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:y,disabled:d,children:`Clear alias`})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Type `,(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,f.length>0?f:`name`]}),` in a message to refer to this machine.`]}),h!==null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive-text`,children:h})]})}var ki=`Lets the agent run commands and scripts on this machine. Off means every command and script is refused, and the agent can only read and copy files inside the folders below. When on, each command still waits for your approval unless it is on the always-run list or you switch on running without asking.`,Ai=`Skips the approval prompt. Reads and writes inside the folders below, and every command and script, run immediately. Leave it off to review each action before it runs on this machine.`,ji=`The agent can list, search, read and copy files off this machine only inside these folders and their subfolders. Anything outside is refused. With none listed it cannot read from this machine at all. Each read waits for your approval unless running without asking is on.`,Mi=`The agent can copy files onto this machine only inside these folders and their subfolders. Leave empty and it cannot write to this machine at all. Each write waits for your approval unless running without asking is on.`,Ni=`Command names, such as git, that run immediately once running commands is allowed. Matching uses the command name only, so git covers every git subcommand. Anything not listed asks you first.`;function Pi(e){return`beacon-explain-${e}`}function Fi({explanationKey:e,subject:t}){let n=W(t=>e in t.openExplanations),r=W(e=>e.toggleExplanation),i=(0,V.useCallback)(()=>{r(e)},[e,r]);return(0,H.jsx)(an,{label:`What does this do?`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-expanded":n,"aria-controls":Pi(e),"aria-label":`What does "${t}" do?`,children:(0,H.jsx)(me,{className:`h-4 w-4`})})})}function Ii({explanationKey:e,text:t}){let n=W(t=>e in t.openExplanations);return(0,H.jsx)(`p`,{id:Pi(e),hidden:!n,className:`text-13 text-muted-foreground`,children:t})}function Li({beaconId:e,scope:t,onSetScope:n}){let r=F(`beacons.setScope`,e),i=P(r),a=(0,V.useCallback)(t=>{N(r,()=>n(e,t))},[e,n,r]),o=(0,V.useCallback)(e=>{a({...t,exec:e.target.checked})},[a,t]),s=(0,V.useCallback)(e=>{a({...t,autoRunScripts:e.target.checked})},[a,t]),c=(0,V.useCallback)(e=>{a({...t,readRoots:e})},[a,t]),l=(0,V.useCallback)(e=>{a({...t,writeRoots:e})},[a,t]),u=(0,V.useCallback)(e=>{a({...t,execAllowlist:e})},[a,t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border bg-muted/40 px-4 py-4`,"aria-busy":i||void 0,children:[(0,H.jsx)(Ri,{explanationKey:_i(e,`exec`),checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,explanation:ki}),(0,H.jsx)(Ri,{explanationKey:_i(e,`autoRunScripts`),checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,explanation:Ai}),(0,H.jsx)(zi,{label:`Folders the agent may read`,explanation:ji,placeholder:`/Users/me/projects`,draftKey:_i(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,H.jsx)(zi,{label:`Folders the agent may write to`,explanation:Mi,placeholder:`/Users/me/inbox`,draftKey:_i(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,H.jsx)(zi,{label:`Commands that always run without asking`,explanation:Ni,placeholder:`git`,draftKey:_i(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function Ri({explanationKey:e,checked:t,disabled:n,onChange:r,title:i,explanation:a}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-center gap-3`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:r}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:i})]}),(0,H.jsx)(Fi,{explanationKey:e,subject:i})]}),(0,H.jsx)(`div`,{className:`pl-7`,children:(0,H.jsx)(Ii,{explanationKey:e,text:a})})]})}function zi({label:e,explanation:t,placeholder:n,draftKey:r,items:i,disabled:a,onChange:o}){let s=W(e=>e.drafts[r]??``),c=W(e=>e.setDraft),l=W(e=>e.clearDraft),u=s.trim(),d=u.length>0&&!i.includes(u),f=(0,V.useCallback)(e=>{c(r,e.target.value)},[r,c]),p=(0,V.useCallback)(()=>{o([...i,u]),l(r)},[l,r,i,o,u]),m=(0,V.useCallback)(e=>{o(i.filter(t=>t!==e))},[i,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(Fi,{explanationKey:r,subject:e})]}),(0,H.jsx)(Ii,{explanationKey:r,text:t}),i.length===0?(0,H.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`None`}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,H.jsx)(Bi,{item:e,disabled:a,onRemove:m},e))}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{value:s,onChange:f,placeholder:n,disabled:a,"aria-label":e}),(0,H.jsx)(M,{variant:`secondary`,size:`sm`,onClick:p,disabled:a||!d,children:`Add`})]})]})}function Bi({item:e,disabled:t,onRemove:n}){let r=(0,V.useCallback)(()=>{n(e)},[e,n]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-13`,children:e}),(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:r,disabled:t,"aria-label":`Remove ${e}`,children:(0,H.jsx)(Ie,{className:`h-4 w-4`})})]})}var Vi=F(`beacons.mintPairingCode`);function Hi(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,alias:e.alias??null,os:e.os,enabled:e.enabled,online:t?.online??!1,lastSeenAt:t?.lastSeenAt??null,beaconVersion:t?.beaconVersion??null,canSelfUpdate:t?.canSelfUpdate??!1,update:t?.update??null}})}function Ui({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=jn,clipboard:a=oe,timer:o=Ve}){let s=Hn(1e3),c=(0,V.useMemo)(()=>Hi(e,t),[e,t]),l=(0,V.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(Wi,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,H.jsx)(oi,{icon:er,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,H.jsx)(si,{children:c.map(e=>(0,H.jsx)(Xi,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function Wi({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=W(e=>e.pairing),o=W(e=>e.setPairing),s=P(Vi),c=(0,V.useCallback)(()=>{N(Vi,async()=>{o(await t.onMint())})},[t,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Beacons`}),(0,H.jsx)(`p`,{className:`mt-1 text-13 text-muted-foreground`,children:`A beacon is a small program on your own machine. Once paired, the agent can read files and run commands there, only within the scope you grant below.`})]}),(0,H.jsxs)(M,{size:`sm`,variant:a?.ok===!0?`secondary`:`default`,onClick:c,pending:s,children:[(0,H.jsx)(we,{className:`mr-1 h-4 w-4`}),`Pair a machine`]})]}),a?.ok===!1&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-text`,children:a.error}),a?.ok===!0&&(0,H.jsx)(Gi,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function Gi({code:e,expiresAt:t,now:n,dom:r,clipboard:i,timer:a}){let o=t-n,s=r.getOrigin(),c=Ci({kannaUrl:s,code:e}),l=Si({kannaUrl:s,code:e}),u=F(`beacons.copyPairCommand`,e),d=P(u),f=se(u),p=(0,V.useCallback)(()=>{N(u,()=>le(u,()=>i.writeText(c),a))},[i,c,u,a]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,H.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums tracking-widest`,children:e}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:o>0?`Expires in ${In(o)}`:`Expired. Pair again for a new code.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,H.jsxs)(`a`,{href:l,className:xe({size:`sm`}),children:[(0,H.jsx)(Bn,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,H.jsx)(`a`,{href:xi,target:`_blank`,rel:`noreferrer`,className:`text-13 text-muted-foreground underline underline-offset-2 hover:text-foreground`,children:`Download Kanna Beacon`})]}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Or run this on the machine you want to pair:`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-3 py-2 font-mono text-13`,children:c}),(0,H.jsx)(an,{label:f?`Copied`:`Copy command`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon`,onClick:p,pending:d,"aria-label":f?`Copied`:`Copy pairing command`,children:f?(0,H.jsx)(ce,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(D,{className:`h-4 w-4`})})})]})]})}function Ki(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${Ln(t-e.lastSeenAt)} ago`}var qi=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function Ji({canSelfUpdate:e}){let t=T(`rounded-full border px-2 py-0.5 text-xs`,Ei.outdated);return e?(0,H.jsx)(`span`,{className:t,children:`Update available`}):(0,H.jsx)(an,{label:qi,children:(0,H.jsx)(`a`,{href:xi,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function Yi({row:e,updateAvailable:t,handlers:n}){let r=F(`beacons.update`,e.id),i=P(r),a=W(t=>t.updateErrors[e.id]??null),o=W(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!ui(e.update),c=(0,V.useCallback)(()=>{N(r,async()=>{let t=await n.onUpdate(e.id);o(e.id,t.ok?null:t.error)})},[n,e.id,o,r]);return(0,H.jsxs)(H.Fragment,{children:[e.update!==null&&(0,H.jsx)(rn,{tone:fi(e.update),label:di(e.update)}),s&&(0,H.jsxs)(M,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${E(e)} now`,children:[(0,H.jsx)(Er,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function Xi({row:e,scope:t,now:n,serverVersion:r,handlers:i,dom:a}){let o=W(t=>t.expandedId===e.id),s=W(e=>e.toggleExpanded),c=F(`beacons.setEnabled`,e.id),l=P(c),u=F(`beacons.delete`,e.id),d=P(u),f=E(e),p=e.beaconVersion!==null&&r!==void 0&&Ti(e.beaconVersion,r),m=(0,V.useCallback)(t=>{let n=t.target.checked;N(c,()=>i.onSetEnabled(e.id,n))},[c,i,e.id]),h=(0,V.useCallback)(()=>{a.confirmDialog(`Revoke "${f}"? The agent will lose access to this machine until you pair it again.`)&&N(u,()=>i.onDelete(e.id))},[u,f,a,i,e.id]),g=(0,V.useCallback)(()=>{s(e.id)},[e.id,s]);return(0,H.jsxs)(`li`,{className:`flex flex-col`,"aria-busy":d||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium`,children:f}),(0,H.jsx)(Di,{beaconId:e.id,alias:e.alias,displayName:f})]}),e.alias!==null&&(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`font-mono`,children:e.label}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,e.alias]})]}),(0,H.jsx)(Oi,{beaconId:e.id,alias:e.alias,displayName:f,onSetAlias:i.onSetAlias}),(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(rn,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:Ki(e,n)}),e.beaconVersion!==null&&(0,H.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),p&&(0,H.jsx)(Ji,{canSelfUpdate:e.canSelfUpdate}),(0,H.jsx)(Yi,{row:e,updateAvailable:p,handlers:i}),(0,H.jsx)(`span`,{children:e.os})]})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[l?(0,H.jsx)(A,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:l,"aria-busy":l||void 0,onChange:m,"aria-label":`Enable ${f}`}),(0,H.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),t!==null&&(0,H.jsxs)(M,{variant:`ghost`,size:`sm`,onClick:g,"aria-expanded":o,children:[`Scope`,(0,H.jsx)(Rn,{className:T(`ml-1 h-4 w-4 transition-transform`,o&&`rotate-180`)})]}),(0,H.jsx)(an,{label:`Revoke this machine`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon`,onClick:h,pending:d,"aria-label":`Revoke ${f}`,children:(0,H.jsx)(De,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,H.jsx)(Li,{beaconId:e.id,scope:t,onSetScope:i.onSetScope})]})}function Zi(e){let t=s(_),n=z(Nt),{handleWriteAppSettings:r,handleMintBeaconPairingCode:i,handleUpdateBeacon:a}=e.state,o=(0,V.useMemo)(()=>({onMint:i,onSetEnabled:async(e,t)=>{await r({customBeacons:{setEnabled:{id:e,enabled:t}}})},onSetScope:async(e,t)=>{await r({customBeacons:{setScope:{id:e,scope:t}}})},onSetAlias:async(e,t)=>{await r({customBeacons:{update:{id:e,patch:{alias:t}}}})},onDelete:async e=>{await r({customBeacons:{delete:{id:e}}})},onUpdate:a}),[r,i,a]);return(0,H.jsx)(Ui,{rows:t,configs:n,handlers:o,serverVersion:Je})}var Qi=3e5,$i=null;function ea(e=Date.now){return $i?e()>=$i.expiresAt?($i=null,null):$i.releases:null}function ta(e,t=Date.now){$i={releases:e,expiresAt:t()+Qi}}async function na(e,t){let n=t?.now??Date.now,r=t?.force?null:ea(n);if(r)return r;let i=await e();return ta(i,n),i}function ra(e){return e.trim().replace(/^v/i,``)}function ia(e,t){let n=e=>ra(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e)),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e+=1){let t=r[e]??0,n=i[e]??0;if(t!==n)return t<n?-1:1}return 0}function aa(e,t,n){return ra(e)===ra(n)?{actionLabel:`Update`,pendingLabel:`Updating…`}:ia(e,t)<0?{actionLabel:`Rollback`,pendingLabel:`Rolling back…`}:{actionLabel:`Install`,pendingLabel:`Installing…`}}function oa(e){if(!e)return`Unpublished`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown date`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,year:`numeric`}).format(t)}function sa({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:s,onForceReload:c}){let l=P(`update.check`),u=ve(`update.install`),d=P(`update.redeploy`),f=ye(e=>e.inFlight),p=u||d,m=i?.latestVersion??t[0]?.tag_name??`Unknown`,h=i?.currentVersion??a,g=i?.status===`checking`||l,_=i?.status===`updating`||i?.status===`restart_pending`,v=_||p,y=i?.updateAvailable===!0,b=ra(m),x=ra(h),S=(0,V.useCallback)(async e=>{await o(e)},[o]),ee=(0,V.useCallback)(async()=>{await c()},[c]),te=d||_;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[e===`loading`||e===`idle`?(0,H.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center rounded-2xl border border-border bg-card/40 px-6 py-8 text-sm text-muted-foreground`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading release notes…`})]})}):null,e===`error`?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-6 py-5`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Could not load changelog`}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n??`Unable to load changelog.`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted`,children:`Retry`})]})}):null,e===`success`&&t.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 px-6 py-8`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No releases yet`}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`GitHub did not return any published releases for this repository.`})]}):null,e===`success`?(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(_r,{variant:`outline`,onClick:()=>N(`update.redeploy`,ee),disabled:v,children:te?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,H.jsx)(_r,{variant:`outline`,onClick:()=>N(`update.check`,s),disabled:g||v,children:g?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}),`Checking…`]}):`Check for updates`})]}):null,e===`success`&&t.length>0?t.map(e=>{let t=ra(e.tag_name),n=t===b,r=t===x;return(0,H.jsxs)(`article`,{className:T(`rounded-xl border bg-card/30 pl-6 pr-4 py-4`,n?`border-border bg-muted`:`border-border`),children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-3 `,children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:e.name?.trim()||e.tag_name}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:oa(e.published_at)}),e.prerelease?(0,H.jsx)(`span`,{className:`rounded-full border border-border px-2.5 py-1 tracking-wide`,children:`Prerelease`}):null]})]}),(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-end min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`a`,{href:e.html_url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`View release on GitHub`,className:T(xe({variant:`ghost`,size:`icon-sm`}),`h-11 w-11 md:h-8 md:w-8 shrink-0 rounded-md hover:!bg-transparent hover:border-border/0`),children:(0,H.jsx)(ca,{className:`h-4 w-4`})}),r?(0,H.jsx)(`span`,{className:T(`bg-transparent border border-border text-secondary-foreground`,`h-9 rounded-full px-3 text-sm`,`h-auto gap-1.5 px-3 py-1.5`),children:`Current`}):null,n&&y||!n&&!r?(()=>{let t=f[F(`update.install`,e.tag_name)]===!0||_&&!p,{actionLabel:n,pendingLabel:r}=aa(e.tag_name,h,m);return(0,H.jsx)(_r,{variant:`default`,className:``,onClick:()=>N(F(`update.install`,e.tag_name),()=>S(e.tag_name)),disabled:v,children:(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2`,children:[t?(0,H.jsx)(j,{className:`size-4 animate-spin`}):(0,H.jsx)(Or,{className:`size-4`}),t?r:n]})})})():null]})]}),e.body?.trim()?(0,H.jsx)(`div`,{className:`prose prose-sm mt-5 max-w-none text-foreground dark:prose-invert`,children:ie(e.body)}):(0,H.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function ca({className:e}){return(0,H.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,H.jsx)(`path`,{d:`M12 .5C5.649.5.5 5.649.5 12A11.5 11.5 0 0 0 8.36 22.04c.575.106.785-.25.785-.556 0-.274-.01-1-.015-1.962-3.181.691-3.853-1.532-3.853-1.532-.52-1.322-1.27-1.674-1.27-1.674-1.038-.71.08-.695.08-.695 1.148.08 1.752 1.178 1.752 1.178 1.02 1.748 2.676 1.243 3.328.95.103-.738.399-1.243.725-1.53-2.54-.289-5.211-1.27-5.211-5.65 0-1.248.446-2.27 1.177-3.07-.118-.288-.51-1.45.112-3.024 0 0 .96-.307 3.145 1.173A10.91 10.91 0 0 1 12 6.03c.973.004 1.954.132 2.87.387 2.182-1.48 3.14-1.173 3.14-1.173.625 1.573.233 2.736.115 3.024.734.8 1.175 1.822 1.175 3.07 0 4.39-2.676 5.358-5.224 5.642.41.353.776 1.05.776 2.117 0 1.528-.014 2.761-.014 3.136 0 .309.207.668.79.555A11.502 11.502 0 0 0 23.5 12C23.5 5.649 18.351.5 12 .5Z`})})}var la=[],ua=L()(e=>({status:`idle`,releases:la,error:null,loadStarted:()=>e({status:`loading`,error:null}),loaded:t=>e({releases:t,status:`success`}),loadFailed:t=>e({error:t,status:`error`})}));function da(e){let t=ua(e=>e.status),n=ua(e=>e.releases),r=ua(e=>e.error),i=ua(e=>e.loadStarted),a=ua(e=>e.loaded),o=ua(e=>e.loadFailed),s=(0,V.useCallback)(async(t,n)=>{i();try{let r=await na(e,{force:t});n()||a(r)}catch(e){n()||o(Xe(e))}},[e,i,a,o]);return(0,V.useEffect)(()=>{let e=!1;return un(`changelog.load`,s(!1,()=>e)),()=>{e=!0}},[s]),{status:t,releases:n,error:r,retry:(0,V.useCallback)(()=>{un(`changelog.retry`,s(!0,()=>!1))},[s])}}function fa({state:e}){let{socket:t}=e,n=da((0,V.useCallback)(()=>t.command({type:`settings.getChangelog`}),[t]));return(0,H.jsx)(sa,{status:n.status,releases:n.releases,error:n.error,onRetry:n.retry,updateSnapshot:e.updateSnapshot,currentVersion:Je,onInstallUpdate:t=>e.handleInstallUpdate(t),onCheckForUpdates:()=>e.handleCheckForUpdates({force:!0}),onForceReload:()=>e.handleForceReload()})}var G=L()(e=>({drafts:{scrollback:``,minColumnWidth:``,tabMinWidth:``,uploadMaxFileSize:``,editorCommand:``,cloudflaredPath:``,shareDefaultTtl:``},appSettingsError:null,tunnelError:null,analyticsDialogOpen:!1,patchDrafts:t=>e(e=>({drafts:{...e.drafts,...t}})),setAppSettingsError:t=>e({appSettingsError:t}),setTunnelError:t=>e({tunnelError:t}),setAnalyticsDialogOpen:t=>e({analyticsDialogOpen:t})}));function pa(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function ma(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}var ha=$e.map(e=>({value:e,label:ma(e)})),ga=L()(e=>({chatSoundPreference:ct,chatSoundId:gt,setChatSoundPreference:t=>e({chatSoundPreference:_t(t)}),setChatSoundId:t=>e({chatSoundId:ht(t)})}));function _a(e){let t=G(e=>e.setAppSettingsError),{handleWriteAppSettings:n}=e,r=(0,V.useCallback)(e=>t(e.message),[t]);return{write:(0,V.useCallback)(e=>{n(e).catch(Ye(r))},[n,r]),writeAsync:(0,V.useCallback)(e=>n(e).catch(Ye(r)),[n,r])}}var va=[{value:`light`,label:`Light`,icon:Xr},{value:`dark`,label:`Dark`,icon:Br},{value:`system`,label:`System`,icon:Se}],ya=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],ba=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],xa=`settings.chatSoundPreference`,Sa=`settings.chatSoundId`;function Ca(e,t){return e!==t}function wa(e){return e?.status===`checking`?`Checking for updates…`:e?.status===`updating`?`Installing update…`:e?.status===`restart_pending`?`Restarting Kanna…`:e?.status===`available`?`Update available${e.latestVersion?`: ${e.latestVersion}`:``}`:e?.status===`up_to_date`?`Up to date`:e?.status===`error`?`Update check failed`:`Not checked yet`}function Ta({updateSnapshot:e}){return(0,H.jsx)(U,{title:`Application Update`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[wa(e),`.`]}),e?.lastCheckedAt?(0,H.jsxs)(`span`,{children:[` Last checked `,new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e.lastCheckedAt),`.`]}):null,e?.error?(0,H.jsxs)(`span`,{children:[` `,e.error]}):null]}),bordered:!1,children:(0,H.jsxs)(`div`,{className:`text-right text-sm text-foreground`,children:[(0,H.jsxs)(`div`,{children:[`Current: `,e?.currentVersion??Je]}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,e?.latestVersion??`Unknown`]})]})})}function Ea({state:e}){let{writeAsync:t}=_a(e),n=z(Gt),r=z(Bt),i=ga(e=>e.setChatSoundPreference),a=ga(e=>e.setChatSoundId),o=P(xa),s=P(Sa);function c(e){Ca(n,e)&&(i(e),N(xa,()=>t({chatSoundPreference:e})),un(`chat sound preview`,Un(r,1)))}function l(e){Ca(r,e)&&(a(e),N(Sa,()=>t({chatSoundId:e})),un(`chat sound preview`,Un(e,1)))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,H.jsxs)(pe,{disabled:o,value:n,onValueChange:e=>{kt(e)&&c(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ba.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]})}),(0,H.jsx)(U,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,H.jsxs)(pe,{disabled:s,value:r,onValueChange:e=>{nt(e)&&l(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ha.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]})})]})}function Da({state:e}){let{write:t}=_a(e),n=z(Lt),r=z(Tt),i=v(e=>e.setEditorPreset),a=v(e=>e.setEditorCommandTemplate),o=G(e=>e.drafts.editorCommand),s=G(e=>e.patchDrafts);(0,V.useEffect)(()=>{s({editorCommand:r})},[r,s]);function c(){a(o),t({editor:{commandTemplate:o}})}function l(e){i(e);let n=e===`custom`?r:dt(e);t({editor:{preset:e,commandTemplate:n}})}let u=o.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,H.jsxs)(pe,{value:n,onValueChange:e=>{Vt(e)&&l(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:Zn.map(e=>(0,H.jsx)(k,{value:e.value,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)($n,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.value))})})]})}),n===`custom`?(0,H.jsx)(`div`,{className:`border-t border-border`,children:(0,H.jsxs)(`div`,{className:`flex justify-between gap-8 py-5 pl-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Command Template`}),(0,H.jsxs)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:[`Include `,`{path}`,` and optionally `,`{line}`,` and `,`{column}`,` in your command.`]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 flex-col items-stretch gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:o,onChange:e=>s({editorCommand:e.target.value}),onBlur:c,onKeyDown:e=>pa(e,c),className:`font-mono`}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Preview: `,(0,H.jsx)(`span`,{className:`font-mono`,children:u})]})]})]})}):null]})}function Oa({state:e}){let{write:t}=_a(e),{theme:n,setTheme:r}=en(),i=o(e=>e.typographyOverride),a=o(e=>e.clearTypographyOverride),s=z(e=>e.settings?.typography.scale),c=Ct(i,s);function l(e){r(e),t({theme:e})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ta,{updateSnapshot:e.updateSnapshot}),(0,H.jsx)(U,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,H.jsx)(I,{value:n,onValueChange:l,options:va,size:`sm`})}),(0,H.jsx)(U,{title:`Typography Scale`,description:i?`This device uses its own text size instead of the account default.`:`Choose how large text and UI elements appear across the app.`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(pe,{value:c,onValueChange:e=>{Pt(e)&&t({typography:{scale:e}})},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ya.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]}),i?(0,H.jsx)(M,{type:`button`,variant:`link`,size:`sm`,onClick:a,children:`Use account default`}):null]})}),(0,H.jsx)(Ea,{state:e}),(0,H.jsx)(Da,{state:e})]})}var ka=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`project_deleted`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],Aa=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`],ja=L()(e=>({permissionState:`unsupported`,deviceId:null,error:null,contactSubjectDraft:``,detected:(t,n)=>e({permissionState:t,deviceId:n}),setPermissionState:t=>e({permissionState:t}),setDeviceId:t=>e({deviceId:t}),setError:t=>e({error:t}),setContactSubjectDraft:t=>e({contactSubjectDraft:t})})),Ma=`inline-flex items-center justify-center rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-muted`,Na=`inline-flex items-center justify-center rounded-lg bg-foreground px-3 py-1.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90`,Pa=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,Fa=`text-xs font-medium tracking-wide text-muted-foreground`,Ia=`gap-1.5 disabled:cursor-default disabled:opacity-60`,La=`push.enable`,Ra=`push.test`,za=`push.disable`,Ba=`push.contactSubject`;async function Va(e){try{await e(),ja.getState().setError(null)}catch(e){ja.getState().setError(Xe(e))}}function Ha(e,t){N(e,()=>Va(t))}function Ua(){let e=ja(e=>e.error);return e?(0,H.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive-text`,children:e}):null}function Wa({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=P(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ha(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:T(n,Ia),children:[a?(0,H.jsx)(A,{}):null,i]})}function Ga({localPath:e,muted:t,onMuteToggle:n}){let r=F(`push.setProjectMute`,e),i=P(r);return(0,H.jsxs)(`label`,{"aria-busy":i||void 0,className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:!t,disabled:i,onChange:t=>Ha(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,H.jsx)(sn,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,H.jsx)(A,{className:`text-muted-foreground`}):null]})}function Ka(e){let{permissionState:t}=e,n=P(Ba);if(t===`unsupported`)return(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Push notifications are not supported in this browser.`});if(t===`insecure-context`)return(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Push requires HTTPS. Run `,(0,H.jsx)(`code`,{className:Pa,children:`kanna --share`}),` or open Kanna over a tunnel, then enable on this device.`]});if(t===`denied`)return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You blocked notifications for this site. Re-enable them in your browser settings, then reload.`}),(0,H.jsx)(Ua,{})]});if(!(t===`granted`&&e.config.devices.some(t=>t.id===e.currentDeviceId)))return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start gap-2 md:w-[440px]`,children:[(0,H.jsx)(Wa,{pendingKey:La,onRun:e.onEnable,className:Na,children:`Enable on this device`}),(0,H.jsx)(Ua,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=ni(i),o=i!==e.contactSubject,s=()=>{a&&o&&Ha(Ba,()=>e.onContactSubjectSave(i))};return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 md:w-[440px]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-card/40 px-3 py-1 text-xs font-medium text-foreground`,children:[(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`,"aria-hidden":!0}),`Enabled on this device`]}),(0,H.jsx)(Wa,{pendingKey:Ra,onRun:e.onTest,className:Ma,children:`Send test`}),(0,H.jsx)(Wa,{pendingKey:za,onRun:e.onDisable,className:Ma,children:`Disable`})]}),(0,H.jsx)(Ua,{}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:T(Fa,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,H.jsx)(A,{}):null]}),(0,H.jsx)(R,{type:`text`,inputMode:`email`,spellCheck:!1,autoCapitalize:`none`,value:e.contactSubjectDraft,readOnly:n,"aria-busy":n||void 0,onChange:t=>e.onContactSubjectDraftChange(t.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:`mailto:you@example.com`,"aria-label":`Push contact subject`,"aria-invalid":i!==``&&!a,className:T(`font-mono`,i!==``&&!a&&`border-destructive`)}),i!==``&&!a?(0,H.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Must be a `,(0,H.jsx)(`code`,{className:Pa,children:`mailto:`}),` address or`,` `,(0,H.jsx)(`code`,{className:Pa,children:`https:`}),` URL with a routable domain (not localhost).`]}):(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Push services require a contact `,(0,H.jsx)(`code`,{className:Pa,children:`mailto:`}),` or`,` `,(0,H.jsx)(`code`,{className:Pa,children:`https:`}),` URL to sign notifications. Set your own so delivery isn’t rejected.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:Fa,children:`Devices`}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.config.devices.map(t=>(0,H.jsxs)(`li`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border bg-card/40 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.label}),(0,H.jsx)(`span`,{className:`line-clamp-2 break-all text-xs leading-snug text-muted-foreground`,children:t.userAgent})]}),!t.isCurrentDevice&&(0,H.jsx)(Wa,{pendingKey:F(`push.unsubscribe`,t.id),onRun:()=>e.onRemoveDevice(t.id),label:`Remove ${t.label}`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-background px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Remove`})]},t.id))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:Fa,children:`Per-project`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Ga,{localPath:t.localPath,muted:r.has(t.localPath),onMuteToggle:e.onMuteToggle})},t.localPath))})]}),(0,H.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Phone setup: this page must be reachable over HTTPS. Run`,` `,(0,H.jsx)(`code`,{className:Pa,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}function qa(e){return e.map(e=>({...e,disabled:!0}))}function Ja({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=P(e);return(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,H.jsx)(A,{className:`text-muted-foreground`}):null,(0,H.jsx)(I,{value:t,onValueChange:t=>N(e,()=>n(t)),options:a?qa(r):r,size:i})]})}function Ya(e){let{pushConfig:t,socket:n}=e,r=ja(e=>e.deviceId),i=ja(e=>e.setDeviceId),a=ja(e=>e.setPermissionState);return{handleEnablePush:(0,V.useCallback)(async()=>{if(t)try{let e=await y({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return f(t.id),{id:t.id}}});i(e)}finally{a(S().state)}},[t,n,i,a]),handleDisablePush:(0,V.useCallback)(async()=>{r&&(await te({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),d(),i(null))},[r,n,i])}}var Xa=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Za=`~/.kanna/data/settings.json`;function Qa({state:e,dom:t}){let n=z(e=>e.settings),r=ja(e=>e.permissionState),i=ja(e=>e.deviceId),a=ja(e=>e.contactSubjectDraft),o=ja(e=>e.setContactSubjectDraft),s=ja(e=>e.detected),c=ja(e=>e.setPermissionState),{handleEnablePush:l,handleDisablePush:u}=Ya(e),{pushConfig:d,socket:f}=e,p=n?.push.contactSubject;return(0,V.useLayoutEffect)(()=>{s(S().state,ee())},[s]),(0,V.useEffect)(()=>t.addWindowListener(`focus`,()=>c(S().state)),[t,c]),(0,V.useEffect)(()=>{p!==void 0&&o(p)},[p,o]),d?(0,H.jsx)(U,{title:`Push notifications`,description:`Get notified when a chat is waiting for you, finishes, or fails. Works on iPhone (after Add to Home Screen), Android, and desktop browsers.`,bordered:!1,alignStart:!0,children:(0,H.jsx)(Ka,{permissionState:r,config:d,projects:e.localProjects?.projects??[],currentDeviceId:i,contactSubject:p??``,contactSubjectDraft:a,onContactSubjectDraftChange:o,onContactSubjectSave:t=>e.handleWriteAppSettings({push:{contactSubject:t}}),onEnable:l,onDisable:u,onTest:async()=>{await f.command({type:`push.test`})},onMuteToggle:async(e,t)=>{await f.command({type:`push.setProjectMute`,localPath:e,muted:t})},onRemoveDevice:async e=>{await f.command({type:`push.unsubscribe`,pushDeviceId:e})}})}):null}function $a({state:e}){let t=z(e=>e.settings),n=G(e=>e.setAppSettingsError),r=G(e=>e.setAnalyticsDialogOpen),i=t?.analyticsEnabled===!1?`disabled`:`enabled`,a=t?.telemetry?.enabled===!1?`disabled`:`enabled`;async function o(t){await B(n,()=>e.handleWriteAppSettings(t))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Anonymous Analytics`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Help improve Kanna with anonymous product analytics. Kanna sends tracked event names plus a small set of event properties like current version, environment, update version info, and launch flags. No message content, prompts, file paths, or provider credentials are sent.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??Za,`.`,` `,(0,H.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`underline underline-offset-2 text-foreground hover:text-foreground/80`,children:`View tracked events`})]}),t?.warning?(0,H.jsx)(`span`,{className:`mt-1 block`,children:t.warning}):null]}),children:(0,H.jsx)(Ja,{pendingKey:`settings.analytics`,value:i,onValueChange:e=>o({analyticsEnabled:e===`enabled`}),options:Xa,size:`sm`})}),(0,H.jsx)(U,{title:`Telemetry Tracing`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Export OpenTelemetry traces and metrics (turn timings, subagent runs, process memory) to Kanna's observability collector so each install can be monitored. This machine reports under its computer name. Turning it off stops the export immediately.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Collector: `,t?.telemetry?.endpoint??`not configured`,`. Stored in `,t?.filePathDisplay??Za,`.`]})]}),children:(0,H.jsx)(Ja,{pendingKey:`settings.telemetry`,value:a,onValueChange:e=>o({telemetry:{enabled:e===`enabled`}}),options:Xa,size:`sm`})})]})}function eo(){let e=G(e=>e.analyticsDialogOpen),t=G(e=>e.setAnalyticsDialogOpen);return(0,H.jsx)(Re,{open:e,onOpenChange:t,children:(0,H.jsxs)(Le,{size:`lg`,children:[(0,H.jsxs)(Be,{className:`space-y-4`,children:[(0,H.jsx)(He,{children:`Tracked Events`}),(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Kanna sends these event names plus the limited property keys below, depending on the event type.`}),(0,H.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/40 p-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Event Names`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:ka.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))}),(0,H.jsx)(`div`,{className:`mt-6 text-xs font-medium tracking-wide text-muted-foreground`,children:`Property Keys`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:Aa.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,H.jsx)(ze,{children:(0,H.jsx)(M,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function to({state:e,dom:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qa,{state:e,dom:t}),(0,H.jsx)($a,{state:e}),(0,H.jsx)(eo,{})]})}var no=[{value:`accept`,label:`Accept`},{value:`refuse`,label:`Refuse`}];function ro({state:e}){let{writeAsync:t}=_a(e),n=z(e=>e.settings?.peerMessagesInbound??`accept`);return(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(U,{title:`Messages from other chats`,description:`Let agents in other chats, in any project, send messages to agents in your chats. Each chat can override this from its sidebar menu.`,bordered:!1,children:(0,H.jsx)(Ja,{pendingKey:`settings.peerMessagesInbound`,value:n,onValueChange:async e=>{await t({peerMessagesInbound:e})},options:no,size:`sm`})})})}var io={path:`shareDefaultTtlHours`,min:1,max:1/0,integer:!0},ao=6e5,oo={path:`subagentRuntime.runTimeoutMs`,min:3e4,max:864e5,integer:!0},so={path:`claudeDriver.lifecycle.idleTimeoutMs`,min:ut,max:st,integer:!1},co={path:`claudeDriver.lifecycle.maxConcurrent`,min:1,max:16,integer:!1};function lo(e,t,n){let r=Number(e);if(!Ot(n,r))return{kind:`invalid`};let i=Math.round(r);return i===t?{kind:`unchanged`}:{kind:`write`,value:i}}function uo({title:e,description:t,min:n,max:r,step:i,value:a,onValueChange:o,onCommit:s,hint:c,unit:l,ariaLabel:u,bordered:d}){let f=(0,H.jsx)(R,{type:`number`,min:n,max:r,step:i,value:a,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>pa(e,s),className:T(`hide-number-steppers w-full text-left font-mono`,l?`tabular-nums md:w-24 md:text-right`:`md:w-28 md:text-right`),"aria-label":u});return(0,H.jsx)(U,{title:e,description:t,bordered:d,children:(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[l?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[f,(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:l})]}):f,(0,H.jsx)(`div`,{className:T(`text-left text-xs text-muted-foreground md:text-right`,l&&`tabular-nums`),children:c})]})})}function fo({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.shareDefaultTtlHours??24),r=G(e=>e.drafts.shareDefaultTtl),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({shareDefaultTtl:String(n)})},[n,i]);function o(){let e=lo(r,n,io);e.kind===`write`?t({shareDefaultTtlHours:e.value}):(i({shareDefaultTtl:String(n)}),e.kind===`invalid`&&a(`Default share link expiry must be a whole number of hours >= 1.`))}return(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(uo,{title:`Public share links`,description:`Default expiry for read-only chat share links. Owners can revoke any link manually at any time.`,min:io.min,step:1,value:r,onValueChange:e=>i({shareDefaultTtl:e}),onCommit:o,unit:`hours`,ariaLabel:`Default share link expiry in hours`,hint:`Minimum 1 hour · default 24`,bordered:!1})})}function po({checked:e,onChange:t}){return(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),`Enabled`]})}function mo(e,t){let n=G(t=>t.drafts[e]),r=G(e=>e.patchDrafts);return(0,V.useEffect)(()=>{r({[e]:String(t)})},[e,t,r]),{draft:n,setDraft:t=>r({[e]:t}),parsed:()=>{let e=Number(n);return Number.isFinite(e)?e:null},reset:()=>r({[e]:String(t)})}}function ho({state:e}){let{write:t}=_a(e),n=z(Mt),r=v(e=>e.setScrollbackLines),i=mo(`scrollback`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{scrollbackLines:e}}))}return(0,H.jsx)(uo,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,min:500,max:wt,step:100,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[500,`-`,wt,` lines`,n===1e3?` (default)`:``]})})}function go({state:e}){let{write:t}=_a(e),n=z(At),r=v(e=>e.setMinColumnWidth),i=mo(`minColumnWidth`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{minColumnWidth:e}}))}return(0,H.jsx)(uo,{title:`Terminal Min Column Width`,description:`Minimum width for each terminal pane`,min:250,max:900,step:10,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[250,`-`,900,` px`,n===450?` (default)`:``]})})}function _o({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.panes.tabMinWidth??60),r=mo(`tabMinWidth`,n);function i(){let e=r.parsed();e===null?r.reset():t({panes:{tabMinWidth:Qn(e)}})}return(0,H.jsx)(uo,{title:`Tab Minimum Width`,description:`How narrow a pane tab may get before the strip scrolls instead of shrinking`,min:60,max:200,step:10,value:r.draft,onValueChange:r.setDraft,onCommit:i,hint:(0,H.jsxs)(H.Fragment,{children:[60,`-`,200,` px`,n===60?` (default)`:``]})})}function vo({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.uploads.maxFileSizeMb??ri.maxFileSizeMb),r=G(e=>e.drafts.uploadMaxFileSize),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({uploadMaxFileSize:String(n)})},[n,i]);function o(){let e=lo(r,n,ii);e.kind===`write`?t({uploads:{maxFileSizeMb:e.value}}):(i({uploadMaxFileSize:String(n)}),e.kind===`invalid`&&a(`Max file size must be between ${ii.min} and ${ii.max} MB.`))}return(0,H.jsx)(uo,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,min:ii.min,max:ii.max,step:1,value:r,onValueChange:e=>i({uploadMaxFileSize:e}),onCommit:o,unit:`MB`,ariaLabel:`Max upload file size in megabytes`,hint:`${ii.min}–${ii.max} MB · default ${ri.maxFileSizeMb}`})}function yo({state:e}){let t=o(e=>e.autoResumeOnRateLimit),n=o(e=>e.setAutoResumeOnRateLimit);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ho,{state:e}),(0,H.jsx)(go,{state:e}),(0,H.jsx)(_o,{state:e}),(0,H.jsx)(vo,{state:e}),(0,H.jsx)(U,{title:`Auto-resume on rate limit`,description:`When you hit a rate limit, automatically schedule "continue" at the reset time instead of asking. You can still cancel each one from the chat.`,children:(0,H.jsx)(po,{checked:t,onChange:n})})]})}var bo=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],xo=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],So=`appSettings.setCloudflareTunnel`,Co=F(So,`cloudflaredPath`);function wo({state:e}){let t=z(e=>e.settings),n=G(e=>e.tunnelError),r=G(e=>e.setTunnelError),i=G(e=>e.drafts.cloudflaredPath),a=G(e=>e.patchDrafts),o=P(Co),s=t?.cloudflareTunnel??ti,c=s.enabled?`enabled`:`disabled`,l=t?.cloudflareTunnel.cloudflaredPath;(0,V.useEffect)(()=>{l!==void 0&&a({cloudflaredPath:l})},[l,a]);async function u(t){await B(r,()=>e.handleWriteCloudflareTunnel(t))}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsx)(U,{title:`Cloudflare Tunnel`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[`When enabled, Claude can call the `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`expose_port`}),` tool to expose a local port via Cloudflare Tunnel. The mode below controls whether each call requires your approval or is exposed automatically. Requires`,` `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`cloudflared`}),` `,`to be installed.`]}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),bordered:!1,children:(0,H.jsx)(Ja,{pendingKey:F(So,`enabled`),value:c,onValueChange:e=>u({enabled:e===`enabled`}),options:bo,size:`sm`})}),s.enabled&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Tool mode`,description:`Always ask: each expose_port call shows an accept card. Auto-expose: expose_port calls spawn cloudflared immediately without prompting.`,children:(0,H.jsx)(Ja,{pendingKey:F(So,`mode`),value:s.mode,onValueChange:e=>u({mode:e}),options:xo,size:`sm`})}),(0,H.jsx)(U,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,H.jsx)(R,{value:i,onChange:e=>a({cloudflaredPath:e.target.value}),onBlur:()=>N(Co,()=>u({cloudflaredPath:i})),readOnly:o,"aria-busy":o||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]})}function To({state:e,dom:t=jn}){let n=G(e=>e.appSettingsError);return(0,H.jsxs)(H.Fragment,{children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(Oa,{state:e}),(0,H.jsx)(yo,{state:e}),(0,H.jsx)(to,{state:e,dom:t})]}),(0,H.jsx)(wo,{state:e}),(0,H.jsx)(fo,{state:e}),(0,H.jsx)(ro,{state:e})]})}var Eo=L()(e=>({draft:``,persistedAtMount:``,error:null,setDraft:t=>e({draft:t}),persistedChanged:t=>e({persistedAtMount:t,draft:t}),setError:t=>e({error:t})})),Do=`settings.globalInstructions`;function Oo({state:e}){let t=z(e=>e.settings?.globalPromptAppend??``),n=Eo(e=>e.draft),r=Eo(e=>e.setDraft),i=Eo(e=>e.persistedAtMount),a=Eo(e=>e.persistedChanged),o=P(Do),s=Eo(e=>e.error),c=Eo(e=>e.setError);(0,V.useEffect)(()=>{t!==i&&a(t)},[t,i,a]);let l=n.replace(/\s+$/u,``),u=l.length>yt,d=l!==t,f=o||u||!d,p=(0,V.useCallback)(async()=>{f||await B(c,()=>e.handleWriteAppSettings({globalPromptAppend:l}))},[f,e,l,c]),m;return m=o?`Saving…`:d?`Save`:`Saved`,(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(U,{title:`Global Instructions`,description:`Appended to every Claude and Codex turn — including subagent turns — as “Workspace instructions”. Kanna does not read CLAUDE.md or AGENTS.md from disk; paste your global instructions here. For rules that apply to one project only, use “Edit instructions” in that project's sidebar menu. Leave blank to disable.`,bordered:!1,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,H.jsx)(`textarea`,{value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Always write tests before implementation. Prefer Tailwind classes over inline styles.`,rows:8,"aria-label":`Global instructions`,className:T(`min-h-[160px] w-full resize-y rounded-md border bg-background px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,u?`border-destructive`:`border-input`),disabled:o}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsxs)(`span`,{className:u?`text-destructive`:`text-muted-foreground`,children:[l.length,` / `,yt,` characters`,u?` — over limit`:``]}),(0,H.jsx)(M,{type:`button`,size:`sm`,onClick:()=>N(Do,p),disabled:f,pending:o,children:m})]}),s?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]})})})}function ko(e){return{async onReload(t){await ln(e,{type:`plugins.reload`,pluginId:t})}}}function Ao({plugins:e,handlers:t}){return e.length===0?(0,H.jsx)(oi,{icon:zn,message:`No plugins installed yet.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plugins`}),(0,H.jsx)(si,{children:e.map(e=>(0,H.jsx)(jo,{plugin:e,onReload:t.onReload},e.id))})]})}function jo({plugin:e,onReload:t}){let n=F(`plugins.reload`,e.id),r=P(n),i=(0,V.useCallback)(()=>{N(n,()=>t(e.id))},[t,e.id,n]);return(0,H.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.id}),(0,H.jsx)(rn,{tone:e.enabled?`active`:`muted`,label:e.enabled?`Enabled`:`Disabled`})]}),(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.sourceDir})]}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}function Mo(){let e=z(Ut),t=z(Jt),n=on(),r=(0,V.useMemo)(()=>ko(n),[n]);return e?(0,H.jsx)(Ao,{plugins:t,handlers:r}):null}var No={},Po=L()(e=>({drafts:No,error:null,setDrafts:t=>e({drafts:t}),setDraft:(t,n)=>e(e=>e.drafts[t]===n?e:{drafts:{...e.drafts,[t]:n}}),setError:t=>e({error:t})}));function Fo(e){let t={};for(let n of vt)t[n]=Nn(e[n]??``);return{...lt,...t}}function Io(e){return F(`settings.writeKeybindings`,e)}function Lo({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=Io(e),s=P(o),c=Pn(lt[e]),l=t!==c,u=()=>{N(o,i)};return(0,H.jsx)(U,{title:Fn[e],description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Comma-separated shortcuts.`}),l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:` `}),(0,H.jsxs)(`button`,{type:`button`,disabled:s,"aria-busy":s||void 0,onClick:()=>{N(o,()=>a(e))},className:`inline rounded text-foreground hover:text-foreground/80 disabled:opacity-60`,children:[`Restore: `,c]})]}):null]}),bordered:n,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 items-center gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:t,"aria-busy":s||void 0,onChange:t=>r(e,t.target.value),onBlur:u,onKeyDown:e=>pa(e,u),className:`font-mono`}),s?(0,H.jsx)(A,{}):null]})})}function Ro({state:e}){let t=Po(e=>e.drafts),n=Po(e=>e.setDrafts),r=Po(e=>e.setDraft),i=Po(e=>e.error),a=Po(e=>e.setError),o=(0,V.useMemo)(()=>Mn(e.keybindings),[e.keybindings]);(0,V.useEffect)(()=>{n(Object.fromEntries(vt.map(e=>[e,Pn(o.bindings[e])])))},[o,n]);async function s(t){await B(a,async()=>{await e.socket.command({type:`settings.writeKeybindings`,bindings:Fo(t)})})}async function c(){await s(t)}async function l(e){let r={...t,[e]:Pn(lt[e])};n(r),await s(r)}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[i?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:i}):null,o.warning?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:o.warning}):null,vt.map((e,n)=>(0,H.jsx)(Lo,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:c,onRestoreDefault:l},e))]})}function zo(e){return e===null?{name:``,transport:`stdio`,command:``,argsText:``,envText:``,cwd:``,url:``,headersText:``}:e.transport===`stdio`?{name:e.name,transport:`stdio`,command:e.command,argsText:e.args.join(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{Ct as a,E as o,M as s,T as c,Y as l,_ as u,a as d,c as f,d as p,g as m,gt as h,h as g,j as _,k as v,l as y,m as b,n as x,o as S,s as ee,u as te,wt as ne,xt as C}from"./useAppGlobalState-Cs47JwWq.js";import{i as w,t as T}from"./utils-gw0dpHSZ.js";import{a as re,l as ie,n as E,o as ae}from"./beacon-alias-CcevdUfB.js";import{a as D,i as oe,n as se,o as ce,t as le}from"./copyFeedbackStore-B4X215_R.js";import{a as O,i as k,n as ue,o as de,r as fe,t as pe}from"./select-DNgFvwVk.js";import{t as me}from"./info-DRKK3Ev3.js";import{c as he,r as ge,s as _e}from"./contextWindow-BVVtk5Al.js";import{a as ve,d as A,f as j,i as ye,l as M,n as N,o as be,r as P,t as F,u as xe}from"./pendingActionsStore-Bw87-8u6.js";import{t as Se}from"./monitor-B1cxkbAV.js";import{t as Ce}from"./pencil-BnnPP0sI.js";import{t as we}from"./plus-k8ypzgh4.js";import{t as Te}from"./refresh-cw-BnSFXoQI.js";import{t as Ee}from"./search-DaMiMFjO.js";import{S as De,a as Oe,c as ke,i as Ae,o as je,r as Me,s as Ne,t as Pe}from"./useProviderCatalog-DJqnDuQQ.js";import{t as Fe}from"./triangle-alert-BlEPrBcS.js";import{g as Ie,i as Le,n as Re,o as ze,r as Be,t as Ve,u as He}from"./timer.adapter-t-ql2eaa.js";import{a as Ue,c as We,o as Ge,s as Ke,t as I}from"./segmented-control-CthWIFFX.js";import{n as L}from"./log-8K5PdGJC.js";import{t as R}from"./input-Bkp2JE9C.js";import{n as qe,o as Je,r as Ye,t as Xe,u as Ze}from"./errors-ewkwYZz5.js";import{f as Qe,i as $e,o as et,u as tt}from"./core-types-BWpRMPSe.js";import{$ as nt,A as rt,C as it,D as at,E as ot,G as st,H as ct,J as lt,K as ut,L as dt,M as ft,N as pt,O as mt,U as ht,V as gt,W as _t,X as vt,Y as yt,Z as bt,_ as xt,a as St,at as Ct,b as wt,c as Tt,ct as Et,d as Dt,dt as Ot,et as kt,f as At,g as jt,h as Mt,i as Nt,it as Pt,j as Ft,k as It,l as Lt,lt as Rt,m as zt,n as Bt,nt as Vt,o as Ht,p as Ut,q as Wt,r as Gt,rt as Kt,s as qt,u as Jt,v as z,w as Yt}from"./tool-call-types-CoEzmgyY.js";import{M as Xt,N as Zt,iu as Qt,j as $t,r as en,ru as tn}from"./useTheme-Cb3XmN93.js";import{a as nn,n as rn}from"./state-mark-p6veyUZZ.js";import{f as B,n as an,o as on,r as sn,t as cn,u as ln}from"./textarea-DCKnXsZI.js";import{t as un}from"./runDetached-Dt8QjzWN.js";import{C as dn,S as fn,T as pn,a as mn,b as hn,d as gn,g as _n,h as vn,i as yn,l as bn,m as xn,n as Sn,o as Cn,p as wn,r as Tn,s as En,t as Dn,v as On,x as kn,y as An}from"./types-tbL38EdO.js";import{t as jn}from"./dom.adapter-C26vNdMA.js";import{d as Mn,f as Nn,l as Pn,t as Fn}from"./keybindings-CqgNeQvJ.js";import{n as In,t as Ln}from"./formatDuration-BbWTR_M_.js";import{En as Rn,On as zn,Sn as Bn,_t as Vn,it as Hn,rn as Un,vt as Wn,yt as Gn}from"./index-Bk7A56Tb.js";import{S as Kn,T as qn,b as Jn,d as Yn,f as Xn,l as Zn,m as Qn,u as $n,x as er,y as tr}from"./ChatPage-BTvroV45.js";import{a as nr,c as rr,d as ir,f as ar,i as or,l as sr,o as cr,p as lr,s as ur,t as dr,u as fr}from"./searchable-select-C5ZlaFYL.js";import{f as pr,l as mr,t as hr,u as gr}from"./inboxAutonomy-B8WAm9lN.js";import{t as _r}from"./settings-header-button-F_g1XSLK.js";import{t as vr}from"./InboundHandlerFields-B-Oaf00T.js";var yr={name:`antenna`,size:24,node:[[`path`,{d:`M2 12 7 2`,key:`117k30`}],[`path`,{d:`m7 12 5-10`,key:`1tvx22`}],[`path`,{d:`m12 12 5-10`,key:`ev1o1a`}],[`path`,{d:`m17 12 5-10`,key:`1e4ti3`}],[`path`,{d:`M4.5 7h15`,key:`vlsxkz`}],[`path`,{d:`M12 16v6`,key:`c8a4gj`}]]};yr.node;var br=w(yr),xr={name:`book-text`,size:24,node:[[`path`,{d:`M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20`,key:`k3hazp`}],[`path`,{d:`M8 11h8`,key:`vwpz6n`}],[`path`,{d:`M8 7h6`,key:`1f0q6e`}]]};xr.node;var Sr=w(xr),Cr={name:`circle-alert`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]],aliases:[`alert-circle`]};Cr.node;var wr=w(Cr),Tr={name:`circle-arrow-up`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]],aliases:[`arrow-up-circle`]};Tr.node;var Er=w(Tr),Dr={name:`cloud-download`,size:24,node:[[`path`,{d:`M12 13v8l-4-4`,key:`1f5nwf`}],[`path`,{d:`m12 21 4-4`,key:`1lfcce`}],[`path`,{d:`M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284`,key:`ui1hmy`}]],aliases:[`download-cloud`]};Dr.node;var Or=w(Dr),kr={name:`command`,size:24,node:[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]};kr.node;var Ar=w(kr),jr={name:`cpu`,size:24,node:[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]};jr.node;var Mr=w(jr),Nr={name:`flask-conical`,size:24,node:[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]};Nr.node;var Pr=w(Nr),Fr={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};Fr.node;var Ir=w(Fr),Lr={name:`message-square-quote`,size:24,node:[[`path`,{d:`M14 14a2 2 0 0 0 2-2V8h-2`,key:`1r06pg`}],[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M8 14a2 2 0 0 0 2-2V8H8`,key:`1jzu5j`}]]};Lr.node;var Rr=w(Lr),zr={name:`moon`,size:24,node:[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]};zr.node;var Br=w(zr),Vr={name:`network`,size:24,node:[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]};Vr.node;var Hr=w(Vr),Ur={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};Ur.node;var Wr=w(Ur),Gr={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};Gr.node;var Kr=w(Gr),qr={name:`power`,size:24,node:[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]};qr.node;var Jr=w(qr),Yr={name:`sun`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]};Yr.node;var Xr=w(Yr),Zr={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Zr.node;var Qr=w(Zr),$r={name:`waypoints`,size:24,node:[[`path`,{d:`m10.586 5.414-5.172 5.172`,key:`4mc350`}],[`path`,{d:`m18.586 13.414-5.172 5.172`,key:`8c96vv`}],[`path`,{d:`M6 12h12`,key:`8npq4p`}],[`circle`,{cx:`12`,cy:`20`,r:`2`,key:`144qzu`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}],[`circle`,{cx:`20`,cy:`12`,r:`2`,key:`1xzzfp`}],[`circle`,{cx:`4`,cy:`12`,r:`2`,key:`1hvhnz`}]]};$r.node;var ei=w($r),ti={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},V=e(t(),1),H=e(i(),1);function ni(e){let t=e.trim();if(t.startsWith(`https://`))try{let e=new URL(t);if(e.protocol!==`https:`)return!1;let n=e.hostname.toLowerCase();return!(n===`localhost`||!n.includes(`.`)||n.startsWith(`.`)||n.endsWith(`.`))}catch{return!1}if(t.startsWith(`mailto:`)){let e=t.slice(7),n=/^[^\s@]+@([^\s@]+)$/.exec(e);if(!n)return!1;let r=n[1].toLowerCase();return!(r===`localhost`||!r.includes(`.`)||r.startsWith(`.`)||r.endsWith(`.`))}return!1}var ri={maxFileSizeMb:2048},ii={path:`uploads.maxFileSizeMb`,min:1,max:51200,integer:!1},ai=L()(e=>({authEnabled:!1,setAuthEnabled:t=>e({authEnabled:t})}));function U({title:e,description:t,children:n,bordered:r=!0,alignStart:i=!1}){return(0,H.jsx)(`div`,{className:r?`border-t border-border`:void 0,children:(0,H.jsxs)(`div`,{className:T(`flex flex-col gap-4 py-5 md:flex-row md:justify-between md:gap-8`,i?`md:items-start`:`md:items-center`),children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:t})]}),(0,H.jsx)(`div`,{className:`flex items-center justify-start md:shrink-0 md:justify-end`,children:n})]})})}function oi({icon:e,message:t}){return(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-md border border-dashed px-6 py-10 text-center`,children:[(0,H.jsx)(e,{className:`mb-3 h-8 w-8 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t})]})}function si({children:e}){return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function ci({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,H.jsx)(Ce,{className:`h-4 w-4`})}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,H.jsx)(De,{className:`h-4 w-4`})})]})}var li=new Set([`checking`,`downloading`,`installing`,`restarting`]);function ui(e){return e!==null&&li.has(e.state)}function di(e){switch(e.state){case`checking`:return`Checking ${e.version}…`;case`downloading`:return`Downloading ${e.version}…`;case`installing`:return`Installing ${e.version}…`;case`restarting`:return`Restarting…`;case`current`:return`Up to date`;case`failed`:return e.message===void 0?`Update failed`:`Update failed: ${e.message}`}}function fi(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var pi={},mi={},hi={},gi={};function _i(e,t){return`${e}:${t}`}function vi(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));return Object.keys(r).length>0?r:n}var W=L()(e=>({pairing:null,expandedId:null,drafts:pi,updateErrors:mi,aliasErrors:hi,openExplanations:gi,setPairing:t=>e({pairing:t}),toggleExpanded:t=>e(e=>({expandedId:e.expandedId===t?null:t})),setDraft:(t,n)=>e(e=>({drafts:{...e.drafts,[t]:n}})),clearDraft:t=>e(e=>({drafts:vi(e.drafts,t,pi)})),setUpdateError:(t,n)=>e(e=>n===null?{updateErrors:vi(e.updateErrors,t,mi)}:{updateErrors:{...e.updateErrors,[t]:n}}),beginAliasEdit:(t,n)=>e(e=>({drafts:{...e.drafts,[_i(t,`alias`)]:n}})),endAliasEdit:t=>e(e=>({drafts:vi(e.drafts,_i(t,`alias`),pi),aliasErrors:vi(e.aliasErrors,t,hi)})),setAliasError:(t,n)=>e(e=>n===null?{aliasErrors:vi(e.aliasErrors,t,hi)}:{aliasErrors:{...e.aliasErrors,[t]:n}}),toggleExplanation:t=>e(e=>({openExplanations:t in e.openExplanations?vi(e.openExplanations,t,gi):{...e.openExplanations,[t]:!0}}))})),yi=`kanna-beacon`,bi=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,xi=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${bi}]{8}$`);function Si(e){return`${yi}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function Ci(e){return`kanna-beacon pair ${e.kannaUrl} ${e.code}`}function wi(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function Ti(e,t){if(e===t)return!1;let n=wi(e),r=wi(t),i=Math.max(n.length,r.length);for(let a=0;a<i;a+=1){let i=n[a]??0,o=r[a]??0;if(Number.isNaN(i)||Number.isNaN(o))return e<t;if(i!==o)return i<o}return!1}var Ei={outdated:`border-warning/40 text-warning-text bg-warning/10`,partial:`border-warning/40 text-warning-text bg-warning/10`,unknown:`border-border text-muted-foreground bg-muted/40`};function Di({beaconId:e,alias:t,displayName:n}){let r=W(e=>e.beginAliasEdit),i=(0,V.useCallback)(()=>{r(e,t??``)},[t,e,r]);return(0,H.jsx)(an,{label:`Set a short name`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`Set a short name for ${n}`,children:(0,H.jsx)(Ce,{className:`h-3.5 w-3.5`})})})}function Oi({beaconId:e,alias:t,displayName:n,onSetAlias:r}){let i=_i(e,`alias`),a=W(e=>e.drafts[i]),o=W(t=>t.aliasErrors[e]??null),s=W(e=>e.setDraft),c=W(e=>e.setAliasError),l=W(e=>e.endAliasEdit),u=F(`beacons.setAlias`,e),d=P(u),f=a??``,p=f.length===0?null:re(f),m=f.length>0&&p===null&&f!==t,h=p??o,g=(0,V.useCallback)(t=>{s(i,t.target.value.toLowerCase()),c(e,null)},[e,i,c,s]),_=(0,V.useCallback)(t=>{N(u,async()=>{try{await r(e,t),l(e)}catch(t){c(e,Xe(t))}})},[e,l,r,u,c]),v=(0,V.useCallback)(()=>{_(f)},[_,f]),y=(0,V.useCallback)(()=>{_(null)},[_]),b=(0,V.useCallback)(()=>{l(e)},[e,l]);return a===void 0?null:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(R,{value:f,onChange:g,placeholder:`office-mac`,disabled:d,"aria-label":`Short name for ${n}`,"aria-invalid":h!==null||void 0,className:`w-48`}),(0,H.jsx)(M,{size:`sm`,onClick:v,pending:d,disabled:!m,children:`Save`}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:b,disabled:d,children:`Cancel`}),t!==null&&(0,H.jsx)(M,{variant:`ghost`,size:`sm`,onClick:y,disabled:d,children:`Clear alias`})]}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Type `,(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,f.length>0?f:`name`]}),` in a message to refer to this machine.`]}),h!==null&&(0,H.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive-text`,children:h})]})}var ki=`Lets the agent run commands and scripts on this machine. Off means every command and script is refused, and the agent can only read and copy files inside the folders below. When on, each command still waits for your approval unless it is on the always-run list or you switch on running without asking.`,Ai=`Skips the approval prompt. Reads and writes inside the folders below, and every command and script, run immediately. Leave it off to review each action before it runs on this machine.`,ji=`The agent can list, search, read and copy files off this machine only inside these folders and their subfolders. Anything outside is refused. With none listed it cannot read from this machine at all. Each read waits for your approval unless running without asking is on.`,Mi=`The agent can copy files onto this machine only inside these folders and their subfolders. Leave empty and it cannot write to this machine at all. Each write waits for your approval unless running without asking is on.`,Ni=`Command names, such as git, that run immediately once running commands is allowed. Matching uses the command name only, so git covers every git subcommand. Anything not listed asks you first.`;function Pi(e){return`beacon-explain-${e}`}function Fi({explanationKey:e,subject:t}){let n=W(t=>e in t.openExplanations),r=W(e=>e.toggleExplanation),i=(0,V.useCallback)(()=>{r(e)},[e,r]);return(0,H.jsx)(an,{label:`What does this do?`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-expanded":n,"aria-controls":Pi(e),"aria-label":`What does "${t}" do?`,children:(0,H.jsx)(me,{className:`h-4 w-4`})})})}function Ii({explanationKey:e,text:t}){let n=W(t=>e in t.openExplanations);return(0,H.jsx)(`p`,{id:Pi(e),hidden:!n,className:`text-13 text-muted-foreground`,children:t})}function Li({beaconId:e,scope:t,onSetScope:n}){let r=F(`beacons.setScope`,e),i=P(r),a=(0,V.useCallback)(t=>{N(r,()=>n(e,t))},[e,n,r]),o=(0,V.useCallback)(e=>{a({...t,exec:e.target.checked})},[a,t]),s=(0,V.useCallback)(e=>{a({...t,autoRunScripts:e.target.checked})},[a,t]),c=(0,V.useCallback)(e=>{a({...t,readRoots:e})},[a,t]),l=(0,V.useCallback)(e=>{a({...t,writeRoots:e})},[a,t]),u=(0,V.useCallback)(e=>{a({...t,execAllowlist:e})},[a,t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border bg-muted/40 px-4 py-4`,"aria-busy":i||void 0,children:[(0,H.jsx)(Ri,{explanationKey:_i(e,`exec`),checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,explanation:ki}),(0,H.jsx)(Ri,{explanationKey:_i(e,`autoRunScripts`),checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,explanation:Ai}),(0,H.jsx)(zi,{label:`Folders the agent may read`,explanation:ji,placeholder:`/Users/me/projects`,draftKey:_i(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,H.jsx)(zi,{label:`Folders the agent may write to`,explanation:Mi,placeholder:`/Users/me/inbox`,draftKey:_i(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,H.jsx)(zi,{label:`Commands that always run without asking`,explanation:Ni,placeholder:`git`,draftKey:_i(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function Ri({explanationKey:e,checked:t,disabled:n,onChange:r,title:i,explanation:a}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`label`,{className:`flex min-w-0 cursor-pointer items-center gap-3`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:t,disabled:n,onChange:r}),(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:i})]}),(0,H.jsx)(Fi,{explanationKey:e,subject:i})]}),(0,H.jsx)(`div`,{className:`pl-7`,children:(0,H.jsx)(Ii,{explanationKey:e,text:a})})]})}function zi({label:e,explanation:t,placeholder:n,draftKey:r,items:i,disabled:a,onChange:o}){let s=W(e=>e.drafts[r]??``),c=W(e=>e.setDraft),l=W(e=>e.clearDraft),u=s.trim(),d=u.length>0&&!i.includes(u),f=(0,V.useCallback)(e=>{c(r,e.target.value)},[r,c]),p=(0,V.useCallback)(()=>{o([...i,u]),l(r)},[l,r,i,o,u]),m=(0,V.useCallback)(e=>{o(i.filter(t=>t!==e))},[i,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),(0,H.jsx)(Fi,{explanationKey:r,subject:e})]}),(0,H.jsx)(Ii,{explanationKey:r,text:t}),i.length===0?(0,H.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`None`}):(0,H.jsx)(`ul`,{className:`flex flex-col gap-1`,children:i.map(e=>(0,H.jsx)(Bi,{item:e,disabled:a,onRemove:m},e))}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{value:s,onChange:f,placeholder:n,disabled:a,"aria-label":e}),(0,H.jsx)(M,{variant:`secondary`,size:`sm`,onClick:p,disabled:a||!d,children:`Add`})]})]})}function Bi({item:e,disabled:t,onRemove:n}){let r=(0,V.useCallback)(()=>{n(e)},[e,n]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-13`,children:e}),(0,H.jsx)(M,{variant:`ghost`,size:`icon-sm`,onClick:r,disabled:t,"aria-label":`Remove ${e}`,children:(0,H.jsx)(Ie,{className:`h-4 w-4`})})]})}var Vi=F(`beacons.mintPairingCode`);function Hi(e,t){let n=new Map(e.map(e=>[e.id,e]));return t.map(e=>{let t=n.get(e.id);return{id:e.id,label:e.label,alias:e.alias??null,os:e.os,enabled:e.enabled,online:t?.online??!1,lastSeenAt:t?.lastSeenAt??null,beaconVersion:t?.beaconVersion??null,canSelfUpdate:t?.canSelfUpdate??!1,update:t?.update??null}})}function Ui({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=jn,clipboard:a=oe,timer:o=Ve}){let s=Hn(1e3),c=(0,V.useMemo)(()=>Hi(e,t),[e,t]),l=(0,V.useMemo)(()=>new Map(t.map(e=>[e.id,e])),[t]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(Wi,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,H.jsx)(oi,{icon:er,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,H.jsx)(si,{children:c.map(e=>(0,H.jsx)(Xi,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function Wi({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=W(e=>e.pairing),o=W(e=>e.setPairing),s=P(Vi),c=(0,V.useCallback)(()=>{N(Vi,async()=>{o(await t.onMint())})},[t,o]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-border bg-card p-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Beacons`}),(0,H.jsx)(`p`,{className:`mt-1 text-13 text-muted-foreground`,children:`A beacon is a small program on your own machine. Once paired, the agent can read files and run commands there, only within the scope you grant below.`})]}),(0,H.jsxs)(M,{size:`sm`,variant:a?.ok===!0?`secondary`:`default`,onClick:c,pending:s,children:[(0,H.jsx)(we,{className:`mr-1 h-4 w-4`}),`Pair a machine`]})]}),a?.ok===!1&&(0,H.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive-text`,children:a.error}),a?.ok===!0&&(0,H.jsx)(Gi,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function Gi({code:e,expiresAt:t,now:n,dom:r,clipboard:i,timer:a}){let o=t-n,s=r.getOrigin(),c=Ci({kannaUrl:s,code:e}),l=Si({kannaUrl:s,code:e}),u=F(`beacons.copyPairCommand`,e),d=P(u),f=se(u),p=(0,V.useCallback)(()=>{N(u,()=>le(u,()=>i.writeText(c),a))},[i,c,u,a]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,H.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums tracking-widest`,children:e}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:o>0?`Expires in ${In(o)}`:`Expired. Pair again for a new code.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,H.jsxs)(`a`,{href:l,className:xe({size:`sm`}),children:[(0,H.jsx)(Bn,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,H.jsx)(`a`,{href:xi,target:`_blank`,rel:`noreferrer`,className:`text-13 text-muted-foreground underline underline-offset-2 hover:text-foreground`,children:`Download Kanna Beacon`})]}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Or run this on the machine you want to pair:`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`code`,{className:`min-w-0 flex-1 break-all rounded-md border border-border bg-muted px-3 py-2 font-mono text-13`,children:c}),(0,H.jsx)(an,{label:f?`Copied`:`Copy command`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon`,onClick:p,pending:d,"aria-label":f?`Copied`:`Copy pairing command`,children:f?(0,H.jsx)(ce,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(D,{className:`h-4 w-4`})})})]})]})}function Ki(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${Ln(t-e.lastSeenAt)} ago`}var qi=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function Ji({canSelfUpdate:e}){let t=T(`rounded-full border px-2 py-0.5 text-xs`,Ei.outdated);return e?(0,H.jsx)(`span`,{className:t,children:`Update available`}):(0,H.jsx)(an,{label:qi,children:(0,H.jsx)(`a`,{href:xi,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function Yi({row:e,updateAvailable:t,handlers:n}){let r=F(`beacons.update`,e.id),i=P(r),a=W(t=>t.updateErrors[e.id]??null),o=W(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!ui(e.update),c=(0,V.useCallback)(()=>{N(r,async()=>{let t=await n.onUpdate(e.id);o(e.id,t.ok?null:t.error)})},[n,e.id,o,r]);return(0,H.jsxs)(H.Fragment,{children:[e.update!==null&&(0,H.jsx)(rn,{tone:fi(e.update),label:di(e.update)}),s&&(0,H.jsxs)(M,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${E(e)} now`,children:[(0,H.jsx)(Er,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function Xi({row:e,scope:t,now:n,serverVersion:r,handlers:i,dom:a}){let o=W(t=>t.expandedId===e.id),s=W(e=>e.toggleExpanded),c=F(`beacons.setEnabled`,e.id),l=P(c),u=F(`beacons.delete`,e.id),d=P(u),f=E(e),p=e.beaconVersion!==null&&r!==void 0&&Ti(e.beaconVersion,r),m=(0,V.useCallback)(t=>{let n=t.target.checked;N(c,()=>i.onSetEnabled(e.id,n))},[c,i,e.id]),h=(0,V.useCallback)(()=>{a.confirmDialog(`Revoke "${f}"? The agent will lose access to this machine until you pair it again.`)&&N(u,()=>i.onDelete(e.id))},[u,f,a,i,e.id]),g=(0,V.useCallback)(()=>{s(e.id)},[e.id,s]);return(0,H.jsxs)(`li`,{className:`flex flex-col`,"aria-busy":d||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium`,children:f}),(0,H.jsx)(Di,{beaconId:e.id,alias:e.alias,displayName:f})]}),e.alias!==null&&(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`font-mono`,children:e.label}),(0,H.jsxs)(`span`,{className:`font-mono`,children:[`@beacon/`,e.alias]})]}),(0,H.jsx)(Oi,{beaconId:e.id,alias:e.alias,displayName:f,onSetAlias:i.onSetAlias}),(0,H.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(rn,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:Ki(e,n)}),e.beaconVersion!==null&&(0,H.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),p&&(0,H.jsx)(Ji,{canSelfUpdate:e.canSelfUpdate}),(0,H.jsx)(Yi,{row:e,updateAvailable:p,handlers:i}),(0,H.jsx)(`span`,{children:e.os})]})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[l?(0,H.jsx)(A,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:l,"aria-busy":l||void 0,onChange:m,"aria-label":`Enable ${f}`}),(0,H.jsx)(`span`,{children:e.enabled?`Enabled`:`Disabled`})]}),t!==null&&(0,H.jsxs)(M,{variant:`ghost`,size:`sm`,onClick:g,"aria-expanded":o,children:[`Scope`,(0,H.jsx)(Rn,{className:T(`ml-1 h-4 w-4 transition-transform`,o&&`rotate-180`)})]}),(0,H.jsx)(an,{label:`Revoke this machine`,children:(0,H.jsx)(M,{variant:`ghost`,size:`icon`,onClick:h,pending:d,"aria-label":`Revoke ${f}`,children:(0,H.jsx)(De,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,H.jsx)(Li,{beaconId:e.id,scope:t,onSetScope:i.onSetScope})]})}function Zi(e){let t=s(_),n=z(Nt),{handleWriteAppSettings:r,handleMintBeaconPairingCode:i,handleUpdateBeacon:a}=e.state,o=(0,V.useMemo)(()=>({onMint:i,onSetEnabled:async(e,t)=>{await r({customBeacons:{setEnabled:{id:e,enabled:t}}})},onSetScope:async(e,t)=>{await r({customBeacons:{setScope:{id:e,scope:t}}})},onSetAlias:async(e,t)=>{await r({customBeacons:{update:{id:e,patch:{alias:t}}}})},onDelete:async e=>{await r({customBeacons:{delete:{id:e}}})},onUpdate:a}),[r,i,a]);return(0,H.jsx)(Ui,{rows:t,configs:n,handlers:o,serverVersion:Je})}var Qi=3e5,$i=null;function ea(e=Date.now){return $i?e()>=$i.expiresAt?($i=null,null):$i.releases:null}function ta(e,t=Date.now){$i={releases:e,expiresAt:t()+Qi}}async function na(e,t){let n=t?.now??Date.now,r=t?.force?null:ea(n);if(r)return r;let i=await e();return ta(i,n),i}function ra(e){return e.trim().replace(/^v/i,``)}function ia(e,t){let n=e=>ra(e).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10)).filter(e=>Number.isFinite(e)),r=n(e),i=n(t),a=Math.max(r.length,i.length);for(let e=0;e<a;e+=1){let t=r[e]??0,n=i[e]??0;if(t!==n)return t<n?-1:1}return 0}function aa(e,t,n){return ra(e)===ra(n)?{actionLabel:`Update`,pendingLabel:`Updating…`}:ia(e,t)<0?{actionLabel:`Rollback`,pendingLabel:`Rolling back…`}:{actionLabel:`Install`,pendingLabel:`Installing…`}}function oa(e){if(!e)return`Unpublished`;let t=new Date(e);return Number.isNaN(t.getTime())?`Unknown date`:new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,year:`numeric`}).format(t)}function sa({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:s,onForceReload:c}){let l=P(`update.check`),u=ve(`update.install`),d=P(`update.redeploy`),f=ye(e=>e.inFlight),p=u||d,m=i?.latestVersion??t[0]?.tag_name??`Unknown`,h=i?.currentVersion??a,g=i?.status===`checking`||l,_=i?.status===`updating`||i?.status===`restart_pending`,v=_||p,y=i?.updateAvailable===!0,b=ra(m),x=ra(h),S=(0,V.useCallback)(async e=>{await o(e)},[o]),ee=(0,V.useCallback)(async()=>{await c()},[c]),te=d||_;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[e===`loading`||e===`idle`?(0,H.jsx)(`div`,{className:`flex min-h-[180px] items-center justify-center rounded-2xl border border-border bg-card/40 px-6 py-8 text-sm text-muted-foreground`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(j,{className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading release notes…`})]})}):null,e===`error`?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-6 py-5`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Could not load changelog`}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:n??`Unable to load changelog.`})]}),(0,H.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted`,children:`Retry`})]})}):null,e===`success`&&t.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 px-6 py-8`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No releases yet`}),(0,H.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:`GitHub did not return any published releases for this repository.`})]}):null,e===`success`?(0,H.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,H.jsx)(_r,{variant:`outline`,onClick:()=>N(`update.redeploy`,ee),disabled:v,children:te?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,H.jsx)(_r,{variant:`outline`,onClick:()=>N(`update.check`,s),disabled:g||v,children:g?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(j,{className:`h-3.5 w-3.5 animate-spin`}),`Checking…`]}):`Check for updates`})]}):null,e===`success`&&t.length>0?t.map(e=>{let t=ra(e.tag_name),n=t===b,r=t===x;return(0,H.jsxs)(`article`,{className:T(`rounded-xl border bg-card/30 pl-6 pr-4 py-4`,n?`border-border bg-muted`:`border-border`),children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-3 `,children:[(0,H.jsxs)(`div`,{className:`flex flex-row items-center min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:e.name?.trim()||e.tag_name}),(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:oa(e.published_at)}),e.prerelease?(0,H.jsx)(`span`,{className:`rounded-full border border-border px-2.5 py-1 tracking-wide`,children:`Prerelease`}):null]})]}),(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-end min-w-0 flex-1 gap-2 `,children:[(0,H.jsx)(`a`,{href:e.html_url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`View release on GitHub`,className:T(xe({variant:`ghost`,size:`icon-sm`}),`h-11 w-11 md:h-8 md:w-8 shrink-0 rounded-md hover:!bg-transparent hover:border-border/0`),children:(0,H.jsx)(ca,{className:`h-4 w-4`})}),r?(0,H.jsx)(`span`,{className:T(`bg-transparent border border-border text-secondary-foreground`,`h-9 rounded-full px-3 text-sm`,`h-auto gap-1.5 px-3 py-1.5`),children:`Current`}):null,n&&y||!n&&!r?(()=>{let t=f[F(`update.install`,e.tag_name)]===!0||_&&!p,{actionLabel:n,pendingLabel:r}=aa(e.tag_name,h,m);return(0,H.jsx)(_r,{variant:`default`,className:``,onClick:()=>N(F(`update.install`,e.tag_name),()=>S(e.tag_name)),disabled:v,children:(0,H.jsxs)(`div`,{className:`flex flex-row items-center justify-center gap-2`,children:[t?(0,H.jsx)(j,{className:`size-4 animate-spin`}):(0,H.jsx)(Or,{className:`size-4`}),t?r:n]})})})():null]})]}),e.body?.trim()?(0,H.jsx)(`div`,{className:`prose prose-sm mt-5 max-w-none text-foreground dark:prose-invert`,children:ie(e.body)}):(0,H.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function ca({className:e}){return(0,H.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,className:e,children:(0,H.jsx)(`path`,{d:`M12 .5C5.649.5.5 5.649.5 12A11.5 11.5 0 0 0 8.36 22.04c.575.106.785-.25.785-.556 0-.274-.01-1-.015-1.962-3.181.691-3.853-1.532-3.853-1.532-.52-1.322-1.27-1.674-1.27-1.674-1.038-.71.08-.695.08-.695 1.148.08 1.752 1.178 1.752 1.178 1.02 1.748 2.676 1.243 3.328.95.103-.738.399-1.243.725-1.53-2.54-.289-5.211-1.27-5.211-5.65 0-1.248.446-2.27 1.177-3.07-.118-.288-.51-1.45.112-3.024 0 0 .96-.307 3.145 1.173A10.91 10.91 0 0 1 12 6.03c.973.004 1.954.132 2.87.387 2.182-1.48 3.14-1.173 3.14-1.173.625 1.573.233 2.736.115 3.024.734.8 1.175 1.822 1.175 3.07 0 4.39-2.676 5.358-5.224 5.642.41.353.776 1.05.776 2.117 0 1.528-.014 2.761-.014 3.136 0 .309.207.668.79.555A11.502 11.502 0 0 0 23.5 12C23.5 5.649 18.351.5 12 .5Z`})})}var la=[],ua=L()(e=>({status:`idle`,releases:la,error:null,loadStarted:()=>e({status:`loading`,error:null}),loaded:t=>e({releases:t,status:`success`}),loadFailed:t=>e({error:t,status:`error`})}));function da(e){let t=ua(e=>e.status),n=ua(e=>e.releases),r=ua(e=>e.error),i=ua(e=>e.loadStarted),a=ua(e=>e.loaded),o=ua(e=>e.loadFailed),s=(0,V.useCallback)(async(t,n)=>{i();try{let r=await na(e,{force:t});n()||a(r)}catch(e){n()||o(Xe(e))}},[e,i,a,o]);return(0,V.useEffect)(()=>{let e=!1;return un(`changelog.load`,s(!1,()=>e)),()=>{e=!0}},[s]),{status:t,releases:n,error:r,retry:(0,V.useCallback)(()=>{un(`changelog.retry`,s(!0,()=>!1))},[s])}}function fa({state:e}){let{socket:t}=e,n=da((0,V.useCallback)(()=>t.command({type:`settings.getChangelog`}),[t]));return(0,H.jsx)(sa,{status:n.status,releases:n.releases,error:n.error,onRetry:n.retry,updateSnapshot:e.updateSnapshot,currentVersion:Je,onInstallUpdate:t=>e.handleInstallUpdate(t),onCheckForUpdates:()=>e.handleCheckForUpdates({force:!0}),onForceReload:()=>e.handleForceReload()})}var G=L()(e=>({drafts:{scrollback:``,minColumnWidth:``,tabMinWidth:``,uploadMaxFileSize:``,editorCommand:``,cloudflaredPath:``,shareDefaultTtl:``},appSettingsError:null,tunnelError:null,analyticsDialogOpen:!1,patchDrafts:t=>e(e=>({drafts:{...e.drafts,...t}})),setAppSettingsError:t=>e({appSettingsError:t}),setTunnelError:t=>e({tunnelError:t}),setAnalyticsDialogOpen:t=>e({analyticsDialogOpen:t})}));function pa(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function ma(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}var ha=$e.map(e=>({value:e,label:ma(e)})),ga=L()(e=>({chatSoundPreference:ct,chatSoundId:gt,setChatSoundPreference:t=>e({chatSoundPreference:_t(t)}),setChatSoundId:t=>e({chatSoundId:ht(t)})}));function _a(e){let t=G(e=>e.setAppSettingsError),{handleWriteAppSettings:n}=e,r=(0,V.useCallback)(e=>t(e.message),[t]);return{write:(0,V.useCallback)(e=>{n(e).catch(Ye(r))},[n,r]),writeAsync:(0,V.useCallback)(e=>n(e).catch(Ye(r)),[n,r])}}var va=[{value:`light`,label:`Light`,icon:Xr},{value:`dark`,label:`Dark`,icon:Br},{value:`system`,label:`System`,icon:Se}],ya=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],ba=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],xa=`settings.chatSoundPreference`,Sa=`settings.chatSoundId`;function Ca(e,t){return e!==t}function wa(e){return e?.status===`checking`?`Checking for updates…`:e?.status===`updating`?`Installing update…`:e?.status===`restart_pending`?`Restarting Kanna…`:e?.status===`available`?`Update available${e.latestVersion?`: ${e.latestVersion}`:``}`:e?.status===`up_to_date`?`Up to date`:e?.status===`error`?`Update check failed`:`Not checked yet`}function Ta({updateSnapshot:e}){return(0,H.jsx)(U,{title:`Application Update`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[wa(e),`.`]}),e?.lastCheckedAt?(0,H.jsxs)(`span`,{children:[` Last checked `,new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}).format(e.lastCheckedAt),`.`]}):null,e?.error?(0,H.jsxs)(`span`,{children:[` `,e.error]}):null]}),bordered:!1,children:(0,H.jsxs)(`div`,{className:`text-right text-sm text-foreground`,children:[(0,H.jsxs)(`div`,{children:[`Current: `,e?.currentVersion??Je]}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,e?.latestVersion??`Unknown`]})]})})}function Ea({state:e}){let{writeAsync:t}=_a(e),n=z(Gt),r=z(Bt),i=ga(e=>e.setChatSoundPreference),a=ga(e=>e.setChatSoundId),o=P(xa),s=P(Sa);function c(e){Ca(n,e)&&(i(e),N(xa,()=>t({chatSoundPreference:e})),un(`chat sound preview`,Un(r,1)))}function l(e){Ca(r,e)&&(a(e),N(Sa,()=>t({chatSoundId:e})),un(`chat sound preview`,Un(e,1)))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Chat Sounds`,description:`Play a pop when a chat starts waiting on you or the unread chat count increases`,children:(0,H.jsxs)(pe,{disabled:o,value:n,onValueChange:e=>{kt(e)&&c(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ba.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]})}),(0,H.jsx)(U,{title:`Chat Sound`,description:`The bundled sound used for chat notification playback and previews`,children:(0,H.jsxs)(pe,{disabled:s,value:r,onValueChange:e=>{nt(e)&&l(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ha.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]})})]})}function Da({state:e}){let{write:t}=_a(e),n=z(Lt),r=z(Tt),i=v(e=>e.setEditorPreset),a=v(e=>e.setEditorCommandTemplate),o=G(e=>e.drafts.editorCommand),s=G(e=>e.patchDrafts);(0,V.useEffect)(()=>{s({editorCommand:r})},[r,s]);function c(){a(o),t({editor:{commandTemplate:o}})}function l(e){i(e);let n=e===`custom`?r:dt(e);t({editor:{preset:e,commandTemplate:n}})}let u=o.replaceAll(`{path}`,`/Users/jake/Projects/kanna/src/client/app/App.tsx`).replaceAll(`{line}`,`12`).replaceAll(`{column}`,`1`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Default Editor`,description:`Used when opening transcript links or files from the git diff menu`,alignStart:!0,children:(0,H.jsxs)(pe,{value:n,onValueChange:e=>{Vt(e)&&l(e)},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:Zn.map(e=>(0,H.jsx)(k,{value:e.value,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)($n,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`truncate`,children:e.label})]})},e.value))})})]})}),n===`custom`?(0,H.jsx)(`div`,{className:`border-t border-border`,children:(0,H.jsxs)(`div`,{className:`flex justify-between gap-8 py-5 pl-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 max-w-xl`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Command Template`}),(0,H.jsxs)(`div`,{className:`mt-1 text-13 text-muted-foreground`,children:[`Include `,`{path}`,` and optionally `,`{line}`,` and `,`{column}`,` in your command.`]})]}),(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 flex-col items-stretch gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:o,onChange:e=>s({editorCommand:e.target.value}),onBlur:c,onKeyDown:e=>pa(e,c),className:`font-mono`}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Preview: `,(0,H.jsx)(`span`,{className:`font-mono`,children:u})]})]})]})}):null]})}function Oa({state:e}){let{write:t}=_a(e),{theme:n,setTheme:r}=en(),i=o(e=>e.typographyOverride),a=o(e=>e.clearTypographyOverride),s=z(e=>e.settings?.typography.scale),c=Ct(i,s);function l(e){r(e),t({theme:e})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ta,{updateSnapshot:e.updateSnapshot}),(0,H.jsx)(U,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,H.jsx)(I,{value:n,onValueChange:l,options:va,size:`sm`})}),(0,H.jsx)(U,{title:`Typography Scale`,description:i?`This device uses its own text size instead of the account default.`:`Choose how large text and UI elements appear across the app.`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsxs)(pe,{value:c,onValueChange:e=>{Pt(e)&&t({typography:{scale:e}})},children:[(0,H.jsx)(O,{className:`min-w-[180px]`,children:(0,H.jsx)(de,{})}),(0,H.jsx)(ue,{children:(0,H.jsx)(fe,{children:ya.map(e=>(0,H.jsx)(k,{value:e.value,children:e.label},e.value))})})]}),i?(0,H.jsx)(M,{type:`button`,variant:`link`,size:`sm`,onClick:a,children:`Use account default`}):null]})}),(0,H.jsx)(Ea,{state:e}),(0,H.jsx)(Da,{state:e})]})}var ka=[`app_launch`,`project_opened`,`project_created`,`project_removed`,`project_deleted`,`chat_created`,`chat_deleted`,`message_sent`,`update_checked`,`update_installed`,`update_failed`,`analytics_enabled`,`analytics_disabled`],Aa=[`current_version`,`environment`,`latest_version`,`custom_port_enabled`,`no_open_enabled`,`password_enabled`,`strict_port_enabled`,`remote_enabled`,`host_enabled`,`share_quick_enabled`,`share_token_enabled`],ja=L()(e=>({permissionState:`unsupported`,deviceId:null,error:null,contactSubjectDraft:``,detected:(t,n)=>e({permissionState:t,deviceId:n}),setPermissionState:t=>e({permissionState:t}),setDeviceId:t=>e({deviceId:t}),setError:t=>e({error:t}),setContactSubjectDraft:t=>e({contactSubjectDraft:t})})),Ma=`inline-flex items-center justify-center rounded-lg border border-border bg-background px-3 py-1.5 text-sm font-medium text-foreground transition-colors hover:bg-muted`,Na=`inline-flex items-center justify-center rounded-lg bg-foreground px-3 py-1.5 text-sm font-medium text-background transition-colors hover:bg-foreground/90`,Pa=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,Fa=`text-xs font-medium tracking-wide text-muted-foreground`,Ia=`gap-1.5 disabled:cursor-default disabled:opacity-60`,La=`push.enable`,Ra=`push.test`,za=`push.disable`,Ba=`push.contactSubject`;async function Va(e){try{await e(),ja.getState().setError(null)}catch(e){ja.getState().setError(Xe(e))}}function Ha(e,t){N(e,()=>Va(t))}function Ua(){let e=ja(e=>e.error);return e?(0,H.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive-text`,children:e}):null}function Wa({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=P(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Ha(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:T(n,Ia),children:[a?(0,H.jsx)(A,{}):null,i]})}function Ga({localPath:e,muted:t,onMuteToggle:n}){let r=F(`push.setProjectMute`,e),i=P(r);return(0,H.jsxs)(`label`,{"aria-busy":i||void 0,className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 transition-colors hover:bg-muted/50`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:!t,disabled:i,onChange:t=>Ha(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,H.jsx)(sn,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,H.jsx)(A,{className:`text-muted-foreground`}):null]})}function Ka(e){let{permissionState:t}=e,n=P(Ba);if(t===`unsupported`)return(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Push notifications are not supported in this browser.`});if(t===`insecure-context`)return(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Push requires HTTPS. Run `,(0,H.jsx)(`code`,{className:Pa,children:`kanna --share`}),` or open Kanna over a tunnel, then enable on this device.`]});if(t===`denied`)return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`You blocked notifications for this site. Re-enable them in your browser settings, then reload.`}),(0,H.jsx)(Ua,{})]});if(!(t===`granted`&&e.config.devices.some(t=>t.id===e.currentDeviceId)))return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-start gap-2 md:w-[440px]`,children:[(0,H.jsx)(Wa,{pendingKey:La,onRun:e.onEnable,className:Na,children:`Enable on this device`}),(0,H.jsx)(Ua,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=ni(i),o=i!==e.contactSubject,s=()=>{a&&o&&Ha(Ba,()=>e.onContactSubjectSave(i))};return(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-5 md:w-[440px]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-card/40 px-3 py-1 text-xs font-medium text-foreground`,children:[(0,H.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-500`,"aria-hidden":!0}),`Enabled on this device`]}),(0,H.jsx)(Wa,{pendingKey:Ra,onRun:e.onTest,className:Ma,children:`Send test`}),(0,H.jsx)(Wa,{pendingKey:za,onRun:e.onDisable,className:Ma,children:`Disable`})]}),(0,H.jsx)(Ua,{}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:T(Fa,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,H.jsx)(A,{}):null]}),(0,H.jsx)(R,{type:`text`,inputMode:`email`,spellCheck:!1,autoCapitalize:`none`,value:e.contactSubjectDraft,readOnly:n,"aria-busy":n||void 0,onChange:t=>e.onContactSubjectDraftChange(t.target.value),onBlur:s,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),s())},placeholder:`mailto:you@example.com`,"aria-label":`Push contact subject`,"aria-invalid":i!==``&&!a,className:T(`font-mono`,i!==``&&!a&&`border-destructive`)}),i!==``&&!a?(0,H.jsxs)(`p`,{className:`text-xs text-destructive`,children:[`Must be a `,(0,H.jsx)(`code`,{className:Pa,children:`mailto:`}),` address or`,` `,(0,H.jsx)(`code`,{className:Pa,children:`https:`}),` URL with a routable domain (not localhost).`]}):(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Push services require a contact `,(0,H.jsx)(`code`,{className:Pa,children:`mailto:`}),` or`,` `,(0,H.jsx)(`code`,{className:Pa,children:`https:`}),` URL to sign notifications. Set your own so delivery isn’t rejected.`]})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:Fa,children:`Devices`}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.config.devices.map(t=>(0,H.jsxs)(`li`,{className:`flex items-start justify-between gap-3 rounded-lg border border-border bg-card/40 px-3 py-2`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.label}),(0,H.jsx)(`span`,{className:`line-clamp-2 break-all text-xs leading-snug text-muted-foreground`,children:t.userAgent})]}),!t.isCurrentDevice&&(0,H.jsx)(Wa,{pendingKey:F(`push.unsubscribe`,t.id),onRun:()=>e.onRemoveDevice(t.id),label:`Remove ${t.label}`,className:`inline-flex shrink-0 items-center rounded-md border border-border bg-background px-2 py-1 text-xs text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:`Remove`})]},t.id))})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`div`,{className:Fa,children:`Per-project`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Ga,{localPath:t.localPath,muted:r.has(t.localPath),onMuteToggle:e.onMuteToggle})},t.localPath))})]}),(0,H.jsxs)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:[`Phone setup: this page must be reachable over HTTPS. Run`,` `,(0,H.jsx)(`code`,{className:Pa,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}function qa(e){return e.map(e=>({...e,disabled:!0}))}function Ja({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=P(e);return(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,H.jsx)(A,{className:`text-muted-foreground`}):null,(0,H.jsx)(I,{value:t,onValueChange:t=>N(e,()=>n(t)),options:a?qa(r):r,size:i})]})}function Ya(e){let{pushConfig:t,socket:n}=e,r=ja(e=>e.deviceId),i=ja(e=>e.setDeviceId),a=ja(e=>e.setPermissionState);return{handleEnablePush:(0,V.useCallback)(async()=>{if(t)try{let e=await y({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return f(t.id),{id:t.id}}});i(e)}finally{a(S().state)}},[t,n,i,a]),handleDisablePush:(0,V.useCallback)(async()=>{r&&(await te({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),d(),i(null))},[r,n,i])}}var Xa=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Za=`~/.kanna/data/settings.json`;function Qa({state:e,dom:t}){let n=z(e=>e.settings),r=ja(e=>e.permissionState),i=ja(e=>e.deviceId),a=ja(e=>e.contactSubjectDraft),o=ja(e=>e.setContactSubjectDraft),s=ja(e=>e.detected),c=ja(e=>e.setPermissionState),{handleEnablePush:l,handleDisablePush:u}=Ya(e),{pushConfig:d,socket:f}=e,p=n?.push.contactSubject;return(0,V.useLayoutEffect)(()=>{s(S().state,ee())},[s]),(0,V.useEffect)(()=>t.addWindowListener(`focus`,()=>c(S().state)),[t,c]),(0,V.useEffect)(()=>{p!==void 0&&o(p)},[p,o]),d?(0,H.jsx)(U,{title:`Push notifications`,description:`Get notified when a chat is waiting for you, finishes, or fails. Works on iPhone (after Add to Home Screen), Android, and desktop browsers.`,bordered:!1,alignStart:!0,children:(0,H.jsx)(Ka,{permissionState:r,config:d,projects:e.localProjects?.projects??[],currentDeviceId:i,contactSubject:p??``,contactSubjectDraft:a,onContactSubjectDraftChange:o,onContactSubjectSave:t=>e.handleWriteAppSettings({push:{contactSubject:t}}),onEnable:l,onDisable:u,onTest:async()=>{await f.command({type:`push.test`})},onMuteToggle:async(e,t)=>{await f.command({type:`push.setProjectMute`,localPath:e,muted:t})},onRemoveDevice:async e=>{await f.command({type:`push.unsubscribe`,pushDeviceId:e})}})}):null}function $a({state:e}){let t=z(e=>e.settings),n=G(e=>e.setAppSettingsError),r=G(e=>e.setAnalyticsDialogOpen),i=t?.analyticsEnabled===!1?`disabled`:`enabled`,a=t?.telemetry?.enabled===!1?`disabled`:`enabled`;async function o(t){await B(n,()=>e.handleWriteAppSettings(t))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Anonymous Analytics`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Help improve Kanna with anonymous product analytics. Kanna sends tracked event names plus a small set of event properties like current version, environment, update version info, and launch flags. No message content, prompts, file paths, or provider credentials are sent.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??Za,`.`,` `,(0,H.jsx)(`button`,{type:`button`,onClick:()=>r(!0),className:`underline underline-offset-2 text-foreground hover:text-foreground/80`,children:`View tracked events`})]}),t?.warning?(0,H.jsx)(`span`,{className:`mt-1 block`,children:t.warning}):null]}),children:(0,H.jsx)(Ja,{pendingKey:`settings.analytics`,value:i,onValueChange:e=>o({analyticsEnabled:e===`enabled`}),options:Xa,size:`sm`})}),(0,H.jsx)(U,{title:`Telemetry Tracing`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Export OpenTelemetry traces and metrics (turn timings, subagent runs, process memory) to Kanna's observability collector so each install can be monitored. This machine reports under its computer name. Turning it off stops the export immediately.`}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Collector: `,t?.telemetry?.endpoint??`not configured`,`. Stored in `,t?.filePathDisplay??Za,`.`]})]}),children:(0,H.jsx)(Ja,{pendingKey:`settings.telemetry`,value:a,onValueChange:e=>o({telemetry:{enabled:e===`enabled`}}),options:Xa,size:`sm`})})]})}function eo(){let e=G(e=>e.analyticsDialogOpen),t=G(e=>e.setAnalyticsDialogOpen);return(0,H.jsx)(Re,{open:e,onOpenChange:t,children:(0,H.jsxs)(Le,{size:`lg`,children:[(0,H.jsxs)(Be,{className:`space-y-4`,children:[(0,H.jsx)(He,{children:`Tracked Events`}),(0,H.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Kanna sends these event names plus the limited property keys below, depending on the event type.`}),(0,H.jsxs)(`div`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted/40 p-3`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:`Event Names`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:ka.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))}),(0,H.jsx)(`div`,{className:`mt-6 text-xs font-medium tracking-wide text-muted-foreground`,children:`Property Keys`}),(0,H.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:Aa.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,H.jsx)(ze,{children:(0,H.jsx)(M,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function to({state:e,dom:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Qa,{state:e,dom:t}),(0,H.jsx)($a,{state:e}),(0,H.jsx)(eo,{})]})}var no=[{value:`accept`,label:`Accept`},{value:`refuse`,label:`Refuse`}];function ro({state:e}){let{writeAsync:t}=_a(e),n=z(e=>e.settings?.peerMessagesInbound??`accept`);return(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(U,{title:`Messages from other chats`,description:`Let agents in other chats, in any project, send messages to agents in your chats. Each chat can override this from its sidebar menu.`,bordered:!1,children:(0,H.jsx)(Ja,{pendingKey:`settings.peerMessagesInbound`,value:n,onValueChange:async e=>{await t({peerMessagesInbound:e})},options:no,size:`sm`})})})}var io={path:`shareDefaultTtlHours`,min:1,max:1/0,integer:!0},ao=6e5,oo={path:`subagentRuntime.runTimeoutMs`,min:3e4,max:864e5,integer:!0},so={path:`claudeDriver.lifecycle.idleTimeoutMs`,min:ut,max:st,integer:!1},co={path:`claudeDriver.lifecycle.maxConcurrent`,min:1,max:16,integer:!1};function lo(e,t,n){let r=Number(e);if(!Ot(n,r))return{kind:`invalid`};let i=Math.round(r);return i===t?{kind:`unchanged`}:{kind:`write`,value:i}}function uo({title:e,description:t,min:n,max:r,step:i,value:a,onValueChange:o,onCommit:s,hint:c,unit:l,ariaLabel:u,bordered:d}){let f=(0,H.jsx)(R,{type:`number`,min:n,max:r,step:i,value:a,onChange:e=>o(e.target.value),onBlur:s,onKeyDown:e=>pa(e,s),className:T(`hide-number-steppers w-full text-left font-mono`,l?`tabular-nums md:w-24 md:text-right`:`md:w-28 md:text-right`),"aria-label":u});return(0,H.jsx)(U,{title:e,description:t,bordered:d,children:(0,H.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-stretch gap-2 md:w-auto md:items-end`,children:[l?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 md:justify-end`,children:[f,(0,H.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:l})]}):f,(0,H.jsx)(`div`,{className:T(`text-left text-xs text-muted-foreground md:text-right`,l&&`tabular-nums`),children:c})]})})}function fo({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.shareDefaultTtlHours??24),r=G(e=>e.drafts.shareDefaultTtl),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({shareDefaultTtl:String(n)})},[n,i]);function o(){let e=lo(r,n,io);e.kind===`write`?t({shareDefaultTtlHours:e.value}):(i({shareDefaultTtl:String(n)}),e.kind===`invalid`&&a(`Default share link expiry must be a whole number of hours >= 1.`))}return(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(uo,{title:`Public share links`,description:`Default expiry for read-only chat share links. Owners can revoke any link manually at any time.`,min:io.min,step:1,value:r,onValueChange:e=>i({shareDefaultTtl:e}),onCommit:o,unit:`hours`,ariaLabel:`Default share link expiry in hours`,hint:`Minimum 1 hour · default 24`,bordered:!1})})}function po({checked:e,onChange:t}){return(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-2`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked)}),`Enabled`]})}function mo(e,t){let n=G(t=>t.drafts[e]),r=G(e=>e.patchDrafts);return(0,V.useEffect)(()=>{r({[e]:String(t)})},[e,t,r]),{draft:n,setDraft:t=>r({[e]:t}),parsed:()=>{let e=Number(n);return Number.isFinite(e)?e:null},reset:()=>r({[e]:String(t)})}}function ho({state:e}){let{write:t}=_a(e),n=z(Mt),r=v(e=>e.setScrollbackLines),i=mo(`scrollback`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{scrollbackLines:e}}))}return(0,H.jsx)(uo,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,min:500,max:wt,step:100,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[500,`-`,wt,` lines`,n===1e3?` (default)`:``]})})}function go({state:e}){let{write:t}=_a(e),n=z(At),r=v(e=>e.setMinColumnWidth),i=mo(`minColumnWidth`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{minColumnWidth:e}}))}return(0,H.jsx)(uo,{title:`Terminal Min Column Width`,description:`Minimum width for each terminal pane`,min:250,max:900,step:10,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[250,`-`,900,` px`,n===450?` (default)`:``]})})}function _o({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.panes.tabMinWidth??60),r=mo(`tabMinWidth`,n);function i(){let e=r.parsed();e===null?r.reset():t({panes:{tabMinWidth:Qn(e)}})}return(0,H.jsx)(uo,{title:`Tab Minimum Width`,description:`How narrow a pane tab may get before the strip scrolls instead of shrinking`,min:60,max:200,step:10,value:r.draft,onValueChange:r.setDraft,onCommit:i,hint:(0,H.jsxs)(H.Fragment,{children:[60,`-`,200,` px`,n===60?` (default)`:``]})})}function vo({state:e}){let{write:t}=_a(e),n=z(e=>e.settings?.uploads.maxFileSizeMb??ri.maxFileSizeMb),r=G(e=>e.drafts.uploadMaxFileSize),i=G(e=>e.patchDrafts),a=G(e=>e.setAppSettingsError);(0,V.useEffect)(()=>{i({uploadMaxFileSize:String(n)})},[n,i]);function o(){let e=lo(r,n,ii);e.kind===`write`?t({uploads:{maxFileSizeMb:e.value}}):(i({uploadMaxFileSize:String(n)}),e.kind===`invalid`&&a(`Max file size must be between ${ii.min} and ${ii.max} MB.`))}return(0,H.jsx)(uo,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,min:ii.min,max:ii.max,step:1,value:r,onValueChange:e=>i({uploadMaxFileSize:e}),onCommit:o,unit:`MB`,ariaLabel:`Max upload file size in megabytes`,hint:`${ii.min}–${ii.max} MB · default ${ri.maxFileSizeMb}`})}function yo({state:e}){let t=o(e=>e.autoResumeOnRateLimit),n=o(e=>e.setAutoResumeOnRateLimit);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ho,{state:e}),(0,H.jsx)(go,{state:e}),(0,H.jsx)(_o,{state:e}),(0,H.jsx)(vo,{state:e}),(0,H.jsx)(U,{title:`Auto-resume on rate limit`,description:`When you hit a rate limit, automatically schedule "continue" at the reset time instead of asking. You can still cancel each one from the chat.`,children:(0,H.jsx)(po,{checked:t,onChange:n})})]})}var bo=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],xo=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],So=`appSettings.setCloudflareTunnel`,Co=F(So,`cloudflaredPath`);function wo({state:e}){let t=z(e=>e.settings),n=G(e=>e.tunnelError),r=G(e=>e.setTunnelError),i=G(e=>e.drafts.cloudflaredPath),a=G(e=>e.patchDrafts),o=P(Co),s=t?.cloudflareTunnel??ti,c=s.enabled?`enabled`:`disabled`,l=t?.cloudflareTunnel.cloudflaredPath;(0,V.useEffect)(()=>{l!==void 0&&a({cloudflaredPath:l})},[l,a]);async function u(t){await B(r,()=>e.handleWriteCloudflareTunnel(t))}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsx)(U,{title:`Cloudflare Tunnel`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[`When enabled, Claude can call the `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`expose_port`}),` tool to expose a local port via Cloudflare Tunnel. The mode below controls whether each call requires your approval or is exposed automatically. Requires`,` `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:`cloudflared`}),` `,`to be installed.`]}),(0,H.jsxs)(`span`,{className:`mt-1 block`,children:[`Stored in `,t?.filePathDisplay??`~/.kanna/data/settings.json`,`.`]})]}),bordered:!1,children:(0,H.jsx)(Ja,{pendingKey:F(So,`enabled`),value:c,onValueChange:e=>u({enabled:e===`enabled`}),options:bo,size:`sm`})}),s.enabled&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Tool mode`,description:`Always ask: each expose_port call shows an accept card. Auto-expose: expose_port calls spawn cloudflared immediately without prompting.`,children:(0,H.jsx)(Ja,{pendingKey:F(So,`mode`),value:s.mode,onValueChange:e=>u({mode:e}),options:xo,size:`sm`})}),(0,H.jsx)(U,{title:`cloudflared path`,description:`Path to the cloudflared binary. Defaults to the one found on $PATH.`,children:(0,H.jsx)(R,{value:i,onChange:e=>a({cloudflaredPath:e.target.value}),onBlur:()=>N(Co,()=>u({cloudflaredPath:i})),readOnly:o,"aria-busy":o||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]})}function To({state:e,dom:t=jn}){let n=G(e=>e.appSettingsError);return(0,H.jsxs)(H.Fragment,{children:[n?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:n}):null,(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(Oa,{state:e}),(0,H.jsx)(yo,{state:e}),(0,H.jsx)(to,{state:e,dom:t})]}),(0,H.jsx)(wo,{state:e}),(0,H.jsx)(fo,{state:e}),(0,H.jsx)(ro,{state:e})]})}var Eo=L()(e=>({draft:``,persistedAtMount:``,error:null,setDraft:t=>e({draft:t}),persistedChanged:t=>e({persistedAtMount:t,draft:t}),setError:t=>e({error:t})})),Do=`settings.globalInstructions`;function Oo({state:e}){let t=z(e=>e.settings?.globalPromptAppend??``),n=Eo(e=>e.draft),r=Eo(e=>e.setDraft),i=Eo(e=>e.persistedAtMount),a=Eo(e=>e.persistedChanged),o=P(Do),s=Eo(e=>e.error),c=Eo(e=>e.setError);(0,V.useEffect)(()=>{t!==i&&a(t)},[t,i,a]);let l=n.replace(/\s+$/u,``),u=l.length>yt,d=l!==t,f=o||u||!d,p=(0,V.useCallback)(async()=>{f||await B(c,()=>e.handleWriteAppSettings({globalPromptAppend:l}))},[f,e,l,c]),m;return m=o?`Saving…`:d?`Save`:`Saved`,(0,H.jsx)(`div`,{className:`border-b border-border`,children:(0,H.jsx)(U,{title:`Global Instructions`,description:`Appended to every Claude and Codex turn — including subagent turns — as “Workspace instructions”. Kanna does not read CLAUDE.md or AGENTS.md from disk; paste your global instructions here. For rules that apply to one project only, use “Edit instructions” in that project's sidebar menu. Leave blank to disable.`,bordered:!1,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,H.jsx)(`textarea`,{value:n,onChange:e=>r(e.target.value),placeholder:`e.g. Always write tests before implementation. Prefer Tailwind classes over inline styles.`,rows:8,"aria-label":`Global instructions`,className:T(`min-h-[160px] w-full resize-y rounded-md border bg-background px-3 py-2 text-sm shadow-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,u?`border-destructive`:`border-input`),disabled:o}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,H.jsxs)(`span`,{className:u?`text-destructive`:`text-muted-foreground`,children:[l.length,` / `,yt,` characters`,u?` — over limit`:``]}),(0,H.jsx)(M,{type:`button`,size:`sm`,onClick:()=>N(Do,p),disabled:f,pending:o,children:m})]}),s?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]})})})}function ko(e){return{async onReload(t){await ln(e,{type:`plugins.reload`,pluginId:t})}}}function Ao({plugins:e,handlers:t}){return e.length===0?(0,H.jsx)(oi,{icon:zn,message:`No plugins installed yet.`}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:`Plugins`}),(0,H.jsx)(si,{children:e.map(e=>(0,H.jsx)(jo,{plugin:e,onReload:t.onReload},e.id))})]})}function jo({plugin:e,onReload:t}){let n=F(`plugins.reload`,e.id),r=P(n),i=(0,V.useCallback)(()=>{N(n,()=>t(e.id))},[t,e.id,n]);return(0,H.jsxs)(`li`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.id}),(0,H.jsx)(rn,{tone:e.enabled?`active`:`muted`,label:e.enabled?`Enabled`:`Disabled`})]}),(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.sourceDir})]}),(0,H.jsx)(M,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}function Mo(){let e=z(Ut),t=z(Jt),n=on(),r=(0,V.useMemo)(()=>ko(n),[n]);return e?(0,H.jsx)(Ao,{plugins:t,handlers:r}):null}var No={},Po=L()(e=>({drafts:No,error:null,setDrafts:t=>e({drafts:t}),setDraft:(t,n)=>e(e=>e.drafts[t]===n?e:{drafts:{...e.drafts,[t]:n}}),setError:t=>e({error:t})}));function Fo(e){let t={};for(let n of vt)t[n]=Nn(e[n]??``);return{...lt,...t}}function Io(e){return F(`settings.writeKeybindings`,e)}function Lo({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=Io(e),s=P(o),c=Pn(lt[e]),l=t!==c,u=()=>{N(o,i)};return(0,H.jsx)(U,{title:Fn[e],description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Comma-separated shortcuts.`}),l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:` `}),(0,H.jsxs)(`button`,{type:`button`,disabled:s,"aria-busy":s||void 0,onClick:()=>{N(o,()=>a(e))},className:`inline rounded text-foreground hover:text-foreground/80 disabled:opacity-60`,children:[`Restore: `,c]})]}):null]}),bordered:n,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 max-w-[420px] flex-1 items-center gap-2`,children:[(0,H.jsx)(R,{type:`text`,value:t,"aria-busy":s||void 0,onChange:t=>r(e,t.target.value),onBlur:u,onKeyDown:e=>pa(e,u),className:`font-mono`}),s?(0,H.jsx)(A,{}):null]})})}function Ro({state:e}){let t=Po(e=>e.drafts),n=Po(e=>e.setDrafts),r=Po(e=>e.setDraft),i=Po(e=>e.error),a=Po(e=>e.setError),o=(0,V.useMemo)(()=>Mn(e.keybindings),[e.keybindings]);(0,V.useEffect)(()=>{n(Object.fromEntries(vt.map(e=>[e,Pn(o.bindings[e])])))},[o,n]);async function s(t){await B(a,async()=>{await e.socket.command({type:`settings.writeKeybindings`,bindings:Fo(t)})})}async function c(){await s(t)}async function l(e){let r={...t,[e]:Pn(lt[e])};n(r),await s(r)}return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[i?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:i}):null,o.warning?(0,H.jsx)(`div`,{className:`mb-4 rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:o.warning}):null,vt.map((e,n)=>(0,H.jsx)(Lo,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:c,onRestoreDefault:l},e))]})}function zo(e){return e===null?{name:``,transport:`stdio`,command:``,argsText:``,envText:``,cwd:``,url:``,headersText:``}:e.transport===`stdio`?{name:e.name,transport:`stdio`,command:e.command,argsText:e.args.join(`
|
|
2
2
|
`),envText:Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
|
|
3
3
|
`),cwd:e.cwd??``,url:``,headersText:``}:{name:e.name,transport:e.transport,command:``,argsText:``,envText:``,cwd:``,url:e.url,headersText:Object.entries(e.headers).map(([e,t])=>`${e}: ${t}`).join(`
|
|
4
4
|
`)}}function Bo(e,t,n){let r={};for(let i of e.split(`
|
package/dist/client/assets/{StackBoardsRoutePage-Dj88KTce.js → StackBoardsRoutePage-DeaUCg6R.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{t as a}from"./BoardsPage-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{l as n,u as r}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{t as a}from"./BoardsPage-C-XPAU3h.js";var o=e(t(),1),s=e(i(),1);function c({stackId:e}){let t=r(),i=n(),c=t.sidebarData.stacks.find(t=>t.id===e),l=c?c.title:`Stack`,u=(0,o.useCallback)(t=>{i(`/boards/stack/${e}/${t}`)},[i,e]);return(0,s.jsx)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,s.jsx)(a,{ownerKind:`stack`,ownerId:e,ownerName:l,socket:t.socket,onOpenBoard:u})})}export{c as StackBoardsRoutePage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{i,t as a}from"./utils-gw0dpHSZ.js";import{o}from"./beacon-alias-DU-hx8ux.js";import{n as s}from"./code-xml-BjFagt-D.js";import{A as c,B as l,E as u,F as d,N as f,P as p,S as m,_ as h,b as g,g as _,i as v,j as y,k as b,m as x,t as ee,w as S,x as te,y as ne}from"./FilePreviewSheet-C2s7k36v.js";import{n as re,t as ie}from"./file-plus-corner-BfUy6cfa.js";import{c as ae,l as oe,r as se,s as ce,u as le}from"./contextWindow-D6tuokPX.js";import{f as ue,l as de}from"./pendingActionsStore-BgvURrXK.js";import{t as fe}from"./pencil-BnnPP0sI.js";import{t as C}from"./search-DaMiMFjO.js";import{t as pe}from"./terminal-D7v6A2Rn.js";import{g as me}from"./timer.adapter-DWVGc3wb.js";import{i as he,n as ge,r as w,t as _e}from"./log-8K5PdGJC.js";import{n as ve,t as ye}from"./createScopedStore-BZ7oYp5V.js";import{n as be,r as T,t as xe}from"./errors-W4jQ4RJU.js";import{ru as Se}from"./useTheme-Cb3XmN93.js";import{c as Ce,n as we,s as E}from"./pathUtils-BU6_uBbH.js";import{c as Te,h as Ee,i as D,m as De,n as O,s as k,v as Oe}from"./state-mark-p6veyUZZ.js";import{t as ke}from"./formatDuration-BbWTR_M_.js";import{c as Ae,s as je,u as Me}from"./tools-CryRpKwA.js";var A={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};A.node;var Ne=i(A),j={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};j.node;var Pe=i(j),Fe={name:`check-line`,size:24,node:[[`path`,{d:`M20 4L9 15`,key:`1qkx8z`}],[`path`,{d:`M21 19L3 19`,key:`100sma`}],[`path`,{d:`M9 15L4 10`,key:`9zxff7`}]]};Fe.node;var M=i(Fe),Ie={name:`file-x`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]};Ie.node;var Le=i(Ie),Re={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Re.node;var N=i(Re),ze={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};ze.node;var Be=i(ze),Ve={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Ve.node;var He=i(Ve),Ue={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};Ue.node;var We=i(Ue),Ge={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};Ge.node;var Ke=i(Ge),qe={name:`toy-brick`,size:24,node:[[`rect`,{width:`18`,height:`12`,x:`3`,y:`8`,rx:`1`,key:`158fvp`}],[`path`,{d:`M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3`,key:`s0042v`}],[`path`,{d:`M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3`,key:`9wmeh2`}]]};qe.node;var Je=i(qe),Ye={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Ye.node;var P=i(Ye),Xe={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Xe.node;var Ze=i(Xe);function Qe(e){return e.kind===`tool`}function F(e){return new Date(e).toISOString()}function $e(e){let{_id:t,createdAt:n,...r}=e;return{...r,id:t,timestamp:F(n)}}function et(e){let{_id:t,createdAt:n,debugRaw:r,...i}=e;return{...i,id:t,timestamp:F(n)}}function tt(e){return{...I(e),kind:`unknown`,json:JSON.stringify(e,null,2)}}function I(e){return{id:e._id,messageId:e.messageId,timestamp:F(e.createdAt),hidden:e.hidden}}var nt=`/.claude/plans/`;function rt(e){return e.includes(nt)&&e.endsWith(`.md`)}function it(e,t){if(e.toolKind!==`exit_plan_mode`)return e.toolKind===`write_file`&&rt(e.input.filePath)?e.input.content:t}function at(e,t){return e.toolKind===`exit_plan_mode`&&!e.input.plan&&t?{...e.input,plan:t}:e.input}function ot(e,t){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:at(e.tool,t),timestamp:F(e.createdAt)}}function st(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).tool_use_result??void 0}catch{return}if(t!==void 0&&typeof t!=`number`&&typeof t!=`boolean`)return t}function L(e){return typeof e==`number`?e:void 0}function R(e){return typeof e==`string`?e:void 0}function ct(e){if(e===void 0||!Se(e))return;let t=e,n={readCount:L(t.readCount),searchCount:L(t.searchCount),bashCount:L(t.bashCount),editFileCount:L(t.editFileCount),linesAdded:L(t.linesAdded),linesRemoved:L(t.linesRemoved),otherToolCount:L(t.otherToolCount)};return Object.values(n).some(e=>e!==void 0)?n:void 0}function lt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).toolUseResult}catch{return}if(t===void 0||!Se(t))return;let n=t,r={agentId:R(n.agentId),agentType:R(n.agentType),status:R(n.status),totalTokens:L(n.totalTokens),totalDurationMs:L(n.totalDurationMs),totalToolUseCount:L(n.totalToolUseCount),toolStats:ct(n.toolStats),content:R(n.content)};return r.agentId!==void 0||r.agentType!==void 0||r.totalTokens!==void 0||r.totalDurationMs!==void 0||r.status!==void 0?r:void 0}function ut(e){let t=new Map,n=[],r;for(let i of e)switch(i.kind){case`user_prompt`:case`account_info`:case`assistant_text`:case`assistant_thinking`:case`api_error`:case`policy_refusal`:case`status`:case`context_window_updated`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`memory_loaded`:case`auto_continue_prompt`:case`pending_tool_request`:case`cron_armed`:case`cron_command_error`:case`cron_run`:case`cron_run_skipped`:case`cron_list`:case`cron_job_change`:case`webhook_delivery`:case`inbound_delivery`:case`loop_disarmed`:n.push(et(i));break;case`system_init`:n.push($e(i));break;case`tool_call`:{let e=ot(i,r);r=it(i.tool,r),t.set(i.tool.toolId,{hydrated:e,normalized:i.tool}),Qe(e)&&n.push(e);break}case`tool_result`:{let e=t.get(i.toolId);if(e){let t=je.has(e.normalized.toolKind)?st(i)??i.content:i.content;e.normalized.toolKind===`subagent_task`?e.hydrated.result=lt(i):e.hydrated.result=Ae(e.normalized,ae(t)),e.hydrated.rawResult=t,e.hydrated.isError=i.isError,i.persisted&&(e.hydrated.persisted=i.persisted)}break}case`result`:n.push({...I(i),kind:`result`,success:!i.isError,cancelled:i.subtype===`cancelled`,result:i.result,durationMs:i.durationMs,costUsd:i.costUsd,codexErrorInfo:i.codexErrorInfo});break;case`tool_request_resolved`:break;default:n.push(tt(i))}return n}var z={key:`other`,singular:`tool call`,plural:`tool calls`},B={key:`task`,singular:`task update`,plural:`task updates`},dt={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},delete_file:{key:`delete`,singular:`delete`,plural:`deletes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`},task_create:B,task_update:B,task_get:B,task_list:B,ask_user_question:z,exit_plan_mode:z,mcp_generic:z,beacon:z,offer_download:z,preview_file:z,image_generation:z,image_view:z,workflow:z,unknown_tool:z};function ft(e){return dt[e]}var V=Je,pt={read_file:l,edit_file:re,write_file:ie,delete_file:Le,bash:pe,grep:C,glob:C,web_search:C,subagent_task:P,skill:oe,todo_write:M,task_create:M,task_update:M,task_get:M,task_list:M,ask_user_question:We,exit_plan_mode:He,image_view:Be,workflow:N,mcp_generic:V,beacon:V,offer_download:V,preview_file:V,image_generation:V,unknown_tool:V},mt={Task:le,TaskOutput:le,Delete:Le,NotebookEdit:fe,WebFetch:Ne,KillShell:Ke,TaskStop:Ke,EnterPlanMode:He};function ht(e){return e.toolKind===`unknown_tool`?mt[e.toolName]??V:pt[e.toolKind]}function gt(e){return ht(Me({toolName:e,toolId:``,input:{}}))}function _t(e,t){switch(e.toolKind){case`skill`:return e.input.skill;case`glob`:return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;case`grep`:return e.input.outputMode===`count`?`Count \`${e.input.pattern}\` occurrences`:e.input.outputMode===`content`?`Find \`${e.input.pattern}\` in text`:`Find \`${e.input.pattern}\` in files`;case`bash`:return e.input.description||(e.input.command?D(e.input.command):`Bash`);case`web_search`:return e.input.query||`Web Search`;case`read_file`:return`Read ${E(e.input.filePath,t)}`;case`image_view`:return`View ${E(e.input.path,t)||e.input.path}`;case`write_file`:return`Write ${E(e.input.filePath,t)}`;case`edit_file`:return`Edit ${E(e.input.filePath,t)}`;case`delete_file`:return`Delete ${E(e.input.filePath,t)}`;case`mcp_generic`:return`${k(e.input.tool)} from ${k(e.input.server)}`;case`beacon`:return e.input.beaconId?`Beacon ${e.input.beaconId}: ${e.input.summary}`:e.input.summary;case`subagent_task`:return e.input.subagentType||e.toolName;case`workflow`:return e.input.name??`Workflow`;case`ask_user_question`:case`exit_plan_mode`:case`todo_write`:case`task_create`:case`task_update`:case`task_get`:case`task_list`:case`offer_download`:case`preview_file`:case`image_generation`:case`unknown_tool`:return e.toolName}}var vt=40;function H(e){return Te(e,vt)}function U(e,t,n,r){let i=E(n,r);return i?`${e} ${H(i)}`:t}function yt(e,t){switch(e.toolKind){case`bash`:{let t=e.input.description||(e.input.command?D(e.input.command):``);return t?`$ ${H(t)}`:`running bash...`}case`read_file`:return U(`reading`,`reading file...`,e.input.filePath,t);case`write_file`:return U(`writing`,`writing file...`,e.input.filePath,t);case`edit_file`:return U(`editing`,`editing file...`,e.input.filePath,t);case`delete_file`:return U(`deleting`,`deleting file...`,e.input.filePath,t);case`glob`:return e.input.pattern?`globbing ${H(e.input.pattern)}`:`globbing...`;case`grep`:return e.input.pattern?`grepping ${H(e.input.pattern)}`:`grepping...`;case`web_search`:return e.input.query?`searching: ${H(e.input.query)}`:`searching web...`;case`skill`:return e.input.skill?`skill ${H(e.input.skill)}`:`running skill...`;case`todo_write`:return`updating todos...`;case`task_create`:return`creating task...`;case`task_update`:return`updating task...`;case`task_get`:case`task_list`:return`reading tasks...`;case`subagent_task`:return e.input.subagentType?`delegating ${H(e.input.subagentType)}`:`delegating...`;case`ask_user_question`:return`asking...`;case`exit_plan_mode`:return`presenting plan...`;case`offer_download`:return`preparing download...`;case`image_generation`:return`generating image...`;case`image_view`:return`viewing image...`;case`mcp_generic`:return H(`${e.input.server}.${e.input.tool}`);case`unknown_tool`:return`running ${H(e.toolName)}`;case`preview_file`:case`beacon`:case`workflow`:return`running...`}}var W=e(t(),1),G=e(r(),1),bt=(0,W.memo)(({message:e})=>(0,G.jsx)(`div`,{className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:v(e.text)})),xt=(0,W.memo)(({message:e})=>(0,G.jsx)(`div`,{className:`px-0.5 w-full max-w-[70ch]`,children:(0,G.jsx)(_,{content:e.text})})),St=({children:e,className:t,animate:n=!0,...r})=>(0,G.jsx)(`span`,{className:a(`mx-auto max-w-md text-foreground/60`,n&&`animate-shiny-pulse`,t),...r,children:e});function Ct(e){let t=e.split(`
|
|
1
|
+
import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{i,t as a}from"./utils-gw0dpHSZ.js";import{o}from"./beacon-alias-CcevdUfB.js";import{n as s}from"./code-xml-BjFagt-D.js";import{A as c,B as l,E as u,F as d,N as f,P as p,S as m,_ as h,b as g,g as _,i as v,j as y,k as b,m as x,t as ee,w as S,x as te,y as ne}from"./FilePreviewSheet-DcMdV7hW.js";import{n as re,t as ie}from"./file-plus-corner-BfUy6cfa.js";import{c as ae,l as oe,r as se,s as ce,u as le}from"./contextWindow-BVVtk5Al.js";import{f as ue,l as de}from"./pendingActionsStore-Bw87-8u6.js";import{t as fe}from"./pencil-BnnPP0sI.js";import{t as C}from"./search-DaMiMFjO.js";import{t as pe}from"./terminal-D7v6A2Rn.js";import{g as me}from"./timer.adapter-t-ql2eaa.js";import{i as he,n as ge,r as w,t as _e}from"./log-8K5PdGJC.js";import{n as ve,t as ye}from"./createScopedStore-BZ7oYp5V.js";import{n as be,r as T,t as xe}from"./errors-ewkwYZz5.js";import{ru as Se}from"./useTheme-Cb3XmN93.js";import{c as Ce,n as we,s as E}from"./pathUtils-BU6_uBbH.js";import{c as Te,h as Ee,i as D,m as De,n as O,s as k,v as Oe}from"./state-mark-p6veyUZZ.js";import{t as ke}from"./formatDuration-BbWTR_M_.js";import{a as Ae,c as je,o as Me}from"./tools-BFWoj5em.js";var A={name:`arrow-down-to-line`,size:24,node:[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]};A.node;var Ne=i(A),j={name:`arrow-up`,size:24,node:[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]};j.node;var Pe=i(j),Fe={name:`check-line`,size:24,node:[[`path`,{d:`M20 4L9 15`,key:`1qkx8z`}],[`path`,{d:`M21 19L3 19`,key:`100sma`}],[`path`,{d:`M9 15L4 10`,key:`9zxff7`}]]};Fe.node;var M=i(Fe),Ie={name:`file-x`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]};Ie.node;var Le=i(Ie),Re={name:`git-branch`,size:24,node:[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]};Re.node;var N=i(Re),ze={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};ze.node;var Be=i(ze),Ve={name:`map`,size:24,node:[[`path`,{d:`M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z`,key:`169xi5`}],[`path`,{d:`M15 5.764v15`,key:`1pn4in`}],[`path`,{d:`M9 3.236v15`,key:`1uimfh`}]]};Ve.node;var He=i(Ve),Ue={name:`message-circle-question-mark`,size:24,node:[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`message-circle-question`]};Ue.node;var We=i(Ue),Ge={name:`square-x`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]],aliases:[`x-square`]};Ge.node;var Ke=i(Ge),qe={name:`toy-brick`,size:24,node:[[`rect`,{width:`18`,height:`12`,x:`3`,y:`8`,rx:`1`,key:`158fvp`}],[`path`,{d:`M10 8V5c0-.6-.4-1-1-1H6a1 1 0 0 0-1 1v3`,key:`s0042v`}],[`path`,{d:`M19 8V5c0-.6-.4-1-1-1h-3a1 1 0 0 0-1 1v3`,key:`9wmeh2`}]]};qe.node;var Je=i(qe),Ye={name:`user-round`,size:24,node:[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]],aliases:[`user-2`]};Ye.node;var P=i(Ye),Xe={name:`workflow`,size:24,node:[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]};Xe.node;var Ze=i(Xe);function Qe(e){return e.kind===`tool`}function F(e){return new Date(e).toISOString()}function $e(e){let{_id:t,createdAt:n,...r}=e;return{...r,id:t,timestamp:F(n)}}function et(e){let{_id:t,createdAt:n,debugRaw:r,...i}=e;return{...i,id:t,timestamp:F(n)}}function tt(e){return{...I(e),kind:`unknown`,json:JSON.stringify(e,null,2)}}function I(e){return{id:e._id,messageId:e.messageId,timestamp:F(e.createdAt),hidden:e.hidden}}var nt=`/.claude/plans/`;function rt(e){return e.includes(nt)&&e.endsWith(`.md`)}function it(e,t){if(e.toolKind!==`exit_plan_mode`)return e.toolKind===`write_file`&&rt(e.input.filePath)?e.input.content:t}function at(e,t){return e.toolKind===`exit_plan_mode`&&!e.input.plan&&t?{...e.input,plan:t}:e.input}function ot(e,t){return{id:e._id,messageId:e.messageId,hidden:e.hidden,kind:`tool`,toolKind:e.tool.toolKind,toolName:e.tool.toolName,toolId:e.tool.toolId,input:at(e.tool,t),timestamp:F(e.createdAt)}}function st(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).tool_use_result??void 0}catch{return}if(t!==void 0&&typeof t!=`number`&&typeof t!=`boolean`)return t}function L(e){return typeof e==`number`?e:void 0}function R(e){return typeof e==`string`?e:void 0}function ct(e){if(e===void 0||!Se(e))return;let t=e,n={readCount:L(t.readCount),searchCount:L(t.searchCount),bashCount:L(t.bashCount),editFileCount:L(t.editFileCount),linesAdded:L(t.linesAdded),linesRemoved:L(t.linesRemoved),otherToolCount:L(t.otherToolCount)};return Object.values(n).some(e=>e!==void 0)?n:void 0}function lt(e){if(!e.debugRaw)return;let t;try{t=JSON.parse(e.debugRaw).toolUseResult}catch{return}if(t===void 0||!Se(t))return;let n=t,r={agentId:R(n.agentId),agentType:R(n.agentType),status:R(n.status),totalTokens:L(n.totalTokens),totalDurationMs:L(n.totalDurationMs),totalToolUseCount:L(n.totalToolUseCount),toolStats:ct(n.toolStats),content:R(n.content)};return r.agentId!==void 0||r.agentType!==void 0||r.totalTokens!==void 0||r.totalDurationMs!==void 0||r.status!==void 0?r:void 0}function ut(e){let t=new Map,n=[],r;for(let i of e)switch(i.kind){case`user_prompt`:case`account_info`:case`assistant_text`:case`assistant_thinking`:case`api_error`:case`policy_refusal`:case`status`:case`context_window_updated`:case`compact_boundary`:case`compact_summary`:case`context_cleared`:case`interrupted`:case`memory_loaded`:case`auto_continue_prompt`:case`pending_tool_request`:case`cron_armed`:case`cron_command_error`:case`cron_run`:case`cron_run_skipped`:case`cron_list`:case`cron_job_change`:case`webhook_delivery`:case`inbound_delivery`:case`loop_disarmed`:n.push(et(i));break;case`system_init`:n.push($e(i));break;case`tool_call`:{let e=ot(i,r);r=it(i.tool,r),t.set(i.tool.toolId,{hydrated:e,normalized:i.tool}),Qe(e)&&n.push(e);break}case`tool_result`:{let e=t.get(i.toolId);if(e){let t=Ae.has(e.normalized.toolKind)?st(i)??i.content:i.content;e.normalized.toolKind===`subagent_task`?e.hydrated.result=lt(i):e.hydrated.result=Me(e.normalized,ae(t)),e.hydrated.rawResult=t,e.hydrated.isError=i.isError,i.persisted&&(e.hydrated.persisted=i.persisted)}break}case`result`:n.push({...I(i),kind:`result`,success:!i.isError,cancelled:i.subtype===`cancelled`,result:i.result,durationMs:i.durationMs,costUsd:i.costUsd,codexErrorInfo:i.codexErrorInfo});break;case`tool_request_resolved`:break;default:n.push(tt(i))}return n}var z={key:`other`,singular:`tool call`,plural:`tool calls`},B={key:`task`,singular:`task update`,plural:`task updates`},dt={read_file:{key:`read`,singular:`read`,plural:`reads`},edit_file:{key:`edit`,singular:`edit`,plural:`edits`},write_file:{key:`write`,singular:`write`,plural:`writes`},delete_file:{key:`delete`,singular:`delete`,plural:`deletes`},bash:{key:`bash`,singular:`command`,plural:`commands`},grep:{key:`grep`,singular:`search`,plural:`searches`},glob:{key:`glob`,singular:`glob`,plural:`globs`},subagent_task:{key:`task`,singular:`agent`,plural:`agents`},web_search:{key:`websearch`,singular:`web search`,plural:`web searches`},skill:{key:`skill`,singular:`skill`,plural:`skills`},todo_write:{key:`todo`,singular:`todo update`,plural:`todo updates`},task_create:B,task_update:B,task_get:B,task_list:B,ask_user_question:z,exit_plan_mode:z,mcp_generic:z,beacon:z,offer_download:z,preview_file:z,image_generation:z,image_view:z,workflow:z,unknown_tool:z};function ft(e){return dt[e]}var V=Je,pt={read_file:l,edit_file:re,write_file:ie,delete_file:Le,bash:pe,grep:C,glob:C,web_search:C,subagent_task:P,skill:oe,todo_write:M,task_create:M,task_update:M,task_get:M,task_list:M,ask_user_question:We,exit_plan_mode:He,image_view:Be,workflow:N,mcp_generic:V,beacon:V,offer_download:V,preview_file:V,image_generation:V,unknown_tool:V},mt={Task:le,TaskOutput:le,Delete:Le,NotebookEdit:fe,WebFetch:Ne,KillShell:Ke,TaskStop:Ke,EnterPlanMode:He};function ht(e){return e.toolKind===`unknown_tool`?mt[e.toolName]??V:pt[e.toolKind]}function gt(e){return ht(je({toolName:e,toolId:``,input:{}}))}function _t(e,t){switch(e.toolKind){case`skill`:return e.input.skill;case`glob`:return`Search files ${e.input.pattern===`**/*`?`in all directories`:`matching ${e.input.pattern}`}`;case`grep`:return e.input.outputMode===`count`?`Count \`${e.input.pattern}\` occurrences`:e.input.outputMode===`content`?`Find \`${e.input.pattern}\` in text`:`Find \`${e.input.pattern}\` in files`;case`bash`:return e.input.description||(e.input.command?D(e.input.command):`Bash`);case`web_search`:return e.input.query||`Web Search`;case`read_file`:return`Read ${E(e.input.filePath,t)}`;case`image_view`:return`View ${E(e.input.path,t)||e.input.path}`;case`write_file`:return`Write ${E(e.input.filePath,t)}`;case`edit_file`:return`Edit ${E(e.input.filePath,t)}`;case`delete_file`:return`Delete ${E(e.input.filePath,t)}`;case`mcp_generic`:return`${k(e.input.tool)} from ${k(e.input.server)}`;case`beacon`:return e.input.beaconId?`Beacon ${e.input.beaconId}: ${e.input.summary}`:e.input.summary;case`subagent_task`:return e.input.subagentType||e.toolName;case`workflow`:return e.input.name??`Workflow`;case`ask_user_question`:case`exit_plan_mode`:case`todo_write`:case`task_create`:case`task_update`:case`task_get`:case`task_list`:case`offer_download`:case`preview_file`:case`image_generation`:case`unknown_tool`:return e.toolName}}var vt=40;function H(e){return Te(e,vt)}function U(e,t,n,r){let i=E(n,r);return i?`${e} ${H(i)}`:t}function yt(e,t){switch(e.toolKind){case`bash`:{let t=e.input.description||(e.input.command?D(e.input.command):``);return t?`$ ${H(t)}`:`running bash...`}case`read_file`:return U(`reading`,`reading file...`,e.input.filePath,t);case`write_file`:return U(`writing`,`writing file...`,e.input.filePath,t);case`edit_file`:return U(`editing`,`editing file...`,e.input.filePath,t);case`delete_file`:return U(`deleting`,`deleting file...`,e.input.filePath,t);case`glob`:return e.input.pattern?`globbing ${H(e.input.pattern)}`:`globbing...`;case`grep`:return e.input.pattern?`grepping ${H(e.input.pattern)}`:`grepping...`;case`web_search`:return e.input.query?`searching: ${H(e.input.query)}`:`searching web...`;case`skill`:return e.input.skill?`skill ${H(e.input.skill)}`:`running skill...`;case`todo_write`:return`updating todos...`;case`task_create`:return`creating task...`;case`task_update`:return`updating task...`;case`task_get`:case`task_list`:return`reading tasks...`;case`subagent_task`:return e.input.subagentType?`delegating ${H(e.input.subagentType)}`:`delegating...`;case`ask_user_question`:return`asking...`;case`exit_plan_mode`:return`presenting plan...`;case`offer_download`:return`preparing download...`;case`image_generation`:return`generating image...`;case`image_view`:return`viewing image...`;case`mcp_generic`:return H(`${e.input.server}.${e.input.tool}`);case`unknown_tool`:return`running ${H(e.toolName)}`;case`preview_file`:case`beacon`:case`workflow`:return`running...`}}var W=e(t(),1),G=e(r(),1),bt=(0,W.memo)(({message:e})=>(0,G.jsx)(`div`,{className:`text-pretty prose prose-sm dark:prose-invert px-0.5 w-full max-w-[70ch] space-y-4`,children:v(e.text)})),xt=(0,W.memo)(({message:e})=>(0,G.jsx)(`div`,{className:`px-0.5 w-full max-w-[70ch]`,children:(0,G.jsx)(_,{content:e.text})})),St=({children:e,className:t,animate:n=!0,...r})=>(0,G.jsx)(`span`,{className:a(`mx-auto max-w-md text-foreground/60`,n&&`animate-shiny-pulse`,t),...r,children:e});function Ct(e){let t=e.split(`
|
|
2
2
|
`),n=/^\s*(\d+)→(.*)$/;return t.map(e=>{let t=e.match(n);return t?{lineNumber:parseInt(t[1],10),content:t[2]}:{lineNumber:null,content:e}})}function wt(e){return e.replace(/<[^>]+>/g,``)}function Tt(e,t){let n=e.split(`
|
|
3
3
|
`),r=t.split(`
|
|
4
4
|
`);return Ot(Dt(n,r,Et(n,r)))}function Et(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=1;a<=n;a++)for(let n=1;n<=r;n++)i[a][n]=e[a-1]===t[n-1]?i[a-1][n-1]+1:Math.max(i[a-1][n],i[a][n-1]);return i}function Dt(e,t,n){let r=[],i=e.length,a=t.length;for(;i>0||a>0;)i>0&&a>0&&e[i-1]===t[a-1]?(r.push({type:`context`,text:e[i-1],oldIdx:i,newIdx:a}),i--,a--):a>0&&(i===0||n[i][a-1]>=n[i-1][a])?(r.push({type:`added`,text:t[a-1],oldIdx:i,newIdx:a}),a--):(r.push({type:`removed`,text:e[i-1],oldIdx:i,newIdx:a}),i--);return r.reverse()}function Ot(e){return e.map(e=>{let t;return t=e.type===`removed`?`-`:e.type===`added`?`+`:` `,{type:e.type,content:`${t}${e.text}`}})}function K({content:e,isDiff:t=!1,oldString:n,newString:r}){let i=(0,W.useMemo)(()=>t&&n!==void 0&&r!==void 0?Tt(n,r):[],[t,n,r]),a=(0,W.useMemo)(()=>t?[]:Ct(e),[e,t]),o=(0,W.useMemo)(()=>a.some(e=>e.lineNumber!==null),[a]);return t&&i.length>0?(0,G.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,G.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,G.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,G.jsx)(`tbody`,{children:i.map((e,t)=>{let n;n=e.type===`removed`?`bg-destructive/10 dark:bg-destructive/15`:e.type===`added`?`bg-success/10 dark:bg-success/15`:``;let r;r=e.type===`removed`?`text-destructive`:e.type===`added`?`text-success`:`text-foreground`;let i;i=e.type===`removed`?`text-destructive/50`:e.type===`added`?`text-success/50`:`text-muted-foreground/50`;let a;return a=e.type===`removed`?`-`:e.type===`added`?`+`:` `,(0,G.jsxs)(`tr`,{className:n,children:[(0,G.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap ${i}`,children:a}),(0,G.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all ${r}`,children:e.content.slice(1)})]},t)})})})})}):(0,G.jsx)(`div`,{className:`my-1 rounded-lg border border-border overflow-hidden`,children:(0,G.jsx)(`div`,{className:`overflow-auto max-h-64 md:max-h-[50vh]`,children:(0,G.jsx)(`table`,{className:`w-full border-collapse text-xs font-mono`,children:(0,G.jsx)(`tbody`,{children:a.map((e,t)=>(0,G.jsxs)(`tr`,{children:[o&&(0,G.jsx)(`td`,{className:`px-2 py-0 select-none w-0 whitespace-nowrap text-muted-foreground/50 text-right`,children:e.lineNumber===null?``:e.lineNumber}),(0,G.jsx)(`td`,{className:`px-2 py-0 whitespace-pre select-all text-foreground`,children:wt(e.content)})]},t))})})})})}var kt=new Map;function q(e,t){if(!t)return;let n=kt.get(e);return n===void 0?void 0:t(n)}function At(e){return{state:e===void 0?`idle`:`ready`,data:e===void 0?null:e,error:null}}function jt(e){let{cacheKey:t,enabled:n,ref:r,fetcher:i,rootMargin:a,fromCache:o}=e,s=q(t,o),c=(0,W.useMemo)(()=>he(()=>At(q(t,o))),[t,o]),l=w(c,e=>e.state),u=w(c,e=>e.data),d=w(c,e=>e.error),f=(0,W.useRef)(t),p=(0,W.useRef)(null),m=(0,W.useRef)(t);return(0,W.useEffect)(()=>{m.current=t},[t]),(0,W.useEffect)(()=>{f.current!==t&&(f.current=t,c.setState(At(q(t,o))))},[t,o,c]),(0,W.useEffect)(()=>{if(!n||s!==void 0)return;let e=r.current;if(!e||typeof IntersectionObserver>`u`)return;let o=!1,l=t,u=new IntersectionObserver(e=>{for(let t of e){if(!t.isIntersecting)continue;if(u.disconnect(),o)return;let e=new AbortController;p.current=e,c.setState({state:`loading`}),i(e.signal).then(e=>{o||m.current!==l||(kt.set(l,e),c.setState({data:e,state:`ready`}))}).catch(T(t=>{o||e.signal.aborted||m.current!==l||c.setState({error:t,state:`error`})}));break}},{rootMargin:a??`200px`});return u.observe(e),()=>{o=!0,u.disconnect(),p.current?.abort(),p.current=null}},[s,t,n,r,i,a,c]),(0,W.useMemo)(()=>({state:l,data:u,error:d}),[l,u,d])}function Mt(e){return typeof e==`string`?e:void 0}function Nt({source:e,onOpen:t,variant:n}){let r=f(e),{iconKind:i,friendlyType:a,sizeLabel:o}=r;return i===`image`?(0,G.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`touch-manipulation overflow-hidden rounded-xl border border-border bg-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:(0,G.jsx)(`img`,{src:e.contentUrl,alt:e.altText??e.displayName,loading:`lazy`,className:`max-h-64 w-auto max-w-full object-contain`})}):n===`expanded`&&(i===`text`||i===`code`||i===`markdown`||i===`json`||i===`table`)?(0,G.jsx)(Pt,{source:e,onOpen:t,friendlyType:a,sizeLabel:o}):(0,G.jsx)(h,{attachment:x(e),onClick:t,meta:(0,G.jsx)(ne,{description:r}),ariaLabel:d(`Preview`,e.displayName,r)})}var Pt=function({source:e,onOpen:t,friendlyType:n,sizeLabel:r}){let i=(0,W.useRef)(null),a=e.contentUrl,o=(0,W.useCallback)(async e=>{let t=await p(a,4096);if(e.aborted)throw Error(`aborted`);return t.content.slice(0,200)},[a]),s=jt({ref:i,enabled:!0,cacheKey:`snippet:${e.id}|${e.contentUrl}|${e.size??0}`,fetcher:o,fromCache:Mt}),c=s.state===`ready`&&typeof s.data==`string`?s.data:``;return(0,G.jsxs)(`button`,{ref:i,type:`button`,onClick:t,"aria-label":`Preview ${e.displayName}`,className:`flex w-full max-w-md flex-col items-start gap-1 rounded-xl border border-border bg-background p-3 text-left hover:bg-accent/40`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.displayName}),(0,G.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n,r?` · ${r}`:``]}),c?(0,G.jsx)(`pre`,{className:`line-clamp-3 max-h-16 w-full whitespace-pre-wrap break-words text-xs text-muted-foreground`,children:c}):null]})},J=y(`ImageViewMessage`);function Ft({toolId:e,path:t,contentUrl:n,mimeType:r}){let i=J.useScopedStore(e=>e.value),a=J.useScopedStore(e=>e.set),o=we(t);if(!n)return(0,G.jsx)(`div`,{className:`rounded-lg border border-border bg-muted/20 px-3 py-2 text-sm text-muted-foreground`,children:t});let s={id:`image-view-${e}`,contentUrl:n,displayName:o,fileName:o,relativePath:t,mimeType:r,origin:`image_view`};return(0,G.jsxs)(`figure`,{className:`flex flex-col gap-2`,"data-testid":`image-view`,children:[(0,G.jsx)(Nt,{source:s,onOpen:()=>a(!0),variant:`expanded`}),(0,G.jsx)(ee,{source:i?s:null,open:i,onOpenChange:a})]})}function It(e){return(0,G.jsx)(J.Provider,{init:!1,children:(0,G.jsx)(Ft,{...e})})}function Lt({status:e}){return(0,G.jsx)(O,{tone:Ee(e),label:De(e)})}function Rt(){return(0,G.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded border border-border bg-card px-1.5 py-0.5 text-xs font-medium tracking-wide text-muted-foreground`,children:`started…`})}function zt({name:e,description:t,run:n}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,G.jsx)(N,{className:`size-4 text-muted-icon shrink-0`}),(0,G.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:e??`Workflow`}),t&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:t}),n?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Lt,{status:n.status}),n.agentCount!=null&&n.agentCount>0&&(0,G.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[n.agentCount,` agents`]})]}):(0,G.jsx)(Rt,{})]})]})}var Y={serverOverloaded:{failureClass:`transient`,shape:`string`,describe:e=>`${e} is temporarily at capacity. Retry, or switch to another model.`},internalServerError:{failureClass:`transient`,shape:`string`,describe:e=>`${e} hit a server-side error. Retrying usually clears it.`},httpConnectionFailed:{failureClass:`transient`,shape:`object`,describe:()=>`Could not reach the model provider. Check your connection, then retry.`},responseStreamConnectionFailed:{failureClass:`transient`,shape:`object`,describe:()=>`The response stream failed to connect. Retry to start a new stream.`},responseStreamDisconnected:{failureClass:`transient`,shape:`object`,describe:()=>`The response stream disconnected mid-turn. Retry to pick up from where it stopped.`},responseTooManyFailedAttempts:{failureClass:`transient`,shape:`object`,describe:e=>`${e} failed repeatedly while streaming. Retry, or switch to another model.`},usageLimitExceeded:{failureClass:`quota`,shape:`string`,describe:()=>`You have reached your Codex usage limit. Access returns when the limit window resets.`},sessionBudgetExceeded:{failureClass:`quota`,shape:`string`,describe:()=>`This session reached its configured token budget.`},unauthorized:{failureClass:`auth`,shape:`string`,describe:()=>"Codex rejected the credentials for this request. Re-authenticate with `codex login`."},contextWindowExceeded:{failureClass:`fatal`,shape:`string`,describe:e=>`The conversation no longer fits in ${e}'s context window. Start a new chat or compact this one.`},badRequest:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex rejected the request as malformed.`},cyberPolicy:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex declined this request under its usage policy.`},sandboxError:{failureClass:`fatal`,shape:`string`,describe:()=>`The Codex sandbox failed to run the requested command.`},threadRollbackFailed:{failureClass:`fatal`,shape:`string`,describe:()=>`Codex could not roll the conversation back to the requested point.`},activeTurnNotSteerable:{failureClass:`fatal`,shape:`object`,describe:()=>`The running turn cannot accept new input. Wait for it to finish, or stop it.`},other:{failureClass:`unknown`,shape:`string`,describe:null}};function X(e){return Object.hasOwn(Y,e)}function Bt(e,t){return Y[e].shape===t}function Vt(e){if(e==null)return null;if(typeof e==`string`)return X(e)&&Bt(e,`string`)?e:null;if(typeof e!=`object`)return null;let t=Object.keys(e);if(t.length!==1)return null;let[n]=t;return X(n)&&Bt(n,`object`)?n:null}function Ht(e){return typeof e==`string`?X(e)?e:null:Vt(e)}function Ut(e){let t=Ht(e);return t===null?`unknown`:Y[t].failureClass}function Wt(e){return Ut(e)===`transient`}var Gt=`The selected model`;function Kt(e,t){let n=Ht(e);if(n===null)return null;let r=Y[n].describe;return r===null?null:r(t??Gt)}var Z=ye(`TranscriptActionCard`,()=>e=>({busyId:null,actionError:null,setBusyId:t=>e({busyId:t}),setActionError:t=>e({actionError:t})})),qt={neutral:`border-border bg-card`,muted:`border-border/50 bg-card/50 opacity-75`,success:`border-emerald-500/30 bg-emerald-500/5`,error:`border-destructive/40 bg-destructive/5`},Jt={primary:`default`,secondary:`secondary`,ghost:`ghost`,destructive:`destructive`};function Yt(e){return(0,G.jsx)(Z.Provider,{init:void 0,children:(0,G.jsx)(Xt,{...e})})}function Xt({title:e,description:t,body:n,errorMessage:r,tone:i=`neutral`,actions:o=[]}){let s=Z.useScopedStore(e=>e.busyId),c=Z.useScopedStore(e=>e.actionError),l=Z.useScopedStoreApi(),u=(0,W.useCallback)(e=>{let t=l.getState();if(t.busyId)return;t.setActionError(null);let n;try{n=e.onClick()}catch(e){_e.error(`[transcript-action-card] sync click threw`,String(e)),l.getState().setActionError(xe(e));return}n instanceof Promise&&(t.setBusyId(e.id),n.then(()=>l.getState().setBusyId(null),T(e=>{_e.error(`[transcript-action-card] async click rejected`,e.message),l.getState().setActionError(e.message),l.getState().setBusyId(null)})))},[l]),d=s!==null;return(0,G.jsxs)(`div`,{"data-focus-fallback-ignore":!0,className:a(`rounded-lg border px-4 py-3 text-sm space-y-2 transition-colors`,qt[i]),children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-3`,children:(0,G.jsxs)(`div`,{className:`space-y-1 min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`font-medium leading-tight`,children:e}),t?(0,G.jsx)(`div`,{className:`text-muted-foreground text-xs leading-snug`,children:t}):null]})}),n?(0,G.jsx)(`div`,{className:`text-xs leading-snug`,children:n}):null,r?(0,G.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,children:r}):null,c?(0,G.jsx)(`div`,{className:`text-destructive text-xs leading-snug`,role:`alert`,children:c}):null,o.length>0?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 pt-1`,children:o.map(e=>{let t=s===e.id;return(0,G.jsxs)(de,{type:`button`,size:`sm`,variant:Jt[e.variant??`ghost`],disabled:e.disabled||d&&!t,pending:t||e.pending===!0,onClick:()=>u(e),className:`gap-1.5`,children:[e.icon,e.label]},e.id)})}):null]})}function Zt(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h${r>0?` ${r}m`:``}`:r>0?`${r}m${i>0?` ${i}s`:``}`:`${i}s`}function Qt({durationMs:e,prefix:t=`Worked for`}){return e<=0?null:(0,G.jsxs)(b,{children:[t,` `,Zt(e)]})}var Q=/\[([^\]]+)\]\(\/chat\/([0-9a-fA-F][0-9a-fA-F-]{7,})\)/g;function $t(e,t){let r=[],i=0,a=0;Q.lastIndex=0;for(let o=Q.exec(e);o!==null;o=Q.exec(e))o.index>i&&r.push(e.slice(i,o.index)),r.push((0,G.jsx)(n,{to:Oe(o[2]),className:t??`underline decoration-destructive/40 hover:decoration-destructive`,children:o[1]},`chat-link-${a++}`)),i=o.index+o[0].length;return i<e.length&&r.push(e.slice(i)),r.length===0?e:r}function en({resultMessageId:e,body:t,onRetry:n}){let r=[{id:`retry`,label:`Retry`,variant:`primary`,onClick:(0,W.useCallback)(()=>n(e),[n,e])}];return(0,G.jsx)(`div`,{className:`mx-2 my-1`,children:(0,G.jsx)(Yt,{title:`Turn failed`,tone:`error`,body:t,actions:r})})}function tn({message:e,onRetry:t}){if(!e.success){let n=e.codexErrorInfo,r=(n?Kt(n,null):null)??e.result??``,i=r.trim().length>0,a=n!==void 0&&Wt(n),o=null;return a&&t?o=(0,G.jsx)(en,{resultMessageId:e.id,body:r,onRetry:t}):i&&(o=(0,G.jsx)(`div`,{className:`px-4 py-3 mx-2 my-1 rounded-lg bg-destructive/10 border border-destructive/20 text-destructive text-sm whitespace-pre-wrap`,children:$t(r)})),(0,G.jsxs)(G.Fragment,{children:[o,e.durationMs>0?(0,G.jsx)(Qt,{durationMs:e.durationMs,prefix:`Failed after`}):null]})}return(0,G.jsx)(Qt,{durationMs:e.durationMs})}var nn=`<persisted-output>`,rn=`</persisted-output>`,an=RegExp(`${nn}\\n?`,`g`),on=RegExp(`\\n?${rn}`,`g`);function sn(e){return e.replace(an,``).replace(on,``)}function cn(e){return typeof e==`string`?e:JSON.stringify(e,null,2)}function ln({message:e,localPath:t,isRunning:n=!1}){if(e.kind===`tool`&&e.persisted){let t=sn(cn(e.rawResult??``));return(0,G.jsxs)(`div`,{className:`animate-in fade-in-0 duration-200 rounded-md border border-border bg-muted/30 p-2 space-y-1 text-xs`,children:[(0,G.jsxs)(`div`,{className:`font-medium`,children:[e.toolName,`: output too large (`,o(e.persisted.originalSize),`) — saved to disk`]}),(0,G.jsx)(`pre`,{className:`text-xs whitespace-pre-wrap overflow-hidden max-h-48`,children:t}),(0,G.jsxs)(`a`,{href:Ce(e.persisted.filePath),className:`text-blue-500 hover:underline break-all`,target:`_blank`,rel:`noreferrer`,children:[`View full output (`,e.persisted.filePath,`)`]})]})}let r;switch(e.kind){case`assistant_text`:r=(0,G.jsx)(bt,{message:e});break;case`assistant_thinking`:r=(0,G.jsx)(xt,{message:e});break;case`tool`:r=(0,G.jsx)(Dn,{message:e,isLoading:n,localPath:t});break;case`result`:r=(0,G.jsx)(tn,{message:e});break;default:return null}return(0,G.jsx)(`div`,{className:`animate-in fade-in-0 duration-200`,children:r})}var un=(0,W.createContext)(null);function dn({children:e,value:t}){return(0,G.jsx)(un.Provider,{value:t,children:e})}function fn(){return(0,W.useContext)(un)}var pn=[],$=ye(`SubagentTaskMessage`,()=>e=>({expanded:!1,loading:!1,loaded:!1,children:pn,error:null,setExpanded:t=>e({expanded:t}),setLoading:t=>e({loading:t}),setLoaded:t=>e({loaded:t}),setChildren:t=>e({children:t}),setError:t=>e({error:t})}));function mn(e,t){return t||e===`failed`||e===`error`?`destructive`:e===`in_progress`||e===`running`?`active`:`muted`}function hn(e){if(!e)return``;let t=[],n=(e,n,r)=>{e&&e>0&&t.push(`${e} ${e===1?n:r}`)};return n(e.readCount,`read`,`reads`),n(e.editFileCount,`edit`,`edits`),n(e.bashCount,`cmd`,`cmds`),n(e.searchCount,`search`,`searches`),n(e.otherToolCount,`tool`,`tools`),t.join(` · `)}function gn({subagentType:e,result:t,isError:n,localPath:r}){let i=e||`Agent`,o=mn(t?.status,n),c=hn(t?.toolStats),l=fn(),u=t?.agentId,d=!!(l&&u),f=$.useScopedStore(e=>e.expanded),p=$.useScopedStore(e=>e.loading),m=$.useScopedStore(e=>e.loaded),h=$.useScopedStore(e=>e.children),g=$.useScopedStore(e=>e.error),_=$.useScopedStore(e=>e.setExpanded),v=$.useScopedStore(e=>e.setLoading),y=$.useScopedStore(e=>e.setLoaded),b=$.useScopedStore(e=>e.setChildren),x=$.useScopedStore(e=>e.setError),ee=(0,W.useCallback)(()=>{if(!l||!u)return;let e=!f;_(e),e&&!m&&!p&&(v(!0),x(null),l(u).then(e=>{b(ut(e)),y(!0)}).catch(T(e=>x(e.message))).finally(()=>v(!1)))},[l,u,f,m,p,_,v,x,b,y]),S=(0,G.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[d?(0,G.jsx)(s,{className:a(`size-4 text-muted-icon shrink-0 transition-transform`,f&&`rotate-90`),"aria-hidden":!0}):(0,G.jsx)(P,{className:`size-4 text-muted-icon shrink-0`}),(0,G.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 min-w-0 overflow-hidden`,children:[(0,G.jsx)(`span`,{className:`font-medium text-foreground/80 text-sm truncate`,children:i}),t?.status&&(0,G.jsx)(O,{tone:o,label:t.status}),t?.totalTokens!=null&&t.totalTokens>0&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums`,children:[(0,G.jsx)(Pe,{className:`size-3`,"aria-hidden":!0}),se(t.totalTokens),` tokens`]}),t?.totalDurationMs!=null&&t.totalDurationMs>0&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:ke(t.totalDurationMs)}),c&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground tabular-nums truncate`,children:c}),p&&(0,G.jsx)(ue,{className:`size-3 animate-spin text-muted-foreground`,"aria-label":`Loading`})]})]});return d?(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`button`,{type:`button`,onClick:ee,"aria-expanded":f,className:`w-full text-left cursor-pointer`,children:S}),f&&(0,G.jsxs)(`div`,{className:`mt-2 ml-2 border-l-2 border-muted-foreground/20 pl-3 space-y-2`,children:[g&&(0,G.jsx)(`div`,{className:`text-xs text-destructive`,children:g}),!g&&m&&h.length===0&&(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:`No subagent activity recorded.`}),h.map(e=>(0,G.jsx)(ln,{message:e,localPath:r??``},e.id))]})]}):S}var _n=ve($,gn),vn=[],yn=ge()(e=>({byChat:{},setRuns:(t,n)=>e(e=>({byChat:{...e.byChat,[t]:n}}))}));function bn(e){return t=>t.byChat[e]??vn}function xn({images:e}){return(0,G.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,t)=>{let n=e.mimeType||`image/png`;return(0,G.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border bg-muted/20`,children:(0,G.jsx)(`img`,{src:`data:${n};base64,${e.data}`,alt:`Read result ${t+1}`,className:`max-h-[50vh] w-full object-contain bg-background`})},`${n}:${t}`)})})}function Sn(e){return e.type===`image`}function Cn({result:e,resultText:t}){let n=typeof e==`object`?(e.blocks??[]).filter(Sn):[];return n.length===0?(0,G.jsx)(K,{content:t}):(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:`Image`}),(0,G.jsx)(`div`,{className:`mt-1`,children:(0,G.jsx)(xn,{images:n})})]})}function wn(e){return(0,G.jsxs)(`span`,{className:`flex items-center gap-2 w-full`,children:[(0,G.jsx)(`span`,{children:`Command`}),!!e.timeoutMs&&(0,G.jsxs)(`span`,{className:`text-muted-foreground`,children:[`timeout: `,String(e.timeoutMs),`ms`]}),!!e.runInBackground&&(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`background`})]})}function Tn(e){switch(e.toolKind){case`edit_file`:return(0,G.jsx)(K,{content:``,isDiff:!0,oldString:e.input.oldString,newString:e.input.newString});case`delete_file`:return(0,G.jsx)(K,{content:e.input.content});case`read_file`:case`write_file`:case`image_view`:return null;case`bash`:return(0,G.jsx)(m,{label:wn(e.input),copyText:e.input.command,children:e.input.command});default:{let t=JSON.stringify(e.input,null,2);return(0,G.jsx)(m,{label:`Input`,copyText:t,children:t})}}}function En(e,t){let n=e.result!==void 0,r=!e.isError,i=n?(0,G.jsx)(m,{label:r?`Result`:`Error`,copyText:t,children:t}):null;switch(e.toolKind){case`read_file`:return n&&r?(0,G.jsx)(Cn,{result:e.result,resultText:t}):null;case`image_view`:return r?(0,G.jsx)(It,{toolId:e.toolId,path:e.input.path,contentUrl:e.input.contentUrl,mimeType:e.input.mimeType}):i;case`write_file`:return r?(0,G.jsx)(K,{content:e.input.content}):i;case`edit_file`:case`delete_file`:return r?null:i;default:return i}}function Dn({message:e,isLoading:t=!1,localPath:n,chatId:r=``}){let i=e.result===void 0&&t,a=yn(ce(bn(r))),o=(0,W.useMemo)(()=>_t(e,n),[e,n]),s=(0,W.useMemo)(()=>{if(typeof e.result==`string`)return e.result;if(!e.result)return``;if(be(e.result)){let t=e.result.content;if(typeof t==`string`)return t}return JSON.stringify(e.result,null,2)},[e.result]),l;if(e.toolKind===`workflow`&&!e.isError){let t=e.result?.taskId,n=t?a.find(e=>e.taskId===t):void 0;l=(0,G.jsx)(zt,{name:e.input.name,description:e.input.description,run:n})}else l=e.toolKind===`subagent_task`&&e.result?(0,G.jsx)(_n,{subagentType:e.input.subagentType,result:e.result,isError:e.isError,localPath:n}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`w-5 h-5 relative flex items-center justify-center`,children:e.isError?(0,G.jsx)(me,{className:`size-4 text-destructive`}):(0,G.jsx)(te,{icon:ht(e),className:`size-4 text-muted-icon`})}),(0,G.jsx)(S,{className:`text-left transition-opacity duration-200 truncate`,children:(0,G.jsx)(St,{animate:i,children:o})})]});return(0,G.jsx)(u,{className:`w-full`,children:(0,G.jsx)(g,{expandedContent:(0,G.jsx)(c,{className:`my-4 text-sm`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[Tn(e),En(e,s)]})}),children:l})})}export{Pe as S,ut as _,ln as a,We as b,Yt as c,St as d,xt as f,gt as g,ft as h,dn as i,Lt as l,yt as m,bn as n,tn as o,bt as p,yn as r,$t as s,Dn as t,Nt as u,Ze as v,N as x,P as y};
|