@cuongtran001/kanna 1.97.0 → 1.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/assets/{BoardsPage-D3TlgAZ_.js → BoardsPage-CPdXl_9L.js} +1 -1
- package/dist/client/assets/{BoardsRoutePage-VkxV-IFk.js → BoardsRoutePage-DrTFjpAZ.js} +1 -1
- package/dist/client/assets/{ChatPage-Dscf_7rF.js → ChatPage-CGQoeYXf.js} +7 -7
- package/dist/client/assets/{CronJobsPage-CRkUkXat.js → CronJobsPage-B7o8EhRk.js} +1 -1
- package/dist/client/assets/{FilePreviewSheet-DeowWf5y.js → FilePreviewSheet-CfXThsQp.js} +1 -1
- package/dist/client/assets/{FlowSurface-CWsaGLfa.js → FlowSurface-CdVOTRYI.js} +1 -1
- package/dist/client/assets/{GenUIBlock-Bv-OFgT5.js → GenUIBlock-B3QE4V69.js} +2 -2
- package/dist/client/assets/{InboundHandlerFields-Bz-crPWC.js → InboundHandlerFields-CDVZGRJq.js} +1 -1
- package/dist/client/assets/InboxPage-C29v9zbq.js +1 -0
- package/dist/client/assets/{LocalProjectsPage-Lx4uBsJV.js → LocalProjectsPage-BYEjT-DZ.js} +1 -1
- package/dist/client/assets/SettingsPage-Bl7lDxe0.js +17 -0
- package/dist/client/assets/{StackBoardsRoutePage-Uy6E-3Gl.js → StackBoardsRoutePage-D8OwGaO7.js} +1 -1
- package/dist/client/assets/{ToolCallMessage-DEfxdq5H.js → ToolCallMessage-BFqfgkCH.js} +1 -1
- package/dist/client/assets/{VChartSurface-UFK0UlX-.js → VChartSurface-CMQoKhau.js} +1 -1
- package/dist/client/assets/{WebhooksPage-6ALLVh_l.js → WebhooksPage-DMmDX-ms.js} +2 -2
- package/dist/client/assets/{WorkflowsPage-1i5hmCxm.js → WorkflowsPage-DvfGbRlt.js} +1 -1
- package/dist/client/assets/{appSettingsStore-DhpIEBz2.js → appSettingsStore-BkV1YU8S.js} +1 -1
- package/dist/client/assets/{arrow-left-Bto85Swe.js → arrow-left-CjtboDsu.js} +1 -1
- package/dist/client/assets/{beacon-alias-HmDCskK6.js → beacon-alias-rXxwPHhZ.js} +3 -3
- package/dist/client/assets/{code-xml-DVVP_fVN.js → code-xml-C3fKotSy.js} +1 -1
- package/dist/client/assets/{commandFeedback-2cA8d_WY.js → commandFeedback-C8JG7P5C.js} +1 -1
- package/dist/client/assets/{contextWindow-B9Tu0rKj.js → contextWindow-h4X5oJjz.js} +1 -1
- package/dist/client/assets/{copyFeedbackStore-CNP3tyq0.js → copyFeedbackStore-DAsM7m9s.js} +1 -1
- package/dist/client/assets/{createScopedStore-jAn6kJBy.js → createScopedStore-VWkEjqnA.js} +1 -1
- package/dist/client/assets/{cronJobsStore-OUyVs58Z.js → cronJobsStore-DBkn33E8.js} +1 -1
- package/dist/client/assets/{file-plus-corner-DY_1K1Ne.js → file-plus-corner-TXCx13rk.js} +1 -1
- package/dist/client/assets/inboxStore-CC3pAzZZ.js +1 -0
- package/dist/client/assets/index-QA9eWHUp.css +1 -0
- package/dist/client/assets/{index-DUJdXxNz.js → index-R-jfstMQ.js} +14 -14
- package/dist/client/assets/{info-BcA9_4Qg.js → info-Dc1D2lOq.js} +1 -1
- package/dist/client/assets/{input-DbE6EzUB.js → input-B23WM9u5.js} +1 -1
- package/dist/client/assets/{log-CFGrfkV1.js → log-DL1J6840.js} +1 -1
- package/dist/client/assets/minus-DpXqEYpv.js +1 -0
- package/dist/client/assets/{monitor-Bd61vIbY.js → monitor-CnCS7O8D.js} +1 -1
- package/dist/client/assets/{pencil-Kx3rEkBI.js → pencil-DbIlj5g0.js} +1 -1
- package/dist/client/assets/{pendingActionsStore-C6o78Bki.js → pendingActionsStore-Bks-EsV3.js} +1 -1
- package/dist/client/assets/{plus-D5yDJAY3.js → plus-BmhG7IUi.js} +1 -1
- package/dist/client/assets/{refresh-cw-CxKjA56k.js → refresh-cw-BxmkSO32.js} +1 -1
- package/dist/client/assets/runDetached-BTPJqi-A.js +1 -0
- package/dist/client/assets/{search-mHZVZKtE.js → search-BUOQUhrF.js} +1 -1
- package/dist/client/assets/{searchable-select-B47fAmOU.js → searchable-select-ByMK5CZ8.js} +1 -1
- package/dist/client/assets/{segmented-control--alEtfTe.js → segmented-control-BXlWFDM8.js} +1 -1
- package/dist/client/assets/{select-BO0FDRBe.js → select-B-SEd4I2.js} +1 -1
- package/dist/client/assets/{settings-header-button-j3Rd0uOx.js → settings-header-button-DQUmCPE_.js} +1 -1
- package/dist/client/assets/{state-mark-Wim8WKu4.js → state-mark-Hjx5ToFs.js} +1 -1
- package/dist/client/assets/{terminal-BLkQOd9o.js → terminal-gOELI9ta.js} +1 -1
- package/dist/client/assets/{timer.adapter-DTTP0Zuq.js → timer.adapter-DgrMEqxC.js} +1 -1
- package/dist/client/assets/{tools-BxqpIPAt.js → tools-MfK2-0IV.js} +1 -1
- package/dist/client/assets/{triangle-alert-B3zlPujO.js → triangle-alert-DnqNE8_X.js} +1 -1
- package/dist/client/assets/{useAppGlobalState-BkMT4XZb.js → useAppGlobalState-BTVDcR0Z.js} +1 -1
- package/dist/client/assets/{useProviderCatalog-BlO4bNcc.js → useProviderCatalog-CxmLsNAf.js} +1 -1
- package/dist/client/assets/{useTheme-DqpsYqBt.js → useTheme-BWGWet54.js} +1 -1
- package/dist/client/index.html +32 -32
- package/package.json +1 -1
- package/src/server/inbound/inbox-reply.test.ts +24 -4
- package/src/server/inbound/inbox-reply.ts +6 -4
- package/src/server/inbound/referenced-chat-ids.test.ts +55 -0
- package/src/server/inbound/referenced-chat-ids.ts +22 -0
- package/src/server/inbox/inbox-boot.test.ts +65 -1
- package/src/server/inbox/inbox-boot.ts +24 -4
- package/src/server/inbox/inbox-outbox.test.ts +229 -0
- package/src/server/inbox/inbox-outbox.ts +107 -0
- package/src/server/inbox/inbox-projection.ts +50 -1
- package/src/server/inbox/inbox-registry.test.ts +56 -0
- package/src/server/inbox/inbox-registry.ts +87 -4
- package/src/server/mcp-sources/mcp-source-client.adapter.test.ts +38 -1
- package/src/server/mcp-sources/mcp-source-client.adapter.ts +13 -7
- package/src/server/mcp-sources/mcp-source-runner.test.ts +69 -0
- package/src/server/mcp-sources/mcp-source-runner.ts +67 -12
- package/src/server/mcp-sources/mcp-sources-boot.test.ts +11 -0
- package/src/server/mcp-sources/mcp-sources-boot.ts +6 -1
- package/src/server/mcp-sources-settings.test.ts +42 -1
- package/src/server/mcp-sources-settings.ts +25 -10
- package/src/server/push/push-manager.test.ts +2 -0
- package/src/server/server.ts +11 -2
- package/src/server/ws-router-abandoned-chat.test.ts +17 -1
- package/src/server/ws-router-broadcast.ts +3 -1
- package/src/server/ws-router-command-results.test.ts +6 -2
- package/src/server/ws-router-inbox.ts +45 -13
- package/src/server/ws-router.ts +7 -6
- package/src/shared/commands/inbox.ts +12 -4
- package/src/shared/commands/results/inbox.ts +8 -0
- package/src/shared/inbound/reply-args.test.ts +45 -0
- package/src/shared/inbound/reply-args.ts +48 -0
- package/src/shared/inbound/reply-prompt.test.ts +20 -6
- package/src/shared/inbound/reply-prompt.ts +22 -6
- package/src/shared/inbound/template.test.ts +6 -0
- package/src/shared/inbound/template.ts +11 -2
- package/src/shared/inbox/events.ts +50 -3
- package/src/shared/inbox/policy.test.ts +2 -0
- package/src/shared/inbox/policy.ts +23 -1
- package/src/shared/inbox/quick-prompts.ts +24 -0
- package/src/shared/inbox/types.schema.ts +25 -0
- package/src/shared/inbox/types.ts +48 -0
- package/src/shared/mcp-sources/presets.ts +10 -2
- package/src/shared/mcp-sources/types.schema.ts +15 -1
- package/src/shared/mcp-sources/types.ts +17 -0
- package/src/shared/mcp-sources/validate.test.ts +9 -0
- package/src/shared/mcp-sources/validate.ts +39 -2
- package/dist/client/assets/InboxPage-Cx2I-D9G.js +0 -1
- package/dist/client/assets/SettingsPage-QUQTA-qY.js +0 -17
- package/dist/client/assets/inboxStore-q-JHTh--.js +0 -1
- package/dist/client/assets/index-D_XO3fZ-.css +0 -1
- package/dist/client/assets/minus-jIhdwm1f.js +0 -1
- package/dist/client/assets/runDetached-138oevj9.js +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
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{A as a,At as o,E as s,Mt as c,N as l,Nt as u,P as d,Pt as f,St as p,T as m,Tt as h,U as g,_,a as v,c as y,d as b,g as ee,h as x,ht as te,j as S,l as ne,m as C,n as w,o as re,s as ie,u as ae,wt as T}from"./useAppGlobalState-BTVDcR0Z.js";import{a as oe,d as E,f as D,h as O,i as se,l as k,m as A,n as j,o as ce,r as M,t as N,u as le}from"./pendingActionsStore-Bks-EsV3.js";import{a as ue,l as de,n as fe,o as pe}from"./beacon-alias-rXxwPHhZ.js";import{a as me,i as he,n as ge,o as _e,t as ve}from"./copyFeedbackStore-DAsM7m9s.js";import{a as ye,i as P,n as be,o as xe,r as Se,t as Ce}from"./select-B-SEd4I2.js";import{t as we}from"./info-Dc1D2lOq.js";import{c as Te,r as Ee,s as De}from"./contextWindow-h4X5oJjz.js";import{t as Oe}from"./monitor-CnCS7O8D.js";import{t as ke}from"./pencil-DbIlj5g0.js";import{t as Ae}from"./plus-BmhG7IUi.js";import{t as je}from"./refresh-cw-BxmkSO32.js";import{t as Me}from"./search-BUOQUhrF.js";import{A as Ne,B as Pe,C as Fe,D as Ie,E as Le,F as Re,L as ze,M as Be,N as Ve,O as He,P as Ue,R as We,T as Ge,U as Ke,V as qe,Z as Je,a as Ye,c as Xe,i as Ze,o as Qe,r as $e,s as et,t as tt,w as nt,z as rt}from"./useProviderCatalog-CxmLsNAf.js";import{g as it,i as at,n as ot,o as st,r as ct,t as lt,u as ut}from"./timer.adapter-DgrMEqxC.js";import{a as dt,c as ft,o as pt,s as mt,t as F}from"./segmented-control-BXlWFDM8.js";import{d as ht,f as I,i as gt,n as L,r as _t,s as vt}from"./log-DL1J6840.js";import{t as R}from"./input-B23WM9u5.js";import{f as yt,i as bt,o as xt,u as St}from"./core-types-Ds7PFmZN.js";import{$ as Ct,A as wt,B as Tt,C as Et,D as Dt,E as Ot,G as kt,H as At,I as jt,J as Mt,K as Nt,M as Pt,O as Ft,Q as It,S as Lt,T as Rt,U as zt,V as Bt,W as Vt,X as Ht,Y as Ut,_ as z,a as Wt,c as Gt,d as Kt,f as qt,g as Jt,h as Yt,i as Xt,it as Zt,j as Qt,k as $t,l as en,lt as tn,m as nn,n as rn,nt as an,o as on,p as sn,q as cn,r as ln,rt as un,s as dn,st as fn,t as pn,tt as mn,u as hn,y as gn}from"./appSettingsStore-BkV1YU8S.js";import{M as _n,N as vn,iu as yn,j as bn,r as xn,ru as Sn}from"./useTheme-BWGWet54.js";import{t as Cn}from"./runDetached-BTPJqi-A.js";import{t as wn}from"./dom.adapter-C26vNdMA.js";import{_ as Tn,a as B,g as En,h as Dn,r as On,y as kn}from"./commandFeedback-C8JG7P5C.js";import{a as An,n as jn}from"./state-mark-Hjx5ToFs.js";import{n as Mn,t as Nn}from"./formatDuration-BbWTR_M_.js";import{n as Pn}from"./cronJobsStore-DBkn33E8.js";import{bt as Fn,en as In,hn as Ln,vt as Rn,yn as zn,yt as Bn}from"./index-R-jfstMQ.js";import{_ as Vn,c as Hn,d as Un,g as Wn,l as Gn,s as Kn,u as qn,v as Jn,x as Yn,y as Xn}from"./ChatPage-CGQoeYXf.js";import{a as Zn,c as Qn,d as $n,f as er,i as tr,l as nr,o as rr,p as ir,s as ar,t as or,u as sr}from"./searchable-select-ByMK5CZ8.js";import{t as cr}from"./settings-header-button-DQUmCPE_.js";import{t as lr}from"./InboundHandlerFields-CDVZGRJq.js";var ur={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`}]]};ur.node;var dr=O(ur),fr={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`}]]};fr.node;var pr=O(fr),mr={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`]};mr.node;var hr=O(mr),gr={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`]};gr.node;var _r=O(gr),vr={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`]};vr.node;var yr=O(vr),br={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`}]]};br.node;var xr=O(br),Sr={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`}]]};Sr.node;var Cr=O(Sr),wr={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`}]]};wr.node;var Tr=O(wr),Er={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`}]]};Er.node;var Dr=O(Er),Or={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`}]]};Or.node;var kr=O(Or),Ar={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`}]]};Ar.node;var jr=O(Ar),Mr={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`}]]};Mr.node;var Nr=O(Mr),Pr={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`}]]};Pr.node;var Fr=O(Pr),Ir={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`}]]};Ir.node;var Lr=O(Ir),Rr={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`}]]};Rr.node;var zr=O(Rr),Br={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`}]]};Br.node;var Vr=O(Br),Hr={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`}]]};Hr.node;var Ur=O(Hr),Wr={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`}]]};Wr.node;var Gr=O(Wr),Kr={enabled:!1,cloudflaredPath:`cloudflared`,mode:`always-ask`},V=e(t(),1),H=e(i(),1);function qr(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 Jr={maxFileSizeMb:2048},Yr={path:`uploads.maxFileSizeMb`,min:1,max:51200,integer:!1},Xr=I()(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:D(`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 Zr({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 Qr({children:e}){return(0,H.jsx)(`ul`,{className:`flex flex-col divide-y rounded-md border`,children:e})}function $r({label:e,onEdit:t,onDelete:n,deletePending:r=!1}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:t,"aria-label":`Edit ${e}`,children:(0,H.jsx)(ke,{className:`h-4 w-4`})}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:n,pending:r,"aria-label":`Delete ${e}`,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})]})}var ei=new Set([`checking`,`downloading`,`installing`,`restarting`]);function ti(e){return e!==null&&ei.has(e.state)}function ni(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 ri(e){switch(e.state){case`failed`:return`destructive`;case`current`:return`muted`;case`checking`:case`downloading`:case`installing`:case`restarting`:return`active`}}var ii={},ai={},oi={},si={};function ci(e,t){return`${e}:${t}`}function li(e,t,n){let r=Object.fromEntries(Object.entries(e).filter(([e])=>e!==t));return Object.keys(r).length>0?r:n}var W=I()(e=>({pairing:null,expandedId:null,drafts:ii,updateErrors:ai,aliasErrors:oi,openExplanations:si,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:li(e.drafts,t,ii)})),setUpdateError:(t,n)=>e(e=>n===null?{updateErrors:li(e.updateErrors,t,ai)}:{updateErrors:{...e.updateErrors,[t]:n}}),beginAliasEdit:(t,n)=>e(e=>({drafts:{...e.drafts,[ci(t,`alias`)]:n}})),endAliasEdit:t=>e(e=>({drafts:li(e.drafts,ci(t,`alias`),ii),aliasErrors:li(e.aliasErrors,t,oi)})),setAliasError:(t,n)=>e(e=>n===null?{aliasErrors:li(e.aliasErrors,t,oi)}:{aliasErrors:{...e.aliasErrors,[t]:n}}),toggleExplanation:t=>e(e=>({openExplanations:t in e.openExplanations?li(e.openExplanations,t,si):{...e.openExplanations,[t]:!0}}))})),ui=`kanna-beacon`,di=`ABCDEFGHJKLMNPQRSTUVWXYZ23456789`,fi=`https://github.com/cuongtranba/kanna/releases/latest`;RegExp(`^[${di}]{8}$`);function pi(e){return`${ui}://pair?url=${encodeURIComponent(e.kannaUrl)}&code=${encodeURIComponent(e.code)}`}function mi(e){return`kanna-beacon pair ${e.kannaUrl} ${e.code}`}function hi(e){return e.replace(/^v/,``).split(`-`)[0].split(`.`).map(e=>Number.parseInt(e,10))}function gi(e,t){if(e===t)return!1;let n=hi(e),r=hi(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 _i={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 vi({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)(En,{label:`Set a short name`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-label":`Set a short name for ${n}`,children:(0,H.jsx)(ke,{className:`h-3.5 w-3.5`})})})}function yi({beaconId:e,alias:t,displayName:n,onSetAlias:r}){let i=ci(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=N(`beacons.setAlias`,e),d=M(u),f=a??``,p=f.length===0?null:ue(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=>{j(u,async()=>{try{await r(e,t),l(e)}catch(t){c(e,L(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)(k,{size:`sm`,onClick:v,pending:d,disabled:!m,children:`Save`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:b,disabled:d,children:`Cancel`}),t!==null&&(0,H.jsx)(k,{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 bi=`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.`,xi=`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.`,Si=`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.`,Ci=`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.`,wi=`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 Ti(e){return`beacon-explain-${e}`}function Ei({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)(En,{label:`What does this do?`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon-sm`,onClick:i,"aria-expanded":n,"aria-controls":Ti(e),"aria-label":`What does "${t}" do?`,children:(0,H.jsx)(we,{className:`h-4 w-4`})})})}function Di({explanationKey:e,text:t}){let n=W(t=>e in t.openExplanations);return(0,H.jsx)(`p`,{id:Ti(e),hidden:!n,className:`text-13 text-muted-foreground`,children:t})}function Oi({beaconId:e,scope:t,onSetScope:n}){let r=N(`beacons.setScope`,e),i=M(r),a=(0,V.useCallback)(t=>{j(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)(ki,{explanationKey:ci(e,`exec`),checked:t.exec,disabled:i,onChange:o,title:`Allow running commands`,explanation:bi}),(0,H.jsx)(ki,{explanationKey:ci(e,`autoRunScripts`),checked:t.autoRunScripts,disabled:i,onChange:s,title:`Run commands and scripts from this chat without asking each time`,explanation:xi}),(0,H.jsx)(Ai,{label:`Folders the agent may read`,explanation:Si,placeholder:`/Users/me/projects`,draftKey:ci(e,`readRoots`),items:t.readRoots,disabled:i,onChange:c}),(0,H.jsx)(Ai,{label:`Folders the agent may write to`,explanation:Ci,placeholder:`/Users/me/inbox`,draftKey:ci(e,`writeRoots`),items:t.writeRoots,disabled:i,onChange:l}),(0,H.jsx)(Ai,{label:`Commands that always run without asking`,explanation:wi,placeholder:`git`,draftKey:ci(e,`execAllowlist`),items:t.execAllowlist,disabled:i,onChange:u})]})}function ki({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)(Ei,{explanationKey:e,subject:i})]}),(0,H.jsx)(`div`,{className:`pl-7`,children:(0,H.jsx)(Di,{explanationKey:e,text:a})})]})}function Ai({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)(Ei,{explanationKey:r,subject:e})]}),(0,H.jsx)(Di,{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)(ji,{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)(k,{variant:`secondary`,size:`sm`,onClick:p,disabled:a||!d,children:`Add`})]})]})}function ji({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)(k,{variant:`ghost`,size:`icon-sm`,onClick:r,disabled:t,"aria-label":`Remove ${e}`,children:(0,H.jsx)(it,{className:`h-4 w-4`})})]})}var Mi=N(`beacons.mintPairingCode`);function Ni(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 Pi({rows:e,configs:t,handlers:n,serverVersion:r,dom:i=wn,clipboard:a=he,timer:o=lt}){let s=Pn(1e3),c=(0,V.useMemo)(()=>Ni(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)(Fi,{now:s,handlers:n,dom:i,clipboard:a,timer:o}),c.length===0?(0,H.jsx)(Zr,{icon:Jn,message:`No machines paired yet. Pair a machine to let the agent read files and run approved commands there.`}):(0,H.jsx)(Qr,{children:c.map(e=>(0,H.jsx)(Vi,{row:e,scope:l.get(e.id)?.scope??null,now:s,serverVersion:r,handlers:n,dom:i},e.id))})]})}function Fi({now:e,handlers:t,dom:n,clipboard:r,timer:i}){let a=W(e=>e.pairing),o=W(e=>e.setPairing),s=M(Mi),c=(0,V.useCallback)(()=>{j(Mi,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)(k,{size:`sm`,variant:a?.ok===!0?`secondary`:`default`,onClick:c,pending:s,children:[(0,H.jsx)(Ae,{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)(Ii,{code:a.code,expiresAt:a.expiresAt,now:e,dom:n,clipboard:r,timer:i})]})}function Ii({code:e,expiresAt:t,now:n,dom:r,clipboard:i,timer:a}){let o=t-n,s=r.getOrigin(),c=mi({kannaUrl:s,code:e}),l=pi({kannaUrl:s,code:e}),u=N(`beacons.copyPairCommand`,e),d=M(u),f=ge(u),p=(0,V.useCallback)(()=>{j(u,()=>ve(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 ${Mn(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:le({size:`sm`}),children:[(0,H.jsx)(Ln,{className:`mr-1 h-4 w-4`}),`Open in Kanna Beacon`]}),(0,H.jsx)(`a`,{href:fi,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)(En,{label:f?`Copied`:`Copy command`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon`,onClick:p,pending:d,"aria-label":f?`Copied`:`Copy pairing command`,children:f?(0,H.jsx)(_e,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(me,{className:`h-4 w-4`})})})]})]})}function Li(e,t){return e.lastSeenAt===null?`Never connected`:`Last seen ${Nn(t-e.lastSeenAt)} ago`}var Ri=`This beacon is too old to update itself. Reinstall it once from the download page; after that, updates are one click.`;function zi({canSelfUpdate:e}){let t=D(`rounded-full border px-2 py-0.5 text-xs`,_i.outdated);return e?(0,H.jsx)(`span`,{className:t,children:`Update available`}):(0,H.jsx)(En,{label:Ri,children:(0,H.jsx)(`a`,{href:fi,target:`_blank`,rel:`noreferrer`,className:t,children:`Update available`})})}function Bi({row:e,updateAvailable:t,handlers:n}){let r=N(`beacons.update`,e.id),i=M(r),a=W(t=>t.updateErrors[e.id]??null),o=W(e=>e.setUpdateError),s=t&&e.online&&e.canSelfUpdate&&!ti(e.update),c=(0,V.useCallback)(()=>{j(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)(jn,{tone:ri(e.update),label:ni(e.update)}),s&&(0,H.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:c,pending:i,"aria-label":`Update ${fe(e)} now`,children:[(0,H.jsx)(_r,{className:`mr-1 h-4 w-4`}),`Update now`]}),a!==null&&(0,H.jsx)(`span`,{role:`alert`,className:`text-destructive-text`,children:a})]})}function Vi({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=N(`beacons.setEnabled`,e.id),l=M(c),u=N(`beacons.delete`,e.id),d=M(u),f=fe(e),p=e.beaconVersion!==null&&r!==void 0&&gi(e.beaconVersion,r),m=(0,V.useCallback)(t=>{let n=t.target.checked;j(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.`)&&j(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)(vi,{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)(yi,{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)(jn,{tone:e.online?`active`:`muted`,label:e.online?`Online`:`Offline`}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:Li(e,n)}),e.beaconVersion!==null&&(0,H.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[`v`,e.beaconVersion]}),p&&(0,H.jsx)(zi,{canSelfUpdate:e.canSelfUpdate}),(0,H.jsx)(Bi,{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)(E,{}):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)(k,{variant:`ghost`,size:`sm`,onClick:g,"aria-expanded":o,children:[`Scope`,(0,H.jsx)(zn,{className:D(`ml-1 h-4 w-4 transition-transform`,o&&`rotate-180`)})]}),(0,H.jsx)(En,{label:`Revoke this machine`,children:(0,H.jsx)(k,{variant:`ghost`,size:`icon`,onClick:h,pending:d,"aria-label":`Revoke ${f}`,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})})]})]}),o&&t!==null&&(0,H.jsx)(Oi,{beaconId:e.id,scope:t,onSetScope:i.onSetScope})]})}function Hi(e){let t=d(l),n=z(ln),{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)(Pi,{rows:t,configs:n,handlers:o,serverVersion:vt})}var Ui=3e5,Wi=null;function Gi(e=Date.now){return Wi?e()>=Wi.expiresAt?(Wi=null,null):Wi.releases:null}function Ki(e,t=Date.now){Wi={releases:e,expiresAt:t()+Ui}}async function qi(e,t){let n=t?.now??Date.now,r=t?.force?null:Gi(n);if(r)return r;let i=await e();return Ki(i,n),i}function Ji(e){return e.trim().replace(/^v/i,``)}function Yi(e,t){let n=e=>Ji(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 Xi(e,t,n){return Ji(e)===Ji(n)?{actionLabel:`Update`,pendingLabel:`Updating…`}:Yi(e,t)<0?{actionLabel:`Rollback`,pendingLabel:`Rolling back…`}:{actionLabel:`Install`,pendingLabel:`Installing…`}}function Zi(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 Qi({status:e,releases:t,error:n,onRetry:r,updateSnapshot:i,currentVersion:a,onInstallUpdate:o,onCheckForUpdates:s,onForceReload:c}){let l=M(`update.check`),u=oe(`update.install`),d=M(`update.redeploy`),f=se(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=Ji(m),ee=Ji(h),x=(0,V.useCallback)(async e=>{await o(e)},[o]),te=(0,V.useCallback)(async()=>{await c()},[c]),S=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)(A,{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)(cr,{variant:`outline`,onClick:()=>j(`update.redeploy`,te),disabled:v,children:S?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Re-deploying…`]}):`Re-deploy`}),(0,H.jsx)(cr,{variant:`outline`,onClick:()=>j(`update.check`,s),disabled:g||v,children:g?(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Checking…`]}):`Check for updates`})]}):null,e===`success`&&t.length>0?t.map(e=>{let t=Ji(e.tag_name),n=t===b,r=t===ee;return(0,H.jsxs)(`article`,{className:D(`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:Zi(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:D(le({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)($i,{className:`h-4 w-4`})}),r?(0,H.jsx)(`span`,{className:D(`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[N(`update.install`,e.tag_name)]===!0||_&&!p,{actionLabel:n,pendingLabel:r}=Xi(e.tag_name,h,m);return(0,H.jsx)(cr,{variant:`default`,className:``,onClick:()=>j(N(`update.install`,e.tag_name),()=>x(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)(A,{className:`size-4 animate-spin`}):(0,H.jsx)(yr,{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:de(e.body)}):(0,H.jsx)(`div`,{className:`mt-5 text-sm text-muted-foreground`,children:`No release notes were provided.`})]},e.id)}):null]})}function $i({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 ea=[],ta=I()(e=>({status:`idle`,releases:ea,error:null,loadStarted:()=>e({status:`loading`,error:null}),loaded:t=>e({releases:t,status:`success`}),loadFailed:t=>e({error:t,status:`error`})}));function na(e){let t=ta(e=>e.status),n=ta(e=>e.releases),r=ta(e=>e.error),i=ta(e=>e.loadStarted),a=ta(e=>e.loaded),o=ta(e=>e.loadFailed),s=(0,V.useCallback)(async(t,n)=>{i();try{let r=await qi(e,{force:t});n()||a(r)}catch(e){n()||o(L(e))}},[e,i,a,o]);return(0,V.useEffect)(()=>{let e=!1;return Cn(`changelog.load`,s(!1,()=>e)),()=>{e=!0}},[s]),{status:t,releases:n,error:r,retry:(0,V.useCallback)(()=>{Cn(`changelog.retry`,s(!0,()=>!1))},[s])}}function ra({state:e}){let{socket:t}=e,n=na((0,V.useCallback)(()=>t.command({type:`settings.getChangelog`}),[t]));return(0,H.jsx)(Qi,{status:n.status,releases:n.releases,error:n.error,onRetry:n.retry,updateSnapshot:e.updateSnapshot,currentVersion:vt,onInstallUpdate:t=>e.handleInstallUpdate(t),onCheckForUpdates:()=>e.handleCheckForUpdates({force:!0}),onForceReload:()=>e.handleForceReload()})}var G=I()(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 ia(e,t){e.key===`Enter`&&(t(),e.currentTarget.blur())}function aa(e){return`${e.charAt(0).toUpperCase()}${e.slice(1)}`}var oa=bt.map(e=>({value:e,label:aa(e)})),sa=I()(e=>({chatSoundPreference:Bt,chatSoundId:Tt,setChatSoundPreference:t=>e({chatSoundPreference:zt(t)}),setChatSoundId:t=>e({chatSoundId:At(t)})}));function ca(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(gt(r))},[n,r]),writeAsync:(0,V.useCallback)(e=>n(e).catch(gt(r)),[n,r])}}var la=[{value:`light`,label:`Light`,icon:Vr},{value:`dark`,label:`Dark`,icon:jr},{value:`system`,label:`System`,icon:Oe}],ua=[{value:`sm`,label:`Small`},{value:`md`,label:`Default`},{value:`lg`,label:`Large`},{value:`xl`,label:`Extra Large`},{value:`xxl`,label:`XX-Large`}],da=[{value:`never`,label:`Never`},{value:`unfocused`,label:`When Unfocused`},{value:`always`,label:`Always`}],fa=`settings.chatSoundPreference`,pa=`settings.chatSoundId`;function ma(e,t){return e!==t}function ha(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 ga({updateSnapshot:e}){return(0,H.jsx)(U,{title:`Application Update`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[ha(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??vt]}),(0,H.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[`Latest: `,e?.latestVersion??`Unknown`]})]})})}function _a({state:e}){let{writeAsync:t}=ca(e),n=z(rn),r=z(pn),i=sa(e=>e.setChatSoundPreference),a=sa(e=>e.setChatSoundId),o=M(fa),s=M(pa);function c(e){ma(n,e)&&(i(e),j(fa,()=>t({chatSoundPreference:e})),Cn(`chat sound preview`,In(r,1)))}function l(e){ma(r,e)&&(a(e),j(pa,()=>t({chatSoundId:e})),Cn(`chat sound preview`,In(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)(Ce,{disabled:o,value:n,onValueChange:e=>{Ct(e)&&c(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:da.map(e=>(0,H.jsx)(P,{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)(Ce,{disabled:s,value:r,onValueChange:e=>{It(e)&&l(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:oa.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]})})]})}function va({state:e}){let{write:t}=ca(e),n=z(Gt),r=z(dn),i=S(e=>e.setEditorPreset),a=S(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:jt(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)(Ce,{value:n,onValueChange:e=>{mn(e)&&l(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:Kn.map(e=>(0,H.jsx)(P,{value:e.value,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Hn,{preset:e.value,className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{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=>ia(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 ya({state:e}){let{write:t}=ca(e),{theme:n,setTheme:r}=xn(),i=s(e=>e.typographyOverride),a=s(e=>e.clearTypographyOverride),o=z(e=>e.settings?.typography.scale),c=Zt(i,o);function l(e){r(e),t({theme:e})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ga,{updateSnapshot:e.updateSnapshot}),(0,H.jsx)(U,{title:`Theme`,description:`Choose between light, dark, or system appearance`,children:(0,H.jsx)(F,{value:n,onValueChange:l,options:la,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)(Ce,{value:c,onValueChange:e=>{un(e)&&t({typography:{scale:e}})},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:ua.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]}),i?(0,H.jsx)(k,{type:`button`,variant:`link`,size:`sm`,onClick:a,children:`Use account default`}):null]})}),(0,H.jsx)(_a,{state:e}),(0,H.jsx)(va,{state:e})]})}var ba=[`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`],xa=[`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`],Sa=I()(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})})),Ca=`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`,wa=`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`,Ta=`rounded bg-muted px-1 py-0.5 font-mono text-12 text-foreground`,Ea=`text-xs font-medium tracking-wide text-muted-foreground`,Da=`gap-1.5 disabled:cursor-default disabled:opacity-60`,Oa=`push.enable`,ka=`push.test`,Aa=`push.disable`,ja=`push.contactSubject`;async function Ma(e){try{await e(),Sa.getState().setError(null)}catch(e){Sa.getState().setError(L(e))}}function Na(e,t){j(e,()=>Ma(t))}function Pa(){let e=Sa(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 Fa({pendingKey:e,onRun:t,className:n,label:r,children:i}){let a=M(e);return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>Na(e,t),disabled:a,"aria-busy":a||void 0,"aria-label":r,className:D(n,Da),children:[a?(0,H.jsx)(E,{}):null,i]})}function Ia({localPath:e,muted:t,onMuteToggle:n}){let r=N(`push.setProjectMute`,e),i=M(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=>Na(r,()=>n(e,!t.target.checked)),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),(0,H.jsx)(Tn,{inline:!0,className:`min-w-0 flex-1 font-mono text-12 text-foreground`,tooltip:e,children:e}),i?(0,H.jsx)(E,{className:`text-muted-foreground`}):null]})}function La(e){let{permissionState:t}=e,n=M(ja);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:Ta,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)(Pa,{})]});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)(Fa,{pendingKey:Oa,onRun:e.onEnable,className:wa,children:`Enable on this device`}),(0,H.jsx)(Pa,{})]});let r=new Set(e.config.preferences.mutedProjectPaths),i=e.contactSubjectDraft.trim(),a=qr(i),o=i!==e.contactSubject,s=()=>{a&&o&&Na(ja,()=>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)(Fa,{pendingKey:ka,onRun:e.onTest,className:Ca,children:`Send test`}),(0,H.jsx)(Fa,{pendingKey:Aa,onRun:e.onDisable,className:Ca,children:`Disable`})]}),(0,H.jsx)(Pa,{}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:D(Ea,`flex items-center gap-1.5`),children:[`Contact for delivery`,n?(0,H.jsx)(E,{}):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:D(`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:Ta,children:`mailto:`}),` address or`,` `,(0,H.jsx)(`code`,{className:Ta,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:Ta,children:`mailto:`}),` or`,` `,(0,H.jsx)(`code`,{className:Ta,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:Ea,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)(Fa,{pendingKey:N(`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:Ea,children:`Per-project`}),(0,H.jsx)(`ul`,{className:`flex flex-col`,children:e.projects.map(t=>(0,H.jsx)(`li`,{children:(0,H.jsx)(Ia,{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:Ta,children:`kanna --share`}),` or open Kanna over your tunnel on the phone, then enable on that device.`]})]})}function Ra(e){return e.map(e=>({...e,disabled:!0}))}function za({pendingKey:e,value:t,onValueChange:n,options:r,size:i}){let a=M(e);return(0,H.jsxs)(`div`,{className:`inline-flex items-center gap-2`,"aria-busy":a||void 0,children:[a?(0,H.jsx)(E,{className:`text-muted-foreground`}):null,(0,H.jsx)(F,{value:t,onValueChange:t=>j(e,()=>n(t)),options:a?Ra(r):r,size:i})]})}function Ba(e){let{pushConfig:t,socket:n}=e,r=Sa(e=>e.deviceId),i=Sa(e=>e.setDeviceId),a=Sa(e=>e.setPermissionState);return{handleEnablePush:(0,V.useCallback)(async()=>{if(t)try{let e=await ne({vapidPublicKey:t.vapidPublicKey,sendToServer:async e=>{let t=await n.command({type:`push.subscribe`,subscription:e.subscription,label:e.label,userAgent:e.userAgent});return y(t.id),{id:t.id}}});i(e)}finally{a(re().state)}},[t,n,i,a]),handleDisablePush:(0,V.useCallback)(async()=>{r&&(await ae({pushDeviceId:r,sendToServer:async e=>{await n.command({type:`push.unsubscribe`,pushDeviceId:e})}}),v(),i(null))},[r,n,i])}}var Va=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],Ha=`~/.kanna/data/settings.json`;function Ua({state:e,dom:t}){let n=z(e=>e.settings),r=Sa(e=>e.permissionState),i=Sa(e=>e.deviceId),a=Sa(e=>e.contactSubjectDraft),o=Sa(e=>e.setContactSubjectDraft),s=Sa(e=>e.detected),c=Sa(e=>e.setPermissionState),{handleEnablePush:l,handleDisablePush:u}=Ba(e),{pushConfig:d,socket:f}=e,p=n?.push.contactSubject;return(0,V.useLayoutEffect)(()=>{s(re().state,ie())},[s]),(0,V.useEffect)(()=>t.addWindowListener(`focus`,()=>c(re().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)(La,{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 Wa({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??Ha,`.`,` `,(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)(za,{pendingKey:`settings.analytics`,value:i,onValueChange:e=>o({analyticsEnabled:e===`enabled`}),options:Va,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??Ha,`.`]})]}),children:(0,H.jsx)(za,{pendingKey:`settings.telemetry`,value:a,onValueChange:e=>o({telemetry:{enabled:e===`enabled`}}),options:Va,size:`sm`})})]})}function Ga(){let e=G(e=>e.analyticsDialogOpen),t=G(e=>e.setAnalyticsDialogOpen);return(0,H.jsx)(ot,{open:e,onOpenChange:t,children:(0,H.jsxs)(at,{size:`lg`,children:[(0,H.jsxs)(ct,{className:`space-y-4`,children:[(0,H.jsx)(ut,{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:ba.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:xa.map(e=>(0,H.jsx)(`li`,{className:`font-mono text-foreground`,children:e},e))})]})]}),(0,H.jsx)(st,{children:(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function Ka({state:e,dom:t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ua,{state:e,dom:t}),(0,H.jsx)(Wa,{state:e}),(0,H.jsx)(Ga,{})]})}var qa={path:`shareDefaultTtlHours`,min:1,max:1/0,integer:!0},Ja=6e5,Ya={path:`subagentRuntime.runTimeoutMs`,min:3e4,max:864e5,integer:!0},Xa={path:`claudeDriver.lifecycle.idleTimeoutMs`,min:kt,max:Vt,integer:!1},Za={path:`claudeDriver.lifecycle.maxConcurrent`,min:1,max:16,integer:!1};function Qa(e,t,n){let r=Number(e);if(!tn(n,r))return{kind:`invalid`};let i=Math.round(r);return i===t?{kind:`unchanged`}:{kind:`write`,value:i}}function $a({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=>ia(e,s),className:D(`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:D(`text-left text-xs text-muted-foreground md:text-right`,l&&`tabular-nums`),children:c})]})})}function eo({state:e}){let{write:t}=ca(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=Qa(r,n,qa);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)($a,{title:`Public share links`,description:`Default expiry for read-only chat share links. Owners can revoke any link manually at any time.`,min:qa.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 to({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 no(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 ro({state:e}){let{write:t}=ca(e),n=z(nn),r=S(e=>e.setScrollbackLines),i=no(`scrollback`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{scrollbackLines:e}}))}return(0,H.jsx)($a,{title:`Terminal Scrollback`,description:`Lines retained for embedded terminal history`,min:500,max:gn,step:100,value:i.draft,onValueChange:i.setDraft,onCommit:a,hint:(0,H.jsxs)(H.Fragment,{children:[500,`-`,gn,` lines`,n===1e3?` (default)`:``]})})}function io({state:e}){let{write:t}=ca(e),n=z(Kt),r=S(e=>e.setMinColumnWidth),i=no(`minColumnWidth`,n);function a(){let e=i.parsed();e===null?i.reset():(r(e),t({terminal:{minColumnWidth:e}}))}return(0,H.jsx)($a,{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 ao({state:e}){let{write:t}=ca(e),n=z(e=>e.settings?.panes.tabMinWidth??60),r=no(`tabMinWidth`,n);function i(){let e=r.parsed();e===null?r.reset():t({panes:{tabMinWidth:Un(e)}})}return(0,H.jsx)($a,{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 oo({state:e}){let{write:t}=ca(e),n=z(e=>e.settings?.uploads.maxFileSizeMb??Jr.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=Qa(r,n,Yr);e.kind===`write`?t({uploads:{maxFileSizeMb:e.value}}):(i({uploadMaxFileSize:String(n)}),e.kind===`invalid`&&a(`Max file size must be between ${Yr.min} and ${Yr.max} MB.`))}return(0,H.jsx)($a,{title:`Max upload file size`,description:`Largest single file the chat upload endpoint accepts.`,min:Yr.min,max:Yr.max,step:1,value:r,onValueChange:e=>i({uploadMaxFileSize:e}),onCommit:o,unit:`MB`,ariaLabel:`Max upload file size in megabytes`,hint:`${Yr.min}–${Yr.max} MB · default ${Jr.maxFileSizeMb}`})}function so({state:e}){let t=s(e=>e.autoResumeOnRateLimit),n=s(e=>e.setAutoResumeOnRateLimit);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ro,{state:e}),(0,H.jsx)(io,{state:e}),(0,H.jsx)(ao,{state:e}),(0,H.jsx)(oo,{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)(to,{checked:t,onChange:n})})]})}var co=[{value:`disabled`,label:`Off`},{value:`enabled`,label:`On`}],lo=[{value:`always-ask`,label:`Always ask`},{value:`auto-expose`,label:`Auto-expose`}],uo=`appSettings.setCloudflareTunnel`,fo=N(uo,`cloudflaredPath`);function po({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=M(fo),s=t?.cloudflareTunnel??Kr,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)(za,{pendingKey:N(uo,`enabled`),value:c,onValueChange:e=>u({enabled:e===`enabled`}),options:co,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)(za,{pendingKey:N(uo,`mode`),value:s.mode,onValueChange:e=>u({mode:e}),options:lo,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:()=>j(fo,()=>u({cloudflaredPath:i})),readOnly:o,"aria-busy":o||void 0,placeholder:`cloudflared`,className:`w-full font-mono md:w-64`})})]})]})}function mo({state:e,dom:t=wn}){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)(ya,{state:e}),(0,H.jsx)(so,{state:e}),(0,H.jsx)(Ka,{state:e,dom:t})]}),(0,H.jsx)(po,{state:e}),(0,H.jsx)(eo,{state:e})]})}var ho=I()(e=>({draft:``,persistedAtMount:``,error:null,setDraft:t=>e({draft:t}),persistedChanged:t=>e({persistedAtMount:t,draft:t}),setError:t=>e({error:t})})),go=`settings.globalInstructions`;function _o({state:e}){let t=z(e=>e.settings?.globalPromptAppend??``),n=ho(e=>e.draft),r=ho(e=>e.setDraft),i=ho(e=>e.persistedAtMount),a=ho(e=>e.persistedChanged),o=M(go),s=ho(e=>e.error),c=ho(e=>e.setError);(0,V.useEffect)(()=>{t!==i&&a(t)},[t,i,a]);let l=n.replace(/\s+$/u,``),u=l.length>Mt,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:D(`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,` / `,Mt,` characters`,u?` — over limit`:``]}),(0,H.jsx)(k,{type:`button`,size:`sm`,onClick:()=>j(go,p),disabled:f,pending:o,children:m})]}),s?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:s}):null]})})})}function vo(e){return{async onReload(t){await On(e,{type:`plugins.reload`,pluginId:t})}}}function yo({plugins:e,handlers:t}){return e.length===0?(0,H.jsx)(Zr,{icon:u,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)(Qr,{children:e.map(e=>(0,H.jsx)(bo,{plugin:e,onReload:t.onReload},e.id))})]})}function bo({plugin:e,onReload:t}){let n=N(`plugins.reload`,e.id),r=M(n),i=(0,V.useCallback)(()=>{j(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)(jn,{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)(k,{variant:`ghost`,size:`sm`,"data-testid":`plugin-reload:${e.id}`,pending:r,onClick:i,children:`Reload`})]})}function xo(){let e=z(qt),t=z(en),n=kn(),r=(0,V.useMemo)(()=>vo(n),[n]);return e?(0,H.jsx)(yo,{plugins:t,handlers:r}):null}var So={},Co=I()(e=>({drafts:So,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 wo(e){let t={};for(let n of Ut)t[n]=h(e[n]??``);return{...cn,...t}}function To(e){return N(`settings.writeKeybindings`,e)}function Eo({action:e,currentValue:t,bordered:n,onDraftChange:r,onCommit:i,onRestoreDefault:a}){let o=To(e),s=M(o),c=p(cn[e]),l=t!==c,u=()=>{j(o,i)};return(0,H.jsx)(U,{title:te[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:()=>{j(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=>ia(e,u),className:`font-mono`}),s?(0,H.jsx)(E,{}):null]})})}function Do({state:e}){let t=Co(e=>e.drafts),n=Co(e=>e.setDrafts),r=Co(e=>e.setDraft),i=Co(e=>e.error),a=Co(e=>e.setError),o=(0,V.useMemo)(()=>T(e.keybindings),[e.keybindings]);(0,V.useEffect)(()=>{n(Object.fromEntries(Ut.map(e=>[e,p(o.bindings[e])])))},[o,n]);async function s(t){await B(a,async()=>{await e.socket.command({type:`settings.writeKeybindings`,bindings:wo(t)})})}async function c(){await s(t)}async function l(e){let r={...t,[e]:p(cn[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,Ut.map((e,n)=>(0,H.jsx)(Eo,{action:e,currentValue:t[e]??``,bordered:n!==0,onDraftChange:r,onCommit:c,onRestoreDefault:l},e))]})}function Oo(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
|
+
`),envText:Object.entries(e.env).map(([e,t])=>`${e}=${t}`).join(`
|
|
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
|
+
`)}}function ko(e,t,n){let r={};for(let i of e.split(`
|
|
5
|
+
`)){let e=i.indexOf(t);if(e<=0)continue;let a=i.slice(e+1);r[i.slice(0,e).trim()]=n?a.trim():a}return r}function Ao(e){return e.transport===`stdio`?{name:e.name,transport:`stdio`,command:e.command,args:e.argsText.split(`
|
|
6
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),env:ko(e.envText,`=`,!1),cwd:e.cwd||void 0}:{name:e.name,transport:e.transport,url:e.url,headers:ko(e.headersText,`:`,!0)}}var jo={kind:`list`};function Mo(e){return{...Oo(e),error:null,oauthEnabled:e!==null&&e.transport!==`stdio`?e.oauth?.enabled??!1:!1,authFlowUrl:null,callbackInput:``,oauthError:null,authenticating:!1,completing:!1}}var No=I()(e=>({editing:jo,editorForm:Mo(null),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:Mo(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))})),Po={customMcpServers:e=>({customMcpServers:e}),mcpSources:e=>({mcpSources:e}),customModels:e=>({customModels:e}),customProviders:e=>({customProviders:e}),textSnippets:e=>({textSnippets:e})},Fo={customMcpServers:e=>({customMcpServers:{setEnabled:e}}),mcpSources:e=>({mcpSources:{setEnabled:e}})};function Io(e,t){return(0,V.useMemo)(()=>{let n=Po[e];return{onCreate:async e=>{await t.handleWriteAppSettings(n({create:e}))},onUpdate:async(e,r)=>{await t.handleWriteAppSettings(n({update:{id:e,patch:r}}))},onDelete:async e=>{await t.handleWriteAppSettings(n({delete:{id:e}}))}}},[e,t])}function Lo(e,t){return(0,V.useCallback)(async(n,r)=>{await t.handleWriteAppSettings(Fo[e]({id:n,enabled:r}))},[e,t])}async function Ro(e){e.patch({error:null});try{await e.save(),e.onDone()}catch(t){e.patch({error:L(t)})}}function zo(e){return e.submitting?`Saving…`:e.isEdit?`Save changes`:e.addLabel}function Bo({server:e,handlers:t,onEdit:n,dom:r=wn}){let i=N(`mcpServers.delete`,e.id),a=M(i),o=N(`mcpServers.setEnabled`,e.id),s=M(o),c=N(`settings.testMcpServer`,e.id),l=M(c),u=(0,V.useCallback)(()=>{r.confirmDialog(`Delete MCP server "${e.name}"?`)&&j(i,()=>t.onDelete(e.id))},[i,r,t,e.id,e.name]),d=(0,V.useCallback)(n=>{let r=n.target.checked;j(o,()=>t.onSetEnabled(e.id,r))},[t,e.id,o]),f=(0,V.useCallback)(()=>{j(c,()=>t.onTest(e.id))},[t,e.id,c]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[(0,H.jsx)(Vo,{transport:e.transport}),(0,H.jsx)(`span`,{className:`ml-2`,children:e.transport===`stdio`?e.command:e.url})]})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,H.jsx)(Uo,{result:e.lastTest,pending:l}),e.transport!==`stdio`&&(0,H.jsx)(Wo,{oauth:e.oauth}),(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[s?(0,H.jsx)(E,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:e.enabled,disabled:s,"aria-busy":s||void 0,onChange:d,"aria-label":`Enabled`}),(0,H.jsx)(`span`,{children:`On`})]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:f,disabled:l,"aria-busy":l||void 0,title:`Test connection`,children:(0,H.jsx)(je,{className:D(`h-4 w-4`,l&&`animate-spin`)})}),(0,H.jsx)($r,{label:e.name,onEdit:n,onDelete:u,deletePending:a})]})]})}function Vo({transport:e}){return(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:e})}function Ho({label:e,detail:t}){return(0,H.jsx)(En,{label:t||`No error details were recorded.`,contentClassName:`max-w-sm whitespace-pre-wrap break-words`,children:(0,H.jsxs)(`span`,{tabIndex:0,className:`inline-flex cursor-help items-center gap-1 text-xs text-destructive-text`,children:[(0,H.jsx)(hr,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),e]})})}function Uo({result:e,pending:t}){if(t||e.status===`pending`)return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Testing…`});switch(e.status){case`ok`:return(0,H.jsxs)(`span`,{className:`text-xs text-green-600`,children:[`OK · `,e.toolCount,` tools`]});case`error`:return(0,H.jsx)(Ho,{label:`Failed`,detail:e.message});default:return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Untested`})}}function Wo({oauth:e}){if(!e?.enabled)return null;switch(e.status){case`authenticated`:return(0,H.jsx)(`span`,{className:`text-xs text-green-600`,children:`OAuth ✓`});case`error`:return(0,H.jsx)(Ho,{label:`OAuth error`,detail:e.errorMessage});default:return(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`OAuth: unauth`})}}var Go=new Set([`stdio`,`http`,`sse`,`ws`]);function Ko(e){return Go.has(e)}var qo=`new`;function Jo({pending:e,copied:t}){return e?(0,H.jsx)(E,{className:`size-3`}):t?(0,H.jsx)(_e,{className:`h-3 w-3 text-success-text`}):(0,H.jsx)(me,{className:`h-3 w-3`})}function Yo(e){return e.editing.kind===`list`?e.servers.length===0?(0,H.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-6 py-16 text-center`,children:[(0,H.jsx)(Fr,{className:`mb-4 h-10 w-10 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`h2`,{className:`text-lg font-medium`,children:`No custom MCP servers`}),(0,H.jsx)(`p`,{className:`mt-2 max-w-md text-sm text-muted-foreground`,children:`Install MCP servers to extend the model's tool surface. Supports stdio, http, sse, and ws transports.`}),(0,H.jsxs)(k,{className:`mt-6`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add server`]})]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Custom MCP servers`}),(0,H.jsxs)(k,{size:`sm`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add server`]})]}),(0,H.jsx)(Qr,{children:e.servers.map(t=>(0,H.jsx)(Bo,{server:t,handlers:e.handlers,onEdit:()=>e.onSelect(t.id),dom:e.dom},t.id))})]}):(0,H.jsx)(Xo,{initial:e.editing.kind===`edit`?e.servers.find(t=>e.editing.kind===`edit`&&t.id===e.editing.id)??null:null,existingNames:e.servers.map(e=>({id:e.id,name:e.name})),onCancel:e.onCancelEditing,handlers:e.handlers})}function Xo({initial:e,existingNames:t,onCancel:n,handlers:r,clipboard:i=he}){let a=No(e=>e.editorForm),o=No(e=>e.resetEditorForm),s=No(e=>e.patchEditorForm),c=(0,V.useCallback)(e=>{Ko(e)&&s({transport:e})},[s]),{name:l,transport:u,command:d,argsText:f,envText:p,cwd:m,url:h,headersText:g,error:_,oauthEnabled:v,authFlowUrl:y,callbackInput:b,oauthError:ee,authenticating:x,completing:te}=a,S=(0,V.useRef)(e);(0,V.useEffect)(()=>{o(S.current)},[o]);let ne=e!==null&&e.transport!==`stdio`?e.oauth:void 0,C=e?.id??qo,w=N(`mcpServers.save`,C),re=M(w),ie=N(`mcpServers.toggleOAuth`,C),ae=M(ie),T=N(`mcpServers.copyAuthUrl`,C),oe=M(T),D=ge(T),O=(0,V.useCallback)(async t=>{s(t?{oauthEnabled:!0}:{oauthEnabled:!1,authFlowUrl:null,callbackInput:``,oauthError:null}),e&&await r.onUpdate(e.id,{oauth:{...ne??{status:`unauthenticated`},enabled:t}})},[e,ne,r,s]),se=(0,V.useCallback)(async()=>{if(e){s({authenticating:!0,oauthError:null});try{let t=await r.onStartMcpOAuth(e.id);t.ok?s({authFlowUrl:`authorizationUrl`in t?t.authorizationUrl:null}):s({oauthError:t.error})}finally{s({authenticating:!1})}}},[e,r,s]),A=(0,V.useCallback)(async()=>{if(e){s({completing:!0,oauthError:null});try{let t=await r.onCompleteMcpOAuth(e.id,b);t.ok?s({authFlowUrl:null,callbackInput:``}):s({oauthError:t.error})}finally{s({completing:!1})}}},[e,b,r,s]),ce=(0,V.useCallback)(e=>{let t=e.target.checked;j(ie,()=>O(t))},[O,ie]),le=(0,V.useCallback)(()=>{j(N(`settings.startMcpOAuth`,C),se)},[C,se]),ue=(0,V.useCallback)(()=>{j(N(`settings.completeMcpOAuth`,C),A)},[A,C]),de=(0,V.useCallback)(()=>{y&&j(T,()=>ve(T,()=>i.writeText(y)))},[y,i,T]),fe=(0,V.useMemo)(()=>{if(l.length===0)return null;let n=vn(l);return n===`INVALID_NAME`?`Name must start with a letter and contain only letters, digits, '_' or '-' (max 32 chars).`:n===`RESERVED_NAME`?`'${l}' is reserved.`:t.find(t=>t.name===l&&t.id!==e?.id)?`Name already taken.`:null},[l,t,e?.id]),pe=(0,V.useCallback)(async()=>{fe||await Ro({patch:s,save:async()=>{let t=Ao({name:l,transport:u,command:d,argsText:f,envText:p,cwd:m,url:h,headersText:g});e?await r.onUpdate(e.id,t):await r.onCreate(t)},onDone:n})},[f,d,m,p,r,g,e,l,fe,n,u,h,s]),me=(0,V.useCallback)(()=>{j(w,pe)},[w,pe]),_e=zo({submitting:re,isEdit:e!==null,addLabel:`Add server`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6 max-w-2xl`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP server`:`Add MCP server`}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Name`}),(0,H.jsx)(R,{value:l,onChange:e=>s({name:e.target.value}),placeholder:`fs`}),fe&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:fe})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Transport`}),(0,H.jsxs)(Ce,{value:u,onValueChange:c,children:[(0,H.jsx)(ye,{children:(0,H.jsx)(xe,{})}),(0,H.jsxs)(be,{children:[(0,H.jsx)(P,{value:`stdio`,children:`stdio (spawn local command)`}),(0,H.jsx)(P,{value:`http`,children:`http (Streamable HTTP)`}),(0,H.jsx)(P,{value:`sse`,children:`sse (Server-Sent Events)`}),(0,H.jsx)(P,{value:`ws`,children:`ws (WebSocket)`})]})]})]}),u===`stdio`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Command`}),(0,H.jsx)(R,{value:d,onChange:e=>s({command:e.target.value}),placeholder:`/usr/local/bin/mcp-filesystem`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Args (one per line)`}),(0,H.jsx)(Dn,{value:f,onChange:e=>s({argsText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Env (KEY=value, one per line)`}),(0,H.jsx)(Dn,{value:p,onChange:e=>s({envText:e.target.value}),rows:3,className:`font-mono text-sm`})]}),(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`cwd (optional)`}),(0,H.jsx)(R,{value:m,onChange:e=>s({cwd:e.target.value}),placeholder:`/optional/working/dir`})]})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`URL`}),(0,H.jsx)(R,{value:h,onChange:e=>s({url:e.target.value}),placeholder:u===`ws`?`wss://example.com/mcp`:`https://example.com/mcp`})]}),u===`ws`?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Headers are not supported on the ws transport.`}):(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:`Headers (Key: value, one per line)`}),(0,H.jsx)(Dn,{value:g,onChange:e=>s({headersText:e.target.value}),rows:3,className:`font-mono text-sm`,disabled:v}),v&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Authorization header is managed by OAuth when enabled.`})]}),(u===`http`||u===`sse`)&&(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Xn,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),(0,H.jsx)(`span`,{className:`text-xs font-medium`,children:`OAuth 2.1`}),(0,H.jsxs)(`label`,{className:`ml-auto flex cursor-pointer items-center gap-1 text-xs text-muted-foreground`,children:[ae?(0,H.jsx)(E,{}):null,(0,H.jsx)(`input`,{type:`checkbox`,checked:v,disabled:ae,"aria-busy":ae||void 0,onChange:ce,"aria-label":`Enable OAuth`}),(0,H.jsx)(`span`,{children:`Enable`})]})]}),v&&!e&&(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Save the server first, then authenticate.`}),v&&e&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(Wo,{oauth:ne}),ne?.status===`authenticated`&&(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:le,pending:x,children:`Re-authenticate`})]}),(ne?.status!==`authenticated`||y)&&(y?(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsxs)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1 text-xs text-blue-600 underline`,children:[`Open authorization URL`,(0,H.jsx)(Ln,{className:`h-3 w-3`})]}),(0,H.jsx)(En,{label:D?`Copied`:`Copy URL`,children:(0,H.jsx)(`button`,{type:`button`,onClick:de,disabled:oe,"aria-busy":oe||void 0,className:`ml-1 text-muted-foreground hover:text-foreground`,"aria-label":D?`Copied`:`Copy authorization URL`,children:(0,H.jsx)(Jo,{pending:oe,copied:D})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-1`,children:[(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`After authorizing, paste the callback URL here:`}),(0,H.jsx)(R,{value:b,onChange:e=>s({callbackInput:e.target.value}),placeholder:`http://localhost:…/callback?code=…`,className:`font-mono text-xs`})]}),(0,H.jsx)(k,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:ue,pending:te,disabled:b.length===0,children:te?`Completing…`:`Complete`})]}):(0,H.jsx)(k,{variant:`outline`,size:`sm`,className:`w-fit`,onClick:le,pending:x,children:x?`Starting…`:`Authenticate`})),ee&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:ee})]})]})]}),_&&(0,H.jsx)(`p`,{className:`text-xs text-red-600`,children:_}),(0,H.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,H.jsx)(k,{variant:`ghost`,onClick:n,disabled:re,children:`Cancel`}),(0,H.jsx)(k,{onClick:me,pending:re,disabled:!!fe||l.length===0,children:_e})]})]})}function Zo(e){let t=z(Xt),n=No(e=>e.editing),r=No(e=>e.setEditing),i=Io(`customMcpServers`,e.state),a=Lo(`customMcpServers`,e.state),o=(0,V.useMemo)(()=>({...i,onDelete:async e=>{await i.onDelete(e),r({kind:`list`})},onSetEnabled:a,onTest:async t=>{await e.state.handleTestMcpServer(t)},onStartMcpOAuth:async t=>e.state.handleStartMcpOAuth(t),onCompleteMcpOAuth:async(t,n)=>e.state.handleCompleteMcpOAuth(t,n)}),[i,a,e.state,r]);return(0,H.jsx)(Yo,{servers:t,editing:n,onSelect:e=>r({kind:`edit`,id:e}),onStartCreate:()=>r({kind:`create`}),onCancelEditing:()=>r({kind:`list`}),handlers:o})}var Qo=[`subscribe`,`poll`],$o=5e3,es=36e5,ts=yt(Qo),ns={disabled:`Disabled`,connecting:`Connecting`,listening:`Listening`,polling:`Polling`,backoff:`Retrying`,error:`Error`},rs={disabled:`muted`,connecting:`attention`,listening:`muted`,polling:`muted`,backoff:`attention`,error:`destructive`},is={subscribe:`Subscribe`,poll:`Poll`},as={subscribe:`Kanna listens for change notifications on the resources you name, reads each one that changes and catches up after a reconnect. A resync interval re-reads them on a timer. Needs a server that supports resource subscriptions.`,poll:`Kanna calls a tool on an interval and remembers a cursor, so each message is delivered once.`};function os(e){return ns[e]}function ss(e){return rs[e]}function cs(e){return is[e]}function ls(e){return as[e]}function us(){return`Between ${$o/1e3} and ${es/1e3}.`}var ds=[`zalo`],fs={zalo:{label:`Zalo`,mode:`subscribe`,resourceUris:[`zalo://inbox`],itemsPath:`messages`,itemKeyPath:`id`,resyncIntervalMs:3e5,threadKeyPath:`threadId`,senderPath:`senderName`,textPath:`text`,handler:{mode:`spawn`,template:`A new Zalo message arrived in a conversation. Read it, decide whether the user needs to act, and draft a reply in the same language the sender used.`,replyHint:`Send the reply with zalo_send_message to the conversation the message came from.`,pushEnabled:!0},reply:{tool:`zalo_send_message`,args:{threadId:`{{message.threadId}}`,threadType:{from:`message.threadType`,map:{dm:0,group:1}},text:`{{reply.text}}`},resultIdPath:`messageId`}}};function ps(e){return e.trim().length>0}function ms(e){return[...ir(e.handler),...er(e.handler.template,{required:!0}),...$n(e.handler.replyHint)]}function hs(e){if(e.mode===`subscribe`)return e.resourceUris.some(ps)?[]:[`At least one resource URI is required`];let t=[],n=[[`Tool`,e.tool],[`Cursor argument`,e.cursorArg],[`Cursor path`,e.cursorPath],[`Items path`,e.itemsPath]];for(let[e,r]of n)ps(r)||t.push(`${e} is required`);return Sn(e.args)||t.push(`Arguments must be a JSON object`),t}function gs(e){if(e==null)return[];let t=[];ps(e.tool)||t.push(`Reply tool is required`);for(let[n,r]of Object.entries(e.args))ps(n)||t.push(`Reply argument names must not be empty`),typeof r!=`string`&&Object.keys(r.map).length===0&&t.push(`Reply argument "${n}" needs at least one mapping`);return t.push(...sr([e.resultIdPath])),t}function _s(e){let t=[];return t.push(...nr(e.name)),ps(e.serverId)||t.push(`An MCP server is required`),ts(e.mode)?t.push(...hs(e)):t.push(`Mode must be subscribe or poll`),t.push(...sr([e.threadKeyPath,e.senderPath,e.textPath,e.itemsPath,e.itemKeyPath])),t.push(...ms(e)),t.push(...gs(e.reply)),t}function vs(e){let t=e.trim();if(t.length===0)return{args:{}};let n=yn(t);return n!==null&&Sn(n)?{args:n}:{error:`Arguments must be a JSON object`}}function ys(e){if(typeof e==`string`)return e;if(!Sn(e))return null;let{from:t,map:n}=e;return typeof t!=`string`||n===void 0||!Sn(n)?null:e.default===void 0?{from:t,map:n}:{from:t,map:n,default:e.default}}function bs(e){let t=e.trim();if(t.length===0)return{args:{}};let n=yn(t);if(n===null||!Sn(n))return{error:`Reply arguments must be a JSON object`};let r={};for(let[e,t]of Object.entries(n)){let n=ys(t);if(n===null)return{error:`Reply argument "${e}" must be a string or an object with "from" and "map"`};r[e]=n}return{args:r}}var xs=`A new message arrived. Read it, decide whether the user needs to act, and draft a reply if one is appropriate.`,Ss=`30`;function Cs(){return{name:``,serverId:``,mode:`subscribe`,resourceUris:``,subscribeItemsPath:``,subscribeItemKeyPath:``,resyncSeconds:``,tool:``,argsText:`{}`,cursorArg:``,cursorPath:``,itemsPath:``,itemKeyPath:``,intervalSeconds:Ss,threadKeyPath:``,senderPath:``,textPath:``,handlerMode:`spawn`,chatId:``,projectId:``,modelValue:``,template:xs,replyHint:``,pushEnabled:!0,...ws(null)}}function ws(e){return{replyTool:e?.tool??``,replyArgsText:JSON.stringify(e?.args??{},null,2),replyResultIdPath:e?.resultIdPath??``}}function Ts(e){return{handlerMode:e.mode,chatId:e.chatId??``,projectId:e.projectId??``,modelValue:e.provider&&e.model?ar(e.provider,e.model):``,template:e.template,replyHint:e.replyHint,pushEnabled:e.pushEnabled}}function Es(e){let t={...Cs(),name:e.name,serverId:e.serverId,mode:e.mode,threadKeyPath:e.threadKeyPath,senderPath:e.senderPath,textPath:e.textPath,...Ts(e.handler),...ws(e.reply)};return e.mode===`subscribe`?{...t,resourceUris:e.resourceUris.join(`
|
|
7
|
+
`),subscribeItemsPath:e.itemsPath,subscribeItemKeyPath:e.itemKeyPath??``,resyncSeconds:Ds(e.resyncIntervalMs)}:{...t,tool:e.tool,argsText:JSON.stringify(e.args,null,2),cursorArg:e.cursorArg,cursorPath:e.cursorPath,itemsPath:e.itemsPath,itemKeyPath:e.itemKeyPath??``,intervalSeconds:String(Math.round(e.intervalMs/1e3))}}function Ds(e){return e===null?``:String(Math.round(e/1e3))}function Os(e,t){let n=fs[t],r={...e,name:e.name.trim().length>0?e.name:n.label,mode:n.mode,threadKeyPath:n.threadKeyPath,senderPath:n.senderPath,textPath:n.textPath??``,...Ts({...n.handler,projectId:e.projectId||void 0}),...ws(n.reply??null)};return n.mode===`subscribe`?{...r,resourceUris:n.resourceUris.join(`
|
|
8
|
+
`),subscribeItemsPath:n.itemsPath??``,subscribeItemKeyPath:n.itemKeyPath??``,resyncSeconds:Ds(n.resyncIntervalMs??null)}:{...r,tool:n.tool,argsText:JSON.stringify(n.args,null,2),cursorArg:n.cursorArg,cursorPath:n.cursorPath,itemsPath:n.itemsPath,itemKeyPath:n.itemKeyPath??``,intervalSeconds:String(Math.round(n.intervalMs/1e3))}}function ks(e){let t=e.handlerMode===`notify`?null:rr(e.modelValue);return{mode:e.handlerMode,template:e.template,replyHint:e.replyHint,pushEnabled:e.pushEnabled,...Qn(e.handlerMode,e.chatId,e.projectId),...t?{provider:t.provider,model:t.model}:{}}}function As(e){let t=e.replyTool.trim();if(t.length===0)return{reply:null,errors:[]};let n=bs(e.replyArgsText);return`error`in n?{reply:null,errors:[n.error]}:{reply:{tool:t,args:n.args,resultIdPath:e.replyResultIdPath.trim()},errors:[]}}function js(e){let{reply:t,errors:n}=As(e),r={name:e.name.trim(),serverId:e.serverId,threadKeyPath:e.threadKeyPath.trim(),senderPath:e.senderPath.trim(),textPath:e.textPath.trim(),handler:ks(e),reply:t};if(e.mode===`subscribe`){let t=e.resyncSeconds.trim(),i=Number(t),a=t.length===0||Number.isFinite(i)&&i>0,o={...r,mode:`subscribe`,resourceUris:e.resourceUris.split(`
|
|
9
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),itemsPath:e.subscribeItemsPath.trim(),itemKeyPath:e.subscribeItemKeyPath.trim()||null,resyncIntervalMs:t.length>0&&a?Math.round(i*1e3):null},s=[...a?[]:[`Resync interval must be a number of seconds`],...n,..._s(o)];return s.length>0?{ok:!1,errors:s}:{ok:!0,input:o}}let i=vs(e.argsText),a=Number(e.intervalSeconds),o={...r,mode:`poll`,tool:e.tool.trim(),args:`args`in i?i.args:{},cursorArg:e.cursorArg.trim(),cursorPath:e.cursorPath.trim(),itemsPath:e.itemsPath.trim(),itemKeyPath:e.itemKeyPath.trim()||null,intervalMs:Number.isFinite(a)?Math.round(a*1e3):$o},s=[...`error`in i?[i.error]:[],...Number.isFinite(a)&&a>0?[]:[`Interval must be a number of seconds`],...n,..._s(o)];return s.length>0?{ok:!1,errors:s}:{ok:!0,input:o}}function Ms(e){let{enabled:t,...n}=e;return n}var Ns=I()(e=>({editing:jo,draft:Cs(),error:null,confirmingDeleteId:null,startCreate:()=>e({editing:{kind:`create`},draft:Cs(),error:null}),startEdit:t=>e({editing:{kind:`edit`,id:t.id},draft:Es(t),error:null}),closeEditor:()=>e({editing:jo,error:null}),patchDraft:t=>e(e=>({draft:{...e.draft,...t}})),applyPreset:t=>e(e=>({draft:Os(e.draft,t)})),setError:t=>e({error:t}),askDelete:t=>e({confirmingDeleteId:t}),cancelDelete:()=>e({confirmingDeleteId:null})})),Ps=[`subscribe`,`poll`].map(e=>({value:e,label:cs(e)}));function K({id:e,label:t,hint:n,children:r}){return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`label`,{htmlFor:e,className:`block text-sm font-medium text-foreground`,children:t}),r,n?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}):null]})}function Fs(e,t){let n=e.filter(e=>e.transport!==`ws`&&(e.enabled||e.id===t)),r=n.filter(e=>e.transport!==`stdio`),i=n.filter(e=>e.transport===`stdio`);return[...r,...i].map(e=>({value:e.id,label:e.name,hint:e.transport}))}function Is({draft:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(K,{id:`mcp-source-uris`,label:`Resource URIs`,hint:`One URI per line. Kanna subscribes to each and reads it whenever the server says it changed.`,children:(0,H.jsx)(Dn,{id:`mcp-source-uris`,rows:3,className:`font-mono`,value:e.resourceUris,onChange:e=>t({resourceUris:e.target.value})})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-sub-items-path`,label:`Items path`,hint:`Optional. Where the array of messages sits in the resource. Leave empty to deliver the whole resource as one message.`,children:(0,H.jsx)(R,{id:`mcp-source-sub-items-path`,className:`font-mono`,value:e.subscribeItemsPath,onChange:e=>t({subscribeItemsPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-sub-item-key`,label:`Item key path`,hint:`Optional. A field that is unique per message. Leave empty to hash the whole item.`,children:(0,H.jsx)(R,{id:`mcp-source-sub-item-key`,className:`font-mono`,value:e.subscribeItemKeyPath,onChange:e=>t({subscribeItemKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-resync`,label:`Resync every (seconds)`,hint:`Optional. Re-reads the resources on a timer to catch missed notifications. ${us()}`,children:(0,H.jsx)(R,{id:`mcp-source-resync`,inputMode:`numeric`,className:`tabular-nums`,value:e.resyncSeconds,onChange:e=>t({resyncSeconds:e.target.value})})})]})]})}function Ls({draft:e,onChange:t}){return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(K,{id:`mcp-source-tool`,label:`List tool`,hint:`The tool Kanna calls on every poll.`,children:(0,H.jsx)(R,{id:`mcp-source-tool`,className:`font-mono`,value:e.tool,onChange:e=>t({tool:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-args`,label:`Arguments`,hint:`A JSON object sent with every call. The cursor is added under the cursor argument.`,children:(0,H.jsx)(Dn,{id:`mcp-source-args`,rows:3,className:`font-mono`,value:e.argsText,onChange:e=>t({argsText:e.target.value})})}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-cursor-arg`,label:`Cursor argument`,children:(0,H.jsx)(R,{id:`mcp-source-cursor-arg`,className:`font-mono`,value:e.cursorArg,onChange:e=>t({cursorArg:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-cursor-path`,label:`Cursor path`,hint:`Where the next cursor sits in the result.`,children:(0,H.jsx)(R,{id:`mcp-source-cursor-path`,className:`font-mono`,value:e.cursorPath,onChange:e=>t({cursorPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-items-path`,label:`Items path`,hint:`Where the array of messages sits in the result.`,children:(0,H.jsx)(R,{id:`mcp-source-items-path`,className:`font-mono`,value:e.itemsPath,onChange:e=>t({itemsPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-item-key`,label:`Item key path`,hint:`A field that is unique per message. Leave empty to hash the whole item.`,children:(0,H.jsx)(R,{id:`mcp-source-item-key`,className:`font-mono`,value:e.itemKeyPath,onChange:e=>t({itemKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-interval`,label:`Interval (seconds)`,hint:us(),children:(0,H.jsx)(R,{id:`mcp-source-interval`,inputMode:`numeric`,className:`tabular-nums`,value:e.intervalSeconds,onChange:e=>t({intervalSeconds:e.target.value})})})]})]})}function Rs({draft:e,onChange:t}){let n=(0,V.useMemo)(()=>{if(e.replyTool.trim().length===0)return null;let t=bs(e.replyArgsText);return`error`in t?t.error:null},[e.replyArgsText,e.replyTool]);return(0,H.jsxs)(`section`,{"aria-label":`Reply tool`,className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Reply tool`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Optional. When set, Send in the Inbox calls this tool on the server itself, with no agent, in every handler mode. Leave the tool name empty to reply through the handler chat instead.`})]}),(0,H.jsx)(K,{id:`mcp-source-reply-tool`,label:`Tool name`,children:(0,H.jsx)(R,{id:`mcp-source-reply-tool`,className:`font-mono`,value:e.replyTool,onChange:e=>t({replyTool:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-reply-args`,label:`Arguments`,hint:(0,H.jsxs)(H.Fragment,{children:[`A JSON object. Use `,(0,H.jsx)(`code`,{className:`font-mono`,children:`{{message.<field>}}`}),` for a field of the latest message and `,(0,H.jsx)(`code`,{className:`font-mono`,children:`{{reply.text}}`}),` for your reply. A value that is exactly one placeholder keeps its type. Turn a value into another with `,(0,H.jsx)(`code`,{className:`font-mono`,children:`{"from": "message.threadType", "map": {"dm": 0, "group": 1}}`}),`; add `,(0,H.jsx)(`code`,{className:`font-mono`,children:`default`}),` for unmatched values.`]}),children:(0,H.jsx)(Dn,{id:`mcp-source-reply-args`,rows:6,className:`font-mono`,value:e.replyArgsText,onChange:e=>t({replyArgsText:e.target.value})})}),n?(0,H.jsx)(`p`,{className:`text-xs text-destructive-text`,children:n}):null,(0,H.jsx)(K,{id:`mcp-source-reply-result-id`,label:`Result id path`,hint:`Optional. Where the sent message's id sits in the tool result, so Kanna does not ingest its own message when it comes back.`,children:(0,H.jsx)(R,{id:`mcp-source-reply-result-id`,className:`font-mono`,value:e.replyResultIdPath,onChange:e=>t({replyResultIdPath:e.target.value})})})]})}function zs({presetId:e,onApply:t}){let n=(0,V.useCallback)(()=>t(e),[t,e]);return(0,H.jsxs)(k,{variant:`secondary`,size:`sm`,onClick:n,children:[fs[e].label,` preset`]})}function Bs({editing:e,servers:t,sidebarData:n,handlers:r}){let i=tt(),a=Ns(e=>e.draft),o=Ns(e=>e.error),s=Ns(e=>e.patchDraft),c=Ns(e=>e.applyPreset),l=Ns(e=>e.closeEditor),u=Ns(e=>e.setError),d=N(`mcpSources.save`,e?.id??`new`),f=M(d),p=(0,V.useMemo)(()=>Zn(n),[n]),m=(0,V.useMemo)(()=>tr(i),[i]),h=(0,V.useMemo)(()=>Fs(t,a.serverId),[t,a.serverId]),g=(0,V.useMemo)(()=>js(a),[a]),_=a.handlerMode!==`notify`,v=(0,V.useCallback)(e=>s({name:e.target.value}),[s]),y=(0,V.useCallback)(()=>{g.ok&&j(d,()=>B(u,async()=>{e?await r.onUpdate(e.id,Ms(g.input)):await r.onCreate(g.input),l()}))},[l,e,r,g,d,u]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-5 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:e?`Edit MCP source`:`Add MCP source`}),(0,H.jsx)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:ds.map(e=>(0,H.jsx)(zs,{presetId:e,onApply:c},e))})]}),(0,H.jsx)(K,{id:`mcp-source-name`,label:`Name`,children:(0,H.jsx)(R,{id:`mcp-source-name`,value:a.name,onChange:v,placeholder:`Zalo`,autoFocus:!0})}),(0,H.jsx)(K,{id:`mcp-source-server`,label:`MCP server`,hint:`A stdio server started here is a separate process from the one your chats use — prefer http or sse.`,children:(0,H.jsx)(or,{id:`mcp-source-server`,value:a.serverId,options:h,placeholder:`Choose an MCP server`,searchPlaceholder:`Search servers...`,emptyMessage:`Add an MCP server first`,onValueChange:e=>s({serverId:e})})}),(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsx)(`span`,{className:`block text-sm font-medium text-foreground`,children:`How messages arrive`}),(0,H.jsx)(F,{value:a.mode,onValueChange:e=>s({mode:e}),options:Ps,size:`sm`}),(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:ls(a.mode)})]}),a.mode===`subscribe`?(0,H.jsx)(Is,{draft:a,onChange:s}):(0,H.jsx)(Ls,{draft:a,onChange:s}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:[(0,H.jsx)(K,{id:`mcp-source-thread-key`,label:`Thread key path`,hint:`Messages with the same value share one Inbox thread.`,children:(0,H.jsx)(R,{id:`mcp-source-thread-key`,className:`font-mono`,value:a.threadKeyPath,onChange:e=>s({threadKeyPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-sender`,label:`Sender path`,hint:`Shown as the sender of the thread.`,children:(0,H.jsx)(R,{id:`mcp-source-sender`,className:`font-mono`,value:a.senderPath,onChange:e=>s({senderPath:e.target.value})})}),(0,H.jsx)(K,{id:`mcp-source-text`,label:`Text path`,hint:`Optional. The field holding the message text, shown as the Inbox preview. Leave empty to show the raw item.`,children:(0,H.jsx)(R,{id:`mcp-source-text`,className:`font-mono`,value:a.textPath,onChange:e=>s({textPath:e.target.value})})})]}),(0,H.jsx)(lr,{idPrefix:`mcp-source`,mode:a.handlerMode,chatId:a.chatId,projectId:a.projectId,modelValue:a.modelValue,targets:p,modelOptions:m,modelHint:`The model the turn started by each message runs with.`,showModeControl:!0,startsTurn:_,onModeChange:e=>s({handlerMode:e}),onChatChange:e=>s({chatId:e}),onProjectChange:e=>s({projectId:e}),onModelChange:e=>s({modelValue:e})}),(0,H.jsx)(K,{id:`mcp-source-template`,label:`Instruction template`,hint:(0,H.jsxs)(H.Fragment,{children:[`Insert fields from the message with `,(0,H.jsx)(`code`,{className:`font-mono`,children:`{{senderName}}`}),`. The message is appended as untrusted data.`]}),children:(0,H.jsx)(Dn,{id:`mcp-source-template`,rows:4,value:a.template,onChange:e=>s({template:e.target.value})})}),(0,H.jsx)(Rs,{draft:a,onChange:s}),(0,H.jsx)(K,{id:`mcp-source-reply-hint`,label:`Reply hint`,hint:`Used only when there is no reply tool: tells the agent how to send a reply through the server's tools when you answer from the Inbox.`,children:(0,H.jsx)(Dn,{id:`mcp-source-reply-hint`,rows:3,value:a.replyHint,onChange:e=>s({replyHint:e.target.value})})}),(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:a.pushEnabled,onChange:e=>s({pushEnabled:e.target.checked}),className:`h-4 w-4 shrink-0 rounded border-border accent-foreground`}),`Send a push notification for new messages`]}),!g.ok&&a.name.length>0?(0,H.jsx)(`p`,{className:`text-xs text-destructive-text`,children:g.errors[0]}):null,o?(0,H.jsx)(`p`,{className:`text-xs text-destructive-text`,children:o}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:y,pending:f,disabled:!g.ok,children:e?`Save changes`:`Add source`}),(0,H.jsx)(k,{variant:`ghost`,onClick:l,disabled:f,children:`Cancel`})]})]})}function Vs({source:e,serverName:t,status:n,now:r,confirmingDelete:i,handlers:a}){let o=Ns(e=>e.startEdit),s=Ns(e=>e.askDelete),c=Ns(e=>e.cancelDelete),l=N(`mcpSources.setEnabled`,e.id),u=N(`mcpSources.delete`,e.id),d=M(l),f=M(u),p=n?.state??(e.enabled?`connecting`:`disabled`),m=An(n?.lastItemAt??void 0,r),h=(0,V.useCallback)(()=>{j(l,()=>a.onSetEnabled(e.id,!e.enabled))},[l,a,e.enabled,e.id]),g=(0,V.useCallback)(()=>o(e),[e,o]),_=(0,V.useCallback)(()=>s(e.id),[s,e.id]),v=(0,V.useCallback)(()=>{j(u,async()=>{await a.onDelete(e.id),c()})},[c,u,a,e.id]);return(0,H.jsxs)(`li`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3`,"aria-busy":d||f||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,H.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[t,` · `,cs(e.mode)]}),n?.lastError?(0,H.jsx)(`span`,{className:`text-xs text-destructive-text`,children:n.lastError}):null]}),(0,H.jsxs)(`div`,{className:`ml-auto flex flex-wrap items-center gap-3 text-xs text-muted-foreground`,children:[(0,H.jsx)(jn,{tone:ss(p),label:os(p)}),(0,H.jsx)(`span`,{className:`tabular-nums`,children:m?`last ${m}`:`no items yet`}),(0,H.jsxs)(`span`,{className:`tabular-nums`,children:[n?.itemCount??0,` items`]}),(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:h,pending:d,children:e.enabled?`Disable`:`Enable`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:g,"aria-label":`Edit ${e.name}`,children:`Edit`}),i?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(k,{variant:`destructive`,size:`sm`,onClick:v,pending:f,children:[`Delete `,e.name,`?`]}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:c,disabled:f,children:`Keep`})]}):(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:_,"aria-label":`Delete ${e.name}`,children:`Delete`})]})]})}function Hs({sources:e,statuses:t,servers:n,sidebarData:r,handlers:i}){let a=Ns(e=>e.editing),o=Ns(e=>e.confirmingDeleteId),s=Ns(e=>e.startCreate),c=Pn(3e4);if(a.kind!==`list`){let t=a.kind===`edit`?e.find(e=>e.id===a.id)??null:null;return(0,H.jsx)(Bs,{editing:t,servers:n,sidebarData:r,handlers:i})}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`MCP sources`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Let Kanna listen to an MCP server you already added, such as a Zalo or mail server, and put what arrives into the Inbox. Replies go back out through the same server.`})]}),(0,H.jsxs)(k,{size:`sm`,onClick:s,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add source`]})]}),e.length===0?(0,H.jsx)(Zr,{icon:dr,message:`No MCP sources yet. Add one to bring a server's messages into the Inbox.`}):(0,H.jsx)(Qr,{children:e.map(e=>(0,H.jsx)(Vs,{source:e,serverName:n.find(t=>t.id===e.serverId)?.name??`Missing server`,status:t.find(t=>t.id===e.id),now:c,confirmingDelete:o===e.id,handlers:i},e.id))})]})}function Us({state:e}){let t=z(hn),n=z(Xt),r=_(e=>e.statuses),i=Io(`mcpSources`,e),a=Lo(`mcpSources`,e),o=(0,V.useMemo)(()=>({...i,onSetEnabled:a}),[i,a]);return(0,H.jsx)(Hs,{sources:t,statuses:r,servers:n,sidebarData:e.sidebarData,handlers:o})}var Ws={id:``,label:``,modelProvider:`claude`,supportedEfforts:[],offersOneMillionContext:!1};function Gs(e){return{...e,error:null}}var Ks=I()(e=>({editing:jo,editorForm:Gs(Ws),setEditing:t=>e({editing:t}),resetEditorForm:t=>e({editorForm:Gs(t)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),toggleSupportedEffort:t=>e(e=>{let n=e.editorForm.supportedEfforts,r=n.includes(t)?n.filter(e=>e!==t):[...n,t];return{editorForm:{...e.editorForm,supportedEfforts:r}}}),toggleOneMillionContext:()=>e(e=>({editorForm:{...e.editorForm,offersOneMillionContext:!e.editorForm.offersOneMillionContext}}))}));function qs({models:e,handlers:t,dom:n=wn}){let r=Ks(e=>e.editing),i=Ks(e=>e.setEditing),a=Ks(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a({id:``,label:``,modelProvider:t.provider,supportedEfforts:[],offersOneMillionContext:!1});else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a({id:n.id,label:n.label,modelProvider:n.provider,supportedEfforts:n.supportedEfforts??[],offersOneMillionContext:Re(n.provider,n.id,n.contextWindowOptions).some(e=>e.id===`1m`)})}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,H.jsx)(Ys,{initial:n,existing:e.map(e=>({id:e.id,provider:e.provider})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,H.jsx)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:He.map(r=>{let i=e.filter(e=>e.provider===r);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`h2`,{className:`text-base font-medium`,children:[ze(r).label,` models`]}),(0,H.jsxs)(k,{size:`sm`,onClick:()=>o({kind:`create`,provider:r}),children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add model`]})]}),i.length===0?(0,H.jsx)(Zr,{icon:Cr,message:`No ${ze(r).label} models configured.`}):(0,H.jsx)(Qr,{children:i.map(e=>(0,H.jsx)(Js,{model:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]},r)})})}function Js({model:e,onEdit:t,onDelete:n,dom:r}){let i=N(`models.delete`,e.provider,e.id),a=M(i),o=(0,V.useCallback)(()=>{r.confirmDialog(`Delete model "${e.label}"?`)&&j(i,()=>n(e.id))},[i,r,e.id,e.label,n]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex flex-col`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:e.label}),(0,H.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,H.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(e.supportedEfforts?.length??0)>0&&(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`effort`}),e.supportedEfforts?.includes(`max`)&&(0,H.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-xs`,children:`max`}),(0,H.jsx)($r,{label:e.label,onEdit:t,onDelete:o,deletePending:a})]})]})}function Ys({initial:e,existing:t,handlers:n,onDone:r}){let i=Ks(e=>e.editorForm),a=Ks(e=>e.patchEditorForm),o=Ks(e=>e.toggleSupportedEffort),s=Ks(e=>e.toggleOneMillionContext),c=(0,V.useCallback)(e=>{qe(e)&&a({modelProvider:e})},[a]),{id:l,label:u,modelProvider:d,supportedEfforts:f,offersOneMillionContext:p,error:m}=i,h=N(`models.save`,e?.id??`new`),g=M(h),_=p?Ge:Ge.filter(e=>e.id===`200k`),v=e!==null,y=(0,V.useMemo)(()=>!v&&t.some(e=>e.id===l.trim()&&e.provider===d),[t,l,v,d]),b=l.trim().length>0&&u.trim().length>0&&!y&&!g,ee=()=>Ro({patch:a,save:async()=>{v&&e?await n.onUpdate(e.id,{label:u.trim(),supportedEfforts:f.length>0?f:null,...d===`claude`?{contextWindowOptions:_}:{}}):await n.onCreate({id:l.trim(),label:u.trim(),provider:d,...f.length>0?{supportedEfforts:f}:{},...d===`claude`?{contextWindowOptions:_}:{}})},onDone:r}),x=zo({submitting:g,isEdit:v,addLabel:`Add model`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:v?`Edit model`:`Add model`}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Provider`}),(0,H.jsxs)(Ce,{value:d,onValueChange:c,disabled:v,children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:He.map(e=>(0,H.jsx)(P,{value:e,children:ze(e).label},e))})]})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Model ID`}),(0,H.jsx)(R,{value:l,onChange:e=>a({id:e.target.value}),placeholder:`claude-opus-4-9`,disabled:v,className:`font-mono`}),y&&(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:`A model with this id already exists.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,H.jsx)(R,{value:u,onChange:e=>a({label:e.target.value}),placeholder:`Opus 4.9`})]}),d===`claude`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Supported effort levels`}),Le.map(e=>(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:f.includes(e.id),onChange:()=>o(e.id)}),(0,H.jsx)(`span`,{children:e.label})]},e.id))]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window`}),(0,H.jsxs)(`label`,{className:`inline-flex cursor-pointer items-center gap-2 text-sm`,children:[(0,H.jsx)(`input`,{type:`checkbox`,checked:p,onChange:s}),(0,H.jsx)(`span`,{children:`Offer the 1M context window`})]}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Off means every turn on this model runs on the 200k window.`})]})]}),m&&(0,H.jsx)(`span`,{className:`text-xs text-red-600`,children:m}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:()=>{j(h,ee)},pending:g,disabled:!b,children:x}),(0,H.jsx)(k,{variant:`ghost`,onClick:r,disabled:g,children:`Cancel`})]})]})}function Xs(e){let t=z(Wt),n=Io(`customModels`,e.state);return(0,H.jsx)(qs,{models:t,handlers:n})}function Zs(e){if(!e)return`—`;let t=e.trim();if(!t)return`—`;let n=t.slice(-4);return`${t.startsWith(`sk-ant-`)?`sk-ant-`:``}…${n}`}var q=I()(e=>({addLabel:``,addToken:``,addBaseUrl:``,addSubmitting:!1,tokenRowStates:{},baseUrlDrafts:{},setAddLabel:t=>e({addLabel:t}),setAddToken:t=>e({addToken:t}),setAddBaseUrl:t=>e({addBaseUrl:t}),setAddSubmitting:t=>e({addSubmitting:t}),resetAddForm:()=>e({addLabel:``,addToken:``,addBaseUrl:``}),setTokenRowTesting:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testing:n}}})),setTokenRowTestResult:(t,n)=>e(e=>({tokenRowStates:{...e.tokenRowStates,[t]:{...e.tokenRowStates[t]??{testResult:null,testing:!1},testResult:n}}})),clearTokenRowState:t=>e(e=>({tokenRowStates:ce(e.tokenRowStates,t)})),setBaseUrlDraft:(t,n)=>e(e=>({baseUrlDrafts:{...e.baseUrlDrafts,[t]:n}})),clearBaseUrlDraft:t=>e(e=>({baseUrlDrafts:ce(e.baseUrlDrafts,t)}))}));function Qs(e){if(e<=0)return`reset now`;let t=Math.ceil(e/1e3),n=Math.floor(t/60),r=t%60;return n<60?`reset in ${n}m ${r.toString().padStart(2,`0`)}s`:`reset in ${Math.floor(n/60)}h ${(n%60).toString().padStart(2,`00`)}m`}function $s({entry:e,now:t}){if(e.status===`active`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/50`,"aria-hidden":`true`}),`Active`]});if(e.status===`limited`){let n=e.limitedUntil===null?null:Qs(e.limitedUntil-t);return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-amber-600 dark:text-amber-400`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-amber-500`,"aria-hidden":`true`}),`Limited`,n!==null&&(0,H.jsxs)(H.Fragment,{children:[` `,`(`,(0,H.jsx)(`span`,{className:`tabular-nums`,children:n}),`)`]})]})}if(e.status===`disabled`)return(0,H.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground/60`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-muted-foreground/30`,"aria-hidden":`true`}),`Disabled`]});let n=e.lastErrorMessage??`Unknown error`;return(0,H.jsx)(mt,{children:(0,H.jsxs)(dt,{children:[(0,H.jsx)(ft,{asChild:!0,children:(0,H.jsxs)(`span`,{className:`inline-flex cursor-default items-center gap-1.5 text-xs text-destructive`,children:[(0,H.jsx)(`span`,{className:`size-1.5 rounded-full bg-destructive`,"aria-hidden":`true`}),`Error`,(0,H.jsx)(`span`,{className:`sr-only`,children:n})]})}),(0,H.jsx)(pt,{"aria-hidden":`true`,children:n})]})})}var ec=3e3;function tc(){return(0,H.jsx)(`div`,{className:`mt-1 text-xs text-destructive`,children:et})}function nc({entry:e,now:t,isCurrent:n,concurrencyDefault:r,onRemove:i,onToggleDisabled:a,onTest:o,onChangeMaxConcurrent:s,onChangeBaseUrl:c,ports:l}){let u=l?.timer??lt,d=q(e=>e.tokenRowStates),f=q(e=>e.setTokenRowTesting),p=q(e=>e.setTokenRowTestResult),m=q(e=>e.baseUrlDrafts),h=q(e=>e.setBaseUrlDraft),g=d[e.id],_=g?.testResult??null,v=g?.testing??!1,y=m[e.id]??e.baseUrl??``,b=Xe(y,512).kind===`invalid`,ee=N(`oauthPool.remove`,e.id),x=N(`oauthPool.toggle`,e.id),te=N(`oauthPool.concurrency`,e.id),S=N(`oauthPool.baseUrl`,e.id),ne=N(`oauthPool.test`,e.id),C=M(ee),w=M(x),re=M(te),ie=M(S),ae=()=>j(S,()=>c(e.id,y)),T=e=>{e.key===`Enter`&&e.currentTarget.blur()},oe=async()=>{f(e.id,!0),p(e.id,null);try{let t=await o(e.token,e.baseUrl),n=t.ok?`OK`:t.error??`Error`;p(e.id,n)}catch{p(e.id,`Error`)}finally{f(e.id,!1),u.setTimeout(()=>p(e.id,null),ec)}},D=e.status===`disabled`,O=D?zr:Lr,se=e.maxConcurrent??r;return(0,H.jsxs)(`div`,{className:`border-t border-border py-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium ${D?`text-muted-foreground/60`:`text-foreground`}`,children:e.label}),(0,H.jsx)(`code`,{className:`text-xs font-mono text-muted-foreground`,children:Zs(e.token)}),n&&(0,H.jsx)(`span`,{className:`inline-flex shrink-0 items-center whitespace-nowrap rounded-full border border-primary/40 bg-primary/10 px-1.5 py-0.5 text-xs font-medium tracking-wide text-primary`,children:`In use`})]}),(0,H.jsx)(`div`,{className:`mt-0.5`,children:(0,H.jsx)($s,{entry:e,now:t})})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,H.jsx)(En,{label:`Maximum concurrent chats sharing this OAuth token. Higher = risks Anthropic rate limits.`,children:(0,H.jsxs)(`label`,{className:`inline-flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{children:`Concurrent`}),re?(0,H.jsx)(E,{className:`size-3`}):null,(0,H.jsx)(R,{type:`number`,value:se,readOnly:re,"aria-busy":re||void 0,onChange:t=>j(te,()=>s(e.id,Ht(Number(t.target.value)))),min:1,"aria-label":`Max concurrent chats`,className:`h-7 w-14 text-xs`,disabled:D})]})}),_!==null&&(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:_}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":`Test`,onClick:()=>j(ne,oe),disabled:v||D,"aria-busy":v||void 0,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[v?(0,H.jsx)(E,{className:`size-3`}):(0,H.jsx)(Tr,{className:`size-3`,"aria-hidden":`true`}),`Test`]}),(0,H.jsx)(mt,{children:(0,H.jsxs)(dt,{children:[(0,H.jsx)(ft,{asChild:!0,children:(0,H.jsxs)(`button`,{type:`button`,"aria-label":D?`Enable`:`Disable`,onClick:()=>j(x,a),disabled:w,"aria-busy":w||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[w?(0,H.jsx)(E,{}):(0,H.jsx)(O,{"aria-hidden":`true`,className:`size-3.5`}),(0,H.jsx)(`span`,{className:`sr-only`,children:D?`Enable`:`Disable`})]})}),(0,H.jsx)(pt,{children:D?`Enable`:`Disable`})]})}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":`Remove`,onClick:()=>j(ee,i),disabled:C,"aria-busy":C||void 0,className:`rounded p-1 text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default`,children:[C?(0,H.jsx)(E,{}):(0,H.jsx)(Je,{className:`size-3.5`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Remove`})]})]})]}),(0,H.jsx)(En,{label:`Anthropic API endpoint this token authenticates against. Leave empty for the default api.anthropic.com; set it to route this credential through a proxy.`,children:(0,H.jsxs)(`label`,{className:`mt-2 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`shrink-0`,children:`Base URL`}),ie?(0,H.jsx)(E,{className:`size-3`}):null,(0,H.jsx)(R,{value:y,readOnly:ie,"aria-busy":ie||void 0,onChange:t=>h(e.id,t.target.value),onBlur:ae,onKeyDown:T,placeholder:`(default)`,maxLength:512,"aria-label":`Anthropic base URL for ${e.label}`,className:`h-7 flex-1 text-xs font-mono`,disabled:D})]})}),b&&(0,H.jsx)(tc,{})]})}function rc({tokens:e,onWrite:t}){let n=q(e=>e.addLabel),r=q(e=>e.addToken),i=q(e=>e.addBaseUrl),a=q(e=>e.addSubmitting),o=q(e=>e.setAddLabel),s=q(e=>e.setAddToken),c=q(e=>e.setAddBaseUrl),l=q(e=>e.setAddSubmitting),u=q(e=>e.resetAddForm),d=Xe(i,512),f=d.kind===`invalid`,p=n.trim().length>0&&r.trim().length>0&&!f&&!a,m=async()=>{if(p){l(!0);try{let i={id:crypto.randomUUID(),label:n.trim(),token:r.trim(),status:`active`,limitedUntil:null,lastUsedAt:null,lastErrorAt:null,lastErrorMessage:null,addedAt:Date.now(),...d.kind===`url`?{baseUrl:d.url}:{}};await t({tokens:[...e,i]}),u()}finally{l(!1)}}};return(0,H.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-end sm:gap-3`,children:[(0,H.jsx)(`div`,{className:`flex-1`,children:(0,H.jsx)(R,{value:n,onChange:e=>o(e.target.value),placeholder:`e.g. personal`,maxLength:64,className:`text-sm`,"aria-label":`Token label`})}),(0,H.jsx)(`div`,{className:`flex-[2]`,children:(0,H.jsx)(R,{value:r,onChange:e=>s(e.target.value),type:`password`,placeholder:`sk-ant-...`,maxLength:1024,className:`text-sm font-mono`,"aria-label":`OAuth token`})}),(0,H.jsxs)(`button`,{type:`button`,onClick:()=>j(`oauthPool.add`,m),disabled:!p,"aria-busy":a||void 0,className:`inline-flex shrink-0 items-center gap-1.5 rounded-lg border border-border bg-background px-3 py-2 text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50`,children:[a?(0,H.jsx)(E,{}):null,`Add token`]})]}),(0,H.jsxs)(`div`,{className:`mt-2`,children:[(0,H.jsx)(R,{value:i,onChange:e=>c(e.target.value),placeholder:`Base URL — leave empty for api.anthropic.com`,maxLength:512,className:`text-sm font-mono`,"aria-label":`Anthropic base URL`}),f&&(0,H.jsx)(tc,{})]})]})}function ic({tokens:e,concurrencyDefault:t,onWrite:n,onTest:r,now:i,ports:a}){let o=i??Date.now(),s=q(e=>e.clearBaseUrlDraft),c=e.reduce((e,t)=>t.lastUsedAt!==null&&(e===null||t.lastUsedAt>(e.lastUsedAt??0))?t:e,null)?.id??null,l=t=>n({tokens:e.filter(e=>e.id!==t)}),u=t=>n({tokens:e.map(e=>e.id===t?{...e,status:e.status===`disabled`?`active`:`disabled`}:e)}),d=(t,r)=>n({tokens:e.map(e=>e.id===t?{...e,maxConcurrent:r}:e)}),f=async(t,r)=>{let i=e.find(e=>e.id===t);if(!i)return;let a=Xe(r,512);if(a.kind===`invalid`)return;let o=a.kind===`url`?a.url:null;s(t),o!==(i.baseUrl??null)&&await n({tokens:e.map(e=>{if(e.id!==t)return e;let{baseUrl:n,...r}=e;return o===null?r:{...e,baseUrl:o}})})},p=M(`oauthPool.concurrencyDefault`),m=e=>{j(`oauthPool.concurrencyDefault`,()=>n({concurrencyDefault:Ht(e)}))};return(0,H.jsxs)(`div`,{children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pb-3`,children:[(0,H.jsx)(En,{label:`Default concurrent-chat cap applied to any OAuth token whose row does not override it. Sharing across N chats burns Anthropic quota and risks 429s.`,children:(0,H.jsxs)(`label`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,H.jsx)(`span`,{className:`font-medium text-foreground`,children:`Default concurrency per token`}),(0,H.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Cap for tokens without an explicit per-row override. Minimum `,1,`, no upper limit.`]})]})}),p?(0,H.jsx)(E,{className:`ml-auto text-muted-foreground`}):null,(0,H.jsx)(R,{type:`number`,value:t,readOnly:p,"aria-busy":p||void 0,onChange:e=>m(Number(e.target.value)),min:1,"aria-label":`Default concurrency per token`,className:`h-8 w-16 text-sm`})]}),e.map(e=>(0,H.jsx)(nc,{entry:e,now:o,isCurrent:e.id===c,concurrencyDefault:t,onRemove:()=>l(e.id),onToggleDisabled:()=>u(e.id),onTest:r,onChangeMaxConcurrent:d,onChangeBaseUrl:f,ports:a},e.id)),(0,H.jsx)(rc,{tokens:e,onWrite:n})]})}var J=I()(e=>({claudeIdleMinutesDraft:``,claudeMaxConcurrentDraft:``,llmProviderDraft:{provider:`openai`,apiKey:``,model:``,baseUrl:``},llmProviderError:null,llmValidationStatus:`idle`,llmValidationError:null,llmValidationDialogOpen:!1,setClaudeIdleMinutesDraft:t=>e({claudeIdleMinutesDraft:t}),setClaudeMaxConcurrentDraft:t=>e({claudeMaxConcurrentDraft:t}),setLlmProviderDraft:t=>e({llmProviderDraft:t}),setLlmProviderError:t=>e({llmProviderError:t}),llmDraftChanged:()=>e({llmValidationStatus:`idle`,llmValidationError:null}),llmValidated:(t,n)=>e({llmValidationStatus:t,llmValidationError:n}),setLlmValidationDialogOpen:t=>e({llmValidationDialogOpen:t})})),ac=32,oc=`-`;function sc(){return{id:``,idTouched:!1,label:``,baseUrl:``,apiKey:``,models:[cc()],contextWindow:``,hint:null}}function cc(){return{id:``,label:``}}function lc(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^[^a-z]+/,``).replace(/-+$/,``).slice(0,ac).replace(/-+$/,``)}function uc(e,t){if(e.length===0||!t.includes(e))return e;for(let n=2;;n+=1){let r=`-${n}`,i=`${e.slice(0,ac-r.length)}${r}`;if(!t.includes(i))return i}}function dc(e,t){return{id:uc(e.id,t),idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:e.defaultApiKey??``,models:e.models.length>0?e.models.map(e=>({...e})):[cc()],contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:e.hint??null}}function fc(e){return{id:e.id,idTouched:!0,label:e.label,baseUrl:e.baseUrl,apiKey:``,models:e.models.map(e=>({...e})),contextWindow:e.contextWindow===void 0?``:String(e.contextWindow),hint:null}}function pc(e,t){return uc(lc(e),t)}function mc(e){return e.map(e=>({id:e.id.trim(),label:e.label.trim()})).filter(e=>e.id.length>0||e.label.length>0)}function hc(e){let t=e.replace(/[\s,_]/g,``);return t.length===0?void 0:Number(t)}function gc(e){let t=hc(e.contextWindow);return{id:e.id.trim(),label:e.label.trim(),baseUrl:e.baseUrl.trim(),apiKey:e.apiKey.trim(),models:mc(e.models),...t===void 0?{}:{contextWindow:t}}}function _c(e){let t=e.apiKey.trim();return{label:e.label.trim(),baseUrl:e.baseUrl.trim(),models:mc(e.models),contextWindow:hc(e.contextWindow)??null,...t.length>0?{apiKey:t}:{}}}function vc(e,t,n){let r=gc(e),i=Ye({...r,apiKey:t===`edit`&&r.apiKey.length===0?oc:r.apiKey},n);return i===null?null:i.code===`INVALID_ID`?`Id must be lowercase letters, digits or dashes, start with a letter, and be at most ${ac} characters (${Ze}).`:i.message}function yc(e){return`${e<1e6&&e%1024==0?`${e/1024}k`:Ee(e)} context`}function bc(e){return e===null?`Key set`:`Key ••••${e}`}function xc(e,t){return e===`create`?`API key`:t===null?`Leave blank to keep the saved key`:`Leave blank to keep ••••${t}`}function Sc(e){return{...e,error:null}}var Y=I()(e=>({editing:jo,menuOpen:!1,listError:null,editorForm:Sc(sc()),setMenuOpen:t=>e({menuOpen:t}),setListError:t=>e({listError:t}),startEditing:(t,n)=>e({editing:t,menuOpen:!1,listError:null,editorForm:Sc(n)}),discardEditor:()=>e({editing:jo,menuOpen:!1,editorForm:Sc(sc())}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}})),setLabel:(t,n)=>e(e=>({editorForm:{...e.editorForm,label:t,id:e.editorForm.idTouched?e.editorForm.id:pc(t,n)}})),setId:t=>e(e=>({editorForm:{...e.editorForm,id:t.toLowerCase(),idTouched:!0}})),setModelField:(t,n,r)=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.map((e,i)=>i===t?{...e,[n]:r}:e)}})),addModelRow:()=>e(e=>({editorForm:{...e.editorForm,models:[...e.editorForm.models,{id:``,label:``}]}})),removeModelRow:t=>e(e=>({editorForm:{...e.editorForm,models:e.editorForm.models.filter((e,n)=>n!==t)}}))})),Cc=[{id:`glm`,label:`GLM (Z.AI)`,baseUrl:`https://api.z.ai/api/anthropic`,models:[{id:`glm-5.3`,label:`GLM-5.3`},{id:`glm-5.3-flash`,label:`GLM-5.3 Flash`}]},{id:`qwen`,label:`Qwen (Alibaba Model Studio)`,baseUrl:`https://coding-intl.dashscope.aliyuncs.com/apps/anthropic`,models:[{id:`qwen3.7-plus`,label:`Qwen3.7 Plus`},{id:`qwen3.7-max`,label:`Qwen3.7 Max`}],hint:`Coding Plan endpoint. Pay-as-you-go uses https://{WorkspaceId}.<region>.maas.aliyuncs.com/apps/anthropic.`},{id:`kimi`,label:`Kimi (Moonshot)`,baseUrl:`https://api.moonshot.ai/anthropic`,models:[{id:`kimi-k3`,label:`Kimi K3`},{id:`kimi-k2.7-code`,label:`Kimi K2.7 Code`}]},{id:`deepseek`,label:`DeepSeek`,baseUrl:`https://api.deepseek.com/anthropic`,models:[{id:`deepseek-v4-pro`,label:`DeepSeek V4 Pro`},{id:`deepseek-flash`,label:`DeepSeek Flash`}]},{id:`minimax`,label:`MiniMax`,baseUrl:`https://api.minimax.io/anthropic`,models:[{id:`MiniMax-M3.1`,label:`MiniMax M3.1`}],hint:`Mainland China: https://api.minimaxi.com/anthropic`},{id:`ollama`,label:`Ollama (local)`,baseUrl:`http://localhost:11434`,models:[],contextWindow:65536,defaultApiKey:`ollama`,hint:"Runs on this machine. Ollama ignores the API key, so any value works. Add the exact model names from `ollama list`, and set Context window to your OLLAMA_CONTEXT_LENGTH."}],wc=`Anthropic-compatible endpoints such as GLM, Qwen, Kimi, DeepSeek or MiniMax. They run through the Claude agent, so tools, skills and MCP work as usual. Pick them in the chat composer under Custom endpoints.`;function Tc(e){return`${e} ${e===1?`model`:`models`}`}function Ec({providers:e,handlers:t,dom:n=wn}){let r=Y(e=>e.editing),i=Y(e=>e.discardEditor);return(0,V.useEffect)(()=>{i()},[i]),(0,H.jsxs)(`div`,{className:`border-t border-border pb-5`,children:[(0,H.jsx)(U,{title:`Custom endpoints`,description:wc,bordered:!1,alignStart:!0,children:r.kind===`list`?(0,H.jsx)(Dc,{providers:e}):null}),r.kind===`list`?(0,H.jsx)(Oc,{providers:e,onDelete:t.onDelete,dom:n}):(0,H.jsx)(Ac,{providers:e,editingId:r.kind===`edit`?r.id:null,handlers:t})]})}function Dc({providers:e}){let t=Y(e=>e.menuOpen),n=Y(e=>e.setMenuOpen),r=Y(e=>e.startEditing),i=(0,V.useMemo)(()=>e.map(e=>e.id),[e]),a=(0,V.useCallback)(e=>{r({kind:`create`},dc(e,i))},[r,i]),o=(0,V.useCallback)(()=>{r({kind:`create`},sc())},[r]);return(0,H.jsxs)(Rn,{open:t,onOpenChange:n,children:[(0,H.jsx)(Fn,{asChild:!0,children:(0,H.jsxs)(k,{size:`sm`,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add endpoint`]})}),(0,H.jsx)(Bn,{align:`end`,className:`w-64 p-1`,children:(0,H.jsxs)(`div`,{className:`space-y-1`,children:[Cc.map(e=>(0,H.jsx)(qn,{onClick:()=>a(e),selected:!1,icon:(0,H.jsx)(Vn,{className:`h-4 w-4 text-muted-foreground`}),label:e.label},e.id)),(0,H.jsx)(qn,{onClick:o,selected:!1,icon:(0,H.jsx)(Ae,{className:`h-4 w-4 text-muted-foreground`}),label:`Custom…`,description:`Any Anthropic-compatible URL`})]})})]})}function Oc({providers:e,onDelete:t,dom:n}){let r=Y(e=>e.listError);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r?(0,H.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r}):null,e.length===0?(0,H.jsx)(Zr,{icon:Vn,message:`No custom endpoints yet.`}):(0,H.jsx)(Qr,{children:e.map(e=>(0,H.jsx)(kc,{provider:e,onDelete:t,dom:n},e.id))})]})}function kc({provider:e,onDelete:t,dom:n}){let r=Y(e=>e.startEditing),i=Y(e=>e.setListError),a=N(`settings.customProviders.delete`,e.id),o=M(a),s=(0,V.useCallback)(()=>{r({kind:`edit`,id:e.id},fc(e))},[e,r]),c=(0,V.useCallback)(()=>{n.confirmDialog(`Delete endpoint "${e.label}"?`)&&j(a,async()=>{i(null);try{await t(e.id)}catch(e){i(L(e))}})},[a,n,t,e.id,e.label,i]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":o||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`truncate font-medium`,children:e.label}),(0,H.jsx)(Tn,{tooltip:e.baseUrl,className:`font-mono text-xs text-muted-foreground`,children:e.baseUrl})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-0.5 text-xs text-muted-foreground`,children:[(0,H.jsx)(`span`,{className:`tabular-nums`,children:Tc(e.models.length)}),e.contextWindow===void 0?null:(0,H.jsx)(`span`,{className:`tabular-nums`,children:yc(e.contextWindow)}),(0,H.jsx)(`span`,{children:bc(e.apiKeyHint)})]}),(0,H.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,H.jsx)($r,{label:e.label,onEdit:s,onDelete:c,deletePending:o})})]})}function Ac({providers:e,editingId:t,handlers:n}){let r=Y(e=>e.editorForm),i=Y(e=>e.patchEditorForm),a=Y(e=>e.setLabel),o=Y(e=>e.setId),s=Y(e=>e.setModelField),c=Y(e=>e.addModelRow),l=Y(e=>e.removeModelRow),u=Y(e=>e.discardEditor),d=t!==null,f=d?`edit`:`create`,p=(0,V.useMemo)(()=>e.find(e=>e.id===t)??null,[e,t]),m=(0,V.useMemo)(()=>e.filter(e=>e.id!==t).map(e=>e.id),[e,t]),h=N(`settings.customProviders`,t??`new`),g=M(h),_=(0,V.useCallback)(e=>{a(e,m)},[m,a]),v=(0,V.useCallback)(()=>{let e=vc(r,f,m);e===null?j(h,()=>Ro({patch:i,save:async()=>{t===null?await n.onCreate(gc(r)):await n.onUpdate(t,_c(r))},onDone:u})):i({error:e})},[u,t,r,n,f,m,i,h]),y=g;return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-md border border-border px-4 py-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium`,children:d?`Edit ${p?.label??t}`:`Add endpoint`}),r.hint?(0,H.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r.hint}):null,(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Label`}),(0,H.jsx)(R,{value:r.label,onChange:e=>_(e.target.value),maxLength:64,placeholder:`GLM (Z.AI)`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Id`}),(0,H.jsx)(R,{value:r.id,onChange:e=>o(e.target.value),disabled:d,placeholder:`glm`,className:`font-mono`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Part of every model id, so it cannot change after the endpoint is created.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Base URL`}),(0,H.jsx)(R,{value:r.baseUrl,onChange:e=>i({baseUrl:e.target.value}),placeholder:`https://api.example.com/anthropic`,className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`API key`}),(0,H.jsx)(R,{type:`password`,autoComplete:`off`,value:r.apiKey,onChange:e=>i({apiKey:e.target.value}),maxLength:$e,placeholder:xc(f,p?.apiKeyHint??null),className:`font-mono`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Context window (tokens)`}),(0,H.jsx)(R,{inputMode:`numeric`,value:r.contextWindow,onChange:e=>i({contextWindow:e.target.value}),placeholder:`200000`,className:`font-mono tabular-nums`}),(0,H.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`The model's real context window. The agent compacts the conversation before reaching it. Leave empty to assume 200,000. For Ollama use your OLLAMA_CONTEXT_LENGTH.`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Models`}),r.models.map((e,t)=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{value:e.id,onChange:e=>s(t,`id`,e.target.value),maxLength:128,placeholder:`Model id`,"aria-label":`Model ${t+1} id`,className:`font-mono`}),(0,H.jsx)(R,{value:e.label,onChange:e=>s(t,`label`,e.target.value),maxLength:64,placeholder:`Label (optional)`,"aria-label":`Model ${t+1} label`}),(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:()=>l(t),"aria-label":`Remove model ${t+1}`,children:(0,H.jsx)(it,{className:`h-4 w-4`})})]},t)),(0,H.jsx)(`div`,{children:(0,H.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:c,children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add model`]})})]}),r.error?(0,H.jsx)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:r.error}):null,(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:v,pending:y,children:zo({submitting:y,isEdit:d,addLabel:`Add endpoint`})}),(0,H.jsx)(k,{variant:`ghost`,onClick:u,disabled:y,children:`Cancel`})]})]})}function jc(e){let t=z(on),n=Io(`customProviders`,e.state);return(0,H.jsx)(Ec,{providers:t,handlers:n})}function Mc(e){return e===`openai`?xt:e===`openrouter`?Ve:``}function Nc(e,t){return{...e,provider:t,model:Mc(t),baseUrl:t===`custom`?e.baseUrl:``}}var Pc=`settings.writeLlmProvider`,Fc=[{value:`openai`,label:`OpenAI`},{value:`openrouter`,label:`OpenRouter`},{value:`custom`,label:`Custom`}];function Ic({saving:e,busy:t}){let n=J(e=>e.llmValidationStatus),r=J(e=>e.llmValidationError),i=J(e=>e.setLlmValidationDialogOpen),a,o;return t?(a=`inline-flex items-center gap-1.5 text-muted-foreground`,o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(E,{}),e?`Saving…`:`Loading…`]})):n===`valid`?(a=`text-success-text`,o=`Credentials valid & saved`):n===`invalid`?(a=`text-destructive`,o=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{children:`Credentials invalid.`}),r?(0,H.jsxs)(H.Fragment,{children:[` `,(0,H.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`underline underline-offset-2`,children:`See error`})]}):null]})):(a=`hidden`,o=null),(0,H.jsx)(`span`,{className:D(`mt-2 block text-sm font-medium`,a),children:o})}function Lc(){let e=J(e=>e.llmValidationDialogOpen),t=J(e=>e.setLlmValidationDialogOpen),n=J(e=>e.llmValidationError),r=n?JSON.stringify(n,null,2):``;return(0,H.jsx)(ot,{open:e,onOpenChange:t,children:(0,H.jsxs)(at,{size:`lg`,children:[(0,H.jsxs)(ct,{className:`space-y-4`,children:[(0,H.jsx)(ut,{children:`Validation Error`}),(0,H.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg border border-border bg-muted p-3 text-xs font-mono whitespace-pre-wrap break-words`,children:r})]}),(0,H.jsx)(st,{children:(0,H.jsx)(k,{variant:`secondary`,size:`sm`,onClick:()=>t(!1),children:`Close`})})]})})}function Rc({state:e}){let{llmProvider:t,handleReadLlmProvider:n,handleWriteLlmProvider:r,handleValidateLlmProvider:i}=e,a=J(e=>e.llmProviderDraft),o=J(e=>e.setLlmProviderDraft),s=J(e=>e.llmProviderError),c=J(e=>e.setLlmProviderError),l=J(e=>e.llmDraftChanged),u=J(e=>e.llmValidated),d=M(Pc),f=M(w),p=d||f;(0,V.useEffect)(()=>{j(w,n)},[n]),(0,V.useEffect)(()=>{t&&o({provider:t.provider,apiKey:t.apiKey,model:t.model,baseUrl:t.baseUrl})},[t,o]),(0,V.useEffect)(()=>{l()},[a.provider,a.apiKey,a.model,a.baseUrl,l]);let m=(0,V.useCallback)(async e=>{try{c(null),await r(e);let t=await i(e);u(t.ok?`valid`:`invalid`,t.error)}catch(e){let t=e instanceof Error?{name:e.name,message:e.message}:Te(e);u(`invalid`,t),c(L(e))}},[r,i,c,u]);function h(e=a){j(Pc,()=>m(e))}function g(e){let t=Nc(a,e);o(t),h(t)}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Quick Response SDK`,description:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{children:[`Use an OpenAI-compatible API for title and commit message generation before Claude and Codex. Stored in `,t?.filePathDisplay??`the active llm-provider.json file`,`.`]}),(0,H.jsx)(Ic,{saving:d,busy:p})]}),alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full max-w-[420px] flex-col gap-3`,children:[s?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:s}):null,t?.warning?(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:t.warning}):null,(0,H.jsxs)(Ce,{value:a.provider,disabled:p,onValueChange:e=>{an(e)&&g(e)},children:[(0,H.jsx)(ye,{className:`w-full`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:Fc.map(e=>(0,H.jsx)(P,{value:e.value,children:e.label},e.value))})})]}),a.provider===`custom`?(0,H.jsx)(R,{value:a.baseUrl,onChange:e=>o({...a,baseUrl:e.target.value}),onBlur:()=>h(),onKeyDown:e=>ia(e,h),readOnly:p,placeholder:`https://your-provider.example/v1`}):null,(0,H.jsx)(R,{type:`password`,value:a.apiKey,onChange:e=>o({...a,apiKey:e.target.value}),onBlur:()=>h(),onKeyDown:e=>ia(e,h),readOnly:p,placeholder:`API key`}),(0,H.jsx)(R,{value:a.model,onChange:e=>o({...a,model:e.target.value}),onBlur:()=>h(),onKeyDown:e=>ia(e,h),readOnly:p,placeholder:`Model id`})]})}),(0,H.jsx)(Lc,{})]})}var zc=Math.round(Xa.min/6e4),Bc=Math.round(Xa.max/6e4),Vc={min:zc,max:Bc},Hc=Math.round(Nt.idleTimeoutMs/6e4);function Uc({state:e}){let{write:t}=ca(e),n=z(e=>e.settings?.claudeDriver.lifecycle),r=G(e=>e.setAppSettingsError),i=Math.round((n?.idleTimeoutMs??Nt.idleTimeoutMs)/6e4),a=n?.maxConcurrent??Nt.maxConcurrent,o=J(e=>e.claudeIdleMinutesDraft),s=J(e=>e.setClaudeIdleMinutesDraft),c=J(e=>e.claudeMaxConcurrentDraft),l=J(e=>e.setClaudeMaxConcurrentDraft);(0,V.useEffect)(()=>{s(String(i))},[i,s]),(0,V.useEffect)(()=>{l(String(a))},[a,l]);function u(){let e=Qa(o,i,Vc);e.kind===`write`?t({claudeDriver:{lifecycle:{idleTimeoutMs:e.value*6e4}}}):(s(String(i)),e.kind===`invalid`&&r(`Idle timeout must be between ${zc} and ${Bc} minutes.`))}function d(){let e=Qa(c,a,Za);e.kind===`write`?t({claudeDriver:{lifecycle:{maxConcurrent:e.value}}}):(l(String(a)),e.kind===`invalid`&&r(`Max concurrent sessions must be between ${Za.min} and ${Za.max}.`))}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($a,{title:`Claude session idle timeout`,description:`Stop a Claude session after this many minutes without user activity. Lower values free memory sooner; higher values keep cold-start latency low.`,min:zc,max:Bc,step:1,value:o,onValueChange:s,onCommit:u,hint:`${zc}–${Bc} min · default ${Hc}`}),(0,H.jsx)($a,{title:`Max concurrent Claude sessions`,description:`Hard cap on resident Claude processes. Excess sessions are evicted LRU; their next activation cold-starts.`,min:Za.min,max:Za.max,step:1,value:c,onValueChange:l,onCommit:d,hint:`${Za.min}–${Za.max} · default ${Nt.maxConcurrent}`})]})}function Wc({state:e}){let{write:t}=ca(e),n=tt(),r=a(e=>e.defaultProvider),i=a(e=>e.providerDefaults),o=a(e=>e.setDefaultProvider),s=a(e=>e.setProviderDefaultModel),c=a(e=>e.setProviderDefaultModelOptions),l=a(e=>e.setProviderDefaultPlanMode);function u(e){o(e),t({defaultProvider:e})}function d(e,n){s(e,n),t({providerDefaults:{[e]:{model:n}}})}function f(e,n){c(e,n),t({providerDefaults:{[e]:{modelOptions:n}}})}function p(e,n){l(e,n),t({providerDefaults:{[e]:{planMode:n}}})}return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(U,{title:`Default Provider`,description:`The default harness used for new chats before a provider is locked by an existing session.`,children:(0,H.jsxs)(Ce,{value:r,onValueChange:e=>{(e===`last_used`||St(e))&&u(e)},children:[(0,H.jsx)(ye,{className:`min-w-[180px]`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsxs)(Se,{children:[(0,H.jsx)(P,{value:`last_used`,children:`Last Used`}),n.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))]})})]})}),(0,H.jsx)(jc,{state:e}),(0,H.jsx)(U,{title:`Claude Code Defaults`,description:`Saved defaults when using Claude Code.`,alignStart:!0,children:(0,H.jsx)(`div`,{className:`max-w-[420px]`,children:(0,H.jsx)(Gn,{availableProviders:n,selectedProvider:`claude`,showProviderPicker:!1,model:i.claude.model,modelOptions:i.claude.modelOptions,onModelChange:(e,t)=>{d(`claude`,t)},onModelOptionChange:e=>{e.type===`claudeReasoningEffort`?f(`claude`,{reasoningEffort:e.effort}):e.type===`contextWindow`&&f(`claude`,{contextWindow:e.contextWindow})},planMode:i.claude.planMode,onPlanModeChange:e=>p(`claude`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})}),(0,H.jsx)(U,{title:`Codex Defaults`,description:`Saved defaults when using Codex.`,alignStart:!0,children:(0,H.jsx)(`div`,{className:`max-w-[420px]`,children:(0,H.jsx)(Gn,{availableProviders:n,selectedProvider:`codex`,showProviderPicker:!1,model:i.codex.model,modelOptions:i.codex.modelOptions,onModelChange:(e,t)=>{d(`codex`,t)},onModelOptionChange:e=>{e.type===`codexReasoningEffort`?f(`codex`,{reasoningEffort:e.effort}):e.type===`fastMode`&&f(`codex`,{fastMode:e.fastMode})},planMode:i.codex.planMode,onPlanModeChange:e=>p(`codex`,e),includePlanMode:!0,className:`justify-start flex-wrap`})})})]})}function Gc({state:e}){let t=z(e=>e.settings?.claudeAuth);return(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Claude OAuth tokens`,description:`Manage multiple Claude OAuth tokens. Kanna switches automatically when one hits its rate limit.`,bordered:!1,alignStart:!0,children:(0,H.jsx)(`div`,{className:`w-full md:w-[420px]`,children:(0,H.jsx)(ic,{tokens:t?.tokens??[],concurrencyDefault:t?.concurrencyDefault??1,onWrite:e.handleWriteClaudeAuth,onTest:e.handleTestOAuthToken})})}),(0,H.jsx)(Uc,{state:e}),(0,H.jsx)(Wc,{state:e}),(0,H.jsx)(Rc,{state:e})]})}var Kc={disabled:`Disabled`,installing:`Installing`,starting:`Starting`,connecting:`Connecting`,connected:`Connected`,reconnecting:`Reconnecting`,restarting:`Restarting`,error:`Error`},qc={disabled:`muted`,installing:`attention`,starting:`attention`,connecting:`attention`,connected:`muted`,reconnecting:`attention`,restarting:`attention`,error:`destructive`};function Jc(e){return Kc[e]}function Yc(e){return qc[e]}var X=I()(e=>({connection:null,stream:null,embedded:null,consumerEditor:null,resetConfirm:!1,error:null,editConnection:(t,n)=>e(e=>({connection:{...e.connection??t,...n}})),discardConnection:()=>e({connection:null}),editStream:(t,n)=>e(e=>({stream:{...e.stream??t,...n}})),discardStream:()=>e({stream:null}),editEmbedded:(t,n)=>e(e=>({embedded:{...e.embedded??t,...n}})),discardEmbedded:()=>e({embedded:null}),openConsumerEditor:(t,n)=>e({consumerEditor:{target:t,draft:n}}),editConsumer:t=>e(e=>e.consumerEditor===null?e:{consumerEditor:{...e.consumerEditor,draft:{...e.consumerEditor.draft,...t}}}),closeConsumerEditor:()=>e({consumerEditor:null}),askResetConfirm:()=>e({resetConfirm:!0}),cancelResetConfirm:()=>e({resetConfirm:!1}),setError:t=>e({error:t})})),Xc=`auto`;function Zc(e){return{name:e.name,subjectPrefix:e.subjectPrefix,extraSubjects:e.extraSubjects.join(`
|
|
10
|
+
`),retention:e.retention,storage:e.storage,maxAgeDays:String(e.maxAgeDays),maxBytesMb:String(e.maxBytesMb),maxMsgs:String(e.maxMsgs),discard:e.discard,duplicateWindowSec:String(e.duplicateWindowSec),replicas:String(e.replicas)}}function Qc(e){return e.trim()===``?NaN:Number(e)}function $c(e){return{name:e.name.trim(),subjectPrefix:e.subjectPrefix.trim(),extraSubjects:e.extraSubjects.split(`
|
|
11
|
+
`).map(e=>e.trim()).filter(e=>e.length>0),retention:e.retention,storage:e.storage,maxAgeDays:Qc(e.maxAgeDays),maxBytesMb:Qc(e.maxBytesMb),maxMsgs:Qc(e.maxMsgs),discard:e.discard,duplicateWindowSec:Qc(e.duplicateWindowSec),replicas:Qc(e.replicas)}}function el(e){return{durableName:e.durableName,filterSubject:e.filterSubject,ackPolicy:e.ackPolicy,deliverPolicy:e.deliverPolicy,maxAckPending:String(e.maxAckPending),ackWaitSec:String(e.ackWaitSec)}}function tl(e){return{durableName:``,filterSubject:`${e}.>`,ackPolicy:Dt.ackPolicy,deliverPolicy:Dt.deliverPolicy,maxAckPending:String(Dt.maxAckPending),ackWaitSec:String(Dt.ackWaitSec)}}function nl(e){return{durableName:e.durableName.trim(),filterSubject:e.filterSubject.trim(),ackPolicy:e.ackPolicy,deliverPolicy:e.deliverPolicy,maxAckPending:Qc(e.maxAckPending),ackWaitSec:Qc(e.ackWaitSec)}}function rl(e){return{maxMemoryStoreMb:String(e.maxMemoryStoreMb),maxFileStoreMb:String(e.maxFileStoreMb),port:String(e.port),logLevel:e.logLevel}}function il(e){let t=e.port.trim().toLowerCase()===`auto`?Xc:Qc(e.port);return{maxMemoryStoreMb:Qc(e.maxMemoryStoreMb),maxFileStoreMb:Qc(e.maxFileStoreMb),port:t,logLevel:e.logLevel}}function al(e,t){return Pt({...e,...t})}function ol(e,t){let n=[];return e.retention!==t.retention&&n.push(`retention`),e.storage!==t.storage&&n.push(`storage`),e.replicas!==t.replicas&&n.push(`replicas`),n}function sl(e,t){return t.maxAgeDays<e.maxAgeDays||t.maxBytesMb<e.maxBytesMb}function cl(e,t){return JSON.stringify(Zc(e))===JSON.stringify(t)}function Z({label:e,note:t,warn:n=!1,children:r}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsx)(`div`,{className:`text-13 font-medium text-foreground`,children:e}),r,t?(0,H.jsx)(`div`,{className:D(`text-xs`,n?`text-warning-text`:`text-muted-foreground`),children:t}):null]})}function ll({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,H.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:e}),(0,H.jsx)(`dd`,{className:`font-mono text-13 tabular-nums text-foreground`,children:t})]})}function ul({problems:e}){return e.length===0?null:(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-xs text-destructive-text`,role:`alert`,children:e.map(e=>(0,H.jsx)(`li`,{children:e},e))})}var dl=N(`settings.serviceBus`,`consumers`),fl={explicit:`Explicit`,all:`All`,none:`None`},pl=Lt.map(e=>({value:e,label:fl[e]})),ml={all:`All`,new:`New`,last:`Last`},hl=Et.map(e=>({value:e,label:ml[e]}));function gl({consumer:e,onEdit:t,onRemove:n}){let r=ee(t=>t.status.consumers.find(t=>t.name===e.durableName)),i=M(N(`settings.serviceBus`,`consumer`,e.durableName));return(0,H.jsxs)(`li`,{className:`flex flex-col gap-1 px-4 py-3 md:flex-row md:items-center md:justify-between`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.durableName}),(0,H.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted-foreground`,children:[e.filterSubject||`all subjects`,` · ack `,e.ackPolicy,` · deliver `,e.deliverPolicy]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:r?`${String(r.pending)} pending · ${String(r.ackPending)} ack pending`:`not reported yet`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Edit ${e.durableName}`,onClick:t,children:(0,H.jsx)(ke,{className:`h-4 w-4`})}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Remove ${e.durableName}`,pending:i,onClick:n,children:(0,H.jsx)(Je,{className:`h-4 w-4`})})]})]})}function _l({state:e}){let t=z(Yt),n=X(e=>e.consumerEditor),r=X(e=>e.openConsumerEditor),i=X(e=>e.editConsumer),a=X(e=>e.closeConsumerEditor),o=X(e=>e.setError),s=M(dl),c=(0,V.useCallback)(t=>B(o,async()=>{await e.handleWriteAppSettings({serviceBus:{consumers:t}}),a()}),[e,a,o]),l=n?nl(n.draft):null,u=n?.target.kind===`edit`?n.target.durableName:null,d=t.consumers.filter(e=>e.durableName!==u),f=l?al(t,{consumers:[...d,l]}):[],p=(0,V.useCallback)(async()=>{if(l===null)return;let e=t.consumers.map(e=>e.durableName===u?l:e);await c(u===null?[...t.consumers,l]:e)},[l,u,t.consumers,c]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:[`Consumers `,(0,H.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:t.consumers.length})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-border py-3`,children:[(0,H.jsx)(`p`,{className:`px-4 text-13 text-muted-foreground`,children:`Durable pull consumers Kanna creates on the stream. Kanna removes only the ones it created, and never touches consumers you add elsewhere.`}),t.consumers.length===0?(0,H.jsx)(`div`,{className:`px-4 text-13 text-muted-foreground`,children:`No consumers configured`}):(0,H.jsx)(`ul`,{className:`flex flex-col divide-y divide-border border-y border-border`,children:t.consumers.map(e=>(0,H.jsx)(gl,{consumer:e,onEdit:()=>r({kind:`edit`,durableName:e.durableName},el(e)),onRemove:()=>j(N(`settings.serviceBus`,`consumer`,e.durableName),()=>c(t.consumers.filter(t=>t.durableName!==e.durableName)))},e.durableName))}),n?(0,H.jsxs)(`div`,{className:`mx-4 flex flex-col gap-4 rounded-lg border border-border p-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Durable name`,children:(0,H.jsx)(R,{"aria-label":`Durable name`,value:n.draft.durableName,disabled:u!==null,onChange:e=>i({durableName:e.target.value}),spellCheck:!1})}),(0,H.jsx)(Z,{label:`Filter subject`,note:`Leave empty for every subject in the stream`,children:(0,H.jsx)(R,{"aria-label":`Filter subject`,value:n.draft.filterSubject,onChange:e=>i({filterSubject:e.target.value}),spellCheck:!1})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Acknowledgement`,note:u===null?void 0:`Cannot change on an existing consumer; remove and add it again`,children:(0,H.jsx)(F,{size:`sm`,value:n.draft.ackPolicy,onValueChange:e=>i({ackPolicy:e}),options:pl})}),(0,H.jsx)(Z,{label:`Deliver`,children:(0,H.jsx)(F,{size:`sm`,value:n.draft.deliverPolicy,onValueChange:e=>i({deliverPolicy:e}),options:hl})}),(0,H.jsx)(Z,{label:`Max ack pending`,children:(0,H.jsx)(R,{"aria-label":`Max ack pending`,inputMode:`numeric`,className:`tabular-nums`,value:n.draft.maxAckPending,onChange:e=>i({maxAckPending:e.target.value})})}),(0,H.jsx)(Z,{label:`Ack wait (s)`,children:(0,H.jsx)(R,{"aria-label":`Ack wait in seconds`,inputMode:`numeric`,className:`tabular-nums`,value:n.draft.ackWaitSec,onChange:e=>i({ackWaitSec:e.target.value})})})]}),(0,H.jsx)(ul,{problems:f}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:s,onClick:a,children:`Cancel`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:f.length>0,pending:s,onClick:()=>j(dl,p),children:`Save consumer`})]})]}):(0,H.jsx)(`div`,{className:`px-4`,children:(0,H.jsxs)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r({kind:`new`},tl(t.stream.subjectPrefix)),children:[(0,H.jsx)(Ae,{className:`mr-1.5 h-4 w-4`}),`Add consumer`]})})]})]})}var vl=N(`settings.serviceBus`,`embedded`),yl=N(`serviceBus.resetStore`),bl={info:`Info`,debug:`Debug`},xl=Rt.map(e=>({value:e,label:bl[e]}));function Sl({state:e}){let t=kn(),n=z(Yt),r=rl(n.embedded),i=X(e=>e.embedded)??r,a=X(e=>e.editEmbedded),o=X(e=>e.discardEmbedded),s=X(e=>e.resetConfirm),c=X(e=>e.askResetConfirm),l=X(e=>e.cancelResetConfirm),u=X(e=>e.setError),d=M(vl),f=M(yl),p=al(n,{embedded:il(i)}),m=JSON.stringify(r)!==JSON.stringify(i),h=e=>a(r,e),g=(0,V.useCallback)(()=>B(u,async()=>{await e.handleWriteAppSettings({serviceBus:{embedded:il(i)}}),o()}),[e,i,o,u]),_=(0,V.useCallback)(async()=>{await B(u,async()=>{await On(t,{type:`serviceBus.resetStore`})}),l()},[t,l,u]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:`Embedded server`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border px-4 py-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Memory store (MB)`,children:(0,H.jsx)(R,{"aria-label":`Memory store in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:i.maxMemoryStoreMb,onChange:e=>h({maxMemoryStoreMb:e.target.value})})}),(0,H.jsx)(Z,{label:`File store (MB)`,children:(0,H.jsx)(R,{"aria-label":`File store in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:i.maxFileStoreMb,onChange:e=>h({maxFileStoreMb:e.target.value})})}),(0,H.jsx)(Z,{label:`Port`,note:`auto picks a free loopback port`,children:(0,H.jsx)(R,{"aria-label":`Port`,inputMode:`numeric`,className:`tabular-nums`,value:i.port,onChange:e=>h({port:e.target.value})})})]}),(0,H.jsx)(Z,{label:`Server log level`,children:(0,H.jsx)(F,{size:`sm`,value:i.logLevel,onValueChange:e=>h({logLevel:e}),options:xl})}),(0,H.jsx)(ul,{problems:p}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:!m||d,onClick:o,children:`Revert`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!m||p.length>0,pending:d,onClick:()=>j(vl,g),children:`Save server`})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-border pt-4`,children:[(0,H.jsx)(`div`,{className:`text-13 font-medium text-foreground`,children:`Reset store`}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:`Stops the embedded server, deletes every message it holds and starts it again. Kanna's own history is not touched.`}),s?(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`destructive`,size:`sm`,pending:f,onClick:()=>j(yl,_),children:`Delete the store`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:f,onClick:l,children:`Cancel`})]}):(0,H.jsx)(`div`,{children:(0,H.jsx)(k,{type:`button`,variant:`outline`,size:`sm`,onClick:c,children:`Reset store`})})]})]})]})}var Cl=N(`settings.serviceBus`,`stream`),wl=`Changing this requires recreating the stream`,Tl=`Lowering this drops older messages`,El={limits:`Limits`,interest:`Interest`,workqueue:`Work queue`},Dl=wt.map(e=>({value:e,label:El[e]})),Ol={file:`File`,memory:`Memory`},kl=Qt.map(e=>({value:e,label:Ol[e]})),Al={old:`Oldest`,new:`Newest`},jl=$t.map(e=>({value:e,label:Al[e]}));function Ml({state:e}){let t=z(Yt),n=Zc(t.stream),r=X(e=>e.stream)??n,i=X(e=>e.editStream),a=X(e=>e.discardStream),o=X(e=>e.setError),s=M(Cl),c=$c(r),l=al(t,{stream:c}),u=!cl(t.stream,r),d=ol(t.stream,c),f=sl(t.stream,c),p=e=>i(n,e),m=(0,V.useCallback)(()=>B(o,async()=>{await e.handleWriteAppSettings({serviceBus:{stream:$c(r)}}),a()}),[e,r,a,o]);return(0,H.jsxs)(`details`,{className:`rounded-lg border border-border`,children:[(0,H.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-foreground`,children:`Stream`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border px-4 py-4`,children:[(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,H.jsx)(Z,{label:`Stream name`,children:(0,H.jsx)(R,{"aria-label":`Stream name`,value:r.name,onChange:e=>p({name:e.target.value}),spellCheck:!1})}),(0,H.jsx)(Z,{label:`Subject prefix`,note:`Kanna publishes under ${r.subjectPrefix||`…`}.>`,children:(0,H.jsx)(R,{"aria-label":`Subject prefix`,value:r.subjectPrefix,onChange:e=>p({subjectPrefix:e.target.value}),spellCheck:!1})})]}),(0,H.jsx)(Z,{label:`Extra subjects`,note:`One per line; the stream also captures these`,children:(0,H.jsx)(Dn,{"aria-label":`Extra subjects`,rows:2,value:r.extraSubjects,onChange:e=>p({extraSubjects:e.target.value}),spellCheck:!1})}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Retention`,note:wl,warn:d.includes(`retention`),children:(0,H.jsx)(F,{size:`sm`,value:r.retention,onValueChange:e=>p({retention:e}),options:Dl})}),(0,H.jsx)(Z,{label:`Storage`,note:wl,warn:d.includes(`storage`),children:(0,H.jsx)(F,{size:`sm`,value:r.storage,onValueChange:e=>p({storage:e}),options:kl})}),(0,H.jsx)(Z,{label:`Replicas`,note:wl,warn:d.includes(`replicas`),children:(0,H.jsx)(R,{"aria-label":`Replicas`,inputMode:`numeric`,className:`tabular-nums`,value:r.replicas,onChange:e=>p({replicas:e.target.value})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`Max age (days)`,note:Tl,warn:f,children:(0,H.jsx)(R,{"aria-label":`Max age in days`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxAgeDays,onChange:e=>p({maxAgeDays:e.target.value})})}),(0,H.jsx)(Z,{label:`Max bytes (MB)`,note:Tl,warn:f,children:(0,H.jsx)(R,{"aria-label":`Max bytes in megabytes`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxBytesMb,onChange:e=>p({maxBytesMb:e.target.value})})}),(0,H.jsx)(Z,{label:`Max messages`,note:`-1 means unlimited`,children:(0,H.jsx)(R,{"aria-label":`Max messages`,inputMode:`numeric`,className:`tabular-nums`,value:r.maxMsgs,onChange:e=>p({maxMsgs:e.target.value})})})]}),(0,H.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,H.jsx)(Z,{label:`When full, discard`,children:(0,H.jsx)(F,{size:`sm`,value:r.discard,onValueChange:e=>p({discard:e}),options:jl})}),(0,H.jsx)(Z,{label:`Duplicate window (s)`,note:`Messages with the same id inside this window are stored once`,children:(0,H.jsx)(R,{"aria-label":`Duplicate window in seconds`,inputMode:`numeric`,className:`tabular-nums`,value:r.duplicateWindowSec,onChange:e=>p({duplicateWindowSec:e.target.value})})})]}),(0,H.jsx)(ul,{problems:l}),(0,H.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:!u||s,onClick:a,children:`Revert`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!u||l.length>0,pending:s,onClick:()=>j(Cl,m),children:`Save stream`})]})]})]})}var Nl=N(`settings.serviceBus`,`enabled`),Pl=N(`settings.serviceBus`,`mode`),Fl=N(`settings.serviceBus`,`start`),Il=N(`settings.serviceBus`,`connection`),Ll=N(`settings.serviceBus`,`token`),Rl=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}],zl={embedded:`Embedded`,external:`External`},Bl=Ft.map(e=>({value:e,label:zl[e]}));function Vl(){let e=ee(x),t=e=>e.toLocaleString(`en-US`);return(0,H.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 md:grid-cols-4`,children:[e.stream?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(ll,{label:`Messages`,value:t(e.stream.messages)}),(0,H.jsx)(ll,{label:`Size`,value:pe(e.stream.bytes)}),(0,H.jsx)(ll,{label:`First seq`,value:t(e.stream.firstSeq)}),(0,H.jsx)(ll,{label:`Last seq`,value:t(e.stream.lastSeq)})]}):null,(0,H.jsx)(ll,{label:`Published`,value:t(e.published)}),(0,H.jsx)(ll,{label:`Dropped`,value:t(e.dropped)}),(0,H.jsx)(ll,{label:`Queued`,value:t(e.queued)}),e.serverVersion?(0,H.jsx)(ll,{label:`Server`,value:`v${e.serverVersion}${e.port?` · :${String(e.port)}`:``}`}):null]})}function Hl({state:e}){let t=z(Yt),n=X(e=>e.connection)??{url:t.url,token:``},r=X(e=>e.editConnection),i=X(e=>e.discardConnection),a=X(e=>e.setError),o=M(Il),s=M(Ll),c=n.url.trim(),l=al({...t,mode:`external`},{url:c}),u=c!==t.url,d=(0,V.useCallback)(()=>B(a,async()=>{await e.handleWriteAppSettings({serviceBus:{url:c}}),i()}),[e,c,i,a]),f=(0,V.useCallback)(t=>B(a,async()=>{await e.handleWriteAppSettings({serviceBus:{token:t}}),i()}),[e,i,a]),p={url:t.url,token:``};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 border-t border-border py-5`,children:[(0,H.jsx)(Z,{label:`Server URL`,note:`Where your own nats-server listens, for example nats://nats.internal:4222`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{"aria-label":`Server URL`,value:n.url,onChange:e=>r(p,{url:e.target.value}),spellCheck:!1}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!u||l.length>0,pending:o,onClick:()=>j(Il,d),children:`Save`})]})}),(0,H.jsx)(Z,{label:`Token`,note:t.tokenHint?`A token ending in ${t.tokenHint} is stored. Kanna never shows it again.`:`No token stored`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(R,{"aria-label":`Token`,type:`password`,autoComplete:`off`,value:n.token,placeholder:t.tokenHint?`Enter a new token to replace it`:`Token`,onChange:e=>r(p,{token:e.target.value})}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:n.token.trim()===``,pending:s,onClick:()=>j(Ll,()=>f(n.token.trim())),children:`Replace token`}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`sm`,disabled:t.tokenHint===null,onClick:()=>j(Ll,()=>f(null)),children:`Clear`})]})}),(0,H.jsx)(ul,{problems:l})]})}function Ul({state:e}){let t=z(Yt),n=ee(x),r=X(e=>e.error),i=X(e=>e.setError),a=M(Fl),o=(0,V.useCallback)(t=>B(i,()=>e.handleWriteAppSettings({serviceBus:t})),[e,i]),s=(0,V.useCallback)(e=>o({enabled:e===`enabled`}),[o]),c=(0,V.useCallback)(e=>o({mode:e}),[o]),l=(0,V.useCallback)(async()=>{t.enabled&&await o({enabled:!1}),await o({enabled:!0})},[t.enabled,o]),u=t.mode===`embedded`,d=u&&(!t.enabled||n.state===`error`);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 pb-2`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Service bus`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Mirror every durable event Kanna records into a NATS JetStream stream, so other programs can read them with the nats CLI or any NATS client. Kanna's own history is not affected, and a bus outage never blocks a chat.`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-13 text-muted-foreground`,children:`Embedded mode downloads nats-server v${Ot} from GitHub on first start and runs it on loopback with a private token.`})]}),(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Mirror to NATS`,description:`When off, nothing is downloaded, started or published.`,children:(0,H.jsx)(za,{pendingKey:Nl,value:t.enabled?`enabled`:`disabled`,onValueChange:s,options:Rl,size:`sm`})}),(0,H.jsx)(U,{title:`Server`,description:`Embedded runs a nats-server that Kanna manages. External connects to one you run.`,children:(0,H.jsx)(za,{pendingKey:Pl,value:t.mode,onValueChange:c,options:Bl,size:`sm`})}),(0,H.jsx)(U,{title:`Status`,description:n.lastError?(0,H.jsx)(`span`,{className:`text-destructive-text`,children:n.lastError}):`Live state of the mirror.`,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(jn,{tone:Yc(n.state),label:Jc(n.state)}),d?(0,H.jsx)(k,{type:`button`,size:`sm`,pending:a,onClick:()=>j(Fl,l),children:t.enabled?`Retry`:`Install & start`}):null]})})]}),r?(0,H.jsx)(`div`,{className:`text-xs text-destructive-text`,role:`alert`,children:r}):null,t.enabled||n.state!==`disabled`?(0,H.jsx)(`div`,{className:`py-3`,children:(0,H.jsx)(Vl,{})}):null,u?null:(0,H.jsx)(Hl,{state:e}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,children:[(0,H.jsx)(Ml,{state:e}),(0,H.jsx)(_l,{state:e}),u?(0,H.jsx)(Sl,{state:e}):null]})]})}function Wl(e,t){if(!e.pinnedRef)return null;let n=t.latestVersion;return!n||n===e.pinnedRef?null:n}var Gl={outdated:`Outdated`,partial:`Partial`,unknown:`Unknown`};function Kl(e){if(!e)return null;let t=Wl(e,e.update);if(t)return`Re-pin to ${t}`;if(e.pinnedRef)return null;let n=e.update.availability;return n===`outdated`||n===`partial`?`Update`:null}function ql({availability:e}){return e===void 0||e===`up_to_date`?null:(0,H.jsx)(`span`,{className:D(`rounded-full border px-2 py-0.5 text-xs font-medium`,_i[e]),children:Gl[e]})}function Jl({label:e,updating:t,onClick:n}){return(0,H.jsxs)(k,{type:`button`,size:`sm`,variant:`secondary`,disabled:t,"aria-busy":t||void 0,onClick:n,className:`h-6 rounded-full px-2 text-xs`,children:[t?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):null,e]})}function Yl({skill:e,packageEntry:t,uninstalling:n,applying:r,onUninstall:i,onUpdate:a}){let o=e.source?`https://skills.sh/${e.source}/${e.name}`:null,s=t?.versionLabel??t?.revision?.slice(0,7)??t?.updatedAt??null,c=t?.pinnedRef??null,l=Kl(t);return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.source||`Unknown source`}),s?(0,H.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:s}):null,c?(0,H.jsxs)(`div`,{className:`truncate font-mono tabular-nums text-xs text-muted-foreground/70`,children:[`Pinned `,c]}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,H.jsx)(ql,{availability:t?.update.availability}),l?(0,H.jsx)(Jl,{label:l,updating:r,onClick:a}):null,o?(0,H.jsx)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}):null,(0,H.jsx)(`button`,{type:`button`,"aria-label":`Uninstall ${e.name}`,disabled:n,onClick:i,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive disabled:pointer-events-none disabled:opacity-50`,children:n?(0,H.jsx)(A,{className:`h-4 w-4 animate-spin`}):(0,H.jsx)(Je,{className:`h-4 w-4`})})]})]})}var Xl=[],Zl=[],Ql={},$l=`Installed globally`;function eu(e){return new Set(e.map(e=>e.name))}function tu(e,t){let{[t]:n,...r}=e;return r}var Q=I()(e=>({query:``,results:Xl,searchLoading:!1,searchError:null,installedSkills:Zl,installedSkillIds:new Set,installedLoading:!1,installedError:null,operationError:null,installMessages:Ql,setQuery:t=>e({query:t}),searchCleared:t=>e({results:Xl,searchError:t,searchLoading:!1}),searchStarted:()=>e({searchLoading:!0,searchError:null}),searchSucceeded:t=>e({results:t,searchLoading:!1}),searchFailed:t=>e({results:Xl,searchError:t,searchLoading:!1}),installedCleared:()=>e({installedSkills:Zl,installedSkillIds:new Set,installedError:null,installedLoading:!1}),installedLoadStarted:()=>e({installedLoading:!0,installedError:null}),installedLoaded:t=>e({installedSkills:t,installedSkillIds:eu(t)}),installedLoadFailed:t=>e({installedSkills:Zl,installedSkillIds:new Set,installedError:t}),installedLoadFinished:()=>e({installedLoading:!1}),setOperationError:t=>e({operationError:t}),installStarted:t=>e(e=>({operationError:null,installMessages:tu(e.installMessages,t)})),installSucceeded:t=>e(e=>({installedSkillIds:new Set([...e.installedSkillIds,t]),installMessages:{...e.installMessages,[t]:$l}})),uninstallSucceeded:t=>e(e=>({installedSkills:e.installedSkills.filter(e=>e.name!==t),installedSkillIds:new Set([...e.installedSkillIds].filter(e=>e!==t)),installMessages:tu(e.installMessages,t)}))}));function nu(e){return N(`skills.install`,e)}function ru(e){return!e||e<=0?`0 installs`:e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,``)}M installs`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}K installs`:`${e} install${e===1?``:`s`}`}var iu=N(`packages.checkUpdates`),au=N(`packages.updateAll`,`skill`);function ou(e){return`skill:${e}`}function su({skill:e,packageEntry:t,applying:n,onUninstall:r,onUpdate:i}){let a=ou(e.name),o=M(N(`packages.update`,a)),s=M(N(`skills.uninstall`,e.name));return(0,H.jsx)(Yl,{skill:e,packageEntry:t,uninstalling:s,applying:n||o,onUninstall:()=>r(e),onUpdate:()=>i(a)})}function cu({message:e}){return(0,H.jsx)(`pre`,{className:`max-w-full overflow-x-auto whitespace-pre-wrap rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-xs text-destructive`,children:e})}function lu({skill:e,installing:t,installed:n,message:r,onInstall:i}){let a;return a=n?`Installed`:t?`Installing`:`Get`,(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),(0,H.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.source,` · `,ru(e.installs)]}),n&&r?(0,H.jsx)(`div`,{className:`mt-1 truncate text-xs text-emerald-500`,children:r}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,H.jsx)(`a`,{href:`https://skills.sh/${e.id}`,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} on skills.sh`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}),(0,H.jsxs)(k,{type:`button`,size:`sm`,variant:n?`secondary`:`default`,disabled:t||n,onClick:i,className:`h-6 rounded-full px-2 text-xs`,children:[t?(0,H.jsx)(A,{className:`mr-1.5 h-3.5 w-3.5 animate-spin`}):null,a]})]})]})}function uu({state:e,ports:t}){let n=t?.timer??lt,r=e.socket,i=e.connectionStatus,a=Q(e=>e.query),o=Q(e=>e.setQuery),s=Q(e=>e.results),c=Q(e=>e.searchLoading),l=Q(e=>e.searchError),u=Q(e=>e.searchCleared),d=Q(e=>e.searchStarted),f=Q(e=>e.searchSucceeded),p=Q(e=>e.searchFailed),m=Q(e=>e.installedSkills),h=Q(e=>e.installedSkillIds),g=Q(e=>e.installedLoading),_=Q(e=>e.installedError),v=Q(e=>e.installedCleared),y=Q(e=>e.installedLoadStarted),b=Q(e=>e.installedLoaded),ee=Q(e=>e.installedLoadFailed),x=Q(e=>e.installedLoadFinished),te=Q(e=>e.operationError),S=Q(e=>e.setOperationError),ne=se(e=>e.inFlight),w=Q(e=>e.installMessages),re=Q(e=>e.installStarted),ie=Q(e=>e.installSucceeded),ae=Q(e=>e.uninstallSucceeded),T=C(e=>e.updateSnapshot),oe=T?.status===`checking`,E=T?.packages.filter(e=>e.kind===`skill`&&!e.pinnedRef).filter(e=>e.update.availability===`outdated`||e.update.availability===`partial`).map(e=>e.id)??[],D=E.length,O=T?.lastCheckedAt?new Date(T.lastCheckedAt).toLocaleTimeString():null,ce=M(iu),le=M(au),ue=oe||ce;async function de(e){await B(S,()=>r.command(e))}function fe(){j(iu,()=>de({type:`packages.checkUpdates`}))}function pe(e){j(N(`packages.update`,e),()=>de({type:`packages.update`,id:e}))}function me(){E.length!==0&&j(au,()=>de({type:`packages.updateAll`,ids:E}))}function he(e){j(nu(e.id),()=>ve(e))}function ge(e){j(N(`skills.uninstall`,e.name),()=>ye(e))}let _e=(0,V.useCallback)(async()=>{if(i!==`connected`)v();else try{y();let e=await r.command({type:`skills.listInstalled`});b(e.skills)}catch(e){ee(L(e))}finally{x()}},[i,r,v,y,b,ee,x]);(0,V.useEffect)(()=>{Cn(`skills.listInstalled`,_e())},[i,_e,r]),(0,V.useEffect)(()=>{let e=a.trim();if(e.length<2){u(null);return}if(i!==`connected`){u(`Backend connection required.`);return}let t=!1;d();let o=n.setTimeout(()=>{r.command({type:`skills.search`,query:e,limit:100}).then(e=>{t||f(e.skills)}).catch(e=>{t||p(L(e))})},250);return()=>{t=!0,n.clearTimeout(o)}},[i,a,r,u,d,f,p,n]);async function ve(e){if(i!==`connected`)S(`Backend connection required.`);else try{re(e.skillId),await r.command({type:`skills.install`,source:e.source,skillId:e.skillId}),ie(e.skillId),Cn(`skills.listInstalled`,_e())}catch(e){S(L(e))}}async function ye(e){i===`connected`?await B(S,async()=>{await r.command({type:`skills.uninstall`,skillId:e.name}),ae(e.name),Cn(`skills.listInstalled`,_e())}):S(`Backend connection required.`)}let P;return P=m.length>0?(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:m.map(e=>(0,H.jsx)(su,{skill:e,packageEntry:T?.packages.find(t=>t.kind===`skill`&&t.name===e.name)??null,applying:T?.applying.includes(ou(e.name))??!1,onUninstall:ge,onUpdate:pe},`${e.source}/${e.name}`))}):g?null:(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No global skills installed.`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[te?(0,H.jsx)(cu,{message:te}):null,(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Installed`}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O?(0,H.jsxs)(`span`,{className:`tabular-nums text-xs text-muted-foreground`,children:[`Checked `,O]}):null,D>0?(0,H.jsxs)(k,{size:`sm`,variant:`secondary`,className:`h-6 rounded-full px-2 text-xs`,pending:le,onClick:me,children:[`Update all (`,D,`)`]}):null,(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:ue,"aria-busy":ue||void 0,onClick:fe,children:[ue?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):null,`Check`]}),g?(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}):null]})]}),_?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:_}):null,P]}),(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Discover`}),(0,H.jsxs)(`div`,{className:`flex h-10 items-center gap-2 rounded-lg border border-border bg-card/30 px-3`,children:[(0,H.jsx)(Me,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,H.jsx)(`input`,{type:`text`,role:`searchbox`,value:a,onChange:e=>o(e.target.value),placeholder:`Search skills`,className:`min-w-0 flex-1 bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground`}),a?(0,H.jsx)(`button`,{type:`button`,"aria-label":`Clear skills search`,onClick:()=>o(``),className:`touch-manipulation inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(it,{className:`h-3.5 w-3.5`})}):null,c?(0,H.jsx)(A,{className:`h-4 w-4 shrink-0 animate-spin text-muted-foreground`}):null]}),l?(0,H.jsx)(`div`,{className:`text-xs text-destructive`,children:l}):null,(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:s.map(e=>(0,H.jsx)(lu,{skill:e,installing:ne[nu(e.id)]===!0,installed:h.has(e.skillId),message:w[e.skillId],onInstall:()=>{he(e)}},e.id))}),!c&&!l&&a.trim().length>=2&&s.length===0?(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:`No skills found.`}):null]})]})}var du=`auto`;function fu(e){return e.triggerMode??`auto`}function pu(e,t,n){return t?.[e].model||n?.find(t=>t.id===e)?.defaultModel||ze(e).defaultModel}function mu(e,t){return e===`claude`?{...t?.claude.modelOptions??Ne}:e===`codex`?{...t?.codex.modelOptions??Be}:{}}function hu(e,t,n){return{name:``,provider:e,model:pu(e,t,n),modelOptions:mu(e,t),systemPrompt:``,contextScope:`previous-assistant-reply`,triggerMode:du}}function gu(e){return{name:e.name,description:e.description,provider:e.provider,model:e.model,modelOptions:e.modelOptions,systemPrompt:e.systemPrompt,contextScope:e.contextScope,triggerMode:e.triggerMode,workingDir:e.workingDir,allowedPaths:e.allowedPaths,maxTurns:e.maxTurns,allowBeaconTools:e.allowBeaconTools}}function _u(e){return{...e,maxTurns:e.maxTurns??null}}function vu(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function yu(e,t){if(!_t(e)||!_t(t))return!1;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!1;return!0}var bu={name:(e,t)=>e.name===t.name,description:(e,t)=>(e.description??``)===(t.description??``),provider:(e,t)=>e.provider===t.provider,model:(e,t)=>e.model===t.model,modelOptions:(e,t)=>yu(e.modelOptions,t.modelOptions),systemPrompt:(e,t)=>e.systemPrompt===t.systemPrompt,contextScope:(e,t)=>e.contextScope===t.contextScope,triggerMode:(e,t)=>fu(e)===fu(t),workingDir:(e,t)=>(e.workingDir??``)===(t.workingDir??``),allowedPaths:(e,t)=>vu(e.allowedPaths,t.allowedPaths),maxTurns:(e,t)=>(e.maxTurns??null)===(t.maxTurns??null),allowBeaconTools:(e,t)=>(e.allowBeaconTools??!1)===(t.allowBeaconTools??!1)};function xu(e,t){return Object.values(bu).some(n=>!n(e,t))}var Su=new Set([`EMPTY_NAME`,`INVALID_CHAR`,`RESERVED_NAME`,`DUPLICATE_NAME`,`TOO_LONG`]);function Cu(e){return Su.has(e.code)?{field:`name`,message:e.message}:{field:`general`,message:e.message}}function wu(e){return e.toLowerCase().replace(_n,`-`).slice(0,64)}function Tu(){return{draft:hu(`claude`,void 0),error:null,confirmDelete:!1}}var Eu=I()(e=>({editing:jo,form:Tu(),timeoutDraft:``,loopError:null,setEditing:t=>e({editing:t}),resetForm:t=>e({form:{draft:t,error:null,confirmDelete:!1}}),patchForm:t=>e(e=>({form:{...e.form,...t}})),patchFormDraft:t=>e(e=>({form:{...e.form,draft:{...e.form.draft,...t}}})),setTimeoutDraft:t=>e({timeoutDraft:t}),setLoopError:t=>e({loopError:t})}));function $(e){return(0,H.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e.label}),e.children,e.hint?(0,H.jsx)(`span`,{className:D(`text-xs`,e.hintTone===`destructive`?`text-destructive`:`text-muted-foreground`),children:e.hint}):null]})}function Du(e){let{draft:t,patchDraft:n}=e;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{label:`Working directory`,hint:`Optional. Relative to the parent chat cwd. Restricts the subagent's filesystem access to this subtree.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-working-dir`,value:t.workingDir??``,onChange:e=>{let t=e.target.value;n({workingDir:t.length>0?t:void 0})},placeholder:`docs`})}),(0,H.jsx)($,{label:`Allowed paths`,hint:`Optional. Newline-separated, relative to the parent chat cwd. When set, file tools can only read/write inside these roots.`,children:(0,H.jsx)(Dn,{"data-testid":`subagent-form-allowed-paths`,value:(t.allowedPaths??[]).join(`
|
|
12
|
+
`),onChange:e=>{let t=e.target.value.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);n({allowedPaths:t.length>0?t:void 0})},placeholder:`docs
|
|
13
|
+
wiki`,rows:3})}),(0,H.jsx)($,{label:`Beacon tools`,hint:`Off by default. When on, this subagent can run commands and read files on your paired machines. Each call still asks for your approval.`,children:(0,H.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-foreground`,children:[(0,H.jsx)(`input`,{type:`checkbox`,"data-testid":`subagent-form-allow-beacon-tools`,checked:t.allowBeaconTools===!0,onChange:e=>{n({allowBeaconTools:e.target.checked})}}),(0,H.jsx)(`span`,{children:`Allow this subagent to use beacon tools (run on your paired machines)`})]})})]})}function Ou(e){return`contextWindow`in e}function ku(e){return`fastMode`in e}function Au(e){let t=e.editing,n=(0,V.useMemo)(()=>t.kind===`edit`?e.subagents.find(e=>e.id===t.id)??null:null,[t,e.subagents]),r=t.kind,i=r!==`list`,a=e.subagents.length===0;return a&&!i?(0,H.jsx)(ju,{onStartCreate:e.onStartCreate}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6 md:flex-row md:items-start md:gap-8`,children:[a?null:(0,H.jsx)(Nu,{subagents:e.subagents,editing:e.editing,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),i?(0,H.jsx)(zu,{mode:r,subject:r===`edit`?n:null,providerDefaults:e.providerDefaults,availableProviders:e.availableProviders,handlers:e.handlers,onCancelEditing:e.onCancelEditing},r===`edit`?n?.id??`edit`:`create`):(0,H.jsx)(Mu,{})]})}function ju(e){return(0,H.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-4 rounded-lg border border-dashed border-border px-6 py-14 text-center`,"data-testid":`subagent-empty`,children:[(0,H.jsx)(`div`,{className:`flex size-10 items-center justify-center rounded-full bg-muted text-muted-foreground`,children:(0,H.jsx)(Yn,{className:`size-5`,"aria-hidden":!0})}),(0,H.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`No subagents yet`}),(0,H.jsxs)(k,{variant:`default`,size:`sm`,onClick:e.onStartCreate,children:[(0,H.jsx)(Ae,{className:`mr-1.5 size-4`}),` Create subagent`]})]})}function Mu(){return(0,H.jsx)(`div`,{className:`hidden flex-1 items-center justify-center rounded-lg border border-dashed border-border px-6 py-12 text-center text-sm text-muted-foreground md:flex`,children:`Select a subagent to edit, or create a new one.`})}function Nu(e){let t=e.editing.kind===`edit`?e.editing.id:null;return(0,H.jsxs)(`aside`,{className:`flex w-full flex-col gap-2 md:w-64 md:flex-shrink-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`span`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,style:{fontVariantNumeric:`tabular-nums`},children:[e.subagents.length,` `,e.subagents.length===1?`agent`:`agents`]}),(0,H.jsxs)(k,{variant:`ghost`,size:`sm`,onClick:e.onStartCreate,"data-testid":`subagent-create`,children:[(0,H.jsx)(Ae,{className:`size-4`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Create subagent`})]})]}),(0,H.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.subagents.map(n=>{let r=n.description?.trim()||(n.contextScope===`previous-assistant-reply`?`Last reply`:`Full transcript`);return(0,H.jsx)(`li`,{children:(0,H.jsxs)(`button`,{type:`button`,"data-testid":`subagent-row:${n.id}`,onClick:()=>e.onSelect(n.id),className:D(`flex w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-muted`,t===n.id&&`bg-muted`),children:[(0,H.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,H.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:n.name}),(0,H.jsx)(Pu,{provider:n.provider})]}),(0,H.jsx)(`span`,{className:`w-full truncate text-xs text-muted-foreground`,children:r})]})},n.id)})})]})}function Pu({provider:e}){let t=ze(e).label;return(0,H.jsxs)(`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:[(0,H.jsx)(Yn,{className:`size-3`}),` `,t]})}function Fu(e,t){return(e.some(e=>e.id===t)?e:[...e,ze(t)]).map(e=>({value:e.id,label:e.label}))}function Iu(e,t){return t.length===0?e:e.map(e=>e.id===`openrouter`?{...e,models:t.map(e=>({id:e.id,label:e.label}))}:e)}var Lu=[{value:`previous-assistant-reply`,label:`Last reply`},{value:`full-transcript`,label:`Full transcript`}],Ru=[{value:`auto`,label:`Auto`},{value:`manual`,label:`Manual`}];function zu(e){let t=(0,V.useMemo)(()=>e.mode===`edit`&&e.subject?gu(e.subject):hu(`claude`,e.providerDefaults,e.availableProviders),[e.mode,e.subject,e.providerDefaults,e.availableProviders]),n=Eu(e=>e.resetForm),r=Eu(e=>e.form),i=Eu(e=>e.patchFormDraft),a=Eu(e=>e.patchForm);(0,V.useEffect)(()=>{n(t)},[]);let{draft:o,error:s,confirmDelete:c}=r,l=N(`subagent.save`,e.subject?.id??`new`),u=N(`subagent.delete`,e.subject?.id??``),d=M(l),f=M(u),p=d||f,m=Fu(e.availableProviders,o.provider),h=s?.field===`name`?s.message:null,g=s?.field===`general`?s.message:null,_=xu(o,t),v=o.name.trim().length>0&&(e.mode===`create`||_);function y(e){i(e),s?.field===`name`&&`name`in e&&a({error:null})}function b(t){if(t===o.provider)return;let n=hu(t,e.providerDefaults,e.availableProviders);i({provider:t,model:n.model,modelOptions:n.modelOptions})}function ee(e){if(o.provider!==`claude`)return;let t=Ou(o.modelOptions)?o.modelOptions:Ne;i({modelOptions:{...Ne,...t,reasoningEffort:e}})}function x(e){if(o.provider!==`claude`)return;let t=Ou(o.modelOptions)?o.modelOptions:Ne;i({modelOptions:{...Ne,...t,contextWindow:e}})}function te(e){if(o.provider!==`codex`)return;let t=ku(o.modelOptions)?o.modelOptions:Be;i({modelOptions:{...Be,...t,reasoningEffort:e}})}async function S(){if(v&&!f){a({error:null,confirmDelete:!1});try{let t=e.mode===`create`?await e.handlers.onCreate(o):await e.handlers.onUpdate(e.subject.id,o);t.ok||a({error:Cu(t.error)})}catch(e){a({error:{field:`general`,message:L(e)}})}}}async function ne(){if(e.mode===`edit`&&e.subject){if(!c)a({confirmDelete:!0});else{a({error:null});try{await e.handlers.onDelete(e.subject.id)}catch(e){a({error:{field:`general`,message:L(e)}})}finally{a({confirmDelete:!1})}}}}let C=o.provider===`claude`?{...Ne,...Ou(o.modelOptions)?o.modelOptions:{}}:null,w=o.provider===`codex`?{...Be,...ku(o.modelOptions)?o.modelOptions:{}}:null,re=e.availableProviders.find(e=>e.id===o.provider)??ze(o.provider);return(0,H.jsxs)(`section`,{className:`flex w-full flex-1 flex-col gap-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h3`,{className:`text-base font-medium text-foreground`,children:e.mode===`create`?`New subagent`:o.name||`Subagent`}),(0,H.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Mention with `,(0,H.jsxs)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono text-xs`,children:[`@agent/`,o.name||`<name>`]}),` in chat.`]})]}),g?(0,H.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive`,children:g}):null,(0,H.jsx)($,{label:`Name`,hint:h,hintTone:h?`destructive`:`muted`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-name`,value:o.name,onChange:e=>y({name:wu(e.target.value)}),maxLength:64,placeholder:`reviewer`,className:`font-mono`})}),(0,H.jsx)($,{label:`Description`,hint:`Optional. Shown next to the name.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-description`,value:o.description??``,onChange:e=>y({description:e.target.value}),placeholder:`Reviews diffs against the repo style`})}),(0,H.jsx)($,{label:`Provider`,children:(0,H.jsx)(F,{value:o.provider,onValueChange:e=>{St(e)&&b(e)},options:m,size:`sm`})}),(0,H.jsx)($,{label:`Model`,children:(0,H.jsxs)(Ce,{value:o.model,onValueChange:e=>y({model:e}),children:[(0,H.jsx)(ye,{"data-testid":`subagent-form-model`,className:`w-full md:w-72`,children:(0,H.jsx)(xe,{placeholder:`Select a model`})}),(0,H.jsx)(be,{children:re.models.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))})]})}),C?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)($,{label:`Reasoning effort`,children:(0,H.jsx)(F,{value:C.reasoningEffort,onValueChange:e=>{rt(e)&&ee(e)},options:Le.map(e=>({value:e.id,label:e.label})),size:`sm`})}),(0,H.jsx)($,{label:`Context window`,children:(0,H.jsx)(F,{value:C.contextWindow,onValueChange:e=>{We(e)&&x(e)},options:Ge.map(e=>({value:e.id,label:e.label})),size:`sm`})})]}):null,w?(0,H.jsx)($,{label:`Reasoning effort`,children:(0,H.jsx)(F,{value:w.reasoningEffort,onValueChange:e=>{Pe(e)&&te(e)},options:Ie.map(e=>({value:e.id,label:e.label})),size:`sm`})}):null,(0,H.jsx)($,{label:`Context scope`,children:(0,H.jsx)(F,{value:o.contextScope,onValueChange:e=>{Fe(e)&&y({contextScope:e})},options:Lu,size:`sm`})}),(0,H.jsx)($,{label:`Trigger`,hint:`Auto: the main agent may delegate on its own. Manual: only runs when you @-mention it.`,children:(0,H.jsx)(F,{value:fu(o),onValueChange:e=>{nt(e)&&y({triggerMode:e})},options:Ru,size:`sm`})}),(0,H.jsx)($,{label:`System prompt`,hint:`What this persona should focus on. Plain text.`,children:(0,H.jsx)(Dn,{"data-testid":`subagent-form-system-prompt`,value:o.systemPrompt,onChange:e=>y({systemPrompt:e.target.value}),placeholder:`You are a careful code reviewer...`,rows:6,className:`min-h-32`})}),(0,H.jsx)($,{label:`Max turns`,hint:`Optional. Caps the agentic turns per run (like Claude Code's per-agent maxTurns). Empty = unbounded. Claude SDK runs stop gracefully at the limit; Codex runs are aborted.`,children:(0,H.jsx)(R,{"data-testid":`subagent-form-max-turns`,type:`number`,min:1,step:1,value:o.maxTurns?.toString()??``,onChange:e=>{let t=Number.parseInt(e.target.value,10);y({maxTurns:Number.isInteger(t)&&t>0?t:void 0})},placeholder:`unbounded`,className:`w-36`})}),o.provider===`claude`?(0,H.jsx)(Du,{draft:o,patchDraft:y}):null,(0,H.jsxs)(`footer`,{className:`flex flex-wrap items-center justify-end gap-2 pt-2`,children:[(0,H.jsx)(k,{variant:`ghost`,size:`sm`,onClick:e.onCancelEditing,children:`Cancel`}),e.mode===`edit`?(0,H.jsx)(k,{variant:`destructive`,size:`sm`,"data-testid":`subagent-form-delete`,disabled:p,pending:f,onClick:()=>{j(u,ne)},children:c?`Confirm delete`:`Delete`}):null,(0,H.jsx)(k,{variant:`default`,size:`sm`,"data-testid":`subagent-form-save`,disabled:!v||p,pending:d,onClick:()=>{j(l,S)},children:p?`Saving…`:`Save`})]})]})}var Bu=[];function Vu(e){let t=z(e=>e.settings?.subagents??Bu),n=z(e=>e.settings?.providerDefaults),r=z(Wt),i=z(on),a=m(De(e=>e.models)),o=(0,V.useMemo)(()=>Iu(Qe(Ke([...Ue],r),i),a),[r,i,a]),s=Eu(e=>e.editing),c=Eu(e=>e.setEditing),l=(0,V.useMemo)(()=>({onCreate:async t=>{let n=await e.state.socket.command({type:`subagent.create`,input:t});return n.ok&&c({kind:`edit`,id:n.subagent.id}),n},onUpdate:async(t,n)=>await e.state.socket.command({type:`subagent.update`,id:t,patch:_u(n)}),onDelete:async t=>{await e.state.socket.command({type:`subagent.delete`,id:t}),c({kind:`list`})}}),[e.state.socket,c]),u=(0,V.useCallback)(e=>{c({kind:`edit`,id:e})},[c]),d=(0,V.useCallback)(()=>{c({kind:`create`})},[c]),f=(0,V.useCallback)(()=>{c({kind:`list`})},[c]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-6 px-6 py-6`,children:[(0,H.jsx)(qu,{subagents:t,handleWriteAppSettings:e.state.handleWriteAppSettings}),(0,H.jsx)(Au,{subagents:t,providerDefaults:n,availableProviders:o,editing:s,onSelect:u,onStartCreate:d,onCancelEditing:f,handlers:l})]})}var Hu=`__none__`,Uu=Ya.min/1e3,Wu=Ya.max/1e3,Gu={min:Uu,max:Wu,integer:!0},Ku=Ja/1e3;function qu(e){let t=z(e=>e.settings?.subagentRuntime),n=t?Math.round(t.runTimeoutMs/1e3):Ku,r=t?.defaultLoopSubagentId??null,i=Eu(e=>e.timeoutDraft),a=Eu(e=>e.setTimeoutDraft),o=Eu(e=>e.loopError),s=Eu(e=>e.setLoopError);(0,V.useEffect)(()=>{a(String(n))},[n]);function c(){let t=Number(i);tn(Gu,t)?(s(null),t!==n&&e.handleWriteAppSettings({subagentRuntime:{runTimeoutMs:t*1e3}}).catch(gt(e=>s(e.message)))):(a(String(n)),s(`Timeout must be a whole number of seconds between ${Uu} and ${Wu}.`))}function l(t){s(null);let n=t===Hu?null:t;e.handleWriteAppSettings({subagentRuntime:{defaultLoopSubagentId:n}}).catch(gt(e=>s(e.message)))}return(0,H.jsxs)(`section`,{className:`flex flex-col gap-4 rounded-lg border border-border/60 bg-card/40 p-4`,children:[(0,H.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-medium text-foreground`,children:`Loop & runtime`}),(0,H.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Applies to background subagent runs and the autonomous `,(0,H.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 font-mono`,children:`/loop`}),`.`]})]}),o?(0,H.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:o}):null,(0,H.jsx)($,{label:`Stall timeout (seconds)`,hint:`A subagent run is aborted only after this long with no streamed activity — not a total wall-clock cap. A steadily-working run is never killed.`,children:(0,H.jsx)(R,{type:`number`,inputMode:`numeric`,min:Uu,max:Wu,value:i,onChange:e=>a(e.target.value),onBlur:c,onKeyDown:e=>{e.key===`Enter`&&(c(),e.currentTarget.blur())},className:`w-full md:w-48 tabular-nums`})}),(0,H.jsx)($,{label:`Default loop subagent`,hint:`The subagent setup_loop delegates each chunk to when no explicit id is given.`,children:(0,H.jsxs)(Ce,{value:r??Hu,onValueChange:l,children:[(0,H.jsx)(ye,{className:`w-full md:w-72`,children:(0,H.jsx)(xe,{placeholder:`None`})}),(0,H.jsxs)(be,{children:[(0,H.jsx)(P,{value:Hu,children:`None (require explicit id)`}),e.subagents.map(e=>(0,H.jsx)(P,{value:e.id,children:e.name},e.id))]})]})})]})}function Ju(e,t){return{shortcut:e,expansion:t,error:null}}var Yu=I()(e=>({editing:jo,editorForm:Ju(``,``),setEditing:t=>e({editing:t}),resetEditorForm:(t,n)=>e({editorForm:Ju(t,n)}),patchEditorForm:t=>e(e=>({editorForm:{...e.editorForm,...t}}))}));function Xu({snippets:e,handlers:t,dom:n=wn}){let r=Yu(e=>e.editing),i=Yu(e=>e.setEditing),a=Yu(e=>e.resetEditorForm);function o(t){if(t.kind===`create`)a(``,``);else if(t.kind===`edit`){let n=e.find(e=>e.id===t.id)??null;n&&a(n.shortcut,n.expansion)}i(t)}if(r.kind!==`list`){let n=r.kind===`edit`?e.find(e=>e.id===r.id)??null:null;return(0,H.jsx)(Qu,{initial:n,existing:e.map(e=>({id:e.id,shortcut:e.shortcut})),handlers:t,onDone:()=>i({kind:`list`})})}return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Text snippets`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Type a shortcut in the chat composer and press Tab to expand it into the full text. Handy for prompts you send often.`})]}),(0,H.jsxs)(k,{size:`sm`,onClick:()=>o({kind:`create`}),children:[(0,H.jsx)(Ae,{className:`mr-1 h-4 w-4`}),`Add snippet`]})]}),e.length===0?(0,H.jsx)(Zr,{icon:Ur,message:`No snippets yet. Add one to expand a shortcut with Tab.`}):(0,H.jsx)(Qr,{children:e.map(e=>(0,H.jsx)(Zu,{snippet:e,onEdit:()=>o({kind:`edit`,id:e.id}),onDelete:t.onDelete,dom:n},e.id))})]})}function Zu({snippet:e,onEdit:t,onDelete:n,dom:r}){let i=N(`textSnippets.delete`,e.id),a=M(i),o=(0,V.useCallback)(()=>{r.confirmDialog(`Delete snippet "${e.shortcut}"?`)&&j(i,()=>n(e.id))},[i,r,n,e.id,e.shortcut]);return(0,H.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3`,"aria-busy":a||void 0,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,H.jsx)(`span`,{className:`font-mono text-sm`,children:e.shortcut}),(0,H.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.expansion})]}),(0,H.jsx)(`div`,{className:`ml-auto flex items-center gap-2`,children:(0,H.jsx)($r,{label:e.shortcut,onEdit:t,onDelete:o,deletePending:a})})]})}function Qu({initial:e,existing:t,handlers:n,onDone:r}){let i=Yu(e=>e.editorForm),a=Yu(e=>e.patchEditorForm),{shortcut:o,expansion:s,error:c}=i,l=N(`textSnippets.save`,e?.id??`new`),u=M(l),d=e!==null,f=o.trim(),p=bn.test(f),m=(0,V.useMemo)(()=>t.some(t=>t.shortcut===f&&t.id!==e?.id),[t,f,e?.id]),h=p&&!m&&s.length>0&&!u,g=()=>Ro({patch:a,save:async()=>{d&&e?await n.onUpdate(e.id,{shortcut:f,expansion:s}):await n.onCreate({shortcut:f,expansion:s})},onDone:r}),_=zo({submitting:u,isEdit:d,addLabel:`Add snippet`});return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4 px-6 py-6`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:d?`Edit snippet`:`Add snippet`}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Shortcut`}),(0,H.jsx)(R,{value:o,onChange:e=>a({shortcut:e.target.value}),placeholder:`pgm`,className:`font-mono`,autoFocus:!0}),o.length>0&&!p&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:`Shortcut must be 1-32 characters with no spaces.`}),m&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:`A snippet with this shortcut already exists.`})]}),(0,H.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,H.jsx)(`span`,{className:`text-sm font-medium`,children:`Expands to`}),(0,H.jsx)(Dn,{value:s,onChange:e=>a({expansion:e.target.value}),placeholder:`pull request green then merge`,rows:4})]}),c&&(0,H.jsx)(`span`,{className:`text-xs text-destructive`,children:c}),(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(k,{onClick:()=>{j(l,g)},pending:u,disabled:!h,children:_}),(0,H.jsx)(k,{variant:`ghost`,onClick:r,disabled:u,children:`Cancel`})]})]})}function $u(e){let t=z(Jt),n=Io(`textSnippets`,e.state);return(0,H.jsx)(Xu,{snippets:t,handlers:n})}var ed=N(`packages.checkUpdates`);function td(e){return N(`packages.update`,e)}var nd=[],rd=[],id=[],ad=[];function od({pkg:e,packageEntry:t,applying:n,onUpdate:r}){let i=M(td(e.id)),a=n||i,o=e.versionLabel??e.version??e.revision?.slice(0,7)??null,s=Kl(t);return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),o?(0,H.jsx)(`div`,{className:`font-mono tabular-nums text-xs text-muted-foreground/70`,children:o}):null]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[(0,H.jsx)(ql,{availability:t?.update.availability}),s?(0,H.jsx)(Jl,{label:s,updating:a,onClick:r}):null,e.sourceUrl?(0,H.jsx)(`a`,{href:e.sourceUrl,target:`_blank`,rel:`noreferrer`,"aria-label":`View ${e.name} source`,className:`touch-manipulation inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,H.jsx)(Ln,{className:`h-4 w-4`})}):null]})]})}function sd({source:e,packages:t,updateEntries:n,applying:r,isChecking:i,onCheckUpdates:a,onUpdate:o}){return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`div`,{className:`text-xs font-medium tracking-wide text-muted-foreground`,children:e}),(0,H.jsxs)(k,{size:`sm`,variant:`ghost`,className:`h-6 rounded-full px-2 text-xs`,disabled:i,"aria-busy":i||void 0,onClick:a,children:[i?(0,H.jsx)(A,{className:`mr-1 h-3 w-3 animate-spin`}):(0,H.jsx)(je,{className:`mr-1 h-3 w-3`}),`Refresh`]})]}),(0,H.jsx)(`div`,{className:`grid gap-2 md:grid-cols-2`,children:t.map(e=>{let t=n.find(t=>t.id===e.id)??null;return(0,H.jsx)(od,{pkg:e,packageEntry:t,applying:r.includes(e.id),onUpdate:()=>o(e.id)},e.id)})})]})}function cd({label:e,kind:t,packages:n,errors:r,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c}){let l=r.find(e=>e.kind===t),u=n.filter(e=>e.kind===t),d=new Map;for(let e of u){let t=e.source||`Unknown`,n=d.get(t);n?n.push(e):d.set(t,[e])}let f=t===`claude-plugin`?`Claude Code CLI`:`Codex CLI`,p;return p=l?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[f,` not found — install it to manage `,e,` plugins.`]}):u.length===0?(0,H.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/30 p-3 text-sm text-muted-foreground`,children:[`No `,e,` plugins installed.`]}):(0,H.jsx)(`div`,{className:`flex flex-col gap-4`,children:[...d.entries()].map(([e,t])=>(0,H.jsx)(sd,{source:e,packages:t,updateEntries:i,applying:a,isChecking:o,onCheckUpdates:s,onUpdate:c},e))}),(0,H.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e}),p]})}function ld({state:e}){let{socket:t,connectionStatus:n}=e,r=C(e=>e.inventory),i=C(e=>e.loading),a=C(e=>e.error),o=C(e=>e.inventoryCleared),s=C(e=>e.inventoryLoadStarted),c=C(e=>e.inventoryLoaded),l=C(e=>e.inventoryLoadFailed),u=C(e=>e.inventoryLoadFinished),d=C(e=>e.updateSnapshot),f=(0,V.useCallback)(async()=>{if(n!==`connected`)o();else try{s(),c(await t.command({type:`packages.listInstalled`}))}catch(e){l(L(e))}finally{u()}},[n,t,o,s,c,l,u]);(0,V.useEffect)(()=>{Cn(`packages.listInstalled`,f())},[f]);let p=(0,V.useCallback)(()=>{j(ed,()=>On(t,{type:`packages.checkUpdates`}))},[t]),m=(0,V.useCallback)(e=>{j(td(e),()=>On(t,{type:`packages.update`,id:e}))},[t]),h=M(ed),g=d?.status===`checking`||h,_=d?.applying??ad,v=d?.packages.filter(e=>e.kind===`claude-plugin`||e.kind===`codex-plugin`)??id,y=r?.packages??nd,b=r?.errors??rd;return a?(0,H.jsx)(`div`,{className:`rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:a}):i&&!r?(0,H.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,H.jsx)(A,{className:`h-3.5 w-3.5 animate-spin`}),`Loading…`]}):(0,H.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,H.jsx)(cd,{label:`Claude Code`,kind:`claude-plugin`,packages:y,errors:b,updateEntries:v,applying:_,isChecking:g,onCheckUpdates:p,onUpdate:m}),(0,H.jsx)(cd,{label:`Codex`,kind:`codex-plugin`,packages:y,errors:b,updateEntries:v,applying:_,isChecking:g,onCheckUpdates:p,onUpdate:m})]})}var ud=I()(e=>({publicUrlDraft:null,error:null,setPublicUrlDraft:t=>e({publicUrlDraft:t}),setError:t=>e({error:t})})),dd=`<your Kanna password>`,fd=`Start Kanna with --password first; the remote MCP server is off without it. `,pd=`The URL must be https and reachable from the internet (a Cloudflare tunnel or --share).`;function md(e){return`${e}/mcp`}function hd({publicOrigin:e,passwordConfigured:t}){let n=md(e??`https://<your-public-kanna-url>`),r=t?``:fd;return[{id:`claude-code`,client:`claude-code`,title:`Claude Code`,instructions:`${r}Add the server with your Kanna password as a bearer header, or add it without one and sign in through OAuth.`,snippet:[`claude mcp add --transport http kanna ${n} --header "Authorization: Bearer ${dd}"`,``,`claude mcp add --transport http kanna ${n}`,`# then run /mcp inside Claude Code and choose Authenticate to sign in with OAuth`].join(`
|
|
14
|
+
`)},{id:`codex`,client:`codex`,title:`Codex`,instructions:`${r}Put the block in ~/.codex/config.toml and export your Kanna password as KANNA_PASSWORD, or sign in through OAuth instead.`,snippet:[`[mcp_servers.kanna]`,`url = "${n}"`,`bearer_token_env_var = "KANNA_PASSWORD"`,``,`# OAuth alternative: drop bearer_token_env_var and run`,`codex mcp login kanna`].join(`
|
|
15
|
+
`)},{id:`claude-desktop`,client:`claude-desktop`,title:`Claude Desktop and claude.ai`,instructions:`${r}Open Settings, Connectors, Add custom connector and enter the URL. Add the request header below, or leave it empty to sign in through OAuth. ${pd}`,snippet:[`URL: ${n}`,`Header: Authorization: Bearer ${dd}`].join(`
|
|
16
|
+
`)},{id:`chatgpt`,client:`chatgpt`,title:`ChatGPT`,instructions:`${r}Open chatgpt.com/plugins, select the plus button, then Add custom MCP server; enter the URL and choose OAuth as the authentication. ${pd}`,snippet:[`URL: ${n}`,`Authentication: OAuth`].join(`
|
|
17
|
+
`)}]}var gd=N(`settings.remoteMcp`,`enabled`),_d=N(`settings.remoteMcp`,`publicUrl`),vd=[{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}];function yd(e){try{return new URL(e).origin}catch{return``}}function bd({snippet:e}){let t=N(`remoteMcp.copySnippet`,e.id),n=ge(t),r=(0,V.useCallback)(()=>ve(t,()=>he.writeText(e.snippet)),[t,e.snippet]);return(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card/30 p-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e.title}),(0,H.jsx)(k,{type:`button`,variant:`ghost`,size:`icon-mobile`,"aria-label":n?`Copied ${e.title} setup`:`Copy ${e.title} setup`,className:`text-muted-foreground hover:text-foreground`,onClick:()=>Cn(`copy remote MCP setup`,r()),children:n?(0,H.jsx)(_e,{className:`h-4 w-4 text-success-text`}):(0,H.jsx)(me,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-13 text-muted-foreground`,children:e.instructions}),(0,H.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md border border-border bg-muted p-2 font-mono text-xs text-foreground`,children:e.snippet})]})}function xd({state:e,dom:t=wn}){let n=z(sn),r=Xr(e=>e.authEnabled),i=ud(e=>e.publicUrlDraft),a=ud(e=>e.setPublicUrlDraft),o=ud(e=>e.error),s=ud(e=>e.setError),c=M(_d),l=i??n.publicUrl??``,u=l.trim(),d=u!==``&&fn(u)===null,f=u!==(n.publicUrl??``),p=n.publicUrl??fn(yd(t.getHref())),m=hd({publicOrigin:p,passwordConfigured:r}),h=(0,V.useCallback)(t=>e.handleWriteAppSettings({remoteMcp:{enabled:t===`enabled`}}),[e]),g=(0,V.useCallback)(async()=>{s(null);try{await e.handleWriteAppSettings({remoteMcp:{publicUrl:u===``?null:u}}),a(null)}catch(e){s(L(e))}},[e,u,a,s]);return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 pb-2`,children:[(0,H.jsx)(`h2`,{className:`text-base font-medium`,children:`Remote MCP`}),(0,H.jsx)(`p`,{className:`max-w-[65ch] text-sm text-muted-foreground`,children:`Let other agents and apps drive Kanna over the Model Context Protocol: Claude Code, Codex, Claude Desktop and ChatGPT can list projects, run chats, move board cards and more.`})]}),r?null:(0,H.jsx)(`div`,{className:`rounded-lg border border-border bg-card/30 px-4 py-3 text-sm text-muted-foreground`,children:`Set --password when starting Kanna to enable the remote MCP server`}),(0,H.jsxs)(`div`,{className:`border-b border-border`,children:[(0,H.jsx)(U,{title:`Remote MCP server`,description:`Serves the /mcp endpoint and the OAuth sign-in pages. Turn it off to answer 404 on all of them.`,children:(0,H.jsx)(za,{pendingKey:gd,value:n.enabled?`enabled`:`disabled`,onValueChange:h,options:vd,size:`sm`})}),(0,H.jsx)(U,{title:`Public URL`,description:`https URL, or http on localhost; the OAuth issuer and resource are derived from it. Leave empty to use this machine's loopback address.`,alignStart:!0,children:(0,H.jsxs)(`div`,{className:`flex w-full flex-col gap-2 md:w-[420px]`,children:[(0,H.jsx)(R,{value:l,onChange:e=>a(e.target.value),placeholder:`https://kanna.example.com`,"aria-label":`Public URL`,"aria-invalid":d||void 0,spellCheck:!1}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,H.jsx)(`span`,{className:d?`text-destructive-text`:`text-muted-foreground`,children:d?`Enter an https URL, or an http URL on localhost`:`Path, query and trailing slash are dropped`}),(0,H.jsx)(k,{type:`button`,size:`sm`,disabled:!f||d,onClick:()=>j(_d,g),pending:c,children:`Save`})]}),o?(0,H.jsx)(`div`,{className:`text-xs text-destructive-text`,children:o}):null]})}),(0,H.jsx)(U,{title:`Endpoint`,description:`Give this URL to your MCP client.`,bordered:!0,children:p?(0,H.jsxs)(`code`,{className:`break-all rounded-md border border-border bg-muted px-2 py-1 font-mono text-xs`,children:[p,`/mcp`]}):(0,H.jsx)(`span`,{className:`text-13 text-muted-foreground`,children:`Set a public URL to see the endpoint`})})]}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-3 pt-4`,children:[(0,H.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`Connect a client`}),(0,H.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:m.map(e=>(0,H.jsx)(bd,{snippet:e},e.id))})]})]})}var Sd=`auth.signOut`,Cd=[{id:`general`,label:`General`,icon:Wn,subtitle:`Manage appearance, editor behavior, and embedded terminal defaults.`},{id:`skills`,label:`Skills`,icon:pr,subtitle:`Manage globally installed agent skills from the active skill lock file.`},{id:`plugins`,label:`Plugins`,icon:Fr,subtitle:`View and update globally installed Claude Code and Codex plugins.`},{id:`kanna-plugins`,label:`Kanna plugins`,icon:u,subtitle:`Install local Kanna plugins that contribute UI surfaces and daemon behavior.`},{id:`providers`,label:`Providers`,icon:kr,subtitle:`Manage the default chat provider and saved model defaults for Claude Code and Codex.`},{id:`models`,label:`Models`,icon:Cr,subtitle:`Add, edit, and remove Claude and Codex models available in the model picker.`},{id:`subagents`,label:`Subagents`,icon:Yn,subtitle:`Define reusable agent personas. Mention them in chat with @agent/<name>.`},{id:`mcp-servers`,label:`MCP servers`,icon:Fr,subtitle:`Install custom MCP servers (stdio, http, sse, ws) and connect-test them.`},{id:`mcp-sources`,label:`MCP sources`,icon:dr,subtitle:`Bring messages from an MCP server, such as Zalo, into the Inbox by subscription or polling.`},{id:`remote-mcp`,label:`Remote MCP`,icon:Nr,subtitle:`Let Claude, Codex and ChatGPT drive Kanna over MCP, with setup snippets for each client.`},{id:`service-bus`,label:`Service bus`,icon:Gr,subtitle:`Mirror Kanna's events into NATS JetStream, with an embedded or your own server.`},{id:`beacons`,label:`Beacons`,icon:Jn,subtitle:`Pair your own machines so the agent can read files and run approved commands there.`},{id:`snippets`,label:`Text snippets`,icon:Ur,subtitle:`Define shortcuts that expand to full text in the chat composer with Tab.`},{id:`instructions`,label:`Instructions`,icon:kr,subtitle:`Global instructions appended to every Claude and Codex turn (main + subagents).`},{id:`keybindings`,label:`Keybindings`,icon:xr,subtitle:`Edit global app shortcuts stored in the active keybindings file.`},{id:`changelog`,label:`Changelog`,icon:pr,subtitle:`Release notes pulled from the public GitHub releases feed.`}],wd={general:mo,skills:uu,plugins:ld,"kanna-plugins":xo,providers:Gc,models:Xs,subagents:Vu,"mcp-servers":Zo,"mcp-sources":Us,"remote-mcp":xd,"service-bus":Ul,beacons:Hi,snippets:$u,instructions:_o,keybindings:Do,changelog:ra};function Td(e){return e?Cd.find(t=>t.id===e)?.id??null:null}function Ed(e){return e?Cd:Cd.filter(e=>e.id!==`kanna-plugins`)}function Dd(e){return`Edit global app shortcuts stored in ${e}.`}function Od({sectionId:e}={}){let t=n(),i=r(),a=M(Sd),s=Xr(e=>e.authEnabled),l=Xr(e=>e.setAuthEnabled),u=Td(e)??`general`,d=wd[u],p=z(e=>e.hydrationStatus===`loading`&&e.settings===null),m=i.connectionStatus===`connecting`||!i.localProjectsReady||p,h=M(`keybindings.openEditor`),_=i.localProjects?.machine.displayName??`Unavailable`,v=i.localProjects?.projects.length??0,y=vt,ee=i.updateSnapshot,x=(0,V.useMemo)(()=>T(i.keybindings).filePathDisplay||ht(),[i.keybindings]);(0,V.useEffect)(()=>{e&&(Td(e)||t(`/settings/general`,{replace:!0}))},[t,e]),(0,V.useEffect)(()=>{let e=!1;return Cn(`read auth status`,b().then(t=>{e||l(t.kind===`ok`&&t.status.enabled===!0)})),()=>{e=!0}},[l]);let te=Cd.find(e=>e.id===u)??Cd[0],S=z(qt),ne=(0,V.useMemo)(()=>Ed(S),[S]),C=u===`keybindings`?Dd(x):te.subtitle,w=!m;return(0,H.jsxs)(`div`,{className:`relative flex h-full flex-1 min-w-0 bg-background`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-1`,children:[(0,H.jsx)(`aside`,{className:`hidden w-[200px] shrink-0 md:block ${w?`pb-[89px]`:``}`,children:(0,H.jsxs)(`div`,{className:`flex flex-col gap-1 px-4 py-6`,children:[(0,H.jsx)(`div`,{className:`px-3 pb-5 text-22 font-extrabold tracking-[-0.5px] text-foreground`,children:`Settings`}),ne.map(e=>{let n=e.id===`changelog`&&ee?.updateAvailable===!0;return(0,H.jsxs)(`button`,{type:`button`,onClick:()=>{t(`/settings/${e.id}`)},className:`relative cursor-pointer rounded-lg px-3 py-2 text-sm ${e.id===u?`font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:[e.id===u?(0,H.jsx)(f.span,{layoutId:`settings-nav-indicator`,className:`absolute inset-0 rounded-lg bg-muted`,transition:{type:`spring`,...g.indicator}}):null,(0,H.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,H.jsx)(e.icon,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),n?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_r,{className:`ml-auto size-3.5 shrink-0 text-warning-text`,"aria-hidden":`true`}),(0,H.jsx)(`span`,{className:`sr-only`,children:`Update available`})]}):null]})]},e.label)}),s?(0,H.jsx)(`button`,{type:`button`,onClick:()=>j(Sd,i.handleSignOut),disabled:a,className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-muted-foreground hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[a?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(Dr,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{children:a?`Signing out...`:`Sign out`})]})}):null]})}),(0,H.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto`,children:[(0,H.jsx)(`div`,{className:`sticky top-0 z-20 border-b border-border bg-background px-2 py-2 md:hidden`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(En,{label:`Open sidebar`,children:(0,H.jsx)(`button`,{type:`button`,onClick:i.openSidebar,className:`flex size-11 shrink-0 items-center justify-center rounded-md text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground`,"aria-label":`Open sidebar`,children:(0,H.jsx)(o,{className:`h-4 w-4 shrink-0`})})}),(0,H.jsxs)(Ce,{value:u,onValueChange:e=>{t(`/settings/${e}`)},children:[(0,H.jsx)(ye,{className:`h-11 min-w-0 flex-1`,"aria-label":`Settings section`,children:(0,H.jsx)(xe,{})}),(0,H.jsx)(be,{children:(0,H.jsx)(Se,{children:ne.map(e=>(0,H.jsx)(P,{value:e.id,children:e.label},e.id))})})]}),s?(0,H.jsxs)(`button`,{type:`button`,onClick:()=>j(Sd,i.handleSignOut),disabled:a,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm text-muted-foreground transition-colors hover:bg-muted/50 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:[a?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(Dr,{className:`h-4 w-4 shrink-0`}),(0,H.jsx)(`span`,{className:`sr-only`,children:a?`Signing out...`:`Sign out`})]}):null]})}),(0,H.jsxs)(`div`,{className:`w-full px-4 pb-32 pt-8 md:px-6 md:pt-16`,children:[m?(0,H.jsx)(`div`,{className:`flex min-h-[240px] items-center justify-center rounded-2xl border border-border bg-card/40 px-4 py-6 text-sm text-muted-foreground`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(A,{className:`h-4 w-4 animate-spin`}),(0,H.jsx)(`span`,{children:`Loading machine settings…`})]})}):(0,H.jsxs)(`div`,{className:`mx-auto max-w-4xl kanna-settings-section-in`,children:[(0,H.jsxs)(`div`,{className:`pb-6`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-4 min-h-[34px]`,children:[(0,H.jsx)(`div`,{className:`text-lg font-semibold tracking-[-0.2px] text-foreground`,children:te.label}),u===`general`?(0,H.jsx)(cr,{variant:`outline`,onClick:()=>{t(`/settings/changelog`)},children:`Check for updates`}):null,u===`keybindings`?(0,H.jsxs)(cr,{onClick:()=>j(`keybindings.openEditor`,()=>i.handleOpenExternalPath(`open_editor`,x)),disabled:h,"aria-busy":h||void 0,icon:h?(0,H.jsx)(E,{className:`h-4 w-4`}):(0,H.jsx)(c,{className:`h-4 w-4`}),children:[`Open in `,i.editorLabel]}):null]}),(0,H.jsx)(`div`,{className:`mt-1 text-sm text-muted-foreground`,children:C})]}),(0,H.jsx)(d,{state:i})]},u),i.commandError?(0,H.jsxs)(`div`,{className:`mx-auto mt-4 flex max-w-4xl items-start gap-3 rounded-lg border border-destructive/20 bg-destructive/5 px-4 py-3 text-sm text-destructive`,children:[(0,H.jsx)(we,{className:`mt-0.5 h-4 w-4 flex-shrink-0`}),(0,H.jsx)(`span`,{children:i.commandError})]}):null]})]})]}),w?(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 border-t border-border bg-background`,children:(0,H.jsx)(`div`,{className:`px-6 py-[14.25px]`,children:(0,H.jsxs)(`div`,{className:`grid gap-3 text-xs text-muted-foreground grid-cols-2 lg:grid-cols-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Machine`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:_})]}),(0,H.jsxs)(`div`,{className:`hidden md:block`,children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Connection`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:i.connectionStatus})]}),(0,H.jsxs)(`div`,{className:`hidden md:block`,children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`Projects Indexed`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:v})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`mb-1 tracking-wide text-xs text-muted-foreground/80`,children:`App Version`}),(0,H.jsx)(`div`,{className:`text-foreground/80`,children:y})]})]})})}):null]})}export{Od as SettingsPage};
|
package/dist/client/assets/{StackBoardsRoutePage-Uy6E-3Gl.js → StackBoardsRoutePage-D8OwGaO7.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-CPdXl_9L.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};
|