@kabmo-labs/kabmo 0.38.0 → 0.38.2
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/index.html +1 -1
- package/dist/client/index.js +421 -420
- package/dist/client/static/js/{CsvGrid-90zfbn7f.js → CsvGrid-4dpsfdrf.js} +1 -1
- package/dist/client/static/js/{DocxView-vwq2rf16.js → DocxView-crdgc0jd.js} +1 -1
- package/dist/client/static/js/{DrawioView-bvx7eqcz.js → DrawioView-1ts9y0yk.js} +1 -1
- package/dist/client/static/js/{ImageView-q6xfmbrq.js → ImageView-w2hyp129.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-qatdaw3n.js → LayoutWrapper-pdvfkncm.js} +1 -1
- package/dist/client/static/js/{Modal-6jx1fvfb.js → Modal-2sx1tgqr.js} +1 -1
- package/dist/client/static/js/{PdfView-tkv2d2zs.js → PdfView-72c123a9.js} +1 -1
- package/dist/client/static/js/{SessionsView-rbnecykz.js → SessionsView-a8921ysr.js} +1 -1
- package/dist/client/static/js/{SheetView-t08g8kdr.js → SheetView-8xh69wgk.js} +1 -1
- package/dist/client/static/js/{SvgPreview-9vh6mdcp.js → SvgPreview-z3fm87h6.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-bxcn33e1.js → abnfDiagram-O67JEVCF-25r2p3vh.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-40ggw6e8.js → architectureDiagram-NJMV4G6O-z3n19xwk.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-k41cvjrd.js → blockDiagram-BEXU5L5S-vzamgz9s.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-rdcmn6ac.js → c4Diagram-YGBWAQC7-jejafgn0.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-txbmbkxv.js → classDiagram-v2-NBCMYWYE-qfa6mj0q.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-bxzh3qj1.js → cose-bilkent-JH36ORCC-9vzdgmk1.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-abx5343b.js → cynefinDiagram-VND7K2PF-a3k3w1t5.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-baj278kt.js → dagre-6A5THRUB-gf04dvxj.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-vqvhdc5m.js → diagram-22UHCM2B-a9e0a684.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-w328rfx0.js → diagram-3UASUU5V-fb73gfjd.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-zzcmwnm8.js → diagram-ATOU4E4O-yb9n3t30.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-8yw39mmj.js → diagram-CDSNMT55-adhbhw28.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-zgc386pv.js → diagram-MLGK6HIB-v4yxyb8r.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-efmvvscm.js → diagram-MPIPVDR6-94ttsqy2.js} +1 -1
- package/dist/client/static/js/{dockerfile-bp5dre33.js → dockerfile-mrranatf.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-p66h0dzq.js → ebnfDiagram-ZINNZB2B-jj4f3pyq.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g0jjxcqd.js → elk-276RUBZZ-mtnkhyte.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-39gat96z.js → erDiagram-OPXOYQCR-18qdkhm5.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-zmz4grtx.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-nsjv1zt4.js → ganttDiagram-FUAMR5RP-vz28h061.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-r4vnkcy3.js → gitGraphDiagram-X574FWY7-cgq3r4rz.js} +1 -1
- package/dist/client/static/js/{index-73jwm4d5.js → index-12p63902.js} +1 -1
- package/dist/client/static/js/{index-h8h5c2r8.js → index-1c7294vk.js} +1 -1
- package/dist/client/static/js/{index-9wtg6ywn.js → index-2xb54jt3.js} +1 -1
- package/dist/client/static/js/{index-da10qpns.js → index-4hsxaa87.js} +1 -1
- package/dist/client/static/js/{index-5y0bvq4q.js → index-5v9v41ap.js} +2 -2
- package/dist/client/static/js/{index-rgp69pa8.js → index-6d5qj0kb.js} +1 -1
- package/dist/client/static/js/{index-11bdd235.js → index-6j9h1fa7.js} +1 -1
- package/dist/client/static/js/{index-dkseg29t.js → index-6k2x281j.js} +2 -2
- package/dist/client/static/js/{index-tzm90bsz.js → index-6rt7gs1j.js} +1 -1
- package/dist/client/static/js/{index-5ebhb94w.js → index-737w2mqf.js} +1 -1
- package/dist/client/static/js/{index-c15r8jd3.js → index-95t1hwr8.js} +1 -1
- package/dist/client/static/js/{index-vnn7m9yp.js → index-a5ptb956.js} +1 -1
- package/dist/client/static/js/{index-2drjp9ks.js → index-aa6qdgmv.js} +1 -1
- package/dist/client/static/js/{index-gwhx66f4.js → index-ajtd1q1h.js} +1 -1
- package/dist/client/static/js/{index-rf0p3v7q.js → index-arvqarv3.js} +1 -1
- package/dist/client/static/js/{index-ra38ggke.js → index-bgcp21ed.js} +1 -1
- package/dist/client/static/js/{index-rqrcw8nj.js → index-d146s9g3.js} +1 -1
- package/dist/client/static/js/{index-st202rjv.js → index-d8kjsgpt.js} +7 -7
- package/dist/client/static/js/{index-z0cpp5bc.js → index-dr7nhha9.js} +1 -1
- package/dist/client/static/js/{index-6ax2z70w.js → index-enxfdvdq.js} +1 -1
- package/dist/client/static/js/{index-dfgdn3fj.js → index-fqhpxzyb.js} +1 -1
- package/dist/client/static/js/{index-24yyj78e.js → index-gbdvr4rt.js} +1 -1
- package/dist/client/static/js/{index-50z4ek83.js → index-hp8kfk9z.js} +1 -1
- package/dist/client/static/js/{index-ha75kff0.js → index-kf9t3mzv.js} +1 -1
- package/dist/client/static/js/{index-hzx81cjq.js → index-naz3px72.js} +1 -1
- package/dist/client/static/js/{index-1qszrvzk.js → index-njqpkcvw.js} +1 -1
- package/dist/client/static/js/{index-e1pr3k50.js → index-qxb8k6py.js} +1 -1
- package/dist/client/static/js/{index-a74k07z2.js → index-rtd9frp1.js} +1 -1
- package/dist/client/static/js/{index-2ndq1ngv.js → index-s16h2nmv.js} +1 -1
- package/dist/client/static/js/{index-k9xsvab3.js → index-s910y31q.js} +1 -1
- package/dist/client/static/js/{index-tv61v3t3.js → index-we2ezmn7.js} +1 -1
- package/dist/client/static/js/{index-0kxqzafy.js → index-y5y7smet.js} +1 -1
- package/dist/client/static/js/{index-tfsaj5d1.js → index-z72wf7q4.js} +1 -1
- package/dist/client/static/js/{index-vxd4gykh.js → index-zdbvm01f.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-e39pvm4j.js → infoDiagram-VRGFBTTK-jjwckbr9.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rqhszgvp.js → ishikawaDiagram-OU5B5YK6-qzk5gejf.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-wgy5qrsv.js → journeyDiagram-ZHPQQLJL-maccpg3q.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-b8bxn0h1.js → kanban-definition-PNTS6WVX-xv2azgws.js} +1 -1
- package/dist/client/static/js/{mermaid.core-vb5ehtre.js → mermaid.core-e4ys760s.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t4p38s38.js → mindmap-definition-NLK3R4M7-b779wz81.js} +1 -1
- package/dist/client/static/js/one-dark-pro-kckm8epj.js +1 -0
- package/dist/client/static/js/one-light-0v7rg9a7.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-3gp4madx.js → pegDiagram-GJSIUBJH-8sgdmhnw.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-0cbm773h.js → pieDiagram-5QR66LMP-nz6n95d6.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-jwg7fc9f.js → quadrantDiagram-O4NWA36T-47dpygk5.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-38xh691s.js → railroadDiagram-XR7U4H2S-wv0bvwve.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-gpddawxh.js → requirementDiagram-PLB6GJNP-w3r8r837.js} +1 -1
- package/dist/client/static/js/{rust-bx3ecv4n.js → rust-42c4h7e4.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s6t6bbhk.js → sankeyDiagram-IPEJSGJF-t55rjgad.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wkq51pmb.js → sequenceDiagram-PO4LG4MO-yfwjwy37.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xtwexf8k.js → sizeCapture-INFHLROL-nq6hy7ce.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-jnwsqa7y.js → stateDiagram-v2-GCMORJYK-4xy0atqh.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-mnkkqcbx.js → swimlanes-2SLR337P-np47cy1q.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-6xmrz03n.js → swimlanesDiagram-TC7HE7FX-56rk9kxv.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-rxq6heqh.js → timeline-definition-EJHVYXUP-rb0gnm35.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-dz94f57t.js → usecaseDiagram-POWQR4AR-gatkznan.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-5mmvkhsq.js → vennDiagram-UO4OBE2U-r3f5xjjq.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-dctdntpa.js → wardleyDiagram-VNRHLVJA-tpass65t.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-njyfrqkv.js → xychartDiagram-PMCCYNJV-8xkh67cw.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/changes/capture-bash.server.ts +69 -4
- package/src/server/lib/changes/capture-fs.server.ts +2 -10
- package/src/server/lib/changes/capture-races.test.ts +107 -0
- package/src/server/lib/changes/capture-scan.test.ts +157 -0
- package/src/server/lib/changes/capture-test-util.ts +1 -1
- package/src/server/lib/changes/capture-types.ts +3 -1
- package/src/server/lib/changes/capture-write.server.ts +50 -0
- package/src/server/lib/changes/capture.server.ts +33 -18
- package/src/server/lib/changes/capture.test.ts +48 -0
- package/src/server/lib/changes/classify-command.test.ts +20 -0
- package/src/server/lib/changes/classify-command.ts +46 -23
- package/src/server/lib/changes/classify-git.ts +12 -11
- package/src/server/lib/changes/classify-tokenize.ts +9 -1
- package/src/server/lib/changes/journal.server.ts +3 -1
- package/src/server/lib/changes/omp-fallback.server.ts +48 -0
- package/src/server/lib/changes/omp-fallback.test.ts +75 -0
- package/src/server/lib/changes/reader.server.ts +28 -0
- package/src/server/lib/changes/scan.server.ts +56 -1
- package/src/server/lib/changes/sessions.server.ts +65 -0
- package/src/server/lib/changes/sessions.test.ts +52 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f6jpcqyq.js +0 -1
- package/dist/client/static/js/one-dark-pro-dhybn1ff.js +0 -1
- package/dist/client/static/js/one-light-bqg77ay0.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d,n,i,o,u,a,se,sn,pa,Qo,BA,e,w,s,di,I,ne,De,Pa,Bn,bn,m,qn,Le,Kt,M,D,Ns,Vt,ma,_n,fa,Yt,xt,br,f,B,ie,Aa,Ki,zr,Yi,ae,tt,$a,he,Ce,wt,Ge,Dt,nt,fe,Qe,za,pe,mi,ga,Ur,jr,en,Jt,ha,Xi,Fo,ba,qr,Dn,Lo,Y,Ai,kr,C,ut,F,gi,hi,cr,ur,Hn,Qt,_e,Hr,$o,b,NA,Uo,vp,Ul,kp,RA,Wn,eo,xp,H,FA,At,Wr,dt,Gl,ka,Kn,ce,rt,Go,J,nn,Nn,Ff,Ie,Ep,Ve,ge,Os,Ho,cn,XA,eg,_p,tg,ng,Sp,rg,Tp,Dp,ki,ag,ig,Qp,Lf,Np,ee,zt,Ut,Me,ao,Op,cg,ug,dg,pg,mg,fg,Ag,Yl,gg,$p,hg,bg,zp,yg,Jl,Lu,Kr,Zl,Up,wi,Ga,Vr,wa,Gp,Mu,jp,Of,kg,xg,wg,$f,qp,gt,Bt,Gs,Cg,zf,un,Wo,ja,Xl,Wp,Ko,ht,Ei,Kp,Uf,Bg,Gf,Pu,Vp,tc,Ig,Yr,nc,_g,Sg,Yp,Jp,jf,Zp,Tg,Xp,rc,em,je,ac,Vo,ic,Yo,qs,oc,sc,lc,tm}from"./index-st202rjv.js";import{yt,ad,id,od,Uc,sd,ld,ol,qc,os,sl,po}from"./index-a74k07z2.js";import{ea,ou,vs,ks,su,lu}from"./index-da10qpns.js";import{cl,_a,iA,oA,ul,sA,lA,ys}from"./index-24yyj78e.js";var hc={name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]},Eo=s(hc);var vc={name:"square-check-big",size:24,node:[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-square"]},Oo=s(vc);var xc={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]},Je=s(xc);var kc={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]},Do=s(kc);var yc={name:"bell-ring",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]},jo=s(yc);var wc={name:"calendar-range",size:24,node:[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M17 13h-6",key:"1qbiup"}],["path",{d:"M13 17H7",key:"1x38vv"}],["path",{d:"M7 13h.01",key:"1vezk1"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]},_o=s(wc);var Sc={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]},Bo=s(Sc);var Nc={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]},Ft=s(Nc);var Pc={name:"dice-5",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]},zo=s(Pc);var Cc={name:"dollar-sign",size:24,node:[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]},qo=s(Cc);var Tc={name:"file-diff",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]},Jo=s(Tc);var Ic={name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]},Xo=s(Ic);var Ac={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]},Zo=s(Ac);var Rc={name:"hammer",size:24,node:[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]},er=s(Rc);var Mc={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]},tr=s(Mc);var Ec={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]},pt=s(Ec);var Lc={name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]},nr=s(Lc);var Oc={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"}]]},jt=s(Oc);var Dc={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]},or=s(Dc);var Fc={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"}]]},$t=s(Fc);var jc={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]},rr=s(jc);var $c={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"}]]},ir=s($c);var _c={name:"store",size:24,node:[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]},at=s(_c);var Bc={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"}]]},_t=s(Bc);var Kc={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]},An=s(Kc);var zc={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]},ar=s(zc);var Hc={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"}]]},Rn=s(Hc);function sr(t,r,l){let c={},p=typeof l==="function"?Object.keys(r):Object.keys(l);for(let g of p)if(r[g]!==t[g])c[g]=r[g];return c}var lr={theme:Os,editorFont:Lu,editorTheme:Zl,autoSessionTitle:!0,soundAlerts:!0,chatCompletionSound:!0,notifyDesktopEnabled:!0,notifyMobileEnabled:!0,notifyOnFinish:!1,notifyOnAsk:!1,notifyOnError:!1,goalAuditEnabled:!0,goalAuditModel:"",goalDefaultBudget:null,chatWidthMode:Op,toolRenderStyle:dg,showChangedFiles:!0,sidebarStyle:iA,composerStyle:Ag,surfaceStyle:hg,iconStyle:tg,followUpBehavior:"queue",keybindingSend:"Enter",keybindingNewLine:"Shift + Enter",keybindingSteering:"Ctrl / Cmd + Enter"};function dr(){let[t,r]=n(!1),l=a(async()=>{r(!0);try{let c=await fetch("/api/omp/reload-engine",{method:"POST"}),p=await c.json().catch(()=>null);if(!c.ok||!p?.success)return{ok:!1,message:p?.error??`Reload failed (HTTP ${c.status})`};wi(),Vr();let g=p.utility??0,h=p.prewarmed??0;return{ok:!0,message:g+h===0?"No standby omp processes were running — the next command starts the current build.":`Reloaded omp engine — ${g} utility, ${h} prewarmed process${g+h===1?"":"es"} recycled.`}}catch(c){return{ok:!1,message:c instanceof Error?c.message:"Failed to reload the omp engine."}}finally{r(!1)}},[]);return{isReloading:t,reload:l}}function pr(t={}){let{restart:r}=t,[l,c]=n(!1),p=a(async()=>{c(!0);try{let g=await Mu(r),h=await fetch("/api/console/restart",{method:"POST"}),v=await h.json().catch(()=>null);if(!h.ok||!v?.success)return{ok:!1,message:v?.error??`Restart failed (HTTP ${h.status})`};if(!v.restarting)return{ok:!1,message:v.message??"This instance cannot be restarted from the console."};let x=await jp(g,r);if(x==="restarted")return window.location.reload(),{ok:!0,message:v.message??"Restarting — this page reloads on its own."};if(x==="timeout")return{ok:!1,message:`The server did not come back within ${Math.round((r?.timeoutMs??Gp)/1000)} seconds — reload this page once it is up.`};return{ok:!1,message:"The restart was cancelled."}}catch(g){return{ok:!1,message:g instanceof Error?g.message:"Failed to restart Kabmo."}}finally{c(!1)}},[r]);return{isRestarting:l,restart:p}}function mr(t,r){if(typeof document<"u"&&r.theme)Np(r.theme);if(typeof window<"u"&&r.editorFont!==t.editorFont)window.dispatchEvent(new CustomEvent(qp,{detail:r.editorFont}));if(typeof window<"u"&&r.editorTheme!==t.editorTheme)window.dispatchEvent(new CustomEvent(ad,{detail:r.editorTheme}));if(r.chatWidthMode!==t.chatWidthMode)Of(r.chatWidthMode);if(r.toolRenderStyle!==t.toolRenderStyle)kg(r.toolRenderStyle);if(r.showChangedFiles!==t.showChangedFiles)xg(r.showChangedFiles);if(r.sidebarStyle!==t.sidebarStyle)lA(r.sidebarStyle);if(r.composerStyle!==t.composerStyle)wg(r.composerStyle);if(r.surfaceStyle!==t.surfaceStyle)$f(r.surfaceStyle);if(r.iconStyle!==t.iconStyle)Lf(r.iconStyle)}var gr=["KABMO","CONNECT","WORKSPACE","OMP","HARNESSES"];var fr=[{id:"appearance",label:"Appearance",icon:ba,section:"KABMO",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:en,section:"KABMO",description:"Chat width, composer style, tool call rendering, session titles, and goal mode."},{id:"keyboard",label:"Keyboard",icon:ga,section:"KABMO",description:"Every command shortcut, the composer Enter keys, and chord conflicts."},{id:"notifications",label:"Notifications",icon:fa,section:"KABMO",description:"Completion sound, separate Desktop and Mobile delivery switches, and the finished, waiting-for-you and failed run triggers."},{id:"usage",label:"Usage",icon:di,section:"KABMO",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:Yi,section:"KABMO",description:"Token telemetry, cache, and cost breakdown."},{id:"panel-plugins",label:"Plugins Kabmo",icon:Ai,section:"KABMO",description:"Plugins installed into Kabmo: panels, background services, and the MCP servers they register."},{id:"connect",label:"Connect",icon:kr,section:"CONNECT",description:"Tunnels, addresses, and the devices paired to this server."},{id:"projects",label:"Projects",icon:Xo,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:$a,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:Bo,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:xt,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:Eo,section:"OMP",description:"Native AGENTS.md and RULES.md: global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:_e,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:br,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"plugins",label:"Plugins",icon:Lo,section:"OMP",description:"Installed omp plugins, marketplaces, features, and plugin settings."},{id:"skills",label:"Skills",icon:nr,section:"OMP",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:Yt,section:"OMP",description:"Browse and install new skills."},...zf().map((t)=>({id:t.id,label:t.label,icon:Rn,section:"HARNESSES",...t.harness?{harness:t.harness}:{},description:t.description}))];function hr(t){let r=zf(t&&t.length>0?t:void 0).map((c)=>({id:c.id,label:c.label,icon:Rn,section:"HARNESSES",...c.harness?{harness:c.harness}:{},description:c.description}));return[...fr.filter((c)=>c.section!=="HARNESSES"),...r]}function Mn({activeCategory:t,onSelectCategory:r,searchQuery:l,onSearchChange:c,onReloadOmp:p,isReloading:g,onRestartKabmo:h,isRestarting:v,disabledHarnesses:x=[],categories:y=fr,className:k=""}){let T=y.filter((S)=>{if(S.harness&&x.includes(S.harness))return!1;if(!l.trim())return!0;let R=l.toLowerCase();return S.label.toLowerCase().includes(R)||S.section.toLowerCase().includes(R)||S.description.toLowerCase().includes(R)});return e("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${k}`,children:[e("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:e("div",{className:"relative flex items-center",children:[e(F,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",placeholder:"Search settings",value:l,onChange:(S)=>c(S.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),l&&e("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:e(b,{size:12})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:T.length===0?e("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):gr.map((S)=>{let R=T.filter((P)=>P.section===S);if(R.length===0)return null;return e("div",{className:"space-y-1",children:[e("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:S}),e("div",{className:"space-y-0.5",children:R.map((P)=>{let L=P.icon,N=t===P.id;return e("button",{type:"button",onClick:()=>r(P.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${N?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center space-x-2.5 truncate",children:[P.harness?e("span",{className:"flex w-[14px] shrink-0 items-center justify-center",children:e(gt,{harness:P.harness,size:14})}):e(L,{size:14,className:N?"text-ink":"text-ink/60"}),e("span",{className:"truncate",children:P.label})]}),P.badge&&e("span",{className:"px-1.5 py-0.2 text-[10px] font-mono font-medium rounded border border-warning/30 bg-warning/15 text-warning",children:P.badge})]},P.id)})})]},S)})}),e("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:g||v,title:"Recycle the standby omp processes so the next command uses the installed binary","aria-label":"Reload OMP",className:"shrink-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(C,{size:12,className:`shrink-0 ${g?"animate-spin text-warning":"text-ink/60"}`}),e("span",{className:"whitespace-nowrap",children:g?"Reloading…":"Reload OMP"})]}),e("button",{type:"button",onClick:h,disabled:g||v,title:"Stop and start this Kabmo instance","aria-label":"Restart Kabmo",className:"flex-1 min-w-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(ir,{size:12,className:`shrink-0 ${v?"animate-pulse text-warning":"text-ink/60"}`}),e("span",{className:"truncate",children:v?"Restarting…":"Restart Kabmo"})]})]})]})}function vr({theme:t,selected:r,onSelect:l}){return e("button",{type:"button",onClick:()=>l(t.id),"aria-pressed":r,className:`group flex w-full flex-col gap-2.5 rounded-lg border p-2.5 text-left transition-all cursor-pointer ${r?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("div",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:t.name,children:t.name}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:t.variant}),r&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("div",{className:"flex items-center gap-1",children:eg.map((c)=>e("span",{title:`${c.label} · ${t[c.key]}`,style:{backgroundColor:t[c.key]},className:"h-5 flex-1 rounded-[3px] border border-ink/10"},c.key))})]})}var Gc=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function Wc(t){return t==="all"?Ho:Ho.filter((r)=>r.variant===t)}function xr({selectedId:t,onSelect:r}){let[l,c]=n("all"),p=u(()=>Wc(l),[l]);return e("div",{className:"space-y-3 pb-6",children:[e("div",{className:"flex items-center gap-1.5",children:[Gc.map((g)=>e("button",{type:"button",onClick:()=>c(g.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${l===g.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[g.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),g.id==="dark"&&e($t,{size:11,className:"mr-1 inline align-[-1px]"}),g.label]},g.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:[p.length," themes"]})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3",children:p.map((g)=>e(vr,{theme:g,selected:g.id===t,onSelect:r},g.id))})]})}function st({width:t,active:r=!1,trailing:l=!1}){return e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:`h-[5px] w-[5px] shrink-0 rounded-full ${r?"bg-ink":"bg-ink/25"}`}),e("span",{className:`h-[3px] rounded-full ${r?"bg-ink/70":"bg-ink/25"}`,style:{width:`${t}%`}}),l&&e("span",{className:"ml-auto h-[3px] w-[6px] rounded-full bg-ink/20"})]})}function Vc(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[7px] w-[30%] rounded-sm bg-ink/80"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"})]}),e("span",{className:"flex h-[7px] items-center gap-1 px-1",children:e("span",{className:"h-[3px] w-[45%] rounded-full bg-ink/45"})}),e(st,{width:62,trailing:!0}),e(st,{width:50,active:!0,trailing:!0}),e(st,{width:44,trailing:!0}),e(st,{width:56,trailing:!0})]})}function Yc(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex h-[7px] items-center rounded-sm bg-ink/5 px-1",children:e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/30"})}),e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[6px] w-[16%] rounded-full bg-ink/80"}),e("span",{className:"h-[6px] w-[22%] rounded-full border border-ink/20"}),e("span",{className:"h-[6px] w-[12%] rounded-full border border-ink/20"})]}),e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:"h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50"}),e("span",{className:"h-[3px] w-[40%] rounded-full bg-ink/45"}),e("span",{className:"ml-auto h-[3px] w-[5px] rounded-full bg-ink/20"})]}),e(st,{width:62,active:!0,trailing:!0}),e(st,{width:50,trailing:!0}),e(st,{width:44,trailing:!0})]})}var Jc={classic:Vc,modern:Yc};function yr({settings:t,onUpdate:r}){let l=ul(t.sidebarStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Session sidebar"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"How the left column draws its workspaces and chats. Both styles list the same workspaces and offer the same actions; the choice applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Session sidebar style",children:oA.map((c)=>{let p=sA[c],g=c===l,h=Jc[c];return e("button",{type:"button",onClick:()=>r({sidebarStyle:c}),"aria-pressed":g,"aria-label":`${p.label} sidebar — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[86px]",children:e(h,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function wr({backdropFilter:t,reducedTransparency:r}){let l=[];if(!t)l.push("no-backdrop-filter");if(r)l.push("reduced-transparency");return l}var Sr={"no-backdrop-filter":"This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.","reduced-transparency":"Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material."};var Nr="(prefers-reduced-transparency: reduce)";function Xc(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;return CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function Pr(){let[t,r]=n(()=>typeof window>"u"?!1:window.matchMedia(Nr).matches);return i(()=>{let l=window.matchMedia(Nr),c=()=>r(l.matches);return c(),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[]),wr({backdropFilter:Xc(),reducedTransparency:t})}function Cr(){return e("span",{className:"flex h-full flex-col gap-1 p-1",children:[e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/40"}),e("span",{className:"ml-auto h-[6px] w-[10%] rounded-[2px] border border-ink/20"})]}),e("span",{className:"h-[2px] w-full rounded-full bg-ink/15"}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[52%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[18%] rounded-full bg-ink/15"})]}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[44%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[22%] rounded-full bg-ink/15"})]})]})}function Qc(){return e("span",{className:"block h-full rounded-md border border-ink/15 bg-paper","aria-hidden":"true",children:[e("span",{className:"block h-[13px] rounded-t-[5px] border-b border-ink/10 bg-paper",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/35"})}),e(Cr,{})]})}function Zc(){return e("span",{className:"relative block h-full overflow-hidden rounded-md border border-ink/15 bg-canvas","aria-hidden":"true",children:[e("span",{className:"pointer-events-none absolute inset-0",children:[e("span",{className:"absolute -left-2 top-2 h-[70%] w-[55%] rounded-full bg-info/40 blur-md"}),e("span",{className:"absolute -right-2 -top-2 h-[60%] w-[50%] rounded-full bg-meta/35 blur-md"}),e("span",{className:"absolute -bottom-2 right-3 h-[45%] w-[45%] rounded-full bg-success/30 blur-md"})]}),e("span",{className:"relative block h-[13px] border-b border-ink/10 bg-paper/40",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/40"})}),e("span",{className:"relative block h-[calc(100%-13px)] bg-paper/50",children:e(Cr,{})})]})}var ep={classic:Qc,glass:Zc};function tp(){let t=Pr();if(t.length===0)return null;return e("ul",{className:"space-y-1 rounded-lg border border-ink/15 bg-ink/[0.03] p-2.5","aria-live":"polite",children:t.map((r)=>e("li",{className:"flex gap-1.5 text-[11px] leading-relaxed text-ink/60",children:[e("span",{"aria-hidden":"true",className:"mt-[5px] h-1 w-1 shrink-0 rounded-full bg-ink/40"}),e("span",{children:Sr[r]})]},r))})}function Tr({settings:t,onUpdate:r}){let l=zp(t.surfaceStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Surfaces"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"What the windows are made of. Both styles draw the same panels, rows and dialogs; the frost is one blur pass per window, and it follows the palette — there is no separate glass colour to tune."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Surface style",children:bg.map((c)=>{let p=yg[c],g=c===l,h=ep[c];return e("button",{type:"button",onClick:()=>r({surfaceStyle:c}),"aria-pressed":g,"aria-label":`${p.label} surfaces — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[78px]",children:e(h,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})}),l==="glass"&&e(tp,{})]})}function np(t){return cn(t).paper}function En({name:t,Icon:r,colored:l,paper:c}){let p=ag(t),g=!l?void 0:p?Dp[p]:ki(ig(t),"light",c);return e(r,{size:13,strokeWidth:2,style:g?{color:g}:void 0,"aria-hidden":"true"})}function Ir({name:t,base:r,colored:l}){let c=l?r:void 0;return e("span",{className:"flex h-5 w-5 items-center justify-center rounded-[5px] border border-ink/10",style:c?{backgroundColor:`${c}22`,color:c}:void 0,title:t,"aria-hidden":"true",children:e("span",{className:`block h-2 w-2 rounded-full ${l?"":"bg-ink/60"}`,style:c?{backgroundColor:c}:void 0})})}function Ar({colored:t,paper:r}){return e("span",{className:"flex h-full items-center gap-1.5 rounded-md border border-ink/10 bg-canvas/60 px-2",children:[e(En,{name:"Trash2",Icon:M,colored:t,paper:r}),e(En,{name:"Check",Icon:f,colored:t,paper:r}),e(En,{name:"Sparkles",Icon:Le,colored:t,paper:r}),e("span",{className:"mx-0.5 h-4 w-px bg-ink/10"}),e(Ir,{name:"claude",base:Tp.claude.light,colored:t}),e(Ir,{name:"Typescript",base:Qp.Typescript.light,colored:t})]})}function Rr({settings:t,onUpdate:r}){let l=Sp(t.iconStyle),c=np(t.theme),p={monochrome:()=>e(Ar,{colored:!1,paper:c}),color:()=>e(Ar,{colored:!0,paper:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Icons"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Every icon: toolbar and panel glyphs, provider logos and file-type marks. Full colour gives each glyph its own hue and keeps the palette’s red, green, amber and blue for signals; a colour that would disappear on the active theme falls back to the ink. A control that sets its own colour keeps it."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Icon style",children:ng.map((g)=>{let h=rg[g],v=g===l,x=p[g];return e("button",{type:"button",onClick:()=>r({iconStyle:g}),"aria-pressed":v,"aria-label":`${h.label} icons — ${h.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:h.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:h.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:h.description})]},g)})})]})}function Mr({settings:t,onUpdate:r}){let l=t.editorFont||Jl[0].id;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(Hr,{size:16,className:"text-ink/60"}),"Editor Font"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:"Typeface for the code editor and its line numbers, in both the desktop panel and the phone's full-screen editor. Only Fira Code ships with the app; the others are used when your device has them, and fall back to Fira Code when it does not."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Jl.map((c)=>{let p=l===c.id;return e("button",{type:"button",onClick:()=>r({editorFont:c.id}),"aria-pressed":p,className:`flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-colors ${p?"border-ink/40 bg-ink/5":"border-ink/12 hover:bg-ink/5"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate text-xs text-ink",style:{fontFamily:`"${c.id}", monospace`},children:"const greet = () => 'hi'"}),e("span",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-ink/50",children:[e("span",{children:c.label}),c.bundled&&e("span",{className:"rounded bg-ink/8 px-1 py-px text-[10px] uppercase tracking-wide",children:"Bundled"})]})]}),p&&e(f,{size:14,className:"text-ink flex-shrink-0"})]},c.id)})})]})}var op=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function rp(t){return`"${Jl.find((l)=>l.id===t)?.id??Jl[0].id}", monospace`}function ip({theme:t,face:r}){return e("span",{className:"block overflow-hidden rounded border border-ink/10",style:{backgroundColor:t.bg,color:t.fg},children:e("span",{className:"block px-1.5 py-1 font-mono text-[10px] leading-[1.4]",style:{fontFamily:r},children:[e("span",{style:{color:t.keyword},children:"const"})," ",e("span",{children:"answer"})," ",e("span",{style:{color:t.keyword},children:"="})," ",e("span",{style:{color:t.string},children:"42"}),e("span",{children:";"}),e("span",{className:"block truncate",style:{color:t.comment},children:["// ",t.label]})]})})}function Er({settings:t,onUpdate:r}){let l=t.editorTheme||Kr,[c,p]=n("all"),g=rp(t.editorFont),h=u(()=>c==="all"?Up:Up.filter((v)=>v.variant===c),[c]);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(ba,{size:16,className:"text-ink/60"}),"Editor Theme"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Colours for the code editor only — the console around it keeps the theme above. ",e("strong",{children:"Auto"})," ","follows the app palette; any other choice paints the editor's own surface, gutter, selection and syntax, and applies to every open editor without a reload."]})]}),e("div",{className:"flex items-center gap-1.5",children:[op.map((v)=>e("button",{type:"button",onClick:()=>p(v.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${c===v.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[v.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),v.id==="dark"&&e($t,{size:11,className:"mr-1 inline align-[-1px]"}),v.label]},v.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:c==="all"?`${h.length} themes`:`${h.length} shown`})]}),e("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e("button",{type:"button",onClick:()=>r({editorTheme:Kr}),"aria-pressed":l===Kr,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${l===Kr?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",children:"Auto"}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:"app palette"}),l===Kr&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("span",{className:"flex h-8 items-center justify-center rounded border border-dashed border-ink/20 text-[10px] text-ink/50",children:"Follows the theme above"})]}),h.map((v)=>{let x=l===v.id;return e("button",{type:"button",onClick:()=>r({editorTheme:v.id}),"aria-pressed":x,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${x?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:v.label,children:v.label}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:v.variant}),x&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e(ip,{theme:v,face:g})]},v.id)})]})]})}function Lr({settings:t,onUpdate:r}){let l=H("editorIndentWidth"),c=typeof l==="number"&&od.includes(l)?l:Uc.width,p=(g)=>{if(g===c)return;let h={...sd(),width:g};Wr({editorIndentWidth:g,editorInsertSpaces:!0}),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(id,{detail:h}))};return e("section",{className:"space-y-3",children:e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor indentation"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"One level, in spaces. Enter, Tab and the auto-indent rules all use it."})]}),e("div",{className:"flex items-center gap-1",role:"group","aria-label":"Indentation width",children:od.map((g)=>e("button",{type:"button",onClick:()=>p(g),"aria-pressed":g===c,"aria-label":`${g} spaces`,className:`px-2.5 py-1 rounded border text-[11px] font-mono transition-colors cursor-pointer ${g===c?"border-ink/40 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:g},g))})]})})}function Or({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.currentTarget.checked),"aria-label":t,className:`${ge} mt-0.5 accent-ink flex-shrink-0`})]})}function Dr({settings:t,onUpdate:r}){let l=qc(),c=H("editorAutoCloseBrackets"),p=H("editorAutocomplete"),g=(h)=>{let v={...qc(),...h};Wr(h),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(ld,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor typing"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Both change what typing does, which is why they are switches rather than always-on."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Or,{label:"Auto-close brackets",hint:"Typing ( or { inserts the matching closer, and typing it again steps over it.",checked:typeof c==="boolean"?c:ol.autoCloseBrackets,onChange:(h)=>g({editorAutoCloseBrackets:h})}),e(Or,{label:"Suggest words from the file",hint:`Offers identifiers already near the caret (${l.autocomplete?"on":"off"}). Words only — this is not a language server.`,checked:typeof p==="boolean"?p:ol.autocomplete,onChange:(h)=>g({editorAutocomplete:h})})]})]})}function Fr({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.target.checked),className:`${ge} mt-0.5 shrink-0 accent-ink`})]})}function $r({settings:t,onUpdate:r}){let l=H("editorBlame"),c=H("editorBlameInline"),p=po(),g=(h)=>{let v={...po(),...h};Wr(h),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(os,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Line blame"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Who last touched a line, and which commit. Read from git, so it needs a committed file."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Fr,{label:"Show blame on hover",hint:"Hover a line number — or the label, when it is on — to see the author, the commit and the line's own history.",checked:typeof l==="boolean"?l:sl.enabled,onChange:(h)=>g({editorBlame:h})}),e(Fr,{label:"Show the label in the editor",hint:`Puts “author · age” at the end of each block. It costs horizontal room, so it is off on a narrow panel by default (${p.inline?"on":"off"}).`,checked:typeof c==="boolean"?c:sl.inline,onChange:(h)=>g({editorBlameInline:h})})]})]})}function _r({settings:t,onUpdate:r}){return e("div",{className:"w-full space-y-8 text-xs text-ink pb-3",children:[e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(ba,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),e(xr,{selectedId:t.theme,onSelect:(l)=>r({theme:XA(l)})})]}),e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(qn,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Layout"})]}),e(yr,{settings:t,onUpdate:r}),e(Tr,{settings:t,onUpdate:r}),e(Rr,{settings:t,onUpdate:r})]}),e(Mr,{settings:t,onUpdate:r}),e(Er,{settings:t,onUpdate:r}),e(Lr,{settings:t,onUpdate:r}),e(Dr,{settings:t,onUpdate:r}),e($r,{settings:t,onUpdate:r})]})}function ye(){let[t,r]=n("list"),l=a(()=>r("detail"),[]),c=a(()=>r("list"),[]);return{pane:t,openDetail:l,back:c}}function we({pane:t,onBack:r,list:l,detail:c,listLabel:p,className:g=""}){return e("div",{className:`flex-1 flex flex-col md:flex-row h-full w-full min-w-0 overflow-hidden bg-paper text-ink ${g}`,children:[e("div",{className:`${t==="list"?"flex":"hidden"} md:flex flex-1 md:flex-none md:w-auto min-h-0 min-w-0 flex-col`,children:l}),e("div",{className:`${t==="detail"?"flex":"hidden"} md:flex flex-1 min-h-0 min-w-0 flex-col`,children:[e("div",{className:"md:hidden flex items-center px-2 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:e("button",{type:"button",onClick:r,"aria-label":`Back to ${p}`,className:"flex items-center gap-1 -ml-0.5 pl-0.5 pr-2 py-1 rounded-lg text-ink hover:bg-ink/5 active:bg-ink/10 transition-colors cursor-pointer",children:[e(Aa,{size:18}),e("span",{className:"text-xs font-semibold truncate",children:p})]})}),c]})]})}function Br({groups:t,activeGroupId:r,onSelectGroup:l}){return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[t.length," group",t.length===1?"":"s"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 text-xs",children:e("div",{className:"space-y-0.5",children:t.map((c)=>{let p=c.id===r,g=c.icon;return e("button",{type:"button",onClick:()=>l(c.id),"aria-current":p?"true":void 0,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${p?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("span",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{"aria-hidden":!0,className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${p?"bg-ink/10 text-ink":"bg-ink/5 text-ink/70"}`,children:e(g,{size:12})}),e("span",{className:"font-semibold text-xs text-ink truncate",children:c.label})]}),e("span",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]",children:c.hint})]},c.id)})})})]})}var Nt=[{id:"layout",label:"Layout",hint:"Chat width and composer shape",description:"How wide the conversation is drawn, and the shape of the box you type into.",icon:qn,sections:["width","composer"]},{id:"transcript",label:"Transcript",hint:"Tool calls, changed files and follow-up dispatch",description:"How a tool call is drawn, whether a run lists the files it changed, and what happens to a prompt sent while the agent is still running.",icon:Ur,sections:["tool-calls","changed-files","follow-up"]},{id:"sessions",label:"Sessions",hint:"Titles and goal mode",description:"How a session gets its name, and the defaults a new goal starts with.",icon:en,sections:["titles","goal"]}];var ap={compact:"60%",wide:"85%",full:"100%"};function Gr({settings:t,onUpdate:r}){let l=t.chatWidthMode;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Chat Width"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How wide the conversation is drawn. The composer follows the transcript, and no mode hides a panel."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",role:"group","aria-label":"Chat width",children:cg.map((c)=>{let p=ug[c],g=l===c;return e("div",{onClick:()=>r({chatWidthMode:c}),role:"button",tabIndex:0,"aria-pressed":g,onKeyDown:(h)=>{if(h.key==="Enter"||h.key===" ")h.preventDefault(),r({chatWidthMode:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${g?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${g?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:g&&e(f,{size:10,strokeWidth:3})})]}),e("div",{"aria-hidden":!0,className:"h-1.5 rounded-full bg-ink/10 mb-2.5 overflow-hidden",children:e("div",{className:`h-full rounded-full ${g?"bg-ink":"bg-ink/35"}`,style:{width:ap[c]}})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"On a phone the column already fills the screen, so the mode has no visible effect."})]})}function Jr({active:t=!1}){return e("span",{className:`h-[6px] w-[16px] rounded-sm border ${t?"border-ink/40 bg-ink/15":"border-ink/20 bg-ink/5"}`})}function sp({hero:t=!1}){return e("span",{className:`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${t?"flex-1 justify-center":""}`,children:[e("span",{className:"h-[2.5px] w-[72%] rounded-full bg-ink/25"}),e("span",{className:"h-[2.5px] w-[54%] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[30%] rounded-full bg-ink/15"})]})}function lp({rail:t=!1}){if(t)return e("span",{className:"flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono",children:[e("span",{className:"h-[2.5px] w-[14px] rounded-full bg-ink/30"}),e("span",{className:"h-[2.5px] w-[9px] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[11px] rounded-full bg-ink/20"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80"})]});return e("span",{className:"flex items-center gap-1 px-1",children:[e("span",{className:"h-[6px] w-[20px] rounded-sm bg-ink/15"}),e("span",{className:"h-[6px] w-[10px] rounded-sm bg-ink/10"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-full border border-ink/25"}),e("span",{className:"h-[7px] w-[7px] rounded-sm bg-ink/80"})]})}var dp={classic:"rounded-md bg-paper border-ink/10",calm:"rounded-lg bg-paper border-ink/10",console:"rounded-sm bg-paper border-ink/10",stage:"rounded-md bg-paper border-ink/15",glass:"rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent"};function cp({style:t}){let r=$p({style:t,hero:t==="stage"});return e("span",{className:`flex h-full flex-col gap-1 border p-1 ${dp[t]}`,"aria-hidden":"true",children:r.wire.map((l,c)=>l==="draft"?e(sp,{hero:t==="stage"},c):l==="chip"?e("span",{className:"flex items-center gap-1 px-1",children:[e(Jr,{active:t!=="calm"}),e(Jr,{})]},c):e(lp,{rail:r.toolbarTone==="rail"},c))})}function Xr({settings:t,onUpdate:r}){let l=Yl(t.composerStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Composer"}),e("p",{className:"mt-0.5 text-[11px] text-ink/60",children:"The shape of the box you type into. Every style offers the same controls — attachments, plan and goal, access mode, model, thinking, voice, send — and only their order and frame change. Applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"group","aria-label":"Composer style",children:fg.map((c)=>{let p=gg[c],g=c===l;return e("button",{type:"button",onClick:()=>r({composerStyle:c}),"aria-pressed":g,"aria-label":`${p.label} composer — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[92px]",children:e(cp,{style:c})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function pp({mode:t}){if(t==="card")return e("div",{"aria-hidden":!0,className:"space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5",children:[e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/50"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/35"}),e("span",{className:"ml-auto h-1 w-5 rounded-full bg-ink/20"})]}),e("div",{className:"h-1 w-16 rounded-full bg-ink/15"})]});if(t==="compact")return e("div",{"aria-hidden":!0,className:"space-y-1.5 rounded-md border border-transparent px-1 py-1",children:[0,1].map((r)=>e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-8 rounded-full bg-ink/30"}),e("span",{className:"ml-auto h-1 w-6 rounded-full bg-ink/15"})]},r))});if(t==="trace")return e("div",{"aria-hidden":!0,className:"relative ml-1 pl-3 py-1",children:[e("span",{className:"absolute left-[3px] top-1 bottom-1 w-px bg-ink/20"}),[0,1,2].map((r)=>e("div",{className:"flex items-center gap-1 py-0.5",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/25"})]},r))]});if(t==="tui")return e("div",{"aria-hidden":!0,className:"space-y-1 px-1 py-1 font-mono",children:[0,1].map((r)=>e("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-[6px] text-success",children:"✔"}),e("span",{className:"h-1 w-3 rounded-full bg-info/70"}),e("span",{className:"h-1 w-6 rounded-full bg-meta/70"}),e("span",{className:"ml-auto h-1 w-2 rounded-full bg-ink/25"})]},r))});return e("div",{"aria-hidden":!0,className:"space-y-1.5 px-1 py-1",children:[e("div",{className:"h-1 w-20 rounded-full bg-ink/25"}),e("div",{className:"h-1 w-14 rounded-full bg-ink/15"})]})}function Qr({settings:t,onUpdate:r}){let l=t.toolRenderStyle;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Tool Calls"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:pg.map((c)=>{let p=mg[c],g=l===c;return e("div",{onClick:()=>r({toolRenderStyle:c}),role:"button",tabIndex:0,"aria-pressed":g,onKeyDown:(h)=>{if(h.key==="Enter"||h.key===" ")h.preventDefault(),r({toolRenderStyle:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${g?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${g?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:g&&e(f,{size:10,strokeWidth:3})})]}),e("div",{className:"mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1",children:e(pp,{mode:c})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"The style is global: it applies to every session, and the composer keeps its own frame."})]})}function up({label:t,enabled:r,onToggle:l}){return e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Disable":"Enable"} ${t}`,onClick:l,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${r?"bg-ink":"bg-ink/20"}`,children:e("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${r?"translate-x-5":"translate-x-0"}`})})}function Zr({settings:t,onUpdate:r}){let l=t.showChangedFiles;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Changed Files"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A collapsed list of the files a run changed, above its footer. Clicking a file opens the agent's own diff — the content it wrote, not the current worktree."})]}),e("div",{className:"flex items-start justify-between gap-4 py-3",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(Jo,{size:16,className:l?"text-ink":"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:"Show changed files"}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Read from the session's change journal. Sessions recorded before omp 18.20.1 have no journal, so the list stays empty there."})]})]}),e(up,{label:"Show changed files",enabled:l,onToggle:()=>r({showChangedFiles:!l})})]})]})}function ei({settings:t,onUpdate:r}){return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e("div",{onClick:()=>r({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="queue"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="queue"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Ur,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="queue"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="queue"&&e(f,{size:10,strokeWidth:3})})]})]}),e("div",{onClick:()=>r({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="steering"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="steering"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Ft,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="steering"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="steering"&&e(f,{size:10,strokeWidth:3})})]})]})]})]})}var mp=[{enabled:!0,label:"Generate Automatically",badge:"Default",icon:Le,description:`As soon as your first message lands, the session is named from it using omp's own tiny title model — retried once when the run ends if that first attempt came back empty. Sessions stop showing "New Session - <timestamp>" in the sidebar.`,note:"One small model call per session"},{enabled:!1,label:"Manual Only",badge:"Opt-out",icon:Hr,description:"Sessions keep their timestamp placeholder until you rename them from the sidebar. Choose this when every title should be deliberate, or to avoid the extra model call.",note:"No background model calls"}];function ti({settings:t,onUpdate:r}){let l=t.autoSessionTitle??!0;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Session Titles"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a session gets its display name. A name you set yourself is never replaced."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:mp.map(({enabled:c,label:p,badge:g,icon:h,description:v,note:x})=>{let y=l===c,k=()=>r({autoSessionTitle:c});return e("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:(T)=>T.key==="Enter"&&k(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${y?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${y?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(h,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:p})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:g})]}),e("p",{className:"text-[11px] text-ink/70 leading-relaxed",children:v})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50",children:x}),y&&e("span",{className:"flex items-center gap-1 text-ink font-medium",children:[e(f,{size:12})," Active"]})]})]},p)})})]})}var gp="flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-left font-mono text-[11px] text-ink transition-colors hover:border-ink/40 focus:border-ink/50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50";function $e({value:t,options:r,placeholder:l,ariaLabel:c,onChange:p,disabled:g,className:h,searchable:v=!0}){let[x,y]=n(null),[k,T]=n(""),[S,R]=n(0),P=o(null),L=o(null),N=o([]),E=o(`search-select-${Math.random().toString(36).slice(2,9)}`).current,A=r.find((q)=>q.value===t),O=x!==null,U=u(()=>{let q=k.trim();if(!q)return r;return r.filter((j)=>Ko(`${j.label} ${j.value} ${j.hint??""}`,q))},[r,k]),_=u(()=>{let q=[];for(let j of U){let G=j.group??"",Q=q.find((te)=>te.name===G);if(Q)Q.rows.push(j);else q.push({name:G,rows:[j]})}return q},[U]),K=(q=!1)=>{if(y(null),T(""),q)P.current?.focus()},V=()=>{if(g||!P.current)return;let q=Math.max(0,r.findIndex((j)=>j.value===t));T(""),R(q),y(zt(P.current))},z=(q)=>{if(q!==t)p(q);K(!0)};i(()=>{R(0)},[k]),i(()=>{if(!O)return;N.current[S]?.scrollIntoView({block:"nearest"})},[O,S]),i(()=>{if(O)L.current?.focus()},[O]);let W=(q)=>{if(q.key==="ArrowDown")q.preventDefault(),R((j)=>Math.max(0,Math.min(U.length-1,j+1)));else if(q.key==="ArrowUp")q.preventDefault(),R((j)=>Math.max(0,j-1));else if(q.key==="Home")q.preventDefault(),R(0);else if(q.key==="End")q.preventDefault(),R(Math.max(0,U.length-1));else if(q.key==="Enter"){q.preventDefault();let j=U[S];if(j)z(j.value)}};return e(d,{children:[e("button",{ref:P,type:"button",role:"combobox","aria-label":c,"aria-haspopup":"listbox","aria-expanded":O,"aria-controls":O?E:void 0,disabled:g,title:A?.label??l,onClick:()=>O?K():V(),onKeyDown:(q)=>{if(q.key==="ArrowDown"||q.key==="Enter"||q.key===" ")q.preventDefault(),V()},className:`${gp} ${h??""}`,children:[e("span",{className:`truncate ${A?"":"text-ink/40"}`,children:A?.label??(t?`${t} (not listed)`:l)}),e(B,{size:12,className:`flex-shrink-0 text-ink/40 transition-transform ${O?"rotate-180":""}`})]}),e(Ut,{anchor:x,align:"start",className:"w-72 max-w-[calc(100vw-2rem)] rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",...{"aria-label":c},onClose:()=>K(!0),children:e("div",{onKeyDown:W,children:[v&&e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{ref:L,type:"text",value:k,"aria-label":`Search ${c}`,placeholder:"Search…",onInput:(q)=>T(q.currentTarget.value),className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{id:E,role:"listbox","aria-label":c,className:"max-h-56 overflow-y-auto py-1",children:[e("button",{type:"button",role:"option","aria-selected":t==="",ref:(q)=>{N.current[0]=q},onClick:()=>z(""),onMouseEnter:()=>R(0),className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left ${t===""?"text-ink":"text-ink/60"} hover:bg-ink/5`,children:[e("span",{className:"truncate italic",children:l}),t===""&&e(f,{size:11,className:"flex-shrink-0"})]}),t!==""&&!A&&e("button",{type:"button",role:"option","aria-selected":!0,onClick:()=>z(t),className:"flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-ink",children:[e("span",{className:"truncate",children:[t," (not listed)"]}),e(f,{size:11,className:"flex-shrink-0"})]}),U.length===0?e("div",{className:"px-3 py-2 italic text-ink/40",children:["No match for “",k.trim(),"”"]}):_.map((q)=>e("div",{children:[q.name&&e("div",{className:"px-3 pb-0.5 pt-2 text-[9px] font-semibold uppercase tracking-wider text-ink/35",children:q.name}),q.rows.map((j)=>{let G=U.indexOf(j),Q=j.value===t;return e("button",{type:"button",role:"option","aria-selected":Q,ref:(te)=>{N.current[G+1]=te},onClick:()=>z(j.value),onMouseEnter:()=>R(G),title:j.hint??j.value,className:`flex w-full items-start justify-between gap-2 px-3 py-1.5 text-left transition-colors ${G===S?"bg-ink/5":""} ${Q?"font-medium text-ink":"text-ink/75"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate",children:j.label}),j.hint&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:j.hint})]}),Q&&e(f,{size:11,className:"mt-0.5 flex-shrink-0"})]},j.value)})]},q.name||"__flat"))]})]})})]})}var bp=[{enabled:!0,label:"Independent auditor",badge:"Default",description:"After every finished turn a separate model reads the objective and the agent's own report and decides: keep going, done, or needs you. Without it nothing advances a goal on its own.",note:"One extra model call per turn"},{enabled:!1,label:"Manual only",badge:"Opt-out",description:"Goals still exist — objective, pause, resume and the token budget all work — but the loop never continues by itself. Use it when a goal should only ever run the turns you ask for.",note:"No background model calls"}];function ni({settings:t,onUpdate:r}){let l=Xl(),[c,p]=n([]),[g,h]=n(!0),v=t.goalAuditEnabled??!0,x=t.goalAuditModel??"",y=t.goalDefaultBudget??null,[k,T]=n(y===null?"":String(y));i(()=>{T(y===null?"":String(y))},[y]);let S=()=>{let R=Wp(k);if(T(R===null?"":String(R)),R!==y)r({goalDefaultBudget:R})};return i(()=>{let R=!0;return Ga().then((P)=>{if(!R)return;p(Array.isArray(P.modelList)?P.modelList.map((L)=>({id:L.id,name:L.name,provider:L.provider})):[])}).catch(()=>{}).finally(()=>{if(R)h(!1)}),()=>{R=!1}},[]),e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Goal Mode"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A goal keeps a session working toward one objective until it is done, out of budget, or the auditor says it needs you."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:bp.map(({enabled:R,label:P,badge:L,description:N,note:E})=>{let A=v===R,O=()=>r({goalAuditEnabled:R});return e("div",{onClick:O,role:"button",tabIndex:0,onKeyDown:(U)=>U.key==="Enter"&&O(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${A?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${A?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(hi,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:P})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:L})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:N})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:E}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${A?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:A&&e(f,{size:10,strokeWidth:3})})]})]},P)})}),v&&e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 space-y-3",children:e("div",{children:[e("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Auditor model"}),e($e,{ariaLabel:"Auditor model",value:x,onChange:(R)=>r({goalAuditModel:R}),disabled:g,placeholder:"Session model (default)",className:"w-full py-1.5 text-[11.5px]",options:c.map((R)=>({value:`${R.provider}/${R.id}`,label:R.name,hint:`${R.provider}/${R.id}`,group:Wo(R.provider,l)}))}),e("p",{className:"mt-1 text-[10.5px] text-ink/45",children:"The audit is a classification, not a task: it runs with thinking off, one small call per turn."})]})}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5",children:[e("label",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:[e(Yi,{size:11})," Default token budget"]}),e("div",{className:"flex items-center gap-2",children:[e("input",{value:k,onChange:(R)=>T(R.currentTarget.value),onBlur:S,onKeyDown:(R)=>{if(R.key==="Enter")S()},placeholder:"none: the turn ceiling is then the only stop",inputMode:"numeric","aria-label":"Default goal token budget",className:"w-56 rounded border border-ink/15 bg-paper px-2 py-1.5 font-mono text-[11.5px] outline-none focus:border-ink"}),e("span",{className:"text-[10.5px] text-ink/45",children:"New goals start with this budget; a goal you set explicitly keeps its own."})]})]}),e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/10 bg-canvas/40 p-3 text-[11px] text-ink/60",children:[e(Qt,{size:12,className:"mt-0.5 shrink-0"}),e("span",{children:"The objective is set per goal from the composer's target button. The auditor judges progress from the objective and the agent's own report only — write an objective that says what finished looks like."})]})]})}var fp={width:Gr,composer:Xr,"tool-calls":Qr,"changed-files":Zr,"follow-up":ei,titles:ti,goal:ni};function oi({settings:t,onUpdate:r}){let l=ye(),[c,p]=n(Nt[0].id),g=Nt.find((h)=>h.id===c)??Nt[0];return e(we,{pane:l.pane,onBack:l.back,listLabel:"Chat settings",list:e(Br,{groups:Nt,activeGroupId:g.id,onSelectGroup:(h)=>{p(h),l.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col text-xs text-ink",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0",children:[e("span",{className:"text-xs font-semibold text-ink/75",children:g.label}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:g.description})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6",children:g.sections.map((h)=>{let v=fp[h];return e(v,{settings:t,onUpdate:r},h)})})]})})}function ri(t){let r=new Map;for(let c of t){let p=Bg(c.chord),g=r.get(p);if(g)g.push(c);else r.set(p,[c])}let l=[];for(let c of r.values())for(let p=0;p<c.length;p+=1)for(let g=p+1;g<c.length;g+=1){let h=c[p],v=c[g];if(h.command===v.command)continue;l.push({chord:h.chord,a:h,b:v,certain:!h.when||!v.when||h.when===v.when})}return l}var hp={Shift:!0,Control:!0,Alt:!0,Meta:!0,OS:!0,Super:!0,Hyper:!0,CapsLock:!0,Fn:!0},yp={ShiftLeft:!0,ShiftRight:!0,ControlLeft:!0,ControlRight:!0,AltLeft:!0,AltRight:!0,MetaLeft:!0,MetaRight:!0,OSLeft:!0,OSRight:!0,CapsLock:!0};function ii(t){return hp[t.key]===!0||yp[t.code]===!0}function ai({chord:t,onCommit:r}){let[l,c]=n(!1),[p,g]=n([]),h=o(null);i(()=>{if(l)h.current?.focus()},[l]);let v=()=>{c(!1),g([])},x=(k)=>{if(!l)return;if(k.preventDefault(),k.stopPropagation(),k.key==="Escape"){v();return}if(k.key==="Backspace"||k.key==="Delete"){if(p.length===0)r(null),v();else g([]);return}if(k.key==="Enter"&&p.length===1){r(Uf(p)),v();return}if(ii(k))return;let T=Kp(k);if(p.length===0){g([T]);return}r(Uf([p[0],T])),v()},y=l?p.length>0?`${Ei(p,ht())} …`:"Press keys…":t||"Unassigned";return e("button",{ref:h,type:"button",onClick:()=>{c(!0),g([])},onBlur:()=>{if(l)v()},onKeyDown:x,"aria-label":l?"Recording shortcut, press keys":`Shortcut ${t||"unassigned"}, click to change`,className:`min-w-[7rem] px-2 py-1 rounded-md border text-[11px] font-mono transition-colors ${l?"border-ink/60 bg-ink/5 text-ink":"border-ink/20 text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:y})}function si(){let{commands:t,chords:r,rules:l}=tc(),[c,p]=n(()=>Vp()),[g,h]=n(""),v=u(()=>ri(l),[l]),x=ht(),y=(P)=>t.find((L)=>L.id===P)?.title??P,k=(P,L)=>{let N={...c,[P]:L};p(N),Pu(N),Gf(N)},T=(P)=>{let L={...c};delete L[P],p(L),Pu(L),Gf(L)},S=g.trim().toLowerCase(),R=t.filter((P)=>!S||P.title.toLowerCase().includes(S)||(r.get(P.id)??"").toLowerCase().includes(S)).sort((P,L)=>P.category.localeCompare(L.category)||P.title.localeCompare(L.title));return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Shortcuts"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Click a chord to record a new one. Two strokes are allowed; Enter keeps a single stroke."})]}),e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border border-ink/15 rounded-md bg-canvas",children:[e(F,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:g,onInput:(P)=>h(P.currentTarget.value),placeholder:"Filter","aria-label":"Filter shortcuts",className:"w-32 bg-transparent text-xs text-ink focus:outline-none placeholder-ink/40"})]})]}),v.length>0?e("div",{className:"border border-ink/15 rounded-lg p-3 space-y-1.5 bg-ink/[0.02]",children:[e("p",{className:"text-[11px] font-semibold text-ink/75",children:[v.length," chord ",v.length===1?"conflict":"conflicts"]}),v.map((P)=>e("p",{className:"text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-ink/80",children:Ei(P.chord,x)})," ","— ",y(P.a.command)," and ",y(P.b.command),P.certain?"":" (may not overlap)"]},`${P.a.command}-${P.b.command}`))]}):null,e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:R.length===0?e("p",{className:"px-3 py-4 text-center text-xs text-ink/50",children:"No command matches that filter."}):R.map((P)=>{let L=c[P.id]!==void 0;return e("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink truncate",children:P.title}),e("div",{className:"text-[10px] text-ink/45",children:[P.category,P.pluginId?` · ${P.pluginId}`:"",L?" · custom":""]})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e(ai,{chord:r.get(P.id)??"",onCommit:(N)=>k(P.id,N)}),L?e("button",{type:"button",onClick:()=>T(P.id),title:"Reset to default","aria-label":`Reset ${P.title} to its default shortcut`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors",children:e(ut,{size:12})}):null]})]},P.id)})})]})}function li({settings:t,onUpdate:r}){let l=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],c=(g,h)=>{r((v)=>{let x={[g]:h},y=["keybindingSend","keybindingNewLine","keybindingSteering"].filter((k)=>k!==g);for(let k of y)if(v[k]===h)x[k]=v[g];return{...v,...x}})},p=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:tt,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:Kt,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:Ft,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:[e(ga,{size:15,className:"text-ink/70"}),e("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),e("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:p.map((g)=>e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:e(g.icon,{size:14})}),e("div",{children:[e("div",{className:"font-semibold text-xs text-ink",children:g.label}),e("div",{className:"text-[11px] text-ink/60 mt-0.5",children:g.desc})]})]}),e("div",{className:"flex items-center gap-2 self-end sm:self-center",children:e("select",{value:g.value,onChange:(h)=>c(g.id,h.currentTarget.value),className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:l.map((h)=>e("option",{value:h,children:h},h))})})]},g.id))})]})}function ci({settings:t,onUpdate:r}){return e("div",{className:"flex-1 h-full overflow-y-auto scrollbar-overlay-container p-4 md:p-6 space-y-8 pb-8",children:[e(si,{}),e(li,{settings:t,onUpdate:r})]})}function pi({projects:t,selectedProjectId:r,onSelectProject:l,onAddProject:c,onTogglePin:p,isAdding:g=!1,folderFacts:h=[],loadError:v=null}){let x=new Map(h.map((y)=>[y.id,y.totalSessions]));return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:[t.length," project",t.length===1?"":"s"]}),e("button",{type:"button",onClick:c,disabled:g,"aria-label":"Add project",title:"Add project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:[v&&e("p",{className:"px-2 py-2 text-[11px] text-error",title:v,children:["Projects could not be read: ",v]}),!v&&t.length===0&&e("div",{className:"px-2 py-3 space-y-1.5",children:[e("p",{className:"text-[11.5px] text-ink/60",children:"No projects yet."}),e("button",{type:"button",onClick:c,className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add the first one"})]}),t.map((y)=>{let k=y.id===r,T=Yr(y.icon),S=y.folderId===void 0?void 0:x.get(y.folderId);return e("div",{className:`group flex items-center rounded-md transition-colors ${k?"bg-ink/10 shadow-2xs":"hover:bg-ink/5"}`,children:[e("button",{type:"button",onClick:()=>l(y.id),"aria-current":k?"true":void 0,className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer",children:[y.customIconUrl?e("img",{src:y.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):e(T,{size:14,className:"flex-shrink-0",style:{color:y.accentColor||"currentColor"}}),e("span",{className:`text-[11.5px] truncate flex-1 ${k?"font-medium text-ink":"text-ink/80"}`,children:y.name}),typeof S==="number"&&S>0&&e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:S})]}),e("button",{type:"button",onClick:()=>p(y),"aria-label":y.isPinned?`Unpin ${y.name}`:`Pin ${y.name}`,title:y.isPinned?"Unpin (stop sorting first)":"Pin (sort first in the sidebar)",className:`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${y.isPinned?"text-ink/70 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:y.isPinned?e(_a,{size:12}):e(cl,{size:12})})]},y.id)})]})]})}function ui({project:t,canDelete:r,isDeleting:l=!1,onDelete:c}){return e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0 flex-1",children:[e("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path||"Not bound to a directory"})]}),r&&e("button",{type:"button",onClick:c,disabled:l,title:"Delete this project",className:"inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1.5 text-[11px] font-medium text-ink/50 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer disabled:opacity-50",children:[e(M,{size:13}),e("span",{children:"Delete"})]})]})}function bi({name:t,disabled:r=!1,onCommit:l}){let[c,p]=n(t);return i(()=>{p(t)},[t]),e("div",{className:"space-y-2",children:[e("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project name"}),e("input",{id:"project-name-input",type:"text",value:c,disabled:r,onChange:(h)=>p(h.currentTarget.value),onBlur:()=>{let h=c.trim();if(!h){p(t);return}if(h===t)return;l(h)},onKeyDown:(h)=>{if(h.key==="Enter")h.preventDefault(),h.currentTarget.blur();if(h.key==="Escape")p(t),h.currentTarget.blur()},placeholder:"Enter project name…",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:"Names are unique: the sidebar identifies a project by it."})]})}function fi({path:t,disabled:r=!1,onCommit:l,onReveal:c,isRevealing:p=!1}){let[g,h]=n(t),[v,x]=n(!1);i(()=>{h(t)},[t]);let y=(k)=>{let T=k.trim();if(T===t)return;l(T)};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("label",{htmlFor:"project-path-input",className:"block text-xs font-semibold text-ink",children:"Project directory"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:()=>x(!0),disabled:r,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(Dn,{size:11}),e("span",{children:"Browse…"})]}),e("button",{type:"button",onClick:c,disabled:r||!t||p,title:t?"Reveal in the file manager":"This project is not bound to a directory",className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40",children:[e(Dt,{size:11}),e("span",{children:"Reveal"})]})]})]}),e("input",{id:"project-path-input",type:"text",value:g,disabled:r,onChange:(k)=>h(k.currentTarget.value),onBlur:()=>y(g),onKeyDown:(k)=>{if(k.key==="Enter")k.preventDefault(),k.currentTarget.blur();if(k.key==="Escape")h(t),k.currentTarget.blur()},placeholder:"~ or /absolute/path, or leave empty for an unbound grouping",spellcheck:!1,className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:t?"Sessions found under this directory appear in the project. One directory can belong to one project.":"Not bound to a directory: this project groups chats only and discovers no sessions."}),v&&e(ys,{initialPath:t||void 0,onSelect:(k)=>{x(!1),h(k),y(k)},onClose:()=>x(!1)})]})}function vi({model:t,models:r,onSelectModel:l,disabled:c=!1}){let[p,g]=n(!1),[h,v]=n(""),x=o(null);ce(x,()=>g(!1));let y=Sg(t,r)??"Inherit Kabmo’s default",k=u(()=>{let S=h.trim().toLowerCase();if(!S)return r;return r.filter((R)=>R.name.toLowerCase().includes(S)||R.id.toLowerCase().includes(S)||R.provider.toLowerCase().includes(S))},[r,h]),T=(S)=>{l(S),g(!1),v("")};return e("div",{className:"space-y-2.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),e("span",{className:"inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help",title:"The model a chat started in this project uses until you pick another one in the composer.",children:e(pe,{size:12})})]}),e("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink",children:"Project model"}),e("div",{className:"text-[11px] text-ink/50",children:r.length===0?"No model catalog yet — connect a provider first.":"Applied when the project starts a chat."})]}),e("div",{className:"relative shrink-0",ref:x,children:[e("button",{type:"button",onClick:()=>g((S)=>!S),disabled:c,className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50",children:[e(Le,{size:13,className:"text-ink/70 shrink-0"}),e("span",{className:"truncate",children:y}),e(B,{size:13,className:"text-ink/50 shrink-0"})]}),p&&e("div",{className:"glass-popover absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden",children:[e("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 shrink-0"}),e("input",{autoFocus:!0,value:h,onInput:(S)=>v(S.currentTarget.value),placeholder:"Search models…",className:"flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"max-h-64 scrollbar-overlay-container py-1",children:[e("button",{type:"button",onClick:()=>T(nc),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:t===nc?"font-semibold text-ink":"text-ink/80",children:"Inherit Kabmo’s default"}),t===nc&&e(f,{size:13,className:"text-ink"})]}),k.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/50",children:r.length===0?"The catalog is empty.":`No model matches “${h.trim()}”.`}):k.map((S)=>{let R=_g({provider:S.provider,modelId:S.id}),P=t===R;return e("button",{type:"button",onClick:()=>T(R),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:`truncate text-xs ${P?"font-semibold text-ink":"text-ink/85"}`,children:S.name}),e("span",{className:"truncate text-[10.5px] text-ink/45",children:S.provider})]}),P&&e(f,{size:13,className:"text-ink shrink-0"})]},R)})]}),t!==nc&&e("button",{type:"button",onClick:()=>T(nc),className:"w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(b,{size:11}),e("span",{children:"Clear the project model"})]})]})]})]})]})}function xi({accentColor:t,onSelectColor:r,options:l=jf,disabled:c=!1}){let p=l.length>0?l:jf,g=t.trim().toLowerCase(),h=p.some((L)=>L.value!==""&&L.value.toLowerCase()===g),v=g!==""&&!h,x=Jp(g)??Yp,[y,k]=n(x);i(()=>k(x),[x]);let T=(L)=>{let N=Jp(L);if(N===null){k(x);return}if(k(N),N!==g)r(N)},S=o(null),R=o(null),P=o({commit:T,clear:()=>r("")});return P.current={commit:T,clear:()=>r("")},i(()=>{let L=S.current,N=R.current;if(!L||!N)return;let E=(_)=>k(_.target.value.toLowerCase()),A=(_)=>P.current.commit(_.target.value),O=()=>{let _=N.value.trim();if(_==="")P.current.clear();else P.current.commit(_)},U=(_)=>{if(_.key==="Enter")_.preventDefault(),O();if(_.key==="Escape")k(x)};return L.addEventListener("input",E),L.addEventListener("change",A),N.addEventListener("blur",O),N.addEventListener("keydown",U),()=>{L.removeEventListener("input",E),L.removeEventListener("change",A),N.removeEventListener("blur",O),N.removeEventListener("keydown",U)}},[x]),e("div",{className:"space-y-2.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Accent colour"}),e("div",{className:"flex flex-wrap items-center gap-2.5",children:p.map((L)=>{let N=g===L.value.toLowerCase();if(L.value==="")return e("button",{type:"button",onClick:()=>r(""),disabled:c,"aria-label":"No accent colour","aria-pressed":N,title:"No accent colour",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${N?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:e(b,{size:12,strokeWidth:2.2})},"none");return e("button",{type:"button",onClick:()=>r(L.value),disabled:c,"aria-label":L.label,"aria-pressed":N,title:L.label,style:{backgroundColor:L.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${N?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},L.value)})}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("label",{title:"Pick a custom accent colour",className:`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${v?"ring-2 ring-ink ring-offset-2 ring-offset-paper":"border-ink/25 hover:border-ink/50"} ${c?"opacity-50 pointer-events-none":""}`,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundColor:y}}),e(rr,{size:12,strokeWidth:2.2,"aria-hidden":"true",className:"absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"}),e("input",{ref:S,type:"color",value:Jp(y)??Yp,disabled:c,"aria-label":"Custom accent colour",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e("input",{ref:R,type:"text",value:y,disabled:c,spellcheck:!1,"aria-label":"Custom accent colour hex",placeholder:Yp,onInput:(L)=>k(L.currentTarget.value),className:"w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"}),e("span",{className:"text-[11px] text-ink/45",children:v?"Custom accent":"Pick any colour"})]})]})}var Ln=128,wp=700000;async function Pp(t){let r=Promise.withResolvers(),l=new FileReader;l.onload=(R)=>{let P=R.target?.result;if(typeof P==="string"&&P)r.resolve(P);else r.reject(Error("That file could not be read as an image."))},l.onerror=()=>r.reject(Error("That file could not be read as an image.")),l.readAsDataURL(t);let c=await r.promise;if(t.type==="image/svg+xml")return c;let p=Promise.withResolvers(),g=new Image;g.onload=()=>p.resolve(g),g.onerror=()=>p.reject(Error("That file is not an image Kabmo can read.")),g.src=c;let h=await p.promise,v=Math.min(1,Ln/Math.max(h.naturalWidth,h.naturalHeight)),x=Math.max(1,Math.round(h.naturalWidth*v)),y=Math.max(1,Math.round(h.naturalHeight*v)),k=document.createElement("canvas");k.width=x,k.height=y;let T=k.getContext("2d");if(!T)return c;T.drawImage(h,0,0,x,y);let S=k.toDataURL("image/png");return S.length>0&&S.length<c.length?S:c}function yi({currentIcon:t,customIconUrl:r,projectName:l,onSelectIcon:c,onSetCustomIcon:p,disabled:g=!1}){let h=o(null),[v,x]=n(!1),[y,k]=n(!1),[T,S]=n(null),R=async(N)=>{let E=N.currentTarget.files?.[0];if(N.currentTarget.value="",!E)return;S(null),k(!0);try{let A=await Pp(E);if(A.length>wp){S("That image is too detailed to store as a mark — try a PNG or SVG.");return}p(A)}catch(A){S(A instanceof Error?A.message:String(A))}finally{k(!1)}},P=()=>{let E=`https://api.dicebear.com/7.x/identicon/svg?seed=${l.toLowerCase().replace(/[^a-z0-9]/g,"")||"project"}&radius=50&size=${Ln}`;S(null),x(!0);let A=new Image;A.onload=()=>{x(!1),p(E)},A.onerror=()=>{x(!1),S("The generated icon could not be loaded — check your connection.")},A.src=E},L=g||y||v;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Project icon"}),r&&e("button",{type:"button",onClick:()=>p(void 0),disabled:L,className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:"Use a standard icon"})]}),e("div",{className:"flex flex-wrap gap-1.5",children:Ig.map((N)=>{let E=!r&&t===N.id,A=N.icon;return e("button",{type:"button",onClick:()=>c(N.id),disabled:L,"aria-label":N.label,"aria-pressed":E,title:N.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${E?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"border border-transparent text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:e(A,{size:14,strokeWidth:1.8})},N.id)})}),e("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e("input",{type:"file",ref:h,onChange:(N)=>void R(N),accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden"}),e("button",{type:"button",onClick:()=>h.current?.click(),disabled:L,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[y?e(m,{size:13,className:"animate-spin text-ink/60"}):e($o,{size:13,className:"text-ink/60"}),e("span",{children:y?"Reading…":"Upload image"})]}),e("button",{type:"button",onClick:P,disabled:L,title:"Generate a stable identicon from the project name",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[v?e(m,{size:13,className:"animate-spin text-ink/60"}):e(zo,{size:13,className:"text-ink/60"}),e("span",{children:v?"Generating…":"Generate mark"})]}),r&&e("div",{className:"flex items-center gap-2 ml-1 pl-2 border-l border-ink/10",children:[e("img",{src:r,alt:"Current custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),e("span",{className:"text-[11px] text-ink/60",children:"Custom icon in use"}),e("button",{type:"button",onClick:()=>p(void 0),disabled:L,"aria-label":"Remove the custom icon",className:"p-0.5 rounded text-ink/40 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:12})})]})]}),e("p",{className:"text-[11px] text-ink/50",children:["Any image works — it is scaled down to a ",Ln,"px mark. PNG, JPEG, WebP, GIF or SVG."]}),T&&e("p",{className:"text-[11px] text-error",children:T})]})}function Si({project:t,canDelete:r,isDeleting:l=!1,isRevealing:c=!1,models:p,accentColorOptions:g,onUpdateField:h,onUpdateFields:v,onReveal:x,onDeleteProject:y}){return e("div",{className:"p-6 md:p-8 space-y-7",children:[e(ui,{project:t,canDelete:r,isDeleting:l,onDelete:y}),e(bi,{name:t.name,onCommit:(k)=>h("name",k)}),e(fi,{path:t.path,onCommit:(k)=>h("path",k),onReveal:x,isRevealing:c}),e(vi,{model:t.model,models:p,onSelectModel:(k)=>h("model",k)}),e(xi,{accentColor:t.accentColor,onSelectColor:(k)=>h("accentColor",k),...g&&g.length>0?{options:g}:{}}),e(yi,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:(k)=>v({icon:k,customIconUrl:void 0}),onSetCustomIcon:(k)=>v({customIconUrl:k,icon:k===void 0?"default":"custom"})})]})}function Cp(t){return(t.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"").toLowerCase()}function Ip({isSaving:t,onClose:r,onSubmit:l}){let[c,p]=n(""),[g,h]=n(""),[v,x]=n(!1),[y,k]=n(!0),[T,S]=n(null),R=(L)=>{if(h(L),y||!c.trim())p(Cp(L)),k(!0)},P=async()=>{let L=c.trim();if(!L){S("Enter a project name.");return}S(null);try{await l({name:L,path:g.trim()}),r()}catch(N){S(N instanceof Error?N.message:String(N))}};return e(d,{children:e(J,{onClose:t?()=>{}:r,ariaLabel:"Add project",maxWidthClass:"max-w-[480px]",header:e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Add project"}),e("p",{className:"text-[11px] text-ink/50",children:"A name, and the directory its chats run in."})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,disabled:t,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:()=>void P(),disabled:t,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5",children:[t&&e(m,{size:13,className:"animate-spin"}),e("span",{children:t?"Adding…":"Add project"})]})]}),children:[e("div",{className:"px-5 py-4 space-y-4",children:[e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-name",className:"block text-xs font-semibold text-ink",children:"Name"}),e("input",{id:"add-project-name",type:"text",value:c,onInput:(L)=>{p(L.currentTarget.value),k(!1)},placeholder:"e.g. kabmo",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"}),e("p",{className:"text-[11px] text-ink/50",children:"Unique: the sidebar identifies a workspace by it."})]}),e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-path",className:"block text-xs font-semibold text-ink",children:["Directory ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("div",{className:"flex items-center gap-2",children:[e("input",{id:"add-project-path",type:"text",value:g,onInput:(L)=>h(L.currentTarget.value),placeholder:"~ or /absolute/path",spellcheck:!1,className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"}),e("button",{type:"button",onClick:()=>x(!0),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer",children:[e(Dt,{size:12}),e("span",{children:"Browse…"})]})]}),e("p",{className:"text-[11px] text-ink/50",children:"Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory behind it."})]}),T&&e("p",{className:"text-[11px] text-error",children:T})]}),v&&e(ys,{initialPath:g||void 0,onSelect:(L)=>{R(L),x(!1)},onClose:()=>x(!1)})]})})}function Ni({isOpen:t,isSaving:r,onClose:l,onSubmit:c}){if(!t)return null;return e(Ip,{isSaving:r,onClose:l,onSubmit:c})}function Pi({project:t,isDeleting:r,error:l,onClose:c,onConfirm:p}){if(i(()=>{let g=(h)=>{if(h.key!=="Escape"||r)return;h.preventDefault(),c()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,r]),!t)return null;return e(J,{onClose:r?()=>{}:c,zClass:"z-[70]",maxWidthClass:"max-w-[440px]",ariaLabel:"Delete project",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(M,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete project?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:t.name})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:p,disabled:r,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[r?e(m,{size:13,className:"animate-spin"}):e(M,{size:13}),e("span",{children:r?"Deleting…":"Delete project"})]})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspace is unregistered from Kabmo — its place in the sidebar, its chats' grouping and its settings go."}),e("li",{children:t.path?"The directory itself is NOT deleted; a tombstone keeps omp discovery from re-adding it on the next boot.":"It has no directory, so nothing on disk is touched."}),e("li",{children:"Chat transcripts stay on disk under ~/.omp/agent/sessions."})]}),l&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:l})]})]})})}var On="worktreeDirectory",Un="worktreeCarryIgnored";function Ci(t){if(t.missing)return"folder is missing — its chats still open";let r=t.detached?`detached @ ${t.head.slice(0,7)||"unknown"}`:`${t.branch} checked out here`,l=t.sessions===1?"1 chat":`${t.sessions} chats`,c=t.dirty===0?"clean":`${t.dirty} changed`;return`${r} · ${l} · ${c}`}function Ti(t){return!t.detached&&Boolean(t.branch)&&t.aheadOfStart===0}function Fn(t){if(t.isPrimary)return"The main checkout cannot be removed.";if(t.dirty>0)return`${t.dirty} uncommitted file${t.dirty===1?"":"s"} here would be lost.`;return null}function Ii({root:t,folderId:r,onReport:l}){let{worktrees:c,base:p,loading:g,error:h,isRepo:v,refresh:x}=Zp({root:t,folderId:r},Boolean(t)),[y,k]=n(()=>{let N=H(On);return typeof N==="string"?N:""}),[T,S]=n(()=>H(Un)!==!1),[R,P]=n(null);if(!t)return e("p",{className:"text-xs text-ink/50",children:"Bind this workspace to a repository to manage its worktrees."});let L=c.filter((N)=>!N.isPrimary);return e("div",{className:"flex flex-col gap-4",children:[e("section",{className:"flex flex-col gap-1",children:[e("h3",{className:"text-xs font-semibold text-ink",children:"Worktrees"}),g&&e("p",{className:"text-[11px] text-ink/50",children:"Reading worktrees…"}),h&&e("p",{className:"text-[11px] text-error",title:h,children:["Worktrees could not be read: ",h]}),!g&&!h&&v===!1&&e("p",{className:"text-[11px] text-ink/50",children:"Worktrees need a Git repository."}),!g&&!h&&v!==!1&&L.length===0&&e("p",{className:"text-[11px] text-ink/50",children:"No worktrees yet."}),L.map((N)=>e("div",{className:"group flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-ink/5",children:[e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"truncate text-xs text-ink",children:N.branch||"detached"}),e("p",{className:"truncate text-[10.5px] text-ink/50",title:N.path,children:Ci(N)})]}),e("button",{type:"button",disabled:R===N.path||Fn(N)!==null,"aria-label":`Remove worktree ${N.branch||N.path}`,title:Fn(N)??"Remove worktree",onClick:()=>{P(N.path),Tg({root:t,folderId:r},N.path,{deleteBranch:Ti(N)}).then((E)=>(l(E.branchDeleted?`Removed ${N.branch} and its branch`:`Removed ${N.branch}${E.branchKept?" (branch kept)":""}`,"success"),x())).catch((E)=>l(E instanceof Error?E.message:String(E),"error")).finally(()=>P(null))},className:"shrink-0 rounded px-2 py-1 text-[11px] text-ink/60 hover:bg-error/10 hover:text-error disabled:opacity-40",children:"Remove"})]},N.path))]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Worktree location"}),e("input",{value:y,onChange:(N)=>k(N.currentTarget.value),onBlur:()=>At(On,y.trim()),placeholder:p,className:"h-8 rounded-md border border-ink/15 bg-paper px-2 text-xs text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10.5px] text-ink/50",children:["Where new worktrees are created. Relative paths are resolved against the project; ~ is your home directory. Empty uses ",p,"."]})]}),e("label",{className:"flex items-start gap-2",children:[e("input",{type:"checkbox",checked:T,onChange:(N)=>{let E=N.currentTarget.checked;S(E),At(Un,E)},className:`${ge} mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Copy ignored files into new worktrees"}),e("span",{className:"text-[10.5px] text-ink/50",children:"A new worktree gets the project's ignored build folders (node_modules, .venv, target) copied in, so it works without reinstalling."})]})]})]})}var Ap={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},Ae=({variant:t="full",children:r})=>e("div",{className:Ap[t],children:r});var Ht="";function Ri(t){if(!w(t))return!1;return typeof t.id==="string"&&typeof t.name==="string"&&typeof t.path==="string"}function Rp(t){if(!w(t))return!1;return typeof t.label==="string"&&typeof t.value==="string"&&typeof t.bgHex==="string"}function Mp(t,r){return t.some((c)=>c.id===r.id)?t.map((c)=>c.id===r.id?r:c):[...t,r]}function Mi(t){let[r,l]=n([]),[c,p]=n([]),[g,h]=n(Ht),[v,x]=n(!0),[y,k]=n(null),[T,S]=n(!1),[R,P]=n(!1),L=o(t);L.current=t;let N=a((j)=>{if(!w(j))return;let G=Array.isArray(j.projects)?j.projects.filter(Ri):null;if(G)l(G),h((Q)=>G.some((te)=>te.id===Q)?Q:G[0]?.id??Ht);if(Array.isArray(j.accentColorOptions))p(j.accentColorOptions.filter(Rp))},[]),E=a(async()=>{try{let j=await fetch("/api/settings/projects"),G=await j.json();if(!j.ok){let Q=w(G)&&typeof G.error==="string"?G.error:`HTTP ${j.status}`;k(Q);return}k(null),N(G)}catch(j){k(j instanceof Error?j.message:String(j))}},[N]);i(()=>{let j=!0;return(async()=>{if(await E(),j)x(!1)})(),()=>{j=!1}},[E]);let A=je().folders,O=u(()=>A.map((j)=>`${j.id}:${j.name}:${j.model??""}:${j.icon??""}:${j.accentColor??""}:${j.project_path??""}:${j.isPinned?1:0}`).join("|"),[A]);i(()=>{if(!O)return;E()},[O,E]);let U=a(async(j,G)=>{if(j.folderId===void 0)return L.current("This project has no workspace row to save to."),!1;let Q=r;l((Z)=>Z.map((X)=>X.id===j.id?{...X,...G}:X));let te={folderId:j.folderId};for(let[Z,X]of Object.entries(G))te[Z]=X===void 0?null:X;try{let Z=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:te})}),X=await Z.json().catch(()=>null);if(!Z.ok){let oe=w(X)&&typeof X.error==="string"?X.error:`HTTP ${Z.status}`;throw Error(oe)}let re=w(X)&&Ri(X.project)?X.project:null;if(re)l((oe)=>Mp(oe,re));return!0}catch(Z){return l(Q),L.current(Z instanceof Error?Z.message:String(Z)),!1}},[r]),_=a((j,G,Q)=>U(j,{[G]:Q}),[U]),K=a((j,G)=>U(j,G),[U]),V=a(async(j)=>{S(!0);try{let G=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name,path:j.path})}),Q=await G.json().catch(()=>null),te=w(Q)?Q.folder:null,Z=w(te)&&typeof te.id==="number"?te.id:null;if(!G.ok||!w(Q)||Q.success!==!0||Z===null){let X=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${G.status}`;throw Error(X)}await E(),h(`folder-${Z}`)}catch(G){throw L.current(G instanceof Error?G.message:String(G)),G}finally{S(!1)}},[E]),z=a(async(j)=>{P(!0);try{let G=await fetch(`/api/settings/projects?id=${encodeURIComponent(j.id)}`,{method:"DELETE"}),Q=await G.json().catch(()=>null);if(!G.ok||!w(Q)||Q.success!==!0){let te=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${G.status}`;throw Error(te)}l((te)=>{let Z=te.filter((X)=>X.id!==j.id);return h((X)=>X===j.id?Z[0]?.id??Ht:X),Z})}catch(G){throw L.current(G instanceof Error?G.message:String(G)),G}finally{P(!1)}},[]),W=ja((j)=>Array.isArray(j.modelList)&&j.modelList.length>0?j.modelList.map((G)=>({provider:G.provider,id:G.id,name:G.name||G.id})):void 0)??[],q=r.find((j)=>j.id===g)??r[0]??null;return{projects:r,selected:q,selectedId:q?.id??Ht,select:h,accentColorOptions:c,models:W,isLoading:v,loadError:y,refresh:E,updateField:_,updateFields:K,isAdding:T,addProject:V,isDeleting:R,deleteProject:z,onError:t}}function Li(){let t=ye(),{pushToast:r}=Ve(),[l,c]=n(!1),[p,g]=n(null),[h,v]=n(null),[x,y]=n(null),k=Mi((L)=>r(L,"error",{duration:7000})),{folders:T}=je(),S=async(L)=>{if(!L.path||L.folderId===void 0){r("This project is not bound to a directory.","error");return}y(L.id);try{let N=await fetch(`/api/folders/${L.folderId}/open`,{method:"POST"}),E=await N.json().catch(()=>null);if(!N.ok){let A=E&&typeof E==="object"&&"error"in E&&typeof E.error==="string"?E.error:`HTTP ${N.status}`;throw Error(A)}}catch(N){r(N instanceof Error?N.message:String(N),"error")}finally{y(null)}},R=async()=>{if(!p)return;v(null);try{await k.deleteProject(p),g(null),t.back()}catch(L){v(L instanceof Error?L.message:String(L))}};if(k.isLoading)return e(Ae,{children:"Loading projects…"});let P=k.selected;return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(we,{pane:t.pane,onBack:t.back,listLabel:"Projects",list:e(pi,{projects:k.projects,selectedProjectId:P?.id??"",onSelectProject:(L)=>{k.select(L),t.openDetail()},onAddProject:()=>c(!0),onTogglePin:(L)=>{k.updateField(L,"isPinned",!L.isPinned)},isAdding:k.isAdding,folderFacts:T,loadError:k.loadError}),detail:P?e("div",{className:"flex-1 min-h-0 scrollbar-overlay-container flex flex-col",children:[e(Si,{project:P,canDelete:k.projects.length>1,isDeleting:k.isDeleting&&p?.id===P.id,isRevealing:x===P.id,models:k.models,accentColorOptions:k.accentColorOptions,onUpdateField:(L,N)=>{k.updateField(P,L,N)},onUpdateFields:(L)=>{k.updateFields(P,L)},onReveal:()=>void S(P),onDeleteProject:()=>{v(null),g(P)}}),e("div",{className:"border-t border-ink/10 px-6 md:px-8 py-4",children:e(Ii,{root:P.path||null,folderId:P.folderId??null,onReport:(L,N)=>r(L,N??"success",{duration:6000})})})]}):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center",children:e("div",{className:"space-y-2",children:[e("p",{className:"text-xs text-ink/60",children:"No project selected."}),e("button",{type:"button",onClick:()=>c(!0),className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add a project"})]})})}),e(Ni,{isOpen:l,isSaving:k.isAdding,onClose:()=>c(!1),onSubmit:async(L)=>{await k.addProject(L),t.openDetail()}}),e(Pi,{project:p,isDeleting:k.isDeleting,error:h,onClose:()=>{g(null),v(null)},onConfirm:()=>void R()})]})}function Oi(t){return t!==void 0&&(t.status==="connected"||Boolean(t.baseUrl))}function Di(t){return t.filter((r)=>r.slug.trim().length>0&&Oi(r)).map((r)=>r.slug)}function Ui(t,r){let l=new Map;for(let g of t){let h=g.slug.trim().toLowerCase();if(h)l.set(h,g)}let c=new Set,p=[];for(let g of r){let h=g.slug.trim().toLowerCase();if(c.has(h))continue;if(!g.bundled&&Oi(l.get(h)))continue;c.add(h),p.push(g)}return p}function Fi(t){let r=[];for(let l of t){let c=r.find((p)=>p.group===l.group);if(c)c.options.push(l);else r.push({group:l.group,options:[l]})}return r}var ji="/api/settings/providers";async function $i(t){let r=await fetch(ji,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)throw Error(l?.error||`Providers request failed (HTTP ${r.status})`);return Vr(),Array.isArray(l.providers)?l.providers:null}function _i(t){return $i({providers:t})}function Bi(t,r){return $i(r?{enableProvider:t}:{disableProvider:t})}async function zi(t,r){try{let l=await fetch("/api/settings/provider-entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,...r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??c.reason??`HTTP ${l.status}`};return Vr(),{...c,ok:!0}}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while saving the provider"}}}async function Hi(t,r){try{let l=await fetch("/api/provider-icon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,baseUrl:r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??`HTTP ${l.status}`};return c}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while fetching the icon"}}}async function Gi(t){try{let r=await fetch("/api/settings/providers/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{slug:t}:{})}),l=await r.json();if(!r.ok)return{ok:!1,added:0,removed:0,changed:[],error:l.error??`HTTP ${r.status}`};return Vr(),l}catch(r){return{ok:!1,added:0,removed:0,changed:[],error:r instanceof Error?r.message:"Network error while refreshing models"}}}async function Wi(t){try{let r=await fetch(`${ji}?id=${encodeURIComponent(t)}`,{method:"DELETE"}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Delete failed (HTTP ${r.status})`};return Vr(),{...l,ok:!0}}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while deleting the provider"}}}function qi(t,r){if(t.modelSource==="discovery")return{text:`${t.name} registered — omp discovers its models on each run.`,tone:"success"};if(t.modelSource==="override")return{text:`${t.name} endpoint registered — omp keeps its own model list for this provider.`,tone:"success"};if(r.fetchedCount>0)return{text:`Fetched ${r.fetchedCount} new model${r.fetchedCount===1?"":"s"} from the provider.`,tone:"success"};if(r.fetchedCount===-1)return{text:r.ompNote?`Provider registered, but models could not be listed: ${r.ompNote}`:"Auto-fetch models failed — provider added with default models.",tone:"warning"};return{text:`${t.name} registered — no new models to add.`,tone:"success"}}function Vi(t){let r=(l)=>l===1?"":"s";if(t.addedCount>0&&t.removedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} and removed ${t.removedCount} the provider no longer serves.`,tone:"success"};if(t.addedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} from the provider.`,tone:"success"};if(t.removedCount>0)return{text:`Removed ${t.removedCount} model${r(t.removedCount)} the provider no longer serves.`,tone:"success"};return{text:"Models refreshed — the list already matches the provider.",tone:"success"}}function Ji(t){if(!t.omp)return null;if(t.omp.written){let r=[];if(t.omp.addedCount>0)r.push(`${t.omp.addedCount} new model${t.omp.addedCount===1?"":"s"} registered`);if(t.omp.backfilledCount>0)r.push(`${t.omp.backfilledCount} model${t.omp.backfilledCount===1?"":"s"} enriched`);if((t.omp.removedCount??0)>0)r.push(`${t.omp.removedCount} model${t.omp.removedCount===1?"":"s"} removed`);return{text:`omp models.yml updated${r.length>0?`: ${r.join(", ")}`:""}.`,tone:"success"}}if(t.omp.reason)return{text:`omp models.yml not updated: ${t.omp.reason}`,tone:"warning"};return null}function Qi(t,r){let l=(c)=>c===1?"":"s";if(r.added>0||r.removed>0){let c=[];if(r.added>0)c.push(`${r.added} new model${l(r.added)}`);if(r.removed>0)c.push(`${r.removed} model${l(r.removed)} gone`);return{text:`${t}: ${c.join(", ")} after omp re-ran discovery.`,tone:"success"}}return{text:`${t}: omp re-ran discovery — this provider's list is unchanged.`,tone:"success"}}async function mt(){try{let r=await(await fetch("/api/settings/providers")).json();if(!Array.isArray(r?.providers))return null;return{providers:r.providers,...r.presetProviders?{presetProviders:r.presetProviders}:{},...typeof r.catalogError==="string"?{catalogError:r.catalogError}:{}}}catch(t){return console.error("Failed to load providers from API:",t),null}}async function Zi(t,r,l){let c={provider:t,modelId:r};if("maxTokens"in l)c.maxTokens=l.maxTokens??null;if("reasoningEffort"in l)c.reasoningEffort=l.reasoningEffort??null;if(Object.keys(c).length===2)return{ok:!0,written:!1};try{let p=await fetch("/api/settings/model-override",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),g=await p.json();if(!p.ok)return{ok:!1,error:g.error||"Failed to save the model configuration."};return{ok:!0,written:g.written,reason:g.reason}}catch(p){return console.error("Failed to save model override:",p),{ok:!1,error:"Failed to save the model configuration."}}}function ta(t){let{providers:r,selectedProvider:l,isDeletingProvider:c,pushToast:p,setProviders:g,setSelectedProviderId:h,setIsAddModalOpen:v,setIsDeleteModalOpen:x,setIsDeletingProvider:y,openLogin:k,openEntryEditor:T,onAddModalClose:S}=t,R=async(K)=>{g(K);try{let V=await _i(K);if(V)g(V)}catch(V){console.error("Failed to save providers via API:",V),p("Failed to save provider settings.","error")}},P=async()=>{let K=await mt();if(K)g(K.providers);return K?.providers??[]},L=async(K,V)=>{try{let z=await Bi(K,V);if(z)g(z);return z}catch(z){return console.error("Failed to update provider connection:",z),p("Failed to update the provider connection.","error"),null}};return{handleAddProvider:async(K,V)=>{let z=K.slug.trim().toLowerCase(),W=r.filter((Q)=>Q.slug.trim().toLowerCase()!==z);await R([...W,K]);let j=(await L(K.slug,!0))?.find((Q)=>Q.slug.trim().toLowerCase()===z);h(j?.id||K.id),v(!1),S?.();let G=qi(K,V);p(G.text,G.tone)},handleConnect:(K)=>{if(!l)return;if(K==="login")k();else T()},handleEntrySaved:async(K)=>{if(!l)return;p(K.length>0?`${l.name}: updated ${K.join(", ")} in models.yml.`:`${l.name}: nothing to change.`,"success"),await P()},handleOmpAuthSuccess:async()=>{if(!l)return;let K=l.slug;p(`${l.name} signed in — omp stored the credential.`,"success");let z=(await P()).find((W)=>W.slug===K);if(z)h(z.id)},handleToggleProviderDisabled:async()=>{if(!l)return;let K=l,V=K.disabled!==!0;if(!await L(K.slug,!V))return;p(V?`${K.name} disabled — it no longer appears in the model list.`:`${K.name} enabled — its models are offered again.`,"success")},handleDeleteProvider:async(K)=>{let V=K??l;if(!V||c)return;y(!0);try{let z=await Wi(V.id);if(!z.ok){p(z.error||"Failed to delete the provider.","error");return}x(!1);let W=z.providers??[];if(l?.id===V.id)h(W[0]?.id??"");if(g(W),z.warning)p(`${V.name} removed from Kabmo, but models.yml cleanup failed: ${z.warning}`,"warning");else if(z.removedFromOmp){let q=z.modelsRemoved??0;p(`${V.name} deleted from models.yml${q>0?` with its ${q} model${q===1?"":"s"}`:""}.`,"success")}else p(`${V.name} removed from Kabmo.`,"success")}finally{y(!1)}},persistProviders:R,reloadProviders:P}}async function Gt(t){try{let r=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Request failed (HTTP ${r.status})`};return l}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while fetching models"}}}async function na(t){try{let r=await fetch("/api/settings/provider-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{...l,success:!1,written:!1,error:l?.error||l?.reason};return Vr(),l}catch(r){return{success:!1,written:!1,error:r instanceof Error?r.message:"Network error while adding the model"}}}function oa(t,r){let l=new Map(t.map((v)=>[v.id,v])),c=new Set,p=[],g=[];for(let v of r){if(!v.id||c.has(v.id))continue;c.add(v.id);let x=l.get(v.id);if(!x){let y={...v};g.push(y),p.push(y);continue}p.push({...v,isVisible:x.isVisible!==!1,...x.temperature!==void 0?{temperature:x.temperature}:{},...x.maxTokens!==void 0?{maxTokens:x.maxTokens}:{},...x.topP!==void 0?{topP:x.topP}:{},...x.reasoningEffort!==void 0?{reasoningEffort:x.reasoningEffort}:{}})}let h=t.filter((v)=>!c.has(v.id)).map((v)=>v.id);return{models:p,added:g,addedCount:g.length,removed:h,removedCount:h.length}}async function ra(t,r){try{await Promise.all(r.map((l)=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:l.id,name:l.name,provider:t,contextWindow:l.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),Vr()}catch(l){console.error("Failed to sync provider models to catalog:",l)}}var Lp=/^model-\d+-(?:1|2)$/;function Fp(t){return`${t.name} ${t.slug} ${t.baseUrl||""}`.toLowerCase().includes("kenari")}function ia(t,r){if(!Fp(t))return r;return r.filter((l)=>{let c=l.name.trim().toLowerCase(),p=c==="kenari default model"||c==="kenari fast / flash";return!(Lp.test(l.id)&&p)})}function aa(t){let{providers:r,selectedProvider:l,isFetchingModels:c,pushToast:p,setProviders:g,setIsFetchingModels:h,persistProviders:v,reloadProviders:x}=t,y=async()=>{if(!l||c)return;let N=l;h(!0);try{let E=await Gi(N.slug);if(!E.ok){p(E.error||"omp could not refresh the model catalog.","error");return}if(E.providers)g(E.providers);let A=Qi(N.name,E);p(A.text,A.tone)}finally{h(!1)}},k=async()=>{if(!l||c)return;let N=l;if(!N.baseUrl){p("This provider has no endpoint to import from — use “refresh” instead.","error");return}h(!0);try{let E=await Gt({baseUrl:N.baseUrl,apiKey:N.apiKey,providerSlug:N.slug,persistToOmp:!0,replaceModels:!0,...N.api?{api:N.api}:{},...N.auth?{auth:N.auth}:{}});if(!E.ok||!E.models){p(E.error||"Failed to fetch models from the provider.","error");return}if(E.omp?.written)Vr();let A=ia(N,N.models),O=N.models.length-A.length,{added:U,addedCount:_,removedCount:K}=oa(A,E.models),V=K+O,z=Vi({addedCount:_,removedCount:V});p(z.text,z.tone);let W=Ji(E);if(W)p(W.text,W.tone);if(_>0)ra(N.name,U);await x()}finally{h(!1)}},T=(N)=>{if(!l)return;v(r.map((E)=>E.id===l.id?{...E,models:N(E.models)}:E))};return{handleRefreshModels:y,handleFetchModels:k,handleHideAll:()=>T((N)=>N.map((E)=>({...E,isVisible:!1}))),handleShowAll:()=>T((N)=>N.map((E)=>({...E,isVisible:!0}))),handleToggleModelVisibility:(N)=>T((E)=>E.map((A)=>A.id===N?{...A,isVisible:!A.isVisible}:A)),handleSaveModelConfig:async(N,E)=>{if(!l)return;let A=l;T((U)=>U.map((_)=>_.id===N?{..._,...E}:_));let O=await Zi(A.slug,N,E);if(!O.ok){p(O.error||"Failed to save the model configuration.","error");return}if(O.written)Vr();else if(O.reason)p(O.reason,"error")}}}function sa({autoOpenAdd:t=!1,onAddModalClose:r}={}){let[l,c]=n([]),[p,g]=n([]),[h,v]=n(""),[x,y]=n(null),[k,T]=n(!0),[S,R]=n(!1),[P,L]=n(!1),[N,E]=n(!1),{pushToast:A}=Ve(),[O,U]=n(t),[_,K]=n(!1),[V,z]=n(!1),[W,q]=n(!1),[j,G]=n(!1),[Q,te]=n(!1),[Z,X]=n(!1),[re,oe]=n(null),[be,xe]=n(null);i(()=>{if(t)U(!0)},[t]),i(()=>{let le=!0;return mt().then((me)=>{if(!le)return;if(T(!1),!me)return;c(me.providers),g(me.presetProviders??[]),y(me.catalogError??null);let Ke=me.providers.filter((Ye)=>Ye.status==="connected");v(Ke[0]?.id??me.providers[0]?.id??"")}),()=>{le=!1}},[]),i(()=>{let le=null,me=wa(()=>{if(le)clearTimeout(le);le=setTimeout(()=>{le=null,mt().then((Ke)=>{if(Ke)c(Ke.providers)})},400)});return()=>{if(me(),le)clearTimeout(le)}},[]);let Pe=u(()=>Ui(l,p),[l,p]),ue=u(()=>Di(l),[l]),ve=l.find((le)=>le.id===h)??l[0],Te=ta({providers:l,selectedProvider:ve,isDeletingProvider:j,pushToast:A,setProviders:c,setSelectedProviderId:v,setIsAddModalOpen:U,setIsDeleteModalOpen:z,setIsDeletingProvider:G,openLogin:()=>X(!0),openEntryEditor:()=>te(!0),...r?{onAddModalClose:r}:{}}),ke=aa({providers:l,selectedProvider:ve,isFetchingModels:P,pushToast:A,setProviders:c,setIsFetchingModels:L,persistProviders:Te.persistProviders,reloadProviders:Te.reloadProviders});return{providers:l,availablePresetProviders:Pe,existingSlugs:ue,selectedProvider:ve,catalogError:x,isLoading:k,isRefreshingList:S,handleRefreshList:async()=>{if(S)return;R(!0);try{let le=await mt();if(!le){A("Could not read the provider list — omp may still be starting.","error");return}c(le.providers),g(le.presetProviders??[]),y(le.catalogError??null),v((Ke)=>le.providers.some((Ye)=>Ye.id===Ke)?Ke:le.providers.find((Ye)=>Ye.status==="connected")?.id??le.providers[0]?.id??"");let me=le.providers.length;A(`Provider list refreshed — ${me} provider${me===1?"":"s"}.`,"success")}finally{R(!1)}},isFetchingModels:P,isRefreshingIcon:N,handleRefreshIcon:async()=>{let le=ve;if(!le||N)return;if(!le.baseUrl){A("This provider has no endpoint, so there is no site to read an icon from.","error");return}E(!0);try{let me=await Hi(le.slug,le.baseUrl);if(!me.ok){A(me.error||"No usable icon on that host or its base domain — keeping the current mark.","error");return}let Ye=(await Te.reloadProviders()).find((fc)=>fc.slug===le.slug);if(Ye)v(Ye.id);A(`${le.name}: icon updated from ${le.baseUrl}.`,"success")}finally{E(!1)}},pushToast:A,isAddModelModalOpen:_,setIsAddModelModalOpen:K,handleModelAdded:async(le)=>{A(`${le} registered in models.yml.`,"success"),await Te.reloadProviders()},handleSignedOut:async(le)=>{q(!1),A(le,"success"),await Te.reloadProviders()},isDeleteModalOpen:V,setIsDeleteModalOpen:z,isLogoutModalOpen:W,setIsLogoutModalOpen:q,isDeletingProvider:j,isAddModalOpen:O,setIsAddModalOpen:U,isEntryModalOpen:Q,setIsEntryModalOpen:te,isLoginModalOpen:Z,setIsLoginModalOpen:X,configModel:re,setConfigModel:oe,capabilitiesModel:be,setCapabilitiesModel:xe,setSelectedProviderId:v,...Te,...ke}}function Bp(t){if(t.disabled===!0)return"disabled";if(t.status==="connected")return"connected";return"signed-out"}var Hp=[{id:"connected",label:"Signed in"},{id:"signed-out",label:"Not signed in",hint:"omp knows these providers; pick one to sign in or add its key."},{id:"disabled",label:"Disabled",hint:"Hidden from the model picker."}];function la(t,r=""){let l=r.trim().toLowerCase(),c=l?t.filter((g)=>g.name.toLowerCase().includes(l)||g.slug.toLowerCase().includes(l)||g.models.some((h)=>h.id.toLowerCase().includes(l))):t,p=new Map;for(let g of c){let h=Bp(g),v=p.get(h);if(v)v.push(g);else p.set(h,[g])}return Hp.flatMap((g)=>{let h=p.get(g.id);if(!h||h.length===0)return[];return[{...g,providers:[...h].sort((v,x)=>v.name.localeCompare(x.name))}]})}function jn(t){return t.inModelsYml===!0||t.inOverlay===!0}function da(t){if(t.disabled===!0)return"Disabled — hidden from the model picker";if(t.status==="connected")switch(t.credentialOrigin){case"models.yml":return"Signed in — key stored in models.yml";case"login":return"Signed in — OAuth credential stored by omp";case"api-key":return"Signed in — API key stored by omp";case"environment":return"Signed in — credential comes from the environment";default:return"Signed in"}return t.oauth===!0?"Not signed in — pick this row to sign in with OAuth":"Not signed in — no credential omp can resolve"}function ca({providers:t,selectedProviderId:r,onSelectProvider:l,onOpenAddModal:c,onRefresh:p,isRefreshing:g,isLoading:h,catalogError:v}){let[x,y]=n(""),k=o(null),T=la(t,x);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3 pt-3 pb-2 flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:h?"Loading…":`${t.length} provider${t.length===1?"":"s"}`}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:g||h,title:"Refresh the provider list","aria-label":"Refresh the provider list",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:14,strokeWidth:2.2,className:g?"animate-spin":""})}),e("button",{type:"button",onClick:c,title:"Add provider","aria-label":"Add provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]})]}),e("div",{className:"px-3 pb-2",children:e("div",{className:"relative flex items-center",children:[e(F,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{ref:k,type:"text",value:x,onChange:(S)=>y(S.currentTarget.value),placeholder:"Filter providers or models…","aria-label":"Filter providers",className:"w-full bg-paper border border-ink/15 rounded-md pl-7 pr-7 py-1.5 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),x&&e("button",{type:"button",onClick:()=>{y(""),k.current?.focus()},title:"Clear the filter","aria-label":"Clear the filter",className:"absolute right-1.5 p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:11})})]})}),v&&e("p",{className:"mx-3 mb-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10 text-[10px] leading-relaxed text-ink/70",children:["Model catalog unavailable: ",v]}),e("div",{className:"flex-1 scrollbar-overlay-container px-1.5 pb-3",children:h?e("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-[11px] text-ink/45",role:"status","aria-live":"polite",children:[e(m,{size:16,className:"animate-spin"}),e("span",{children:"Reading providers…"})]}):T.length===0?e("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:x?`No provider or model matches “${x}”.`:"No providers detected yet. Use the plus button above to register one."}):T.map((S)=>e("div",{className:"pt-1.5 first:pt-0",children:[e("div",{className:"px-2 pb-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/45 uppercase",children:S.label}),e("span",{className:"text-[10px] font-mono text-ink/35",children:S.providers.length})]}),S.hint&&e("p",{className:"text-[10px] leading-snug text-ink/40 mt-0.5",children:S.hint})]}),e("div",{className:"space-y-0.5",children:S.providers.map((R)=>{let P=R.id===r;return e("button",{type:"button",onClick:()=>l(R.id),"aria-current":P?"true":void 0,title:da(R),className:`w-full flex items-center gap-2 pl-1.5 pr-2 py-1 rounded-md text-left transition-colors cursor-pointer ${P?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Me,{provider:R,size:22}),e("span",{className:"flex-1 min-w-0 text-[12px] truncate",children:R.name}),e("span",{className:"w-8 shrink-0 text-right text-[10px] font-mono tabular-nums text-ink/45",children:R.models.length})]},R.id)})})]},S.id))})]})}function ua({provider:t,onRefreshIcon:r,isRefreshingIcon:l=!1}){return e("div",{className:"flex items-start gap-3 pb-4",children:[e(Me,{provider:t,size:30,className:"mt-0.5"}),e("div",{className:"min-w-0 flex flex-1 flex-col gap-0.5",children:[e("h2",{className:"text-xl font-bold leading-tight tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs font-mono text-ink/50 truncate",children:t.slug})]}),r&&e("button",{type:"button",onClick:r,disabled:l,title:t.baseUrl?`Refetch the icon from ${t.baseUrl}`:"This provider has no endpoint to read an icon from","aria-label":"Refresh provider icon",className:"shrink-0 p-1.5 rounded-md border border-ink/15 text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:12,className:l?"animate-spin":""})})]})}function va(t){switch(t){case"models.yml":return"models.yml key";case"login":return"OAuth login";case"api-key":return"stored API key";case"environment":return"environment variable";default:return"no credential"}}function xa(t){return t==="login"||t==="api-key"}function ya(t){let r=t.oauth===!0&&t.auth!=="none"&&t.credentialOrigin!=="models.yml",l=t.inModelsYml===!0;if(r||l)return{login:r,edit:l};return{login:!1,edit:!1,reason:"omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit."}}function Sa({provider:t,onConnect:r,onToggleDisabled:l,onDelete:c,onSignOut:p}){let[g,h]=n(!1),v=t.status==="connected",x=t.disabled===!0,y=t.credentialOrigin,k=xa(y),T=ya(t);return e("div",{className:"space-y-6",children:[e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[x?e(d,{children:[e(_n,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):v?e(d,{children:[e(f,{size:15,className:"text-success flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):e(d,{children:[e(I,{size:15,className:"text-warning flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/80",children:"Not signed in"})]}),e("span",{className:"text-[11px] text-ink/55 font-mono px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10",children:va(y)}),e("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[e(pe,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),g&&e("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl w-64 z-50 pointer-events-none leading-relaxed",children:x?"Disabled in omp’s config.yml — none of its models appear in the chat model list. The credential is untouched.":v?"omp can resolve a credential for this provider, so its models are offered in the chat picker.":"omp knows this provider but has no credential for it. Connect to sign in or supply a key."})]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:l,title:x?"Offer this provider in the model list again":"Hide this provider and its models from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:x?"enable":"disable"}),T.login&&e("button",{type:"button",onClick:()=>r("login"),title:"Sign in to this provider through omp",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:[e(or,{size:12}),e("span",{children:v&&y==="login"?"sign in again":"sign in"})]}),T.edit&&e("button",{type:"button",onClick:()=>r("edit"),title:"Edit this provider’s endpoint, credential and dialect in models.yml",className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer border ${T.login?"bg-ink/5 hover:bg-ink/10 text-ink border-ink/15":"bg-ink text-canvas hover:opacity-90 border-ink"}`,children:[e(Dn,{size:12}),e("span",{children:"edit"})]}),!T.login&&!T.edit&&e("button",{type:"button",disabled:!0,title:T.reason,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium opacity-40 cursor-not-allowed",children:[e(mi,{size:12}),e("span",{children:"connect"})]}),k&&e("button",{type:"button",onClick:p,title:"Remove the credential omp stored for this provider",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:[e(jt,{size:12}),e("span",{children:"sign out"})]}),e("button",{type:"button",onClick:c,disabled:!jn(t),title:jn(t)?t.inModelsYml?"Remove this provider’s models.yml entry":"Remove this provider’s Kabmo settings row":"Nothing to delete: omp discovered this provider from its endpoint. Use disable to hide it.",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-error/10 hover:bg-error/20 text-error text-xs font-medium transition-colors cursor-pointer border border-error/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(M,{size:12}),e("span",{children:"delete"})]})]})]})]}),e("div",{className:"border-b border-ink/10"}),e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Connection details"}),e("div",{className:"flex items-center justify-between gap-4",children:[e("div",{className:"text-xs text-ink/70 min-w-0",children:["Configured in:"," ",e("span",{className:"font-mono text-ink font-medium break-all",children:t.configuredIn})]}),e("span",{className:"text-[11px] text-ink/40 italic shrink-0",children:x?"hidden":v?"active":"inactive"})]}),(t.api||t.auth||t.discovery||t.transport)&&e("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[t.api&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Wire API omp uses for this provider",children:t.api}),t.auth&&t.auth!=="apiKey"&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Auth mode from models.yml",children:["auth: ",t.auth]}),t.discovery&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"omp lists this provider's models live",children:["discovery: ",t.discovery]}),t.transport&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Requests are routed through the auth gateway",children:["transport: ",t.transport]}),t.headers&&Object.keys(t.headers).length>0&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:Object.entries(t.headers).map(([S,R])=>`${S}: ${R}`).join(`
|
|
1
|
+
import{d,n,i,o,u,a,se,sn,pa,Qo,BA,e,w,s,di,I,ne,De,Pa,Bn,bn,m,qn,Le,Kt,M,D,Ns,Vt,ma,_n,fa,Yt,xt,br,f,B,ie,Aa,Ki,zr,Yi,ae,tt,$a,he,Ce,wt,Ge,Dt,nt,fe,Qe,za,pe,mi,ga,Ur,jr,en,Jt,ha,Xi,Fo,ba,qr,Dn,Lo,Y,Ai,kr,C,ut,F,gi,hi,cr,ur,Hn,Qt,_e,Hr,$o,b,NA,Uo,vp,Ul,kp,RA,Wn,eo,xp,H,FA,At,Wr,dt,Gl,ka,Kn,ce,rt,Go,J,nn,Nn,Ff,Ie,Ep,Ve,ge,Os,Ho,cn,XA,eg,_p,tg,ng,Sp,rg,Tp,Dp,ki,ag,ig,Qp,Lf,Np,ee,zt,Ut,Me,ao,Op,cg,ug,dg,pg,mg,fg,Ag,Yl,gg,$p,hg,bg,zp,yg,Jl,Lu,Kr,Zl,Up,wi,Ga,Vr,wa,Gp,Mu,jp,Of,kg,xg,wg,$f,qp,gt,Bt,Gs,Cg,zf,un,Wo,ja,Xl,Wp,Ko,ht,Ei,Kp,Uf,Bg,Gf,Pu,Vp,tc,Ig,Yr,nc,_g,Sg,Yp,Jp,jf,Zp,Tg,Xp,rc,em,je,ac,Vo,ic,Yo,qs,oc,sc,lc,tm}from"./index-d8kjsgpt.js";import{yt,ad,id,od,Uc,sd,ld,ol,qc,os,sl,po}from"./index-rtd9frp1.js";import{ea,ou,vs,ks,su,lu}from"./index-4hsxaa87.js";import{cl,_a,iA,oA,ul,sA,lA,ys}from"./index-gbdvr4rt.js";var hc={name:"sliders-vertical",size:24,node:[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],aliases:["sliders"]},Eo=s(hc);var vc={name:"square-check-big",size:24,node:[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aliases:["check-square"]},Oo=s(vc);var xc={name:"arrow-down-to-line",size:24,node:[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]]},Je=s(xc);var kc={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]},Do=s(kc);var yc={name:"bell-ring",size:24,node:[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]},jo=s(yc);var wc={name:"calendar-range",size:24,node:[["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}],["path",{d:"M16 2v3",key:"otl347"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M8 2v3",key:"1ioesn"}],["path",{d:"M17 13h-6",key:"1qbiup"}],["path",{d:"M13 17H7",key:"1x38vv"}],["path",{d:"M7 13h.01",key:"1vezk1"}],["path",{d:"M17 17h.01",key:"1sd3ek"}]]},_o=s(wc);var Sc={name:"cloud",size:24,node:[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]},Bo=s(Sc);var Nc={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]},Ft=s(Nc);var Pc={name:"dice-5",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"M16 8h.01",key:"cr5u4v"}],["path",{d:"M8 8h.01",key:"1e4136"}],["path",{d:"M8 16h.01",key:"18s6g9"}],["path",{d:"M16 16h.01",key:"1f9h7w"}],["path",{d:"M12 12h.01",key:"1mp3jc"}]]},zo=s(Pc);var Cc={name:"dollar-sign",size:24,node:[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]]},qo=s(Cc);var Tc={name:"file-diff",size:24,node:[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]]},Jo=s(Tc);var Ic={name:"folder-git",size:24,node:[["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M14 13h3",key:"1dgedf"}],["path",{d:"M7 13h3",key:"1pygq7"}]]},Xo=s(Ic);var Ac={name:"folder-input",size:24,node:[["path",{d:"M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1",key:"fm4g5t"}],["path",{d:"M2 13h10",key:"pgb2dq"}],["path",{d:"m9 16 3-3-3-3",key:"6m91ic"}]]},Zo=s(Ac);var Rc={name:"hammer",size:24,node:[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]},er=s(Rc);var Mc={name:"image",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]},tr=s(Mc);var Ec={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]},pt=s(Ec);var Lc={name:"library",size:24,node:[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]},nr=s(Lc);var Oc={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"}]]},jt=s(Oc);var Dc={name:"log-in",size:24,node:[["path",{d:"m10 17 5-5-5-5",key:"1bsop3"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}]]},or=s(Dc);var Fc={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"}]]},$t=s(Fc);var jc={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]},rr=s(jc);var $c={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"}]]},ir=s($c);var _c={name:"store",size:24,node:[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]},at=s(_c);var Bc={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"}]]},_t=s(Bc);var Kc={name:"volume-2",size:24,node:[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]]},An=s(Kc);var zc={name:"volume-x",size:24,node:[["path",{d:"M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z",key:"1p7khw"}],["path",{d:"m16.5 14.5 5-5",key:"cul3yw"}],["path",{d:"m16.5 9.5 5 5",key:"1akey5"}]]},ar=s(zc);var Hc={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"}]]},Rn=s(Hc);function sr(t,r,l){let c={},p=typeof l==="function"?Object.keys(r):Object.keys(l);for(let g of p)if(r[g]!==t[g])c[g]=r[g];return c}var lr={theme:Os,editorFont:Lu,editorTheme:Zl,autoSessionTitle:!0,soundAlerts:!0,chatCompletionSound:!0,notifyDesktopEnabled:!0,notifyMobileEnabled:!0,notifyOnFinish:!1,notifyOnAsk:!1,notifyOnError:!1,goalAuditEnabled:!0,goalAuditModel:"",goalDefaultBudget:null,chatWidthMode:Op,toolRenderStyle:dg,showChangedFiles:!0,sidebarStyle:iA,composerStyle:Ag,surfaceStyle:hg,iconStyle:tg,followUpBehavior:"queue",keybindingSend:"Enter",keybindingNewLine:"Shift + Enter",keybindingSteering:"Ctrl / Cmd + Enter"};function dr(){let[t,r]=n(!1),l=a(async()=>{r(!0);try{let c=await fetch("/api/omp/reload-engine",{method:"POST"}),p=await c.json().catch(()=>null);if(!c.ok||!p?.success)return{ok:!1,message:p?.error??`Reload failed (HTTP ${c.status})`};wi(),Vr();let g=p.utility??0,h=p.prewarmed??0;return{ok:!0,message:g+h===0?"No standby omp processes were running — the next command starts the current build.":`Reloaded omp engine — ${g} utility, ${h} prewarmed process${g+h===1?"":"es"} recycled.`}}catch(c){return{ok:!1,message:c instanceof Error?c.message:"Failed to reload the omp engine."}}finally{r(!1)}},[]);return{isReloading:t,reload:l}}function pr(t={}){let{restart:r}=t,[l,c]=n(!1),p=a(async()=>{c(!0);try{let g=await Mu(r),h=await fetch("/api/console/restart",{method:"POST"}),v=await h.json().catch(()=>null);if(!h.ok||!v?.success)return{ok:!1,message:v?.error??`Restart failed (HTTP ${h.status})`};if(!v.restarting)return{ok:!1,message:v.message??"This instance cannot be restarted from the console."};let x=await jp(g,r);if(x==="restarted")return window.location.reload(),{ok:!0,message:v.message??"Restarting — this page reloads on its own."};if(x==="timeout")return{ok:!1,message:`The server did not come back within ${Math.round((r?.timeoutMs??Gp)/1000)} seconds — reload this page once it is up.`};return{ok:!1,message:"The restart was cancelled."}}catch(g){return{ok:!1,message:g instanceof Error?g.message:"Failed to restart Kabmo."}}finally{c(!1)}},[r]);return{isRestarting:l,restart:p}}function mr(t,r){if(typeof document<"u"&&r.theme)Np(r.theme);if(typeof window<"u"&&r.editorFont!==t.editorFont)window.dispatchEvent(new CustomEvent(qp,{detail:r.editorFont}));if(typeof window<"u"&&r.editorTheme!==t.editorTheme)window.dispatchEvent(new CustomEvent(ad,{detail:r.editorTheme}));if(r.chatWidthMode!==t.chatWidthMode)Of(r.chatWidthMode);if(r.toolRenderStyle!==t.toolRenderStyle)kg(r.toolRenderStyle);if(r.showChangedFiles!==t.showChangedFiles)xg(r.showChangedFiles);if(r.sidebarStyle!==t.sidebarStyle)lA(r.sidebarStyle);if(r.composerStyle!==t.composerStyle)wg(r.composerStyle);if(r.surfaceStyle!==t.surfaceStyle)$f(r.surfaceStyle);if(r.iconStyle!==t.iconStyle)Lf(r.iconStyle)}var gr=["KABMO","CONNECT","WORKSPACE","OMP","HARNESSES"];var fr=[{id:"appearance",label:"Appearance",icon:ba,section:"KABMO",description:"Custom themes, typography scale, and layout density."},{id:"chats",label:"Chats",icon:en,section:"KABMO",description:"Chat width, composer style, tool call rendering, session titles, and goal mode."},{id:"keyboard",label:"Keyboard",icon:ga,section:"KABMO",description:"Every command shortcut, the composer Enter keys, and chord conflicts."},{id:"notifications",label:"Notifications",icon:fa,section:"KABMO",description:"Completion sound, separate Desktop and Mobile delivery switches, and the finished, waiting-for-you and failed run triggers."},{id:"usage",label:"Usage",icon:di,section:"KABMO",description:"Build minutes quota, storage, and general usage."},{id:"token-usage",label:"Token Usage",icon:Yi,section:"KABMO",description:"Token telemetry, cache, and cost breakdown."},{id:"panel-plugins",label:"Plugins Kabmo",icon:Ai,section:"KABMO",description:"Plugins installed into Kabmo: panels, background services, and the MCP servers they register."},{id:"connect",label:"Connect",icon:kr,section:"CONNECT",description:"Tunnels, addresses, and the devices paired to this server."},{id:"projects",label:"Projects",icon:Xo,section:"WORKSPACE",description:"Workspace directories, roots, and ignored paths."},{id:"omp",label:"OMP Engine",icon:$a,section:"OMP",description:"Live agent state and native omp config keys."},{id:"providers",label:"Providers",icon:Bo,section:"OMP",description:"AI model engines, endpoints, and credentials."},{id:"agents",label:"Agents",icon:xt,section:"OMP",description:"Autonomous agent persona, self-healing, and reasoning."},{id:"behavior",label:"Behavior",icon:Eo,section:"OMP",description:"Native AGENTS.md and RULES.md: global instructions, permission gates, and safety filters."},{id:"commands",label:"Commands",icon:_e,section:"OMP",description:"Slash command macros and terminal shortcuts."},{id:"mcp",label:"MCP",icon:br,section:"OMP",description:"Model Context Protocol servers and dynamic tools."},{id:"plugins",label:"Plugins",icon:Lo,section:"OMP",description:"Installed omp plugins, marketplaces, features, and plugin settings."},{id:"skills",label:"Skills",icon:nr,section:"OMP",description:"Manage downloaded skills and scripts."},{id:"skills-catalog",label:"Skills Catalog",icon:Yt,section:"OMP",description:"Browse and install new skills."},...zf().map((t)=>({id:t.id,label:t.label,icon:Rn,section:"HARNESSES",...t.harness?{harness:t.harness}:{},description:t.description}))];function hr(t){let r=zf(t&&t.length>0?t:void 0).map((c)=>({id:c.id,label:c.label,icon:Rn,section:"HARNESSES",...c.harness?{harness:c.harness}:{},description:c.description}));return[...fr.filter((c)=>c.section!=="HARNESSES"),...r]}function Mn({activeCategory:t,onSelectCategory:r,searchQuery:l,onSearchChange:c,onReloadOmp:p,isReloading:g,onRestartKabmo:h,isRestarting:v,disabledHarnesses:x=[],categories:y=fr,className:k=""}){let T=y.filter((S)=>{if(S.harness&&x.includes(S.harness))return!1;if(!l.trim())return!0;let R=l.toLowerCase();return S.label.toLowerCase().includes(R)||S.section.toLowerCase().includes(R)||S.description.toLowerCase().includes(R)});return e("div",{className:`flex flex-col h-full bg-canvas border-r border-ink/10 text-ink select-none ${k}`,children:[e("div",{className:"p-3 border-b border-ink/10 flex-shrink-0",children:e("div",{className:"relative flex items-center",children:[e(F,{size:14,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",placeholder:"Search settings",value:l,onChange:(S)=>c(S.currentTarget.value),className:"w-full bg-paper border border-ink/15 rounded-lg pl-8 pr-7 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),l&&e("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 text-ink/40 hover:text-ink p-0.5",children:e(b,{size:12})})]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:T.length===0?e("div",{className:"text-center py-8 text-xs text-ink/50 italic",children:"No matching settings found"}):gr.map((S)=>{let R=T.filter((P)=>P.section===S);if(R.length===0)return null;return e("div",{className:"space-y-1",children:[e("div",{className:"px-2.5 py-1 text-[10px] font-bold text-ink/40 tracking-wider font-mono uppercase",children:S}),e("div",{className:"space-y-0.5",children:R.map((P)=>{let L=P.icon,N=t===P.id;return e("button",{type:"button",onClick:()=>r(P.id),className:`w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-all text-left ${N?"bg-ink/10 font-semibold text-ink shadow-2xs":"text-ink/75 hover:bg-ink/5 hover:text-ink"}`,children:[e("div",{className:"flex items-center space-x-2.5 truncate",children:[P.harness?e("span",{className:"flex w-[14px] shrink-0 items-center justify-center",children:e(gt,{harness:P.harness,size:14})}):e(L,{size:14,className:N?"text-ink":"text-ink/60"}),e("span",{className:"truncate",children:P.label})]}),P.badge&&e("span",{className:"px-1.5 py-0.2 text-[10px] font-mono font-medium rounded border border-warning/30 bg-warning/15 text-warning",children:P.badge})]},P.id)})})]},S)})}),e("div",{className:"p-2 border-t border-ink/10 flex-shrink-0 bg-canvas flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:g||v,title:"Recycle the standby omp processes so the next command uses the installed binary","aria-label":"Reload OMP",className:"shrink-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(C,{size:12,className:`shrink-0 ${g?"animate-spin text-warning":"text-ink/60"}`}),e("span",{className:"whitespace-nowrap",children:g?"Reloading…":"Reload OMP"})]}),e("button",{type:"button",onClick:h,disabled:g||v,title:"Stop and start this Kabmo instance","aria-label":"Restart Kabmo",className:"flex-1 min-w-0 flex items-center space-x-1 px-1 py-1.5 text-[11px] text-ink/75 hover:text-ink hover:bg-ink/5 rounded-lg transition-colors font-medium cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed",children:[e(ir,{size:12,className:`shrink-0 ${v?"animate-pulse text-warning":"text-ink/60"}`}),e("span",{className:"truncate",children:v?"Restarting…":"Restart Kabmo"})]})]})]})}function vr({theme:t,selected:r,onSelect:l}){return e("button",{type:"button",onClick:()=>l(t.id),"aria-pressed":r,className:`group flex w-full flex-col gap-2.5 rounded-lg border p-2.5 text-left transition-all cursor-pointer ${r?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("div",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:t.name,children:t.name}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:t.variant}),r&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("div",{className:"flex items-center gap-1",children:eg.map((c)=>e("span",{title:`${c.label} · ${t[c.key]}`,style:{backgroundColor:t[c.key]},className:"h-5 flex-1 rounded-[3px] border border-ink/10"},c.key))})]})}var Gc=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function Wc(t){return t==="all"?Ho:Ho.filter((r)=>r.variant===t)}function xr({selectedId:t,onSelect:r}){let[l,c]=n("all"),p=u(()=>Wc(l),[l]);return e("div",{className:"space-y-3 pb-6",children:[e("div",{className:"flex items-center gap-1.5",children:[Gc.map((g)=>e("button",{type:"button",onClick:()=>c(g.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${l===g.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[g.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),g.id==="dark"&&e($t,{size:11,className:"mr-1 inline align-[-1px]"}),g.label]},g.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:[p.length," themes"]})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2 lg:grid-cols-3",children:p.map((g)=>e(vr,{theme:g,selected:g.id===t,onSelect:r},g.id))})]})}function st({width:t,active:r=!1,trailing:l=!1}){return e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:`h-[5px] w-[5px] shrink-0 rounded-full ${r?"bg-ink":"bg-ink/25"}`}),e("span",{className:`h-[3px] rounded-full ${r?"bg-ink/70":"bg-ink/25"}`,style:{width:`${t}%`}}),l&&e("span",{className:"ml-auto h-[3px] w-[6px] rounded-full bg-ink/20"})]})}function Vc(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[7px] w-[30%] rounded-sm bg-ink/80"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"}),e("span",{className:"h-[7px] w-[7px] rounded-sm border border-ink/20 bg-paper"})]}),e("span",{className:"flex h-[7px] items-center gap-1 px-1",children:e("span",{className:"h-[3px] w-[45%] rounded-full bg-ink/45"})}),e(st,{width:62,trailing:!0}),e(st,{width:50,active:!0,trailing:!0}),e(st,{width:44,trailing:!0}),e(st,{width:56,trailing:!0})]})}function Yc(){return e("span",{className:"flex h-full flex-col gap-1 rounded-md border border-ink/10 bg-paper p-1","aria-hidden":"true",children:[e("span",{className:"flex h-[7px] items-center rounded-sm bg-ink/5 px-1",children:e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/30"})}),e("span",{className:"flex items-center gap-0.5",children:[e("span",{className:"h-[6px] w-[16%] rounded-full bg-ink/80"}),e("span",{className:"h-[6px] w-[22%] rounded-full border border-ink/20"}),e("span",{className:"h-[6px] w-[12%] rounded-full border border-ink/20"})]}),e("span",{className:"flex h-[9px] items-center gap-1 px-1",children:[e("span",{className:"h-[5px] w-[5px] shrink-0 rounded-full bg-ink/50"}),e("span",{className:"h-[3px] w-[40%] rounded-full bg-ink/45"}),e("span",{className:"ml-auto h-[3px] w-[5px] rounded-full bg-ink/20"})]}),e(st,{width:62,active:!0,trailing:!0}),e(st,{width:50,trailing:!0}),e(st,{width:44,trailing:!0})]})}var Jc={classic:Vc,modern:Yc};function yr({settings:t,onUpdate:r}){let l=ul(t.sidebarStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Session sidebar"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"How the left column draws its workspaces and chats. Both styles list the same workspaces and offer the same actions; the choice applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Session sidebar style",children:oA.map((c)=>{let p=sA[c],g=c===l,h=Jc[c];return e("button",{type:"button",onClick:()=>r({sidebarStyle:c}),"aria-pressed":g,"aria-label":`${p.label} sidebar — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[86px]",children:e(h,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function wr({backdropFilter:t,reducedTransparency:r}){let l=[];if(!t)l.push("no-backdrop-filter");if(r)l.push("reduced-transparency");return l}var Sr={"no-backdrop-filter":"This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.","reduced-transparency":"Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material."};var Nr="(prefers-reduced-transparency: reduce)";function Xc(){if(typeof CSS>"u"||typeof CSS.supports!=="function")return!1;return CSS.supports("backdrop-filter","blur(1px)")||CSS.supports("-webkit-backdrop-filter","blur(1px)")}function Pr(){let[t,r]=n(()=>typeof window>"u"?!1:window.matchMedia(Nr).matches);return i(()=>{let l=window.matchMedia(Nr),c=()=>r(l.matches);return c(),l.addEventListener("change",c),()=>l.removeEventListener("change",c)},[]),wr({backdropFilter:Xc(),reducedTransparency:t})}function Cr(){return e("span",{className:"flex h-full flex-col gap-1 p-1",children:[e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[38%] rounded-full bg-ink/40"}),e("span",{className:"ml-auto h-[6px] w-[10%] rounded-[2px] border border-ink/20"})]}),e("span",{className:"h-[2px] w-full rounded-full bg-ink/15"}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[52%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[18%] rounded-full bg-ink/15"})]}),e("span",{className:"flex items-center gap-1",children:[e("span",{className:"h-[3px] w-[44%] rounded-full bg-ink/30"}),e("span",{className:"h-[3px] w-[22%] rounded-full bg-ink/15"})]})]})}function Qc(){return e("span",{className:"block h-full rounded-md border border-ink/15 bg-paper","aria-hidden":"true",children:[e("span",{className:"block h-[13px] rounded-t-[5px] border-b border-ink/10 bg-paper",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/35"})}),e(Cr,{})]})}function Zc(){return e("span",{className:"relative block h-full overflow-hidden rounded-md border border-ink/15 bg-canvas","aria-hidden":"true",children:[e("span",{className:"pointer-events-none absolute inset-0",children:[e("span",{className:"absolute -left-2 top-2 h-[70%] w-[55%] rounded-full bg-info/40 blur-md"}),e("span",{className:"absolute -right-2 -top-2 h-[60%] w-[50%] rounded-full bg-meta/35 blur-md"}),e("span",{className:"absolute -bottom-2 right-3 h-[45%] w-[45%] rounded-full bg-success/30 blur-md"})]}),e("span",{className:"relative block h-[13px] border-b border-ink/10 bg-paper/40",children:e("span",{className:"mx-1 mt-[4px] block h-[3px] w-[40%] rounded-full bg-ink/40"})}),e("span",{className:"relative block h-[calc(100%-13px)] bg-paper/50",children:e(Cr,{})})]})}var ep={classic:Qc,glass:Zc};function tp(){let t=Pr();if(t.length===0)return null;return e("ul",{className:"space-y-1 rounded-lg border border-ink/15 bg-ink/[0.03] p-2.5","aria-live":"polite",children:t.map((r)=>e("li",{className:"flex gap-1.5 text-[11px] leading-relaxed text-ink/60",children:[e("span",{"aria-hidden":"true",className:"mt-[5px] h-1 w-1 shrink-0 rounded-full bg-ink/40"}),e("span",{children:Sr[r]})]},r))})}function Tr({settings:t,onUpdate:r}){let l=zp(t.surfaceStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Surfaces"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"What the windows are made of. Both styles draw the same panels, rows and dialogs; the frost is one blur pass per window, and it follows the palette — there is no separate glass colour to tune."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Surface style",children:bg.map((c)=>{let p=yg[c],g=c===l,h=ep[c];return e("button",{type:"button",onClick:()=>r({surfaceStyle:c}),"aria-pressed":g,"aria-label":`${p.label} surfaces — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[78px]",children:e(h,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:p.caption}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})}),l==="glass"&&e(tp,{})]})}function np(t){return cn(t).paper}function En({name:t,Icon:r,colored:l,paper:c}){let p=ag(t),g=!l?void 0:p?Dp[p]:ki(ig(t),"light",c);return e(r,{size:13,strokeWidth:2,style:g?{color:g}:void 0,"aria-hidden":"true"})}function Ir({name:t,base:r,colored:l}){let c=l?r:void 0;return e("span",{className:"flex h-5 w-5 items-center justify-center rounded-[5px] border border-ink/10",style:c?{backgroundColor:`${c}22`,color:c}:void 0,title:t,"aria-hidden":"true",children:e("span",{className:`block h-2 w-2 rounded-full ${l?"":"bg-ink/60"}`,style:c?{backgroundColor:c}:void 0})})}function Ar({colored:t,paper:r}){return e("span",{className:"flex h-full items-center gap-1.5 rounded-md border border-ink/10 bg-canvas/60 px-2",children:[e(En,{name:"Trash2",Icon:M,colored:t,paper:r}),e(En,{name:"Check",Icon:f,colored:t,paper:r}),e(En,{name:"Sparkles",Icon:Le,colored:t,paper:r}),e("span",{className:"mx-0.5 h-4 w-px bg-ink/10"}),e(Ir,{name:"claude",base:Tp.claude.light,colored:t}),e(Ir,{name:"Typescript",base:Qp.Typescript.light,colored:t})]})}function Rr({settings:t,onUpdate:r}){let l=Sp(t.iconStyle),c=np(t.theme),p={monochrome:()=>e(Ar,{colored:!1,paper:c}),color:()=>e(Ar,{colored:!0,paper:c})};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Icons"}),e("p",{className:"mt-0.5 text-[11px] text-ink/50",children:"Every icon: toolbar and panel glyphs, provider logos and file-type marks. Full colour gives each glyph its own hue and keeps the palette’s red, green, amber and blue for signals; a colour that would disappear on the active theme falls back to the ink. A control that sets its own colour keeps it."})]}),e("div",{className:"grid grid-cols-1 gap-2.5 sm:grid-cols-2",role:"group","aria-label":"Icon style",children:ng.map((g)=>{let h=rg[g],v=g===l,x=p[g];return e("button",{type:"button",onClick:()=>r({iconStyle:g}),"aria-pressed":v,"aria-label":`${h.label} icons — ${h.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${v?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[42px]",children:e(x,{})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:h.label}),e("span",{className:"font-mono text-[10px] text-ink/40",children:h.caption}),v&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:h.description})]},g)})})]})}function Mr({settings:t,onUpdate:r}){let l=t.editorFont||Jl[0].id;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(Hr,{size:16,className:"text-ink/60"}),"Editor Font"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:"Typeface for the code editor and its line numbers, in both the desktop panel and the phone's full-screen editor. Only Fira Code ships with the app; the others are used when your device has them, and fall back to Fira Code when it does not."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:Jl.map((c)=>{let p=l===c.id;return e("button",{type:"button",onClick:()=>r({editorFont:c.id}),"aria-pressed":p,className:`flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-left transition-colors ${p?"border-ink/40 bg-ink/5":"border-ink/12 hover:bg-ink/5"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate text-xs text-ink",style:{fontFamily:`"${c.id}", monospace`},children:"const greet = () => 'hi'"}),e("span",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-ink/50",children:[e("span",{children:c.label}),c.bundled&&e("span",{className:"rounded bg-ink/8 px-1 py-px text-[10px] uppercase tracking-wide",children:"Bundled"})]})]}),p&&e(f,{size:14,className:"text-ink flex-shrink-0"})]},c.id)})})]})}var op=[{id:"all",label:"All"},{id:"light",label:"Light"},{id:"dark",label:"Dark"}];function rp(t){return`"${Jl.find((l)=>l.id===t)?.id??Jl[0].id}", monospace`}function ip({theme:t,face:r}){return e("span",{className:"block overflow-hidden rounded border border-ink/10",style:{backgroundColor:t.bg,color:t.fg},children:e("span",{className:"block px-1.5 py-1 font-mono text-[10px] leading-[1.4]",style:{fontFamily:r},children:[e("span",{style:{color:t.keyword},children:"const"})," ",e("span",{children:"answer"})," ",e("span",{style:{color:t.keyword},children:"="})," ",e("span",{style:{color:t.string},children:"42"}),e("span",{children:";"}),e("span",{className:"block truncate",style:{color:t.comment},children:["// ",t.label]})]})})}function Er({settings:t,onUpdate:r}){let l=t.editorTheme||Kr,[c,p]=n("all"),g=rp(t.editorFont),h=u(()=>c==="all"?Up:Up.filter((v)=>v.variant===c),[c]);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80 flex items-center gap-2",children:[e(ba,{size:16,className:"text-ink/60"}),"Editor Theme"]}),e("p",{className:"text-[11px] text-ink/60 mt-1",children:["Colours for the code editor only — the console around it keeps the theme above. ",e("strong",{children:"Auto"})," ","follows the app palette; any other choice paints the editor's own surface, gutter, selection and syntax, and applies to every open editor without a reload."]})]}),e("div",{className:"flex items-center gap-1.5",children:[op.map((v)=>e("button",{type:"button",onClick:()=>p(v.id),className:`rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors cursor-pointer ${c===v.id?"border-ink bg-ink text-paper":"border-ink/20 bg-paper text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:[v.id==="light"&&e(_t,{size:11,className:"mr-1 inline align-[-1px]"}),v.id==="dark"&&e($t,{size:11,className:"mr-1 inline align-[-1px]"}),v.label]},v.id)),e("span",{className:"ml-auto font-mono text-[11px] text-ink/50",children:c==="all"?`${h.length} themes`:`${h.length} shown`})]}),e("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:[e("button",{type:"button",onClick:()=>r({editorTheme:Kr}),"aria-pressed":l===Kr,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${l===Kr?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",children:"Auto"}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:"app palette"}),l===Kr&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e("span",{className:"flex h-8 items-center justify-center rounded border border-dashed border-ink/20 text-[10px] text-ink/50",children:"Follows the theme above"})]}),h.map((v)=>{let x=l===v.id;return e("button",{type:"button",onClick:()=>r({editorTheme:v.id}),"aria-pressed":x,className:`flex w-full flex-col gap-2 rounded-lg border p-2 text-left transition-colors cursor-pointer ${x?"border-ink bg-ink/5 ring-1 ring-ink/20":"border-ink/20 bg-paper hover:border-ink/40 hover:bg-ink/5"}`,children:[e("span",{className:"flex items-center gap-2",children:[e("span",{className:"truncate font-semibold text-ink",title:v.label,children:v.label}),e("span",{className:"shrink-0 rounded-full border border-ink/15 px-1.5 py-px text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:v.variant}),x&&e(f,{size:14,className:"ml-auto shrink-0 text-ink"})]}),e(ip,{theme:v,face:g})]},v.id)})]})]})}function Lr({settings:t,onUpdate:r}){let l=H("editorIndentWidth"),c=typeof l==="number"&&od.includes(l)?l:Uc.width,p=(g)=>{if(g===c)return;let h={...sd(),width:g};Wr({editorIndentWidth:g,editorInsertSpaces:!0}),r((v)=>({...v})),window.dispatchEvent(new CustomEvent(id,{detail:h}))};return e("section",{className:"space-y-3",children:e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor indentation"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"One level, in spaces. Enter, Tab and the auto-indent rules all use it."})]}),e("div",{className:"flex items-center gap-1",role:"group","aria-label":"Indentation width",children:od.map((g)=>e("button",{type:"button",onClick:()=>p(g),"aria-pressed":g===c,"aria-label":`${g} spaces`,className:`px-2.5 py-1 rounded border text-[11px] font-mono transition-colors cursor-pointer ${g===c?"border-ink/40 bg-ink/10 text-ink":"border-ink/15 text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:g},g))})]})})}function Or({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.currentTarget.checked),"aria-label":t,className:`${ge} mt-0.5 accent-ink flex-shrink-0`})]})}function Dr({settings:t,onUpdate:r}){let l=qc(),c=H("editorAutoCloseBrackets"),p=H("editorAutocomplete"),g=(h)=>{let v={...qc(),...h};Wr(h),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(ld,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Editor typing"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Both change what typing does, which is why they are switches rather than always-on."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Or,{label:"Auto-close brackets",hint:"Typing ( or { inserts the matching closer, and typing it again steps over it.",checked:typeof c==="boolean"?c:ol.autoCloseBrackets,onChange:(h)=>g({editorAutoCloseBrackets:h})}),e(Or,{label:"Suggest words from the file",hint:`Offers identifiers already near the caret (${l.autocomplete?"on":"off"}). Words only — this is not a language server.`,checked:typeof p==="boolean"?p:ol.autocomplete,onChange:(h)=>g({editorAutocomplete:h})})]})]})}function Fr({label:t,hint:r,checked:l,onChange:c}){return e("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[e("span",{className:"min-w-0",children:[e("span",{className:"block text-xs text-ink",children:t}),e("span",{className:"block text-[11px] text-ink/50 mt-0.5",children:r})]}),e("input",{type:"checkbox",checked:l,onChange:(p)=>c(p.target.checked),className:`${ge} mt-0.5 shrink-0 accent-ink`})]})}function $r({settings:t,onUpdate:r}){let l=H("editorBlame"),c=H("editorBlameInline"),p=po(),g=(h)=>{let v={...po(),...h};Wr(h),r((x)=>({...x})),window.dispatchEvent(new CustomEvent(os,{detail:v}))};return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Line blame"}),e("p",{className:"text-[11px] text-ink/50 mt-0.5",children:"Who last touched a line, and which commit. Read from git, so it needs a committed file."})]}),e("div",{className:"space-y-2.5 rounded-lg border border-ink/10 p-3",children:[e(Fr,{label:"Show blame on hover",hint:"Hover a line number — or the label, when it is on — to see the author, the commit and the line's own history.",checked:typeof l==="boolean"?l:sl.enabled,onChange:(h)=>g({editorBlame:h})}),e(Fr,{label:"Show the label in the editor",hint:`Puts “author · age” at the end of each block. It costs horizontal room, so it is off on a narrow panel by default (${p.inline?"on":"off"}).`,checked:typeof c==="boolean"?c:sl.inline,onChange:(h)=>g({editorBlameInline:h})})]})]})}function _r({settings:t,onUpdate:r}){return e("div",{className:"w-full space-y-8 text-xs text-ink pb-3",children:[e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(ba,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Theme Preferences"})]}),e(xr,{selectedId:t.theme,onSelect:(l)=>r({theme:XA(l)})})]}),e("section",{className:"space-y-4",children:[e("div",{className:"flex items-center space-x-2 border-b border-ink/10 pb-2",children:[e(qn,{size:16,className:"text-ink/60"}),e("h3",{className:"font-semibold text-sm uppercase tracking-wider text-ink/80",children:"Layout"})]}),e(yr,{settings:t,onUpdate:r}),e(Tr,{settings:t,onUpdate:r}),e(Rr,{settings:t,onUpdate:r})]}),e(Mr,{settings:t,onUpdate:r}),e(Er,{settings:t,onUpdate:r}),e(Lr,{settings:t,onUpdate:r}),e(Dr,{settings:t,onUpdate:r}),e($r,{settings:t,onUpdate:r})]})}function ye(){let[t,r]=n("list"),l=a(()=>r("detail"),[]),c=a(()=>r("list"),[]);return{pane:t,openDetail:l,back:c}}function we({pane:t,onBack:r,list:l,detail:c,listLabel:p,className:g=""}){return e("div",{className:`flex-1 flex flex-col md:flex-row h-full w-full min-w-0 overflow-hidden bg-paper text-ink ${g}`,children:[e("div",{className:`${t==="list"?"flex":"hidden"} md:flex flex-1 md:flex-none md:w-auto min-h-0 min-w-0 flex-col`,children:l}),e("div",{className:`${t==="detail"?"flex":"hidden"} md:flex flex-1 min-h-0 min-w-0 flex-col`,children:[e("div",{className:"md:hidden flex items-center px-2 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:e("button",{type:"button",onClick:r,"aria-label":`Back to ${p}`,className:"flex items-center gap-1 -ml-0.5 pl-0.5 pr-2 py-1 rounded-lg text-ink hover:bg-ink/5 active:bg-ink/10 transition-colors cursor-pointer",children:[e(Aa,{size:18}),e("span",{className:"text-xs font-semibold truncate",children:p})]})}),c]})]})}function Br({groups:t,activeGroupId:r,onSelectGroup:l}){return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0 select-none",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:e("span",{className:"text-xs font-semibold text-ink",children:[t.length," group",t.length===1?"":"s"]})}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 text-xs",children:e("div",{className:"space-y-0.5",children:t.map((c)=>{let p=c.id===r,g=c.icon;return e("button",{type:"button",onClick:()=>l(c.id),"aria-current":p?"true":void 0,className:`w-full text-left px-2.5 py-2 rounded-lg transition-colors cursor-pointer flex flex-col gap-0.5 ${p?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e("span",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{"aria-hidden":!0,className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 ${p?"bg-ink/10 text-ink":"bg-ink/5 text-ink/70"}`,children:e(g,{size:12})}),e("span",{className:"font-semibold text-xs text-ink truncate",children:c.label})]}),e("span",{className:"text-[11px] text-ink/60 line-clamp-1 leading-snug pl-[26px]",children:c.hint})]},c.id)})})})]})}var Nt=[{id:"layout",label:"Layout",hint:"Chat width and composer shape",description:"How wide the conversation is drawn, and the shape of the box you type into.",icon:qn,sections:["width","composer"]},{id:"transcript",label:"Transcript",hint:"Tool calls, changed files and follow-up dispatch",description:"How a tool call is drawn, whether a run lists the files it changed, and what happens to a prompt sent while the agent is still running.",icon:Ur,sections:["tool-calls","changed-files","follow-up"]},{id:"sessions",label:"Sessions",hint:"Titles and goal mode",description:"How a session gets its name, and the defaults a new goal starts with.",icon:en,sections:["titles","goal"]}];var ap={compact:"60%",wide:"85%",full:"100%"};function Gr({settings:t,onUpdate:r}){let l=t.chatWidthMode;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Chat Width"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How wide the conversation is drawn. The composer follows the transcript, and no mode hides a panel."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",role:"group","aria-label":"Chat width",children:cg.map((c)=>{let p=ug[c],g=l===c;return e("div",{onClick:()=>r({chatWidthMode:c}),role:"button",tabIndex:0,"aria-pressed":g,onKeyDown:(h)=>{if(h.key==="Enter"||h.key===" ")h.preventDefault(),r({chatWidthMode:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${g?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${g?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:g&&e(f,{size:10,strokeWidth:3})})]}),e("div",{"aria-hidden":!0,className:"h-1.5 rounded-full bg-ink/10 mb-2.5 overflow-hidden",children:e("div",{className:`h-full rounded-full ${g?"bg-ink":"bg-ink/35"}`,style:{width:ap[c]}})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"On a phone the column already fills the screen, so the mode has no visible effect."})]})}function Jr({active:t=!1}){return e("span",{className:`h-[6px] w-[16px] rounded-sm border ${t?"border-ink/40 bg-ink/15":"border-ink/20 bg-ink/5"}`})}function sp({hero:t=!1}){return e("span",{className:`flex flex-col gap-[3px] rounded-md border border-ink/15 bg-paper px-1.5 py-1 ${t?"flex-1 justify-center":""}`,children:[e("span",{className:"h-[2.5px] w-[72%] rounded-full bg-ink/25"}),e("span",{className:"h-[2.5px] w-[54%] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[30%] rounded-full bg-ink/15"})]})}function lp({rail:t=!1}){if(t)return e("span",{className:"flex items-center gap-1 border-t border-ink/10 px-1 pt-1 font-mono",children:[e("span",{className:"h-[2.5px] w-[14px] rounded-full bg-ink/30"}),e("span",{className:"h-[2.5px] w-[9px] rounded-full bg-ink/20"}),e("span",{className:"h-[2.5px] w-[11px] rounded-full bg-ink/20"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-sm bg-ink/80"})]});return e("span",{className:"flex items-center gap-1 px-1",children:[e("span",{className:"h-[6px] w-[20px] rounded-sm bg-ink/15"}),e("span",{className:"h-[6px] w-[10px] rounded-sm bg-ink/10"}),e("span",{className:"ml-auto h-[7px] w-[7px] rounded-full border border-ink/25"}),e("span",{className:"h-[7px] w-[7px] rounded-sm bg-ink/80"})]})}var dp={classic:"rounded-md bg-paper border-ink/10",calm:"rounded-lg bg-paper border-ink/10",console:"rounded-sm bg-paper border-ink/10",stage:"rounded-md bg-paper border-ink/15",glass:"rounded-xl border-ink/15 bg-gradient-to-b from-ink/[0.06] to-transparent"};function cp({style:t}){let r=$p({style:t,hero:t==="stage"});return e("span",{className:`flex h-full flex-col gap-1 border p-1 ${dp[t]}`,"aria-hidden":"true",children:r.wire.map((l,c)=>l==="draft"?e(sp,{hero:t==="stage"},c):l==="chip"?e("span",{className:"flex items-center gap-1 px-1",children:[e(Jr,{active:t!=="calm"}),e(Jr,{})]},c):e(lp,{rail:r.toolbarTone==="rail"},c))})}function Xr({settings:t,onUpdate:r}){let l=Yl(t.composerStyle);return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Composer"}),e("p",{className:"mt-0.5 text-[11px] text-ink/60",children:"The shape of the box you type into. Every style offers the same controls — attachments, plan and goal, access mode, model, thinking, voice, send — and only their order and frame change. Applies to desktop and phone, and takes effect immediately."})]}),e("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",role:"group","aria-label":"Composer style",children:fg.map((c)=>{let p=gg[c],g=c===l;return e("button",{type:"button",onClick:()=>r({composerStyle:c}),"aria-pressed":g,"aria-label":`${p.label} composer — ${p.description}`,className:`flex flex-col gap-2 rounded-xl border p-2.5 text-left transition-colors cursor-pointer ${g?"border-ink/40 bg-ink/5":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/5"}`,children:[e("span",{className:"block h-[92px]",children:e(cp,{style:c})}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:p.label}),g&&e("span",{className:"ml-auto rounded-full bg-ink px-1.5 py-[1px] text-[10px] font-semibold text-paper",children:"active"})]}),e("span",{className:"text-[11px] leading-relaxed text-ink/60",children:p.description})]},c)})})]})}function pp({mode:t}){if(t==="card")return e("div",{"aria-hidden":!0,className:"space-y-1 rounded-md border border-ink/15 bg-paper px-2 py-1.5",children:[e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/50"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/35"}),e("span",{className:"ml-auto h-1 w-5 rounded-full bg-ink/20"})]}),e("div",{className:"h-1 w-16 rounded-full bg-ink/15"})]});if(t==="compact")return e("div",{"aria-hidden":!0,className:"space-y-1.5 rounded-md border border-transparent px-1 py-1",children:[0,1].map((r)=>e("div",{className:"flex items-center gap-1",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-8 rounded-full bg-ink/30"}),e("span",{className:"ml-auto h-1 w-6 rounded-full bg-ink/15"})]},r))});if(t==="trace")return e("div",{"aria-hidden":!0,className:"relative ml-1 pl-3 py-1",children:[e("span",{className:"absolute left-[3px] top-1 bottom-1 w-px bg-ink/20"}),[0,1,2].map((r)=>e("div",{className:"flex items-center gap-1 py-0.5",children:[e("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/40"}),e("span",{className:"h-1 w-10 rounded-full bg-ink/25"})]},r))]});if(t==="tui")return e("div",{"aria-hidden":!0,className:"space-y-1 px-1 py-1 font-mono",children:[0,1].map((r)=>e("div",{className:"flex items-baseline gap-1",children:[e("span",{className:"text-[6px] text-success",children:"✔"}),e("span",{className:"h-1 w-3 rounded-full bg-info/70"}),e("span",{className:"h-1 w-6 rounded-full bg-meta/70"}),e("span",{className:"ml-auto h-1 w-2 rounded-full bg-ink/25"})]},r))});return e("div",{"aria-hidden":!0,className:"space-y-1.5 px-1 py-1",children:[e("div",{className:"h-1 w-20 rounded-full bg-ink/25"}),e("div",{className:"h-1 w-14 rounded-full bg-ink/15"})]})}function Qr({settings:t,onUpdate:r}){let l=t.toolRenderStyle;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Tool Calls"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a tool call is drawn in the transcript. Every style shows the same outcome, facts and body."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:pg.map((c)=>{let p=mg[c],g=l===c;return e("div",{onClick:()=>r({toolRenderStyle:c}),role:"button",tabIndex:0,"aria-pressed":g,onKeyDown:(h)=>{if(h.key==="Enter"||h.key===" ")h.preventDefault(),r({toolRenderStyle:c})},className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${g?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("span",{className:"font-semibold text-xs text-ink",children:p.label}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${g?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:g&&e(f,{size:10,strokeWidth:3})})]}),e("div",{className:"mb-2.5 h-12 rounded-md bg-canvas/50 px-1 py-1",children:e(pp,{mode:c})}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:p.description})]})},c)})}),e("p",{className:"text-[10px] text-ink/45 font-mono",children:"The style is global: it applies to every session, and the composer keeps its own frame."})]})}function up({label:t,enabled:r,onToggle:l}){return e("button",{type:"button",role:"switch","aria-checked":r,"aria-label":`${r?"Disable":"Enable"} ${t}`,onClick:l,className:`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${r?"bg-ink":"bg-ink/20"}`,children:e("span",{"aria-hidden":"true",className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${r?"translate-x-5":"translate-x-0"}`})})}function Zr({settings:t,onUpdate:r}){let l=t.showChangedFiles;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Changed Files"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A collapsed list of the files a run changed, above its footer. Clicking a file opens the agent's own diff — the content it wrote, not the current worktree."})]}),e("div",{className:"flex items-start justify-between gap-4 py-3",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e(Jo,{size:16,className:l?"text-ink":"text-ink/40"})}),e("div",{children:[e("div",{className:"text-sm font-semibold text-ink",children:"Show changed files"}),e("p",{className:"text-ink/65 text-[11px] mt-1 leading-relaxed",children:"Read from the session's change journal. Sessions recorded before omp 18.20.1 have no journal, so the list stays empty there."})]})]}),e(up,{label:"Show changed files",enabled:l,onToggle:()=>r({showChangedFiles:!l})})]})]})}function ei({settings:t,onUpdate:r}){return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Follow-up Dispatch"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Choose how new user prompts are handled while the AI agent is actively executing."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e("div",{onClick:()=>r({followUpBehavior:"queue"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"queue"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="queue"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="queue"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Ur,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Queue Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Sequential"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Messages wait in an execution queue and run in succession once current inference completes."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for batch operations"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="queue"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="queue"&&e(f,{size:10,strokeWidth:3})})]})]}),e("div",{onClick:()=>r({followUpBehavior:"steering"}),role:"button",tabIndex:0,onKeyDown:(l)=>l.key==="Enter"&&r({followUpBehavior:"steering"}),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${t.followUpBehavior==="steering"?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${t.followUpBehavior==="steering"?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(Ft,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:"Steering Mode"})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:"Intervention"})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:"Immediately redirects current agent trajectory and focuses runtime resources onto the new instruction."})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:"Recommended for active debugging"}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${t.followUpBehavior==="steering"?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:t.followUpBehavior==="steering"&&e(f,{size:10,strokeWidth:3})})]})]})]})]})}var mp=[{enabled:!0,label:"Generate Automatically",badge:"Default",icon:Le,description:`As soon as your first message lands, the session is named from it using omp's own tiny title model — retried once when the run ends if that first attempt came back empty. Sessions stop showing "New Session - <timestamp>" in the sidebar.`,note:"One small model call per session"},{enabled:!1,label:"Manual Only",badge:"Opt-out",icon:Hr,description:"Sessions keep their timestamp placeholder until you rename them from the sidebar. Choose this when every title should be deliberate, or to avoid the extra model call.",note:"No background model calls"}];function ti({settings:t,onUpdate:r}){let l=t.autoSessionTitle??!0;return e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Session Titles"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"How a session gets its display name. A name you set yourself is never replaced."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:mp.map(({enabled:c,label:p,badge:g,icon:h,description:v,note:x})=>{let y=l===c,k=()=>r({autoSessionTitle:c});return e("div",{onClick:k,role:"button",tabIndex:0,onKeyDown:(T)=>T.key==="Enter"&&k(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${y?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${y?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(h,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:p})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:g})]}),e("p",{className:"text-[11px] text-ink/70 leading-relaxed",children:v})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50",children:x}),y&&e("span",{className:"flex items-center gap-1 text-ink font-medium",children:[e(f,{size:12})," Active"]})]})]},p)})})]})}var gp="flex w-full min-w-0 items-center justify-between gap-2 rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-left font-mono text-[11px] text-ink transition-colors hover:border-ink/40 focus:border-ink/50 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50";function $e({value:t,options:r,placeholder:l,ariaLabel:c,onChange:p,disabled:g,className:h,searchable:v=!0}){let[x,y]=n(null),[k,T]=n(""),[S,R]=n(0),P=o(null),L=o(null),N=o([]),E=o(`search-select-${Math.random().toString(36).slice(2,9)}`).current,A=r.find((q)=>q.value===t),O=x!==null,U=u(()=>{let q=k.trim();if(!q)return r;return r.filter((j)=>Ko(`${j.label} ${j.value} ${j.hint??""}`,q))},[r,k]),_=u(()=>{let q=[];for(let j of U){let G=j.group??"",Q=q.find((te)=>te.name===G);if(Q)Q.rows.push(j);else q.push({name:G,rows:[j]})}return q},[U]),K=(q=!1)=>{if(y(null),T(""),q)P.current?.focus()},V=()=>{if(g||!P.current)return;let q=Math.max(0,r.findIndex((j)=>j.value===t));T(""),R(q),y(zt(P.current))},z=(q)=>{if(q!==t)p(q);K(!0)};i(()=>{R(0)},[k]),i(()=>{if(!O)return;N.current[S]?.scrollIntoView({block:"nearest"})},[O,S]),i(()=>{if(O)L.current?.focus()},[O]);let W=(q)=>{if(q.key==="ArrowDown")q.preventDefault(),R((j)=>Math.max(0,Math.min(U.length-1,j+1)));else if(q.key==="ArrowUp")q.preventDefault(),R((j)=>Math.max(0,j-1));else if(q.key==="Home")q.preventDefault(),R(0);else if(q.key==="End")q.preventDefault(),R(Math.max(0,U.length-1));else if(q.key==="Enter"){q.preventDefault();let j=U[S];if(j)z(j.value)}};return e(d,{children:[e("button",{ref:P,type:"button",role:"combobox","aria-label":c,"aria-haspopup":"listbox","aria-expanded":O,"aria-controls":O?E:void 0,disabled:g,title:A?.label??l,onClick:()=>O?K():V(),onKeyDown:(q)=>{if(q.key==="ArrowDown"||q.key==="Enter"||q.key===" ")q.preventDefault(),V()},className:`${gp} ${h??""}`,children:[e("span",{className:`truncate ${A?"":"text-ink/40"}`,children:A?.label??(t?`${t} (not listed)`:l)}),e(B,{size:12,className:`flex-shrink-0 text-ink/40 transition-transform ${O?"rotate-180":""}`})]}),e(Ut,{anchor:x,align:"start",className:"w-72 max-w-[calc(100vw-2rem)] rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",...{"aria-label":c},onClose:()=>K(!0),children:e("div",{onKeyDown:W,children:[v&&e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{ref:L,type:"text",value:k,"aria-label":`Search ${c}`,placeholder:"Search…",onInput:(q)=>T(q.currentTarget.value),className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{id:E,role:"listbox","aria-label":c,className:"max-h-56 overflow-y-auto py-1",children:[e("button",{type:"button",role:"option","aria-selected":t==="",ref:(q)=>{N.current[0]=q},onClick:()=>z(""),onMouseEnter:()=>R(0),className:`flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left ${t===""?"text-ink":"text-ink/60"} hover:bg-ink/5`,children:[e("span",{className:"truncate italic",children:l}),t===""&&e(f,{size:11,className:"flex-shrink-0"})]}),t!==""&&!A&&e("button",{type:"button",role:"option","aria-selected":!0,onClick:()=>z(t),className:"flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-ink",children:[e("span",{className:"truncate",children:[t," (not listed)"]}),e(f,{size:11,className:"flex-shrink-0"})]}),U.length===0?e("div",{className:"px-3 py-2 italic text-ink/40",children:["No match for “",k.trim(),"”"]}):_.map((q)=>e("div",{children:[q.name&&e("div",{className:"px-3 pb-0.5 pt-2 text-[9px] font-semibold uppercase tracking-wider text-ink/35",children:q.name}),q.rows.map((j)=>{let G=U.indexOf(j),Q=j.value===t;return e("button",{type:"button",role:"option","aria-selected":Q,ref:(te)=>{N.current[G+1]=te},onClick:()=>z(j.value),onMouseEnter:()=>R(G),title:j.hint??j.value,className:`flex w-full items-start justify-between gap-2 px-3 py-1.5 text-left transition-colors ${G===S?"bg-ink/5":""} ${Q?"font-medium text-ink":"text-ink/75"}`,children:[e("span",{className:"min-w-0",children:[e("span",{className:"block truncate",children:j.label}),j.hint&&e("span",{className:"block truncate font-mono text-[10px] text-ink/40",children:j.hint})]}),Q&&e(f,{size:11,className:"mt-0.5 flex-shrink-0"})]},j.value)})]},q.name||"__flat"))]})]})})]})}var bp=[{enabled:!0,label:"Independent auditor",badge:"Default",description:"After every finished turn a separate model reads the objective and the agent's own report and decides: keep going, done, or needs you. Without it nothing advances a goal on its own.",note:"One extra model call per turn"},{enabled:!1,label:"Manual only",badge:"Opt-out",description:"Goals still exist — objective, pause, resume and the token budget all work — but the loop never continues by itself. Use it when a goal should only ever run the turns you ask for.",note:"No background model calls"}];function ni({settings:t,onUpdate:r}){let l=Xl(),[c,p]=n([]),[g,h]=n(!0),v=t.goalAuditEnabled??!0,x=t.goalAuditModel??"",y=t.goalDefaultBudget??null,[k,T]=n(y===null?"":String(y));i(()=>{T(y===null?"":String(y))},[y]);let S=()=>{let R=Wp(k);if(T(R===null?"":String(R)),R!==y)r({goalDefaultBudget:R})};return i(()=>{let R=!0;return Ga().then((P)=>{if(!R)return;p(Array.isArray(P.modelList)?P.modelList.map((L)=>({id:L.id,name:L.name,provider:L.provider})):[])}).catch(()=>{}).finally(()=>{if(R)h(!1)}),()=>{R=!1}},[]),e("section",{className:"space-y-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Goal Mode"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"A goal keeps a session working toward one objective until it is done, out of budget, or the auditor says it needs you."})]}),e("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:bp.map(({enabled:R,label:P,badge:L,description:N,note:E})=>{let A=v===R,O=()=>r({goalAuditEnabled:R});return e("div",{onClick:O,role:"button",tabIndex:0,onKeyDown:(U)=>U.key==="Enter"&&O(),className:`p-3.5 rounded-lg border text-left transition-all cursor-pointer flex flex-col justify-between select-none ${A?"border-ink bg-ink/5 ring-1 ring-ink/20 shadow-xs":"border-ink/15 bg-paper hover:border-ink/30 hover:bg-ink/[0.02]"}`,children:[e("div",{children:[e("div",{className:"flex items-center justify-between mb-2",children:[e("div",{className:"flex items-center gap-2",children:[e("div",{className:`w-7 h-7 rounded-md flex items-center justify-center ${A?"bg-ink text-paper":"bg-ink/5 text-ink/70"}`,children:e(hi,{size:15})}),e("span",{className:"font-semibold text-xs text-ink",children:P})]}),e("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-ink/10 text-ink/70 font-medium",children:L})]}),e("p",{className:"text-[11px] text-ink/65 leading-relaxed",children:N})]}),e("div",{className:"mt-3 pt-2.5 border-t border-ink/10 flex items-center justify-between text-[11px]",children:[e("span",{className:"text-ink/50 text-[10px]",children:E}),e("div",{className:`w-4 h-4 rounded-full border flex items-center justify-center ${A?"border-ink bg-ink text-paper":"border-ink/30 bg-transparent"}`,children:A&&e(f,{size:10,strokeWidth:3})})]})]},P)})}),v&&e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5 space-y-3",children:e("div",{children:[e("label",{className:"mb-1 block text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:"Auditor model"}),e($e,{ariaLabel:"Auditor model",value:x,onChange:(R)=>r({goalAuditModel:R}),disabled:g,placeholder:"Session model (default)",className:"w-full py-1.5 text-[11.5px]",options:c.map((R)=>({value:`${R.provider}/${R.id}`,label:R.name,hint:`${R.provider}/${R.id}`,group:Wo(R.provider,l)}))}),e("p",{className:"mt-1 text-[10.5px] text-ink/45",children:"The audit is a classification, not a task: it runs with thinking off, one small call per turn."})]})}),e("div",{className:"rounded-lg border border-ink/15 bg-paper p-3.5",children:[e("label",{className:"mb-1 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-ink/45",children:[e(Yi,{size:11})," Default token budget"]}),e("div",{className:"flex items-center gap-2",children:[e("input",{value:k,onChange:(R)=>T(R.currentTarget.value),onBlur:S,onKeyDown:(R)=>{if(R.key==="Enter")S()},placeholder:"none: the turn ceiling is then the only stop",inputMode:"numeric","aria-label":"Default goal token budget",className:"w-56 rounded border border-ink/15 bg-paper px-2 py-1.5 font-mono text-[11.5px] outline-none focus:border-ink"}),e("span",{className:"text-[10.5px] text-ink/45",children:"New goals start with this budget; a goal you set explicitly keeps its own."})]})]}),e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/10 bg-canvas/40 p-3 text-[11px] text-ink/60",children:[e(Qt,{size:12,className:"mt-0.5 shrink-0"}),e("span",{children:"The objective is set per goal from the composer's target button. The auditor judges progress from the objective and the agent's own report only — write an objective that says what finished looks like."})]})]})}var fp={width:Gr,composer:Xr,"tool-calls":Qr,"changed-files":Zr,"follow-up":ei,titles:ti,goal:ni};function oi({settings:t,onUpdate:r}){let l=ye(),[c,p]=n(Nt[0].id),g=Nt.find((h)=>h.id===c)??Nt[0];return e(we,{pane:l.pane,onBack:l.back,listLabel:"Chat settings",list:e(Br,{groups:Nt,activeGroupId:g.id,onSelectGroup:(h)=>{p(h),l.openDetail()}}),detail:e("div",{className:"flex-1 h-full overflow-hidden flex flex-col text-xs text-ink",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex-shrink-0",children:[e("span",{className:"text-xs font-semibold text-ink/75",children:g.label}),e("p",{className:"text-[11px] text-ink/60 leading-snug mt-0.5",children:g.description})]}),e("div",{className:"flex-1 overflow-y-auto scrollbar-overlay-container p-3.5 space-y-7 pb-6",children:g.sections.map((h)=>{let v=fp[h];return e(v,{settings:t,onUpdate:r},h)})})]})})}function ri(t){let r=new Map;for(let c of t){let p=Bg(c.chord),g=r.get(p);if(g)g.push(c);else r.set(p,[c])}let l=[];for(let c of r.values())for(let p=0;p<c.length;p+=1)for(let g=p+1;g<c.length;g+=1){let h=c[p],v=c[g];if(h.command===v.command)continue;l.push({chord:h.chord,a:h,b:v,certain:!h.when||!v.when||h.when===v.when})}return l}var hp={Shift:!0,Control:!0,Alt:!0,Meta:!0,OS:!0,Super:!0,Hyper:!0,CapsLock:!0,Fn:!0},yp={ShiftLeft:!0,ShiftRight:!0,ControlLeft:!0,ControlRight:!0,AltLeft:!0,AltRight:!0,MetaLeft:!0,MetaRight:!0,OSLeft:!0,OSRight:!0,CapsLock:!0};function ii(t){return hp[t.key]===!0||yp[t.code]===!0}function ai({chord:t,onCommit:r}){let[l,c]=n(!1),[p,g]=n([]),h=o(null);i(()=>{if(l)h.current?.focus()},[l]);let v=()=>{c(!1),g([])},x=(k)=>{if(!l)return;if(k.preventDefault(),k.stopPropagation(),k.key==="Escape"){v();return}if(k.key==="Backspace"||k.key==="Delete"){if(p.length===0)r(null),v();else g([]);return}if(k.key==="Enter"&&p.length===1){r(Uf(p)),v();return}if(ii(k))return;let T=Kp(k);if(p.length===0){g([T]);return}r(Uf([p[0],T])),v()},y=l?p.length>0?`${Ei(p,ht())} …`:"Press keys…":t||"Unassigned";return e("button",{ref:h,type:"button",onClick:()=>{c(!0),g([])},onBlur:()=>{if(l)v()},onKeyDown:x,"aria-label":l?"Recording shortcut, press keys":`Shortcut ${t||"unassigned"}, click to change`,className:`min-w-[7rem] px-2 py-1 rounded-md border text-[11px] font-mono transition-colors ${l?"border-ink/60 bg-ink/5 text-ink":"border-ink/20 text-ink/70 hover:border-ink/40 hover:text-ink"}`,children:y})}function si(){let{commands:t,chords:r,rules:l}=tc(),[c,p]=n(()=>Vp()),[g,h]=n(""),v=u(()=>ri(l),[l]),x=ht(),y=(P)=>t.find((L)=>L.id===P)?.title??P,k=(P,L)=>{let N={...c,[P]:L};p(N),Pu(N),Gf(N)},T=(P)=>{let L={...c};delete L[P],p(L),Pu(L),Gf(L)},S=g.trim().toLowerCase(),R=t.filter((P)=>!S||P.title.toLowerCase().includes(S)||(r.get(P.id)??"").toLowerCase().includes(S)).sort((P,L)=>P.category.localeCompare(L.category)||P.title.localeCompare(L.title));return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-3",children:[e("div",{children:[e("h4",{className:"text-sm font-semibold text-ink",children:"Shortcuts"}),e("p",{className:"text-[11px] text-ink/60 mt-0.5",children:"Click a chord to record a new one. Two strokes are allowed; Enter keeps a single stroke."})]}),e("div",{className:"flex items-center gap-2 px-2.5 py-1.5 border border-ink/15 rounded-md bg-canvas",children:[e(F,{size:13,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:g,onInput:(P)=>h(P.currentTarget.value),placeholder:"Filter","aria-label":"Filter shortcuts",className:"w-32 bg-transparent text-xs text-ink focus:outline-none placeholder-ink/40"})]})]}),v.length>0?e("div",{className:"border border-ink/15 rounded-lg p-3 space-y-1.5 bg-ink/[0.02]",children:[e("p",{className:"text-[11px] font-semibold text-ink/75",children:[v.length," chord ",v.length===1?"conflict":"conflicts"]}),v.map((P)=>e("p",{className:"text-[11px] text-ink/60",children:[e("span",{className:"font-mono text-ink/80",children:Ei(P.chord,x)})," ","— ",y(P.a.command)," and ",y(P.b.command),P.certain?"":" (may not overlap)"]},`${P.a.command}-${P.b.command}`))]}):null,e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:R.length===0?e("p",{className:"px-3 py-4 text-center text-xs text-ink/50",children:"No command matches that filter."}):R.map((P)=>{let L=c[P.id]!==void 0;return e("div",{className:"px-3 py-2 flex items-center justify-between gap-3",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink truncate",children:P.title}),e("div",{className:"text-[10px] text-ink/45",children:[P.category,P.pluginId?` · ${P.pluginId}`:"",L?" · custom":""]})]}),e("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e(ai,{chord:r.get(P.id)??"",onCommit:(N)=>k(P.id,N)}),L?e("button",{type:"button",onClick:()=>T(P.id),title:"Reset to default","aria-label":`Reset ${P.title} to its default shortcut`,className:"p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors",children:e(ut,{size:12})}):null]})]},P.id)})})]})}function li({settings:t,onUpdate:r}){let l=["Enter","Shift + Enter","Ctrl / Cmd + Enter"],c=(g,h)=>{r((v)=>{let x={[g]:h},y=["keybindingSend","keybindingNewLine","keybindingSteering"].filter((k)=>k!==g);for(let k of y)if(v[k]===h)x[k]=v[g];return{...v,...x}})},p=[{id:"keybindingSend",label:"Send Message",desc:"Submit prompt and initiate agent reasoning",icon:tt,value:t.keybindingSend||"Enter"},{id:"keybindingNewLine",label:"Line Break",desc:"Insert newline inside input box without dispatching",icon:Kt,value:t.keybindingNewLine||"Shift + Enter"},{id:"keybindingSteering",label:"Steering Intervention",desc:"Send prompt with steering interruption priority",icon:Ft,value:t.keybindingSteering||"Ctrl / Cmd + Enter"}];return e("section",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center gap-2",children:[e(ga,{size:15,className:"text-ink/70"}),e("h4",{className:"text-sm font-semibold text-ink",children:"Keyboard Shortcuts"})]}),e("span",{className:"text-[10px] text-ink/50 font-mono",children:"Auto-conflict resolution"})]}),e("div",{className:"bg-paper border border-ink/15 rounded-lg divide-y divide-ink/10 shadow-xs overflow-hidden",children:p.map((g)=>e("div",{className:"p-3.5 flex flex-col sm:flex-row sm:items-center justify-between gap-3 hover:bg-ink/[0.015] transition-colors",children:[e("div",{className:"flex items-start gap-3",children:[e("div",{className:"w-7 h-7 rounded-md bg-ink/5 flex items-center justify-center text-ink/70 flex-shrink-0 mt-0.5",children:e(g.icon,{size:14})}),e("div",{children:[e("div",{className:"font-semibold text-xs text-ink",children:g.label}),e("div",{className:"text-[11px] text-ink/60 mt-0.5",children:g.desc})]})]}),e("div",{className:"flex items-center gap-2 self-end sm:self-center",children:e("select",{value:g.value,onChange:(h)=>c(g.id,h.currentTarget.value),className:"bg-paper border border-ink/20 rounded-md px-2.5 py-1.5 outline-none focus:border-ink text-[11px] font-medium text-ink cursor-pointer hover:border-ink/40 transition-colors",children:l.map((h)=>e("option",{value:h,children:h},h))})})]},g.id))})]})}function ci({settings:t,onUpdate:r}){return e("div",{className:"flex-1 h-full overflow-y-auto scrollbar-overlay-container p-4 md:p-6 space-y-8 pb-8",children:[e(si,{}),e(li,{settings:t,onUpdate:r})]})}function pi({projects:t,selectedProjectId:r,onSelectProject:l,onAddProject:c,onTogglePin:p,isAdding:g=!1,folderFacts:h=[],loadError:v=null}){let x=new Map(h.map((y)=>[y.id,y.totalSessions]));return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3.5 py-2.5 border-b border-ink/10 flex items-center justify-between",children:[e("span",{className:"text-xs font-semibold text-ink",children:[t.length," project",t.length===1?"":"s"]}),e("button",{type:"button",onClick:c,disabled:g,"aria-label":"Add project",title:"Add project",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:e(Y,{size:15,strokeWidth:2.2})})]}),e("div",{className:"flex-1 scrollbar-overlay-container p-1.5 space-y-0.5",children:[v&&e("p",{className:"px-2 py-2 text-[11px] text-error",title:v,children:["Projects could not be read: ",v]}),!v&&t.length===0&&e("div",{className:"px-2 py-3 space-y-1.5",children:[e("p",{className:"text-[11.5px] text-ink/60",children:"No projects yet."}),e("button",{type:"button",onClick:c,className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add the first one"})]}),t.map((y)=>{let k=y.id===r,T=Yr(y.icon),S=y.folderId===void 0?void 0:x.get(y.folderId);return e("div",{className:`group flex items-center rounded-md transition-colors ${k?"bg-ink/10 shadow-2xs":"hover:bg-ink/5"}`,children:[e("button",{type:"button",onClick:()=>l(y.id),"aria-current":k?"true":void 0,className:"flex-1 min-w-0 flex items-center gap-2 px-2.5 py-1.5 text-left cursor-pointer",children:[y.customIconUrl?e("img",{src:y.customIconUrl,alt:"",className:"w-3.5 h-3.5 rounded-xs object-contain flex-shrink-0",referrerPolicy:"no-referrer"}):e(T,{size:14,className:"flex-shrink-0",style:{color:y.accentColor||"currentColor"}}),e("span",{className:`text-[11.5px] truncate flex-1 ${k?"font-medium text-ink":"text-ink/80"}`,children:y.name}),typeof S==="number"&&S>0&&e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:S})]}),e("button",{type:"button",onClick:()=>p(y),"aria-label":y.isPinned?`Unpin ${y.name}`:`Pin ${y.name}`,title:y.isPinned?"Unpin (stop sorting first)":"Pin (sort first in the sidebar)",className:`shrink-0 mr-1 p-1 rounded transition-colors cursor-pointer ${y.isPinned?"text-ink/70 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10 opacity-0 group-hover:opacity-100 focus-visible:opacity-100"}`,children:y.isPinned?e(_a,{size:12}):e(cl,{size:12})})]},y.id)})]})]})}function ui({project:t,canDelete:r,isDeleting:l=!1,onDelete:c}){return e("div",{className:"flex items-start justify-between gap-4 pb-4 border-b border-ink/10",children:[e("div",{className:"min-w-0 flex-1",children:[e("h2",{className:"text-xl font-bold tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-[11px] font-mono text-ink/50 truncate mt-0.5 select-all",children:t.path||"Not bound to a directory"})]}),r&&e("button",{type:"button",onClick:c,disabled:l,title:"Delete this project",className:"inline-flex items-center gap-1.5 shrink-0 px-2.5 py-1.5 text-[11px] font-medium text-ink/50 hover:text-error hover:bg-error/10 rounded-md transition-colors cursor-pointer disabled:opacity-50",children:[e(M,{size:13}),e("span",{children:"Delete"})]})]})}function bi({name:t,disabled:r=!1,onCommit:l}){let[c,p]=n(t);return i(()=>{p(t)},[t]),e("div",{className:"space-y-2",children:[e("label",{htmlFor:"project-name-input",className:"block text-xs font-semibold text-ink",children:"Project name"}),e("input",{id:"project-name-input",type:"text",value:c,disabled:r,onChange:(h)=>p(h.currentTarget.value),onBlur:()=>{let h=c.trim();if(!h){p(t);return}if(h===t)return;l(h)},onKeyDown:(h)=>{if(h.key==="Enter")h.preventDefault(),h.currentTarget.blur();if(h.key==="Escape")p(t),h.currentTarget.blur()},placeholder:"Enter project name…",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:"Names are unique: the sidebar identifies a project by it."})]})}function fi({path:t,disabled:r=!1,onCommit:l,onReveal:c,isRevealing:p=!1}){let[g,h]=n(t),[v,x]=n(!1);i(()=>{h(t)},[t]);let y=(k)=>{let T=k.trim();if(T===t)return;l(T)};return e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("label",{htmlFor:"project-path-input",className:"block text-xs font-semibold text-ink",children:"Project directory"}),e("div",{className:"flex items-center gap-1",children:[e("button",{type:"button",onClick:()=>x(!0),disabled:r,className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50",children:[e(Dn,{size:11}),e("span",{children:"Browse…"})]}),e("button",{type:"button",onClick:c,disabled:r||!t||p,title:t?"Reveal in the file manager":"This project is not bound to a directory",className:"inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40",children:[e(Dt,{size:11}),e("span",{children:"Reveal"})]})]})]}),e("input",{id:"project-path-input",type:"text",value:g,disabled:r,onChange:(k)=>h(k.currentTarget.value),onBlur:()=>y(g),onKeyDown:(k)=>{if(k.key==="Enter")k.preventDefault(),k.currentTarget.blur();if(k.key==="Escape")h(t),k.currentTarget.blur()},placeholder:"~ or /absolute/path, or leave empty for an unbound grouping",spellcheck:!1,className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"}),e("p",{className:"text-[11px] text-ink/50",children:t?"Sessions found under this directory appear in the project. One directory can belong to one project.":"Not bound to a directory: this project groups chats only and discovers no sessions."}),v&&e(ys,{initialPath:t||void 0,onSelect:(k)=>{x(!1),h(k),y(k)},onClose:()=>x(!1)})]})}function vi({model:t,models:r,onSelectModel:l,disabled:c=!1}){let[p,g]=n(!1),[h,v]=n(""),x=o(null);ce(x,()=>g(!1));let y=Sg(t,r)??"Inherit Kabmo’s default",k=u(()=>{let S=h.trim().toLowerCase();if(!S)return r;return r.filter((R)=>R.name.toLowerCase().includes(S)||R.id.toLowerCase().includes(S)||R.provider.toLowerCase().includes(S))},[r,h]),T=(S)=>{l(S),g(!1),v("")};return e("div",{className:"space-y-2.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Defaults for new chats"}),e("span",{className:"inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help",title:"The model a chat started in this project uses until you pick another one in the composer.",children:e(pe,{size:12})})]}),e("div",{className:"flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg",children:[e("div",{className:"min-w-0",children:[e("div",{className:"text-xs font-medium text-ink",children:"Project model"}),e("div",{className:"text-[11px] text-ink/50",children:r.length===0?"No model catalog yet — connect a provider first.":"Applied when the project starts a chat."})]}),e("div",{className:"relative shrink-0",ref:x,children:[e("button",{type:"button",onClick:()=>g((S)=>!S),disabled:c,className:"flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50",children:[e(Le,{size:13,className:"text-ink/70 shrink-0"}),e("span",{className:"truncate",children:y}),e(B,{size:13,className:"text-ink/50 shrink-0"})]}),p&&e("div",{className:"glass-popover absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden",children:[e("div",{className:"flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 shrink-0"}),e("input",{autoFocus:!0,value:h,onInput:(S)=>v(S.currentTarget.value),placeholder:"Search models…",className:"flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"})]}),e("div",{className:"max-h-64 scrollbar-overlay-container py-1",children:[e("button",{type:"button",onClick:()=>T(nc),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:t===nc?"font-semibold text-ink":"text-ink/80",children:"Inherit Kabmo’s default"}),t===nc&&e(f,{size:13,className:"text-ink"})]}),k.length===0?e("p",{className:"px-3 py-2 text-[11px] text-ink/50",children:r.length===0?"The catalog is empty.":`No model matches “${h.trim()}”.`}):k.map((S)=>{let R=_g({provider:S.provider,modelId:S.id}),P=t===R;return e("button",{type:"button",onClick:()=>T(R),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer",children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:`truncate text-xs ${P?"font-semibold text-ink":"text-ink/85"}`,children:S.name}),e("span",{className:"truncate text-[10.5px] text-ink/45",children:S.provider})]}),P&&e(f,{size:13,className:"text-ink shrink-0"})]},R)})]}),t!==nc&&e("button",{type:"button",onClick:()=>T(nc),className:"w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(b,{size:11}),e("span",{children:"Clear the project model"})]})]})]})]})]})}function xi({accentColor:t,onSelectColor:r,options:l=jf,disabled:c=!1}){let p=l.length>0?l:jf,g=t.trim().toLowerCase(),h=p.some((L)=>L.value!==""&&L.value.toLowerCase()===g),v=g!==""&&!h,x=Jp(g)??Yp,[y,k]=n(x);i(()=>k(x),[x]);let T=(L)=>{let N=Jp(L);if(N===null){k(x);return}if(k(N),N!==g)r(N)},S=o(null),R=o(null),P=o({commit:T,clear:()=>r("")});return P.current={commit:T,clear:()=>r("")},i(()=>{let L=S.current,N=R.current;if(!L||!N)return;let E=(_)=>k(_.target.value.toLowerCase()),A=(_)=>P.current.commit(_.target.value),O=()=>{let _=N.value.trim();if(_==="")P.current.clear();else P.current.commit(_)},U=(_)=>{if(_.key==="Enter")_.preventDefault(),O();if(_.key==="Escape")k(x)};return L.addEventListener("input",E),L.addEventListener("change",A),N.addEventListener("blur",O),N.addEventListener("keydown",U),()=>{L.removeEventListener("input",E),L.removeEventListener("change",A),N.removeEventListener("blur",O),N.removeEventListener("keydown",U)}},[x]),e("div",{className:"space-y-2.5",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Accent colour"}),e("div",{className:"flex flex-wrap items-center gap-2.5",children:p.map((L)=>{let N=g===L.value.toLowerCase();if(L.value==="")return e("button",{type:"button",onClick:()=>r(""),disabled:c,"aria-label":"No accent colour","aria-pressed":N,title:"No accent colour",className:`w-7 h-7 rounded-full border flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${N?"border-ink bg-ink/10 ring-2 ring-ink/30 ring-offset-2 ring-offset-paper":"border-ink/25 bg-paper hover:border-ink/50 text-ink/60"}`,children:e(b,{size:12,strokeWidth:2.2})},"none");return e("button",{type:"button",onClick:()=>r(L.value),disabled:c,"aria-label":L.label,"aria-pressed":N,title:L.label,style:{backgroundColor:L.bgHex},className:`w-7 h-7 rounded-full transition-all cursor-pointer shadow-2xs disabled:opacity-50 ${N?"ring-2 ring-ink ring-offset-2 ring-offset-paper scale-105":"hover:scale-105 opacity-90 hover:opacity-100"}`},L.value)})}),e("div",{className:"flex items-center gap-2 pt-0.5",children:[e("label",{title:"Pick a custom accent colour",className:`relative w-7 h-7 shrink-0 rounded-full border overflow-hidden cursor-pointer transition-all ${v?"ring-2 ring-ink ring-offset-2 ring-offset-paper":"border-ink/25 hover:border-ink/50"} ${c?"opacity-50 pointer-events-none":""}`,children:[e("span",{"aria-hidden":"true",className:"absolute inset-0",style:{backgroundColor:y}}),e(rr,{size:12,strokeWidth:2.2,"aria-hidden":"true",className:"absolute inset-0 m-auto text-white/90 mix-blend-difference pointer-events-none"}),e("input",{ref:S,type:"color",value:Jp(y)??Yp,disabled:c,"aria-label":"Custom accent colour",className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]}),e("input",{ref:R,type:"text",value:y,disabled:c,spellcheck:!1,"aria-label":"Custom accent colour hex",placeholder:Yp,onInput:(L)=>k(L.currentTarget.value),className:"w-[86px] bg-paper border border-ink/20 rounded-md px-2 py-1 text-[11px] font-mono text-ink outline-none focus:border-ink/60 transition-colors disabled:opacity-50"}),e("span",{className:"text-[11px] text-ink/45",children:v?"Custom accent":"Pick any colour"})]})]})}var Ln=128,wp=700000;async function Pp(t){let r=Promise.withResolvers(),l=new FileReader;l.onload=(R)=>{let P=R.target?.result;if(typeof P==="string"&&P)r.resolve(P);else r.reject(Error("That file could not be read as an image."))},l.onerror=()=>r.reject(Error("That file could not be read as an image.")),l.readAsDataURL(t);let c=await r.promise;if(t.type==="image/svg+xml")return c;let p=Promise.withResolvers(),g=new Image;g.onload=()=>p.resolve(g),g.onerror=()=>p.reject(Error("That file is not an image Kabmo can read.")),g.src=c;let h=await p.promise,v=Math.min(1,Ln/Math.max(h.naturalWidth,h.naturalHeight)),x=Math.max(1,Math.round(h.naturalWidth*v)),y=Math.max(1,Math.round(h.naturalHeight*v)),k=document.createElement("canvas");k.width=x,k.height=y;let T=k.getContext("2d");if(!T)return c;T.drawImage(h,0,0,x,y);let S=k.toDataURL("image/png");return S.length>0&&S.length<c.length?S:c}function yi({currentIcon:t,customIconUrl:r,projectName:l,onSelectIcon:c,onSetCustomIcon:p,disabled:g=!1}){let h=o(null),[v,x]=n(!1),[y,k]=n(!1),[T,S]=n(null),R=async(N)=>{let E=N.currentTarget.files?.[0];if(N.currentTarget.value="",!E)return;S(null),k(!0);try{let A=await Pp(E);if(A.length>wp){S("That image is too detailed to store as a mark — try a PNG or SVG.");return}p(A)}catch(A){S(A instanceof Error?A.message:String(A))}finally{k(!1)}},P=()=>{let E=`https://api.dicebear.com/7.x/identicon/svg?seed=${l.toLowerCase().replace(/[^a-z0-9]/g,"")||"project"}&radius=50&size=${Ln}`;S(null),x(!0);let A=new Image;A.onload=()=>{x(!1),p(E)},A.onerror=()=>{x(!1),S("The generated icon could not be loaded — check your connection.")},A.src=E},L=g||y||v;return e("div",{className:"space-y-3",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("h4",{className:"text-xs font-semibold text-ink",children:"Project icon"}),r&&e("button",{type:"button",onClick:()=>p(void 0),disabled:L,className:"text-[11px] text-ink/50 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:"Use a standard icon"})]}),e("div",{className:"flex flex-wrap gap-1.5",children:Ig.map((N)=>{let E=!r&&t===N.id,A=N.icon;return e("button",{type:"button",onClick:()=>c(N.id),disabled:L,"aria-label":N.label,"aria-pressed":E,title:N.label,className:`w-7 h-7 rounded-md flex items-center justify-center transition-all cursor-pointer disabled:opacity-50 ${E?"border border-ink/40 bg-ink/5 text-ink shadow-2xs":"border border-transparent text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:e(A,{size:14,strokeWidth:1.8})},N.id)})}),e("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[e("input",{type:"file",ref:h,onChange:(N)=>void R(N),accept:"image/png,image/jpeg,image/svg+xml,image/webp,image/gif",className:"hidden"}),e("button",{type:"button",onClick:()=>h.current?.click(),disabled:L,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[y?e(m,{size:13,className:"animate-spin text-ink/60"}):e($o,{size:13,className:"text-ink/60"}),e("span",{children:y?"Reading…":"Upload image"})]}),e("button",{type:"button",onClick:P,disabled:L,title:"Generate a stable identicon from the project name",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs disabled:opacity-50",children:[v?e(m,{size:13,className:"animate-spin text-ink/60"}):e(zo,{size:13,className:"text-ink/60"}),e("span",{children:v?"Generating…":"Generate mark"})]}),r&&e("div",{className:"flex items-center gap-2 ml-1 pl-2 border-l border-ink/10",children:[e("img",{src:r,alt:"Current custom icon",className:"w-5 h-5 rounded-xs object-contain border border-ink/15",referrerPolicy:"no-referrer"}),e("span",{className:"text-[11px] text-ink/60",children:"Custom icon in use"}),e("button",{type:"button",onClick:()=>p(void 0),disabled:L,"aria-label":"Remove the custom icon",className:"p-0.5 rounded text-ink/40 hover:text-error transition-colors cursor-pointer disabled:opacity-50",children:e(b,{size:12})})]})]}),e("p",{className:"text-[11px] text-ink/50",children:["Any image works — it is scaled down to a ",Ln,"px mark. PNG, JPEG, WebP, GIF or SVG."]}),T&&e("p",{className:"text-[11px] text-error",children:T})]})}function Si({project:t,canDelete:r,isDeleting:l=!1,isRevealing:c=!1,models:p,accentColorOptions:g,onUpdateField:h,onUpdateFields:v,onReveal:x,onDeleteProject:y}){return e("div",{className:"p-6 md:p-8 space-y-7",children:[e(ui,{project:t,canDelete:r,isDeleting:l,onDelete:y}),e(bi,{name:t.name,onCommit:(k)=>h("name",k)}),e(fi,{path:t.path,onCommit:(k)=>h("path",k),onReveal:x,isRevealing:c}),e(vi,{model:t.model,models:p,onSelectModel:(k)=>h("model",k)}),e(xi,{accentColor:t.accentColor,onSelectColor:(k)=>h("accentColor",k),...g&&g.length>0?{options:g}:{}}),e(yi,{currentIcon:t.icon,customIconUrl:t.customIconUrl,projectName:t.name,onSelectIcon:(k)=>v({icon:k,customIconUrl:void 0}),onSetCustomIcon:(k)=>v({customIconUrl:k,icon:k===void 0?"default":"custom"})})]})}function Cp(t){return(t.replace(/[\\/]+$/,"").split(/[\\/]/).pop()??"").toLowerCase()}function Ip({isSaving:t,onClose:r,onSubmit:l}){let[c,p]=n(""),[g,h]=n(""),[v,x]=n(!1),[y,k]=n(!0),[T,S]=n(null),R=(L)=>{if(h(L),y||!c.trim())p(Cp(L)),k(!0)},P=async()=>{let L=c.trim();if(!L){S("Enter a project name.");return}S(null);try{await l({name:L,path:g.trim()}),r()}catch(N){S(N instanceof Error?N.message:String(N))}};return e(d,{children:e(J,{onClose:t?()=>{}:r,ariaLabel:"Add project",maxWidthClass:"max-w-[480px]",header:e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Add project"}),e("p",{className:"text-[11px] text-ink/50",children:"A name, and the directory its chats run in."})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,disabled:t,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:()=>void P(),disabled:t,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 inline-flex items-center gap-1.5",children:[t&&e(m,{size:13,className:"animate-spin"}),e("span",{children:t?"Adding…":"Add project"})]})]}),children:[e("div",{className:"px-5 py-4 space-y-4",children:[e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-name",className:"block text-xs font-semibold text-ink",children:"Name"}),e("input",{id:"add-project-name",type:"text",value:c,onInput:(L)=>{p(L.currentTarget.value),k(!1)},placeholder:"e.g. kabmo",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs text-ink outline-none focus:border-ink/60 transition-colors"}),e("p",{className:"text-[11px] text-ink/50",children:"Unique: the sidebar identifies a workspace by it."})]}),e("div",{className:"space-y-1.5",children:[e("label",{htmlFor:"add-project-path",className:"block text-xs font-semibold text-ink",children:["Directory ",e("span",{className:"text-ink/40 font-normal",children:"(optional)"})]}),e("div",{className:"flex items-center gap-2",children:[e("input",{id:"add-project-path",type:"text",value:g,onInput:(L)=>h(L.currentTarget.value),placeholder:"~ or /absolute/path",spellcheck:!1,className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors"}),e("button",{type:"button",onClick:()=>x(!0),className:"shrink-0 inline-flex items-center gap-1 px-2.5 py-2 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer",children:[e(Dt,{size:12}),e("span",{children:"Browse…"})]})]}),e("p",{className:"text-[11px] text-ink/50",children:"Sessions under this directory are listed in the project. Leave it empty for a grouping with no directory behind it."})]}),T&&e("p",{className:"text-[11px] text-error",children:T})]}),v&&e(ys,{initialPath:g||void 0,onSelect:(L)=>{R(L),x(!1)},onClose:()=>x(!1)})]})})}function Ni({isOpen:t,isSaving:r,onClose:l,onSubmit:c}){if(!t)return null;return e(Ip,{isSaving:r,onClose:l,onSubmit:c})}function Pi({project:t,isDeleting:r,error:l,onClose:c,onConfirm:p}){if(i(()=>{let g=(h)=>{if(h.key!=="Escape"||r)return;h.preventDefault(),c()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[c,r]),!t)return null;return e(J,{onClose:r?()=>{}:c,zClass:"z-[70]",maxWidthClass:"max-w-[440px]",ariaLabel:"Delete project",header:e("div",{className:"flex items-center gap-3 min-w-0",children:[e(M,{size:16,className:"text-error shrink-0"}),e("div",{className:"min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Delete project?"}),e("p",{className:"text-[11px] text-ink/50 truncate",children:t.name})]})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-5 py-3.5 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,disabled:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-50",children:"Cancel"}),e("button",{type:"button",onClick:p,disabled:r,className:"px-3.5 py-1.5 rounded-md bg-error text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:[r?e(m,{size:13,className:"animate-spin"}):e(M,{size:13}),e("span",{children:r?"Deleting…":"Delete project"})]})]}),children:e("div",{className:"px-5 py-4 space-y-3",children:[e("ul",{className:"text-[11.5px] leading-relaxed text-ink/70 space-y-1.5",children:[e("li",{children:"The workspace is unregistered from Kabmo — its place in the sidebar, its chats' grouping and its settings go."}),e("li",{children:t.path?"The directory itself is NOT deleted; a tombstone keeps omp discovery from re-adding it on the next boot.":"It has no directory, so nothing on disk is touched."}),e("li",{children:"Chat transcripts stay on disk under ~/.omp/agent/sessions."})]}),l&&e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md border border-error/30 bg-error/5 text-[11px] text-ink/75",children:[e(D,{size:13,className:"mt-0.5 shrink-0 text-error"}),e("span",{children:l})]})]})})}var On="worktreeDirectory",Un="worktreeCarryIgnored";function Ci(t){if(t.missing)return"folder is missing — its chats still open";let r=t.detached?`detached @ ${t.head.slice(0,7)||"unknown"}`:`${t.branch} checked out here`,l=t.sessions===1?"1 chat":`${t.sessions} chats`,c=t.dirty===0?"clean":`${t.dirty} changed`;return`${r} · ${l} · ${c}`}function Ti(t){return!t.detached&&Boolean(t.branch)&&t.aheadOfStart===0}function Fn(t){if(t.isPrimary)return"The main checkout cannot be removed.";if(t.dirty>0)return`${t.dirty} uncommitted file${t.dirty===1?"":"s"} here would be lost.`;return null}function Ii({root:t,folderId:r,onReport:l}){let{worktrees:c,base:p,loading:g,error:h,isRepo:v,refresh:x}=Zp({root:t,folderId:r},Boolean(t)),[y,k]=n(()=>{let N=H(On);return typeof N==="string"?N:""}),[T,S]=n(()=>H(Un)!==!1),[R,P]=n(null);if(!t)return e("p",{className:"text-xs text-ink/50",children:"Bind this workspace to a repository to manage its worktrees."});let L=c.filter((N)=>!N.isPrimary);return e("div",{className:"flex flex-col gap-4",children:[e("section",{className:"flex flex-col gap-1",children:[e("h3",{className:"text-xs font-semibold text-ink",children:"Worktrees"}),g&&e("p",{className:"text-[11px] text-ink/50",children:"Reading worktrees…"}),h&&e("p",{className:"text-[11px] text-error",title:h,children:["Worktrees could not be read: ",h]}),!g&&!h&&v===!1&&e("p",{className:"text-[11px] text-ink/50",children:"Worktrees need a Git repository."}),!g&&!h&&v!==!1&&L.length===0&&e("p",{className:"text-[11px] text-ink/50",children:"No worktrees yet."}),L.map((N)=>e("div",{className:"group flex items-center gap-2 rounded-md px-1 py-1.5 hover:bg-ink/5",children:[e("div",{className:"min-w-0 flex-1",children:[e("p",{className:"truncate text-xs text-ink",children:N.branch||"detached"}),e("p",{className:"truncate text-[10.5px] text-ink/50",title:N.path,children:Ci(N)})]}),e("button",{type:"button",disabled:R===N.path||Fn(N)!==null,"aria-label":`Remove worktree ${N.branch||N.path}`,title:Fn(N)??"Remove worktree",onClick:()=>{P(N.path),Tg({root:t,folderId:r},N.path,{deleteBranch:Ti(N)}).then((E)=>(l(E.branchDeleted?`Removed ${N.branch} and its branch`:`Removed ${N.branch}${E.branchKept?" (branch kept)":""}`,"success"),x())).catch((E)=>l(E instanceof Error?E.message:String(E),"error")).finally(()=>P(null))},className:"shrink-0 rounded px-2 py-1 text-[11px] text-ink/60 hover:bg-error/10 hover:text-error disabled:opacity-40",children:"Remove"})]},N.path))]}),e("label",{className:"flex flex-col gap-1",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Worktree location"}),e("input",{value:y,onChange:(N)=>k(N.currentTarget.value),onBlur:()=>At(On,y.trim()),placeholder:p,className:"h-8 rounded-md border border-ink/15 bg-paper px-2 text-xs text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10.5px] text-ink/50",children:["Where new worktrees are created. Relative paths are resolved against the project; ~ is your home directory. Empty uses ",p,"."]})]}),e("label",{className:"flex items-start gap-2",children:[e("input",{type:"checkbox",checked:T,onChange:(N)=>{let E=N.currentTarget.checked;S(E),At(Un,E)},className:`${ge} mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-xs font-semibold text-ink",children:"Copy ignored files into new worktrees"}),e("span",{className:"text-[10.5px] text-ink/50",children:"A new worktree gets the project's ignored build folders (node_modules, .venv, target) copied in, so it works without reinstalling."})]})]})]})}var Ap={full:"flex h-full w-full items-center justify-center text-xs text-ink/40",fill:"flex-1 flex items-center justify-center text-xs text-ink/40"},Ae=({variant:t="full",children:r})=>e("div",{className:Ap[t],children:r});var Ht="";function Ri(t){if(!w(t))return!1;return typeof t.id==="string"&&typeof t.name==="string"&&typeof t.path==="string"}function Rp(t){if(!w(t))return!1;return typeof t.label==="string"&&typeof t.value==="string"&&typeof t.bgHex==="string"}function Mp(t,r){return t.some((c)=>c.id===r.id)?t.map((c)=>c.id===r.id?r:c):[...t,r]}function Mi(t){let[r,l]=n([]),[c,p]=n([]),[g,h]=n(Ht),[v,x]=n(!0),[y,k]=n(null),[T,S]=n(!1),[R,P]=n(!1),L=o(t);L.current=t;let N=a((j)=>{if(!w(j))return;let G=Array.isArray(j.projects)?j.projects.filter(Ri):null;if(G)l(G),h((Q)=>G.some((te)=>te.id===Q)?Q:G[0]?.id??Ht);if(Array.isArray(j.accentColorOptions))p(j.accentColorOptions.filter(Rp))},[]),E=a(async()=>{try{let j=await fetch("/api/settings/projects"),G=await j.json();if(!j.ok){let Q=w(G)&&typeof G.error==="string"?G.error:`HTTP ${j.status}`;k(Q);return}k(null),N(G)}catch(j){k(j instanceof Error?j.message:String(j))}},[N]);i(()=>{let j=!0;return(async()=>{if(await E(),j)x(!1)})(),()=>{j=!1}},[E]);let A=je().folders,O=u(()=>A.map((j)=>`${j.id}:${j.name}:${j.model??""}:${j.icon??""}:${j.accentColor??""}:${j.project_path??""}:${j.isPinned?1:0}`).join("|"),[A]);i(()=>{if(!O)return;E()},[O,E]);let U=a(async(j,G)=>{if(j.folderId===void 0)return L.current("This project has no workspace row to save to."),!1;let Q=r;l((Z)=>Z.map((X)=>X.id===j.id?{...X,...G}:X));let te={folderId:j.folderId};for(let[Z,X]of Object.entries(G))te[Z]=X===void 0?null:X;try{let Z=await fetch("/api/settings/projects",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:te})}),X=await Z.json().catch(()=>null);if(!Z.ok){let oe=w(X)&&typeof X.error==="string"?X.error:`HTTP ${Z.status}`;throw Error(oe)}let re=w(X)&&Ri(X.project)?X.project:null;if(re)l((oe)=>Mp(oe,re));return!0}catch(Z){return l(Q),L.current(Z instanceof Error?Z.message:String(Z)),!1}},[r]),_=a((j,G,Q)=>U(j,{[G]:Q}),[U]),K=a((j,G)=>U(j,G),[U]),V=a(async(j)=>{S(!0);try{let G=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:j.name,path:j.path})}),Q=await G.json().catch(()=>null),te=w(Q)?Q.folder:null,Z=w(te)&&typeof te.id==="number"?te.id:null;if(!G.ok||!w(Q)||Q.success!==!0||Z===null){let X=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${G.status}`;throw Error(X)}await E(),h(`folder-${Z}`)}catch(G){throw L.current(G instanceof Error?G.message:String(G)),G}finally{S(!1)}},[E]),z=a(async(j)=>{P(!0);try{let G=await fetch(`/api/settings/projects?id=${encodeURIComponent(j.id)}`,{method:"DELETE"}),Q=await G.json().catch(()=>null);if(!G.ok||!w(Q)||Q.success!==!0){let te=w(Q)&&typeof Q.error==="string"?Q.error:`HTTP ${G.status}`;throw Error(te)}l((te)=>{let Z=te.filter((X)=>X.id!==j.id);return h((X)=>X===j.id?Z[0]?.id??Ht:X),Z})}catch(G){throw L.current(G instanceof Error?G.message:String(G)),G}finally{P(!1)}},[]),W=ja((j)=>Array.isArray(j.modelList)&&j.modelList.length>0?j.modelList.map((G)=>({provider:G.provider,id:G.id,name:G.name||G.id})):void 0)??[],q=r.find((j)=>j.id===g)??r[0]??null;return{projects:r,selected:q,selectedId:q?.id??Ht,select:h,accentColorOptions:c,models:W,isLoading:v,loadError:y,refresh:E,updateField:_,updateFields:K,isAdding:T,addProject:V,isDeleting:R,deleteProject:z,onError:t}}function Li(){let t=ye(),{pushToast:r}=Ve(),[l,c]=n(!1),[p,g]=n(null),[h,v]=n(null),[x,y]=n(null),k=Mi((L)=>r(L,"error",{duration:7000})),{folders:T}=je(),S=async(L)=>{if(!L.path||L.folderId===void 0){r("This project is not bound to a directory.","error");return}y(L.id);try{let N=await fetch(`/api/folders/${L.folderId}/open`,{method:"POST"}),E=await N.json().catch(()=>null);if(!N.ok){let A=E&&typeof E==="object"&&"error"in E&&typeof E.error==="string"?E.error:`HTTP ${N.status}`;throw Error(A)}}catch(N){r(N instanceof Error?N.message:String(N),"error")}finally{y(null)}},R=async()=>{if(!p)return;v(null);try{await k.deleteProject(p),g(null),t.back()}catch(L){v(L instanceof Error?L.message:String(L))}};if(k.isLoading)return e(Ae,{children:"Loading projects…"});let P=k.selected;return e("div",{className:"w-full h-full flex flex-col overflow-hidden bg-paper text-ink",children:[e(we,{pane:t.pane,onBack:t.back,listLabel:"Projects",list:e(pi,{projects:k.projects,selectedProjectId:P?.id??"",onSelectProject:(L)=>{k.select(L),t.openDetail()},onAddProject:()=>c(!0),onTogglePin:(L)=>{k.updateField(L,"isPinned",!L.isPinned)},isAdding:k.isAdding,folderFacts:T,loadError:k.loadError}),detail:P?e("div",{className:"flex-1 min-h-0 scrollbar-overlay-container flex flex-col",children:[e(Si,{project:P,canDelete:k.projects.length>1,isDeleting:k.isDeleting&&p?.id===P.id,isRevealing:x===P.id,models:k.models,accentColorOptions:k.accentColorOptions,onUpdateField:(L,N)=>{k.updateField(P,L,N)},onUpdateFields:(L)=>{k.updateFields(P,L)},onReveal:()=>void S(P),onDeleteProject:()=>{v(null),g(P)}}),e("div",{className:"border-t border-ink/10 px-6 md:px-8 py-4",children:e(Ii,{root:P.path||null,folderId:P.folderId??null,onReport:(L,N)=>r(L,N??"success",{duration:6000})})})]}):e("div",{className:"flex-1 flex items-center justify-center px-6 text-center",children:e("div",{className:"space-y-2",children:[e("p",{className:"text-xs text-ink/60",children:"No project selected."}),e("button",{type:"button",onClick:()=>c(!0),className:"text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer",children:"Add a project"})]})})}),e(Ni,{isOpen:l,isSaving:k.isAdding,onClose:()=>c(!1),onSubmit:async(L)=>{await k.addProject(L),t.openDetail()}}),e(Pi,{project:p,isDeleting:k.isDeleting,error:h,onClose:()=>{g(null),v(null)},onConfirm:()=>void R()})]})}function Oi(t){return t!==void 0&&(t.status==="connected"||Boolean(t.baseUrl))}function Di(t){return t.filter((r)=>r.slug.trim().length>0&&Oi(r)).map((r)=>r.slug)}function Ui(t,r){let l=new Map;for(let g of t){let h=g.slug.trim().toLowerCase();if(h)l.set(h,g)}let c=new Set,p=[];for(let g of r){let h=g.slug.trim().toLowerCase();if(c.has(h))continue;if(!g.bundled&&Oi(l.get(h)))continue;c.add(h),p.push(g)}return p}function Fi(t){let r=[];for(let l of t){let c=r.find((p)=>p.group===l.group);if(c)c.options.push(l);else r.push({group:l.group,options:[l]})}return r}var ji="/api/settings/providers";async function $i(t){let r=await fetch(ji,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)throw Error(l?.error||`Providers request failed (HTTP ${r.status})`);return Vr(),Array.isArray(l.providers)?l.providers:null}function _i(t){return $i({providers:t})}function Bi(t,r){return $i(r?{enableProvider:t}:{disableProvider:t})}async function zi(t,r){try{let l=await fetch("/api/settings/provider-entry",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,...r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??c.reason??`HTTP ${l.status}`};return Vr(),{...c,ok:!0}}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while saving the provider"}}}async function Hi(t,r){try{let l=await fetch("/api/provider-icon",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:t,baseUrl:r})}),c=await l.json();if(!l.ok)return{ok:!1,error:c.error??`HTTP ${l.status}`};return c}catch(l){return{ok:!1,error:l instanceof Error?l.message:"Network error while fetching the icon"}}}async function Gi(t){try{let r=await fetch("/api/settings/providers/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t?{slug:t}:{})}),l=await r.json();if(!r.ok)return{ok:!1,added:0,removed:0,changed:[],error:l.error??`HTTP ${r.status}`};return Vr(),l}catch(r){return{ok:!1,added:0,removed:0,changed:[],error:r instanceof Error?r.message:"Network error while refreshing models"}}}async function Wi(t){try{let r=await fetch(`${ji}?id=${encodeURIComponent(t)}`,{method:"DELETE"}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Delete failed (HTTP ${r.status})`};return Vr(),{...l,ok:!0}}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while deleting the provider"}}}function qi(t,r){if(t.modelSource==="discovery")return{text:`${t.name} registered — omp discovers its models on each run.`,tone:"success"};if(t.modelSource==="override")return{text:`${t.name} endpoint registered — omp keeps its own model list for this provider.`,tone:"success"};if(r.fetchedCount>0)return{text:`Fetched ${r.fetchedCount} new model${r.fetchedCount===1?"":"s"} from the provider.`,tone:"success"};if(r.fetchedCount===-1)return{text:r.ompNote?`Provider registered, but models could not be listed: ${r.ompNote}`:"Auto-fetch models failed — provider added with default models.",tone:"warning"};return{text:`${t.name} registered — no new models to add.`,tone:"success"}}function Vi(t){let r=(l)=>l===1?"":"s";if(t.addedCount>0&&t.removedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} and removed ${t.removedCount} the provider no longer serves.`,tone:"success"};if(t.addedCount>0)return{text:`Fetched ${t.addedCount} new model${r(t.addedCount)} from the provider.`,tone:"success"};if(t.removedCount>0)return{text:`Removed ${t.removedCount} model${r(t.removedCount)} the provider no longer serves.`,tone:"success"};return{text:"Models refreshed — the list already matches the provider.",tone:"success"}}function Ji(t){if(!t.omp)return null;if(t.omp.written){let r=[];if(t.omp.addedCount>0)r.push(`${t.omp.addedCount} new model${t.omp.addedCount===1?"":"s"} registered`);if(t.omp.backfilledCount>0)r.push(`${t.omp.backfilledCount} model${t.omp.backfilledCount===1?"":"s"} enriched`);if((t.omp.removedCount??0)>0)r.push(`${t.omp.removedCount} model${t.omp.removedCount===1?"":"s"} removed`);return{text:`omp models.yml updated${r.length>0?`: ${r.join(", ")}`:""}.`,tone:"success"}}if(t.omp.reason)return{text:`omp models.yml not updated: ${t.omp.reason}`,tone:"warning"};return null}function Qi(t,r){let l=(c)=>c===1?"":"s";if(r.added>0||r.removed>0){let c=[];if(r.added>0)c.push(`${r.added} new model${l(r.added)}`);if(r.removed>0)c.push(`${r.removed} model${l(r.removed)} gone`);return{text:`${t}: ${c.join(", ")} after omp re-ran discovery.`,tone:"success"}}return{text:`${t}: omp re-ran discovery — this provider's list is unchanged.`,tone:"success"}}async function mt(){try{let r=await(await fetch("/api/settings/providers")).json();if(!Array.isArray(r?.providers))return null;return{providers:r.providers,...r.presetProviders?{presetProviders:r.presetProviders}:{},...typeof r.catalogError==="string"?{catalogError:r.catalogError}:{}}}catch(t){return console.error("Failed to load providers from API:",t),null}}async function Zi(t,r,l){let c={provider:t,modelId:r};if("maxTokens"in l)c.maxTokens=l.maxTokens??null;if("reasoningEffort"in l)c.reasoningEffort=l.reasoningEffort??null;if(Object.keys(c).length===2)return{ok:!0,written:!1};try{let p=await fetch("/api/settings/model-override",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),g=await p.json();if(!p.ok)return{ok:!1,error:g.error||"Failed to save the model configuration."};return{ok:!0,written:g.written,reason:g.reason}}catch(p){return console.error("Failed to save model override:",p),{ok:!1,error:"Failed to save the model configuration."}}}function ta(t){let{providers:r,selectedProvider:l,isDeletingProvider:c,pushToast:p,setProviders:g,setSelectedProviderId:h,setIsAddModalOpen:v,setIsDeleteModalOpen:x,setIsDeletingProvider:y,openLogin:k,openEntryEditor:T,onAddModalClose:S}=t,R=async(K)=>{g(K);try{let V=await _i(K);if(V)g(V)}catch(V){console.error("Failed to save providers via API:",V),p("Failed to save provider settings.","error")}},P=async()=>{let K=await mt();if(K)g(K.providers);return K?.providers??[]},L=async(K,V)=>{try{let z=await Bi(K,V);if(z)g(z);return z}catch(z){return console.error("Failed to update provider connection:",z),p("Failed to update the provider connection.","error"),null}};return{handleAddProvider:async(K,V)=>{let z=K.slug.trim().toLowerCase(),W=r.filter((Q)=>Q.slug.trim().toLowerCase()!==z);await R([...W,K]);let j=(await L(K.slug,!0))?.find((Q)=>Q.slug.trim().toLowerCase()===z);h(j?.id||K.id),v(!1),S?.();let G=qi(K,V);p(G.text,G.tone)},handleConnect:(K)=>{if(!l)return;if(K==="login")k();else T()},handleEntrySaved:async(K)=>{if(!l)return;p(K.length>0?`${l.name}: updated ${K.join(", ")} in models.yml.`:`${l.name}: nothing to change.`,"success"),await P()},handleOmpAuthSuccess:async()=>{if(!l)return;let K=l.slug;p(`${l.name} signed in — omp stored the credential.`,"success");let z=(await P()).find((W)=>W.slug===K);if(z)h(z.id)},handleToggleProviderDisabled:async()=>{if(!l)return;let K=l,V=K.disabled!==!0;if(!await L(K.slug,!V))return;p(V?`${K.name} disabled — it no longer appears in the model list.`:`${K.name} enabled — its models are offered again.`,"success")},handleDeleteProvider:async(K)=>{let V=K??l;if(!V||c)return;y(!0);try{let z=await Wi(V.id);if(!z.ok){p(z.error||"Failed to delete the provider.","error");return}x(!1);let W=z.providers??[];if(l?.id===V.id)h(W[0]?.id??"");if(g(W),z.warning)p(`${V.name} removed from Kabmo, but models.yml cleanup failed: ${z.warning}`,"warning");else if(z.removedFromOmp){let q=z.modelsRemoved??0;p(`${V.name} deleted from models.yml${q>0?` with its ${q} model${q===1?"":"s"}`:""}.`,"success")}else p(`${V.name} removed from Kabmo.`,"success")}finally{y(!1)}},persistProviders:R,reloadProviders:P}}async function Gt(t){try{let r=await fetch("/api/settings/provider-models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{ok:!1,error:l?.error||`Request failed (HTTP ${r.status})`};return l}catch(r){return{ok:!1,error:r instanceof Error?r.message:"Network error while fetching models"}}}async function na(t){try{let r=await fetch("/api/settings/provider-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await r.json();if(!r.ok)return{...l,success:!1,written:!1,error:l?.error||l?.reason};return Vr(),l}catch(r){return{success:!1,written:!1,error:r instanceof Error?r.message:"Network error while adding the model"}}}function oa(t,r){let l=new Map(t.map((v)=>[v.id,v])),c=new Set,p=[],g=[];for(let v of r){if(!v.id||c.has(v.id))continue;c.add(v.id);let x=l.get(v.id);if(!x){let y={...v};g.push(y),p.push(y);continue}p.push({...v,isVisible:x.isVisible!==!1,...x.temperature!==void 0?{temperature:x.temperature}:{},...x.maxTokens!==void 0?{maxTokens:x.maxTokens}:{},...x.topP!==void 0?{topP:x.topP}:{},...x.reasoningEffort!==void 0?{reasoningEffort:x.reasoningEffort}:{}})}let h=t.filter((v)=>!c.has(v.id)).map((v)=>v.id);return{models:p,added:g,addedCount:g.length,removed:h,removedCount:h.length}}async function ra(t,r){try{await Promise.all(r.map((l)=>fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"addModel",model:{id:l.id,name:l.name,provider:t,contextWindow:l.contextWindow?.split(" ")[0]||"128K",thinkingLevel:"Default",capabilities:["Tool calling","Reasoning"],inputFormats:["text"],outputFormats:["text"]}})}))),Vr()}catch(l){console.error("Failed to sync provider models to catalog:",l)}}var Lp=/^model-\d+-(?:1|2)$/;function Fp(t){return`${t.name} ${t.slug} ${t.baseUrl||""}`.toLowerCase().includes("kenari")}function ia(t,r){if(!Fp(t))return r;return r.filter((l)=>{let c=l.name.trim().toLowerCase(),p=c==="kenari default model"||c==="kenari fast / flash";return!(Lp.test(l.id)&&p)})}function aa(t){let{providers:r,selectedProvider:l,isFetchingModels:c,pushToast:p,setProviders:g,setIsFetchingModels:h,persistProviders:v,reloadProviders:x}=t,y=async()=>{if(!l||c)return;let N=l;h(!0);try{let E=await Gi(N.slug);if(!E.ok){p(E.error||"omp could not refresh the model catalog.","error");return}if(E.providers)g(E.providers);let A=Qi(N.name,E);p(A.text,A.tone)}finally{h(!1)}},k=async()=>{if(!l||c)return;let N=l;if(!N.baseUrl){p("This provider has no endpoint to import from — use “refresh” instead.","error");return}h(!0);try{let E=await Gt({baseUrl:N.baseUrl,apiKey:N.apiKey,providerSlug:N.slug,persistToOmp:!0,replaceModels:!0,...N.api?{api:N.api}:{},...N.auth?{auth:N.auth}:{}});if(!E.ok||!E.models){p(E.error||"Failed to fetch models from the provider.","error");return}if(E.omp?.written)Vr();let A=ia(N,N.models),O=N.models.length-A.length,{added:U,addedCount:_,removedCount:K}=oa(A,E.models),V=K+O,z=Vi({addedCount:_,removedCount:V});p(z.text,z.tone);let W=Ji(E);if(W)p(W.text,W.tone);if(_>0)ra(N.name,U);await x()}finally{h(!1)}},T=(N)=>{if(!l)return;v(r.map((E)=>E.id===l.id?{...E,models:N(E.models)}:E))};return{handleRefreshModels:y,handleFetchModels:k,handleHideAll:()=>T((N)=>N.map((E)=>({...E,isVisible:!1}))),handleShowAll:()=>T((N)=>N.map((E)=>({...E,isVisible:!0}))),handleToggleModelVisibility:(N)=>T((E)=>E.map((A)=>A.id===N?{...A,isVisible:!A.isVisible}:A)),handleSaveModelConfig:async(N,E)=>{if(!l)return;let A=l;T((U)=>U.map((_)=>_.id===N?{..._,...E}:_));let O=await Zi(A.slug,N,E);if(!O.ok){p(O.error||"Failed to save the model configuration.","error");return}if(O.written)Vr();else if(O.reason)p(O.reason,"error")}}}function sa({autoOpenAdd:t=!1,onAddModalClose:r}={}){let[l,c]=n([]),[p,g]=n([]),[h,v]=n(""),[x,y]=n(null),[k,T]=n(!0),[S,R]=n(!1),[P,L]=n(!1),[N,E]=n(!1),{pushToast:A}=Ve(),[O,U]=n(t),[_,K]=n(!1),[V,z]=n(!1),[W,q]=n(!1),[j,G]=n(!1),[Q,te]=n(!1),[Z,X]=n(!1),[re,oe]=n(null),[be,xe]=n(null);i(()=>{if(t)U(!0)},[t]),i(()=>{let le=!0;return mt().then((me)=>{if(!le)return;if(T(!1),!me)return;c(me.providers),g(me.presetProviders??[]),y(me.catalogError??null);let Ke=me.providers.filter((Ye)=>Ye.status==="connected");v(Ke[0]?.id??me.providers[0]?.id??"")}),()=>{le=!1}},[]),i(()=>{let le=null,me=wa(()=>{if(le)clearTimeout(le);le=setTimeout(()=>{le=null,mt().then((Ke)=>{if(Ke)c(Ke.providers)})},400)});return()=>{if(me(),le)clearTimeout(le)}},[]);let Pe=u(()=>Ui(l,p),[l,p]),ue=u(()=>Di(l),[l]),ve=l.find((le)=>le.id===h)??l[0],Te=ta({providers:l,selectedProvider:ve,isDeletingProvider:j,pushToast:A,setProviders:c,setSelectedProviderId:v,setIsAddModalOpen:U,setIsDeleteModalOpen:z,setIsDeletingProvider:G,openLogin:()=>X(!0),openEntryEditor:()=>te(!0),...r?{onAddModalClose:r}:{}}),ke=aa({providers:l,selectedProvider:ve,isFetchingModels:P,pushToast:A,setProviders:c,setIsFetchingModels:L,persistProviders:Te.persistProviders,reloadProviders:Te.reloadProviders});return{providers:l,availablePresetProviders:Pe,existingSlugs:ue,selectedProvider:ve,catalogError:x,isLoading:k,isRefreshingList:S,handleRefreshList:async()=>{if(S)return;R(!0);try{let le=await mt();if(!le){A("Could not read the provider list — omp may still be starting.","error");return}c(le.providers),g(le.presetProviders??[]),y(le.catalogError??null),v((Ke)=>le.providers.some((Ye)=>Ye.id===Ke)?Ke:le.providers.find((Ye)=>Ye.status==="connected")?.id??le.providers[0]?.id??"");let me=le.providers.length;A(`Provider list refreshed — ${me} provider${me===1?"":"s"}.`,"success")}finally{R(!1)}},isFetchingModels:P,isRefreshingIcon:N,handleRefreshIcon:async()=>{let le=ve;if(!le||N)return;if(!le.baseUrl){A("This provider has no endpoint, so there is no site to read an icon from.","error");return}E(!0);try{let me=await Hi(le.slug,le.baseUrl);if(!me.ok){A(me.error||"No usable icon on that host or its base domain — keeping the current mark.","error");return}let Ye=(await Te.reloadProviders()).find((fc)=>fc.slug===le.slug);if(Ye)v(Ye.id);A(`${le.name}: icon updated from ${le.baseUrl}.`,"success")}finally{E(!1)}},pushToast:A,isAddModelModalOpen:_,setIsAddModelModalOpen:K,handleModelAdded:async(le)=>{A(`${le} registered in models.yml.`,"success"),await Te.reloadProviders()},handleSignedOut:async(le)=>{q(!1),A(le,"success"),await Te.reloadProviders()},isDeleteModalOpen:V,setIsDeleteModalOpen:z,isLogoutModalOpen:W,setIsLogoutModalOpen:q,isDeletingProvider:j,isAddModalOpen:O,setIsAddModalOpen:U,isEntryModalOpen:Q,setIsEntryModalOpen:te,isLoginModalOpen:Z,setIsLoginModalOpen:X,configModel:re,setConfigModel:oe,capabilitiesModel:be,setCapabilitiesModel:xe,setSelectedProviderId:v,...Te,...ke}}function Bp(t){if(t.disabled===!0)return"disabled";if(t.status==="connected")return"connected";return"signed-out"}var Hp=[{id:"connected",label:"Signed in"},{id:"signed-out",label:"Not signed in",hint:"omp knows these providers; pick one to sign in or add its key."},{id:"disabled",label:"Disabled",hint:"Hidden from the model picker."}];function la(t,r=""){let l=r.trim().toLowerCase(),c=l?t.filter((g)=>g.name.toLowerCase().includes(l)||g.slug.toLowerCase().includes(l)||g.models.some((h)=>h.id.toLowerCase().includes(l))):t,p=new Map;for(let g of c){let h=Bp(g),v=p.get(h);if(v)v.push(g);else p.set(h,[g])}return Hp.flatMap((g)=>{let h=p.get(g.id);if(!h||h.length===0)return[];return[{...g,providers:[...h].sort((v,x)=>v.name.localeCompare(x.name))}]})}function jn(t){return t.inModelsYml===!0||t.inOverlay===!0}function da(t){if(t.disabled===!0)return"Disabled — hidden from the model picker";if(t.status==="connected")switch(t.credentialOrigin){case"models.yml":return"Signed in — key stored in models.yml";case"login":return"Signed in — OAuth credential stored by omp";case"api-key":return"Signed in — API key stored by omp";case"environment":return"Signed in — credential comes from the environment";default:return"Signed in"}return t.oauth===!0?"Not signed in — pick this row to sign in with OAuth":"Not signed in — no credential omp can resolve"}function ca({providers:t,selectedProviderId:r,onSelectProvider:l,onOpenAddModal:c,onRefresh:p,isRefreshing:g,isLoading:h,catalogError:v}){let[x,y]=n(""),k=o(null),T=la(t,x);return e("div",{className:"w-full md:w-64 md:border-r border-ink/10 h-full flex flex-col bg-paper/50 flex-shrink-0",children:[e("div",{className:"px-3 pt-3 pb-2 flex items-center justify-between gap-2",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/50 uppercase",children:h?"Loading…":`${t.length} provider${t.length===1?"":"s"}`}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",onClick:p,disabled:g||h,title:"Refresh the provider list","aria-label":"Refresh the provider list",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:14,strokeWidth:2.2,className:g?"animate-spin":""})}),e("button",{type:"button",onClick:c,title:"Add provider","aria-label":"Add provider",className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:e(Y,{size:15,strokeWidth:2.2})})]})]}),e("div",{className:"px-3 pb-2",children:e("div",{className:"relative flex items-center",children:[e(F,{size:12,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{ref:k,type:"text",value:x,onChange:(S)=>y(S.currentTarget.value),placeholder:"Filter providers or models…","aria-label":"Filter providers",className:"w-full bg-paper border border-ink/15 rounded-md pl-7 pr-7 py-1.5 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors"}),x&&e("button",{type:"button",onClick:()=>{y(""),k.current?.focus()},title:"Clear the filter","aria-label":"Clear the filter",className:"absolute right-1.5 p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:11})})]})}),v&&e("p",{className:"mx-3 mb-2 px-2 py-1.5 rounded border border-amber-500/30 bg-amber-500/10 text-[10px] leading-relaxed text-ink/70",children:["Model catalog unavailable: ",v]}),e("div",{className:"flex-1 scrollbar-overlay-container px-1.5 pb-3",children:h?e("div",{className:"flex flex-col items-center justify-center gap-2 py-10 text-[11px] text-ink/45",role:"status","aria-live":"polite",children:[e(m,{size:16,className:"animate-spin"}),e("span",{children:"Reading providers…"})]}):T.length===0?e("div",{className:"px-2.5 py-4 text-[11px] leading-relaxed text-ink/50",children:x?`No provider or model matches “${x}”.`:"No providers detected yet. Use the plus button above to register one."}):T.map((S)=>e("div",{className:"pt-1.5 first:pt-0",children:[e("div",{className:"px-2 pb-1",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] font-semibold tracking-wider text-ink/45 uppercase",children:S.label}),e("span",{className:"text-[10px] font-mono text-ink/35",children:S.providers.length})]}),S.hint&&e("p",{className:"text-[10px] leading-snug text-ink/40 mt-0.5",children:S.hint})]}),e("div",{className:"space-y-0.5",children:S.providers.map((R)=>{let P=R.id===r;return e("button",{type:"button",onClick:()=>l(R.id),"aria-current":P?"true":void 0,title:da(R),className:`w-full flex items-center gap-2 pl-1.5 pr-2 py-1 rounded-md text-left transition-colors cursor-pointer ${P?"bg-ink/10 text-ink font-medium shadow-2xs":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[e(Me,{provider:R,size:22}),e("span",{className:"flex-1 min-w-0 text-[12px] truncate",children:R.name}),e("span",{className:"w-8 shrink-0 text-right text-[10px] font-mono tabular-nums text-ink/45",children:R.models.length})]},R.id)})})]},S.id))})]})}function ua({provider:t,onRefreshIcon:r,isRefreshingIcon:l=!1}){return e("div",{className:"flex items-start gap-3 pb-4",children:[e(Me,{provider:t,size:30,className:"mt-0.5"}),e("div",{className:"min-w-0 flex flex-1 flex-col gap-0.5",children:[e("h2",{className:"text-xl font-bold leading-tight tracking-tight text-ink truncate",children:t.name}),e("p",{className:"text-xs font-mono text-ink/50 truncate",children:t.slug})]}),r&&e("button",{type:"button",onClick:r,disabled:l,title:t.baseUrl?`Refetch the icon from ${t.baseUrl}`:"This provider has no endpoint to read an icon from","aria-label":"Refresh provider icon",className:"shrink-0 p-1.5 rounded-md border border-ink/15 text-ink/50 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:e(C,{size:12,className:l?"animate-spin":""})})]})}function va(t){switch(t){case"models.yml":return"models.yml key";case"login":return"OAuth login";case"api-key":return"stored API key";case"environment":return"environment variable";default:return"no credential"}}function xa(t){return t==="login"||t==="api-key"}function ya(t){let r=t.oauth===!0&&t.auth!=="none"&&t.credentialOrigin!=="models.yml",l=t.inModelsYml===!0;if(r||l)return{login:r,edit:l};return{login:!1,edit:!1,reason:"omp discovers this provider itself — its models come from its own endpoint, so there is no login flow and no entry to edit."}}function Sa({provider:t,onConnect:r,onToggleDisabled:l,onDelete:c,onSignOut:p}){let[g,h]=n(!1),v=t.status==="connected",x=t.disabled===!0,y=t.credentialOrigin,k=xa(y),T=ya(t);return e("div",{className:"space-y-6",children:[e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Authentication"}),e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"flex items-center gap-2 min-w-0",children:[x?e(d,{children:[e(_n,{size:15,className:"text-ink/50 flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/70",children:"Disabled"})]}):v?e(d,{children:[e(f,{size:15,className:"text-success flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink",children:"Connected"})]}):e(d,{children:[e(I,{size:15,className:"text-warning flex-shrink-0",strokeWidth:2.4}),e("span",{className:"text-xs font-medium text-ink/80",children:"Not signed in"})]}),e("span",{className:"text-[11px] text-ink/55 font-mono px-1.5 py-0.5 rounded bg-ink/5 border border-ink/10",children:va(y)}),e("div",{className:"relative inline-block cursor-help ml-0.5",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[e(pe,{size:13,className:"text-ink/40 hover:text-ink/70 transition-colors"}),g&&e("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2.5 py-1.5 shadow-xl w-64 z-50 pointer-events-none leading-relaxed",children:x?"Disabled in omp’s config.yml — none of its models appear in the chat model list. The credential is untouched.":v?"omp can resolve a credential for this provider, so its models are offered in the chat picker.":"omp knows this provider but has no credential for it. Connect to sign in or supply a key."})]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:l,title:x?"Offer this provider in the model list again":"Hide this provider and its models from the model list",className:"px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:x?"enable":"disable"}),T.login&&e("button",{type:"button",onClick:()=>r("login"),title:"Sign in to this provider through omp",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer",children:[e(or,{size:12}),e("span",{children:v&&y==="login"?"sign in again":"sign in"})]}),T.edit&&e("button",{type:"button",onClick:()=>r("edit"),title:"Edit this provider’s endpoint, credential and dialect in models.yml",className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-medium transition-colors cursor-pointer border ${T.login?"bg-ink/5 hover:bg-ink/10 text-ink border-ink/15":"bg-ink text-canvas hover:opacity-90 border-ink"}`,children:[e(Dn,{size:12}),e("span",{children:"edit"})]}),!T.login&&!T.edit&&e("button",{type:"button",disabled:!0,title:T.reason,className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium opacity-40 cursor-not-allowed",children:[e(mi,{size:12}),e("span",{children:"connect"})]}),k&&e("button",{type:"button",onClick:p,title:"Remove the credential omp stored for this provider",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-ink/5 hover:bg-ink/10 text-ink text-xs font-medium transition-colors cursor-pointer border border-ink/10",children:[e(jt,{size:12}),e("span",{children:"sign out"})]}),e("button",{type:"button",onClick:c,disabled:!jn(t),title:jn(t)?t.inModelsYml?"Remove this provider’s models.yml entry":"Remove this provider’s Kabmo settings row":"Nothing to delete: omp discovered this provider from its endpoint. Use disable to hide it.",className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-md bg-error/10 hover:bg-error/20 text-error text-xs font-medium transition-colors cursor-pointer border border-error/30 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(M,{size:12}),e("span",{children:"delete"})]})]})]})]}),e("div",{className:"border-b border-ink/10"}),e("div",{className:"space-y-3",children:[e("div",{className:"text-xs font-semibold text-ink",children:"Connection details"}),e("div",{className:"flex items-center justify-between gap-4",children:[e("div",{className:"text-xs text-ink/70 min-w-0",children:["Configured in:"," ",e("span",{className:"font-mono text-ink font-medium break-all",children:t.configuredIn})]}),e("span",{className:"text-[11px] text-ink/40 italic shrink-0",children:x?"hidden":v?"active":"inactive"})]}),(t.api||t.auth||t.discovery||t.transport)&&e("div",{className:"flex flex-wrap items-center gap-1.5 pt-0.5",children:[t.api&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Wire API omp uses for this provider",children:t.api}),t.auth&&t.auth!=="apiKey"&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Auth mode from models.yml",children:["auth: ",t.auth]}),t.discovery&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"omp lists this provider's models live",children:["discovery: ",t.discovery]}),t.transport&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:"Requests are routed through the auth gateway",children:["transport: ",t.transport]}),t.headers&&Object.keys(t.headers).length>0&&e("span",{className:"px-1.5 py-0.5 rounded border border-ink/15 text-[10px] font-mono text-ink/70",title:Object.entries(t.headers).map(([S,R])=>`${S}: ${R}`).join(`
|
|
2
2
|
`),children:[Object.keys(t.headers).length," header",Object.keys(t.headers).length===1?"":"s"]})]})]}),e("div",{className:"border-b border-ink/10"})]})}var Wt=["openai-completions","openai-responses","openai-codex-responses","azure-openai-responses","anthropic-messages","bedrock-converse-stream","google-generative-ai","google-gemini-cli","google-vertex","openrouter-decisions","openai-decisions","workers-ai-systemone","typesafe"],qt={"openai-completions":"[OI] Chat Completions — the default for gateways and local servers","openai-responses":"[OI] Responses API — newer [OI]-shaped endpoints","openai-codex-responses":"[OC] Responses — Codex-style endpoints","azure-openai-responses":"Azure [OI] Responses — api-key header, api-version query","anthropic-messages":"Anthropic Messages — Claude-shaped proxies (x-api-key)","bedrock-converse-stream":"Amazon Bedrock Converse — AWS credential chain","google-generative-ai":"Google Generative AI — Gemini API (x-goog-api-key)","google-gemini-cli":"Google Gemini CLI — OAuth-backed Gemini route","google-vertex":"Google Vertex AI — service-account / ADC route","openrouter-decisions":"OpenRouter decisions — judge role only","openai-decisions":"[OI] decisions — judge role only","workers-ai-systemone":"Workers AI System One — judge role only",typesafe:"Typesafe System One — judge role only"},lt=["minimal","low","medium","high","xhigh","max"];var Pt=[{value:"apiKey",label:"API key",hint:"omp requires a key for this provider"},{value:"none",label:"No auth (keyless)",hint:"Local server that needs no credential"},{value:"oauth",label:"OAuth",hint:"Claude-Code-style proxy expecting the cloaked request shape"}];var $n=["chat","tiny","image","tts","stt","search","judge","embedding","rerank","video"],ct={chat:"Chat",tiny:"Tiny",image:"Image",tts:"Speech",stt:"Transcribe",search:"Search",judge:"Judge",embedding:"Embedding",rerank:"Rerank",video:"Video"};function bt(t){return typeof t==="string"&&$n.includes(t)?t:"chat"}var ft=[{value:"openai-models-list",label:"OpenAI /v1/models",hint:"Any OpenAI-compatible endpoint"},{value:"ollama",label:"Ollama",hint:"Native Ollama /api/tags + /api/show"},{value:"llama.cpp",label:"llama.cpp",hint:"llama.cpp server model endpoints"},{value:"lm-studio",label:"LM Studio",hint:"LM Studio /v1/models + native metadata"},{value:"litellm",label:"LiteLLM proxy",hint:"LiteLLM proxy with rich model metadata"},{value:"proxy",label:"New-API / One-API proxy",hint:"Wire api read per model from the proxy"},{value:"apple-foundation-models",label:"Apple Foundation Models",hint:"On-device model (Apple silicon only)"}];function Na(t){if(/anthropic\./i.test(t))return"anthropic-messages";if(/generativelanguage\.googleapis\.com/i.test(t))return"google-generative-ai";if(/openai\.azure\.com/i.test(t))return"azure-openai-responses";if(/openrouter\.ai/i.test(t))return"openai-completions";return"openai-completions"}function Ca(t){if(t.discovery||t.modelSource==="discovery")return"omp discovers this provider’s models live — they appear in the chat model picker, not here.";if(t.modelSource==="override")return t.auth==="none"?"Endpoint override — omp keeps its own model list for this provider. Use “fetch models” to add specific ids.":"Endpoint override — omp keeps its own model list for this provider. It still needs a credential: use “connect” to supply one, or “fetch models” to add specific ids.";if(t.auth==="none")return"No models registered yet. This server is keyless, so use “fetch models” to list what it serves.";return}function Ta(t){if(t.discovery!==void 0||t.modelSource==="discovery")return"omp lists this provider’s models itself — importing would freeze a snapshot beside that live list. Use “refresh”.";if(!t.baseUrl)return"This provider has no endpoint Kabmo can probe — omp owns its URL. Use “refresh” instead.";return}function Ia({models:t,emptyReason:r,onToggleModelVisibility:l,onHideAll:c,onShowAll:p,onRefreshModels:g,onImportModels:h,onAddModel:v,fetchBlockReason:x,isFetchingModels:y,onOpenModelConfig:k,onOpenModelCapabilities:T}){let[S,R]=n(""),[P,L]=n("all"),N=u(()=>{let U=new Map;for(let _ of t){let K=bt(_.kind);U.set(K,(U.get(K)??0)+1)}return U},[t]),E=u(()=>[...N.entries()].sort((U,_)=>_[1]-U[1]),[N]),A=t.filter((U)=>{if(P!=="all"&&bt(U.kind)!==P)return!1;if(!S.trim())return!0;let _=S.trim().toLowerCase();return U.id.toLowerCase().includes(_)||U.name.toLowerCase().includes(_)}),O=t.filter((U)=>!U.isVisible).length;return e("div",{className:"space-y-3.5",children:[e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-2",children:[e("div",{className:"text-xs font-semibold text-ink",children:["Models ",e("span",{className:"font-normal text-ink/60",children:["(",t.length,")"]}),O>0&&e("span",{className:"font-normal text-ink/40",children:[" · ",O," hidden"]})]}),e("div",{className:"flex flex-wrap items-center gap-2",children:[e("button",{type:"button",onClick:g,disabled:y,title:"Ask omp to re-run model discovery for every provider",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink text-canvas text-[11px] font-medium hover:opacity-90 transition-opacity cursor-pointer border border-ink disabled:opacity-40 disabled:cursor-not-allowed",children:[e(C,{size:12,className:y?"animate-spin":""}),e("span",{children:y?"refreshing…":"refresh"})]}),h&&e("button",{type:"button",onClick:h,disabled:Boolean(x)||y,title:x??"List this endpoint’s models and register them in models.yml",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:[e(he,{size:12}),e("span",{children:"import"})]}),e("button",{type:"button",onClick:v,title:"Register a model by hand",className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10",children:[e(Y,{size:12}),e("span",{children:"add model"})]}),e("button",{type:"button",onClick:c,disabled:t.length===0,title:"Hide every model from the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"hide all"}),e("button",{type:"button",onClick:p,disabled:O===0,title:"Show every model in the chat picker",className:"px-2.5 py-1 rounded bg-ink/5 hover:bg-ink/10 text-[11px] font-medium text-ink/80 hover:text-ink transition-colors cursor-pointer border border-ink/10 disabled:opacity-40 disabled:cursor-not-allowed",children:"show all"})]})]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>L("all"),"aria-pressed":P==="all",className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${P==="all"?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:["All ",e("span",{className:"font-mono text-ink/45",children:t.length})]}),E.map(([U,_])=>e("button",{type:"button",onClick:()=>L(U),"aria-pressed":P===U,className:`px-2 py-0.5 rounded text-[11px] font-medium transition-colors cursor-pointer border ${P===U?"border-ink/40 bg-ink/10 text-ink":"border-ink/10 text-ink/60 hover:text-ink hover:border-ink/25"}`,children:[ct[U]," ",e("span",{className:"font-mono text-ink/45",children:_})]},U))]}),e("div",{className:"relative flex items-center",children:[e(F,{size:14,className:"absolute left-3 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:S,onChange:(U)=>R(U.currentTarget.value),placeholder:"Filter models by id or name…","aria-label":"Filter models",className:"w-full bg-paper border border-ink/15 rounded-lg pl-9 pr-9 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors shadow-2xs"}),S&&e("button",{type:"button",onClick:()=>R(""),title:"Clear the filter","aria-label":"Clear the model filter",className:"absolute right-2 p-1 rounded text-ink/40 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(b,{size:12})})]}),e("div",{className:"space-y-1 pt-1",children:A.length===0?e("div",{className:"py-8 text-center text-xs text-ink/40",children:S||P!=="all"?"No model matches this filter.":r||"No models registered for this provider yet."}):A.map((U)=>{let _=bt(U.kind);return e("div",{className:`flex items-center justify-between gap-3 px-3 py-2 rounded-lg hover:bg-ink/5 transition-colors group ${!U.isVisible?"opacity-50":""}`,children:[e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e("span",{className:`text-xs font-medium truncate ${U.isVisible?"text-ink":"text-ink/60 line-through decoration-ink/40"}`,title:U.id,children:U.name}),_!=="chat"&&e("span",{className:"shrink-0 px-1 py-0 rounded border border-ink/15 text-[10px] font-mono uppercase tracking-wide text-ink/55",children:ct[_]})]}),U.name!==U.id&&e("span",{className:"text-[10px] font-mono text-ink/40 truncate block",children:U.id})]}),e("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[(U.priceInput!==void 0||U.priceOutput!==void 0)&&e("span",{title:`$${U.priceInput??"?"} in / $${U.priceOutput??"?"} out per 1M tokens${U.pricingStatus&&U.pricingStatus!=="exact"?` (${U.pricingStatus})`:""}`,className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:[Ff(U.priceInput)," / ",Ff(U.priceOutput)]}),U.contextWindow&&e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded bg-ink/5 text-ink/70 border border-ink/10",children:ac(U.contextWindow)}),e("button",{type:"button",onClick:()=>T(U),title:"What this model declares: tools, vision, reasoning","aria-label":`Capabilities of ${U.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(cr,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>k(U),title:"Per-model overrides omp honours (max output, reasoning level)","aria-label":`Configure ${U.name}`,className:"p-1 rounded text-ink/50 hover:text-ink hover:bg-ink/10 transition-colors cursor-pointer",children:e(gi,{size:13,strokeWidth:1.8})}),U.hasVision&&e("span",{title:"Accepts image input",className:"p-1 text-ink/60","aria-label":"Accepts image input",children:e(tr,{size:13,strokeWidth:1.8})}),e("button",{type:"button",onClick:()=>l(U.id),title:U.isVisible?"Hide model from chat picker":"Show model in chat picker","aria-label":U.isVisible?`Hide ${U.name}`:`Show ${U.name}`,"aria-pressed":U.isVisible,className:`p-1 rounded transition-colors cursor-pointer ${U.isVisible?"text-ink/60 hover:text-ink hover:bg-ink/10":"text-ink/30 hover:text-ink/70 hover:bg-ink/10"}`,children:U.isVisible?e(Ge,{size:14,strokeWidth:1.8}):e(wt,{size:14,strokeWidth:1.8})})]})]},U.id)})})]})}var Ra=[{value:"fetch",label:"Fetch now",hint:"List the endpoint here and write the ids into models.yml"},{value:"discovery",label:"Let omp discover",hint:"omp lists the models live on every run"},{value:"override",label:"Endpoint only",hint:"Keep omp’s own model list, change only the URL"}],zn="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors cursor-pointer";function Ma({api:t,onApiChange:r,auth:l,onAuthChange:c,source:p,onSourceChange:g,discovery:h,onDiscoveryChange:v}){return e(d,{children:[e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:t,onChange:(x)=>r(x.currentTarget.value),className:zn,children:Wt.map((x)=>e("option",{value:x,children:x},x))})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:l,onChange:(x)=>c(x.currentTarget.value),className:zn,children:Pt.map((x)=>e("option",{value:x.value,children:x.label},x.value))})]})]}),e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-1",children:[qt[t]," · ",Pt.find((x)=>x.value===l)?.hint]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Model source"}),e("div",{className:"grid grid-cols-3 gap-2",children:Ra.map((x)=>{let y=p===x.value;return e("button",{type:"button",onClick:()=>g(x.value),className:`px-2 py-1.5 rounded-lg border text-[11px] transition-colors cursor-pointer ${y?"border-ink/50 bg-ink/5 font-semibold text-ink":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:x.label},x.value)})}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:Ra.find((x)=>x.value===p)?.hint})]}),p==="discovery"&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Discovery protocol"}),e("select",{value:h,onChange:(x)=>v(x.currentTarget.value),className:zn,children:ft.map((x)=>e("option",{value:x.value,children:x.label},x.value))}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:ft.find((x)=>x.value===h)?.hint})]})]})}function Ea({presets:t,selectedPresetId:r,onSelectPreset:l}){let[c,p]=n({}),g=Fi(t);if(t.length===0)return e("p",{className:"px-2 py-3 text-xs text-ink/50",children:"Every known provider is already configured."});return e("div",{className:"max-h-52 scrollbar-overlay-container pr-1 space-y-2",children:g.map((h)=>{let v=c[h.group]===!0;return e("div",{children:[e("button",{type:"button",onClick:()=>p((x)=>({...x,[h.group]:!v})),className:"w-full flex items-center gap-1.5 px-0.5 py-1 text-[10px] font-semibold tracking-wider text-ink/50 uppercase hover:text-ink/80 transition-colors cursor-pointer",children:[e(B,{size:11,className:`transition-transform ${v?"-rotate-90":""}`}),e("span",{children:h.group}),e("span",{className:"text-ink/30 normal-case tracking-normal",children:h.options.length})]}),!v&&e("div",{className:"grid grid-cols-2 gap-2 pt-1",children:h.options.map((x)=>{let y=x.id===r;return e("button",{type:"button",onClick:()=>l(x),title:x.defaultUrl,className:`flex items-center gap-2 p-2 rounded-lg border text-left text-xs transition-colors cursor-pointer ${y?"border-ink/50 bg-ink/5 font-semibold text-ink shadow-2xs":"border-ink/15 hover:border-ink/30 text-ink/70"}`,children:[e(Me,{provider:{icon:x.icon,slug:x.slug,name:x.name},size:18}),e("span",{className:"truncate flex-1",children:x.name}),y&&e(f,{size:12,className:"shrink-0 text-ink"})]},x.id)})})]},h.group)})})}var eu=/^[a-z0-9][a-z0-9._-]{0,63}$/;function La(t){return{api:t?.api??Na(t?.defaultUrl??""),auth:t?.auth??"apiKey",discovery:t?.discovery??"openai-models-list",source:t?.discovery?"discovery":t?.bundled?"override":"fetch"}}function Oa({isOpen:t,onClose:r,onAddProvider:l,presets:c,existingSlugs:p}){let g=c,h=g[0],v=La(h),[x,y]=n(h?.id||"openai"),[k,T]=n(h?.name||"OpenAI"),[S,R]=n(h?.defaultUrl||"https://api.openai.com/v1"),[P,L]=n(""),[N,E]=n(v.api),[A,O]=n(v.auth),[U,_]=n(v.source),[K,V]=n(v.discovery),[z,W]=n(!1),q=(ue)=>{let ve=La(ue);y(ue.id),T(ue.name),R(ue.defaultUrl),E(ve.api),O(ve.auth),V(ve.discovery),_(ve.source)};if(i(()=>{if(!g.find((ve)=>ve.id===x)&&g[0])q(g[0])},[g,x]),!t)return null;let j=g.find((ue)=>ue.id===x),G=k.trim(),Q=(G&&j&&G===j.name?j.slug:G.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")).toLowerCase(),te=new Set(p.map((ue)=>ue.trim().toLowerCase())),Z=j?.bundled===!0,X=!Q?"Enter a provider name to derive an id.":!eu.test(Q)?"The derived id must start with a letter or digit.":te.has(Q)&&!Z?`"${Q}" is already registered in models.yml — connecting it would overwrite that provider. Pick another name.`:"",re=A==="apiKey",oe=re&&U==="fetch",be=oe&&!P.trim()?'Enter the API key, or set Auth to "No auth" for a keyless local server.':"",xe=Boolean(G)&&!X&&!be&&!z;return e(J,{onClose:r,header:e("div",{className:"flex items-center gap-2",children:[e(bn,{size:16,className:"text-ink/70"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Add Model Provider"})]}),form:{onSubmit:async(ue)=>{if(ue.preventDefault(),!xe)return;W(!0);try{let ve=Date.now(),Te=S.trim(),ke=P.trim(),We={id:`provider-${ve}`,name:G,slug:Q,icon:j?.icon||"custom",status:"connected",configuredIn:"auth credentials",credentialSource:"models.yml",baseUrl:Te,...ke?{apiKey:ke}:{},api:N,...A!=="apiKey"?{auth:A}:{},...U==="discovery"?{discovery:K}:{},modelSource:U,models:[]},Ee=await Gt({baseUrl:Te,apiKey:ke||void 0,providerSlug:We.slug,persistToOmp:!0,api:N,auth:A,...U==="discovery"?{discovery:K}:{},...U==="override"?{registerOnly:!0}:{}});if(Ee.ok&&Ee.models)We.models=Ee.models,l(We,{fetchedCount:Ee.models.length,ompNote:Ee.omp?.reason});else l(We,{fetchedCount:-1,ompNote:Ee.omp?.written?void 0:Ee.error});r()}finally{W(!1)}},className:"p-5 space-y-4"},maxWidthClass:"max-w-lg",footer:e("div",{className:"pt-2 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!xe,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-50 flex items-center gap-1.5",children:z?e(d,{children:[e(Pa,{size:14,className:"animate-pulse"}),e("span",{children:U==="fetch"?"Fetching models...":"Registering..."})]}):e(d,{children:[e(f,{size:14}),e("span",{children:"Connect Provider"})]})})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1.5",children:"Provider Preset"}),e(Ea,{presets:g,selectedPresetId:x,onSelectPreset:q})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Display Name"}),e("input",{type:"text",required:!0,value:k,onChange:(ue)=>T(ue.currentTarget.value),placeholder:"e.g. My Provider",className:"w-full bg-paper border border-ink/20 rounded-md px-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60"}),Q&&e("p",{className:"text-[10px] text-ink/40 mt-1 font-mono",children:["models.yml id: ",Q]}),X&&e("p",{className:"text-[11px] text-error mt-1",children:X})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"API Base URL"}),e("div",{className:"relative flex items-center",children:[e(Qe,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",required:!0,value:S,onChange:(ue)=>R(ue.currentTarget.value),placeholder:"https://api.domain.com/v1",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]})]}),e(Ma,{api:N,onApiChange:E,auth:A,onAuthChange:O,source:U,onSourceChange:_,discovery:K,onDiscoveryChange:V}),re&&e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API Key (stored securely)",!oe&&e("span",{className:"font-normal text-ink/40",children:" (optional)"})]}),e("div",{className:"relative flex items-center",children:[e(pt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"password",value:P,onChange:(ue)=>L(ue.currentTarget.value),placeholder:"sk-••••••••••••••••",className:"w-full bg-paper border border-ink/20 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink outline-none focus:border-ink/60 font-mono"})]}),be&&e("p",{className:"text-[11px] text-error mt-1",children:be}),e("p",{className:"text-[10px] text-ink/40 mt-1",children:[oe?"May name an environment variable (e.g. ":"Leave empty to keep using the provider’s existing credential. May name an environment variable (e.g. ",e("span",{className:"font-mono",children:"MY_KEY"}),") or run a command with a leading"," ",e("span",{className:"font-mono",children:"!"}),"."]})]})]})}var Xt="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",tu={"openai-models-list":!0,"lm-studio":!0,proxy:!0};function Da({discovery:t,onDiscoveryChange:r,headers:l,onHeadersChange:c}){let p=(x)=>r({...t,...x}),g=t.type==="openai-models-list",h=tu[t.type]===!0,v=(x,y)=>{c(l.map((k,T)=>T===x?{...k,...y}:k))};return e(d,{children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["Discovery ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("select",{value:t.type,onChange:(x)=>p({type:x.currentTarget.value}),className:Xt,children:[e("option",{value:"",children:"Use the registered model list"}),ft.map((x)=>e("option",{value:x.value,children:x.label},x.value))]}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:t.type?ft.find((x)=>x.value===t.type)?.hint:"With discovery set, omp lists this provider’s models live and importing here would freeze a snapshot beside that list."})]}),t.type&&e("div",{className:"space-y-2 pl-3 border-l-2 border-ink/10",children:[e("div",{children:[e("label",{className:"block text-[11px] font-medium text-ink/70 mb-1",children:["Timeout ",e("span",{className:"font-normal text-ink/40",children:"(ms, optional)"})]}),e("input",{type:"text",inputMode:"numeric",value:t.timeoutMs,onChange:(x)=>p({timeoutMs:x.currentTarget.value}),placeholder:"omp default",className:`${Xt} font-mono`})]}),g&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.injectV1===!0,onChange:(x)=>p({injectV1:x.currentTarget.checked}),className:`${ge} mt-0.5`}),e("span",{children:["Skip the forced ",e("span",{className:"font-mono",children:"/v1"})," prefix — for a gateway rooted at a versioned path."]})]}),h&&e("label",{className:"flex items-start gap-2 text-[11px] text-ink/70",children:[e("input",{type:"checkbox",checked:t.advertisedReasoning===!0,onChange:(x)=>p({advertisedReasoning:x.currentTarget.checked}),className:`${ge} mt-0.5`}),e("span",{children:"Trust the reasoning ladder the endpoint advertises in its model rows."})]})]}),e("div",{children:[e("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e("label",{className:"block text-xs font-semibold text-ink",children:["Request headers ",e("span",{className:"font-normal text-ink/40",children:"(optional)"})]}),e("button",{type:"button",onClick:()=>c([...l,{key:"",value:""}]),className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[11px] text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:[e(Y,{size:11}),e("span",{children:"add"})]})]}),l.length===0?e("p",{className:"text-[10px] text-ink/40 leading-relaxed",children:"Sent with every request to this provider — the place for a gateway’s routing or version header."}):e("div",{className:"space-y-1.5",children:l.map((x,y)=>e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:x.key,onChange:(k)=>v(y,{key:k.currentTarget.value}),placeholder:"Header-Name","aria-label":`Header ${y+1} name`,className:`${Xt} font-mono`}),e("input",{type:"text",value:x.value,onChange:(k)=>v(y,{value:k.currentTarget.value}),placeholder:"value","aria-label":`Header ${y+1} value`,className:`${Xt} font-mono`}),e("button",{type:"button",onClick:()=>c(l.filter((k,T)=>T!==y)),title:"Remove this header","aria-label":`Remove header ${y+1}`,className:"shrink-0 p-1.5 rounded text-ink/40 hover:text-error hover:bg-error/10 transition-colors cursor-pointer",children:e(b,{size:12})})]},y))})]})]})}var Zt="w-full text-xs py-2 px-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors",nu="sk-••••••••••••••••••••••••";function Ua({isOpen:t,provider:r,onClose:l,onSaved:c}){let[p,g]=n(r.baseUrl??""),[h,v]=n(""),[x,y]=n(r.api??""),[k,T]=n(r.auth??"apiKey"),[S,R]=n({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),[P,L]=n(Object.entries(r.headers??{}).map(([W,q])=>({key:W,value:q}))),[N,E]=n(!1),[A,O]=n(null);if(i(()=>{if(!t)return;g(r.baseUrl??""),v(""),y(r.api??""),T(r.auth??"apiKey"),R({type:r.discovery??"",timeoutMs:"",injectV1:void 0,advertisedReasoning:void 0}),L(Object.entries(r.headers??{}).map(([W,q])=>({key:W,value:q}))),O(null)},[t,r.id,r.baseUrl,r.api,r.auth,r.discovery]),!t)return null;let U=r.credentialOrigin==="models.yml"||r.credentialOrigin==="api-key",_=k!=="apiKey",K=!_&&!h.trim()&&!U?'omp needs a credential for a keyed provider — enter the key, or switch Auth to "No auth".':"",V=!N&&!K,z=async(W)=>{if(W.preventDefault(),!V)return;E(!0),O(null);let q={},j=p.trim();if(j!==(r.baseUrl??""))q.baseUrl=j||null;if(h.trim())q.apiKey=h.trim();if(x&&x!==r.api)q.api=x;if(k!==(r.auth??"apiKey"))q.auth=k;if(S.type!==(r.discovery??""))q.discovery=S.type?{type:S.type,...S.timeoutMs.trim()&&Number(S.timeoutMs)>0?{timeoutMs:Number(S.timeoutMs)}:{},...S.injectV1!==void 0?{injectV1:S.injectV1}:{},...S.advertisedReasoning!==void 0?{advertisedReasoning:S.advertisedReasoning}:{}}:null;let G=Object.fromEntries(P.filter((X)=>X.key.trim()).map((X)=>[X.key.trim(),X.value.trim()])),Q=r.headers??{};if(JSON.stringify(G)!==JSON.stringify(Q))q.headers=Object.keys(G).length>0?G:null;if(Object.keys(q).length===0){E(!1),l();return}let Z=await zi(r.slug,q);if(E(!1),!Z.ok){O(Z.error??"Could not write the provider entry.");return}c(Z.changed??[]),l()};return e(J,{onClose:l,header:e("div",{className:"flex items-center gap-2.5",children:[e(Me,{provider:r,size:26}),e("div",{children:[e("h3",{className:"text-sm font-semibold text-ink",children:"Edit connection"}),e("p",{className:"text-[11px] text-ink/50 font-mono",children:["models.yml · ",r.slug]})]})]}),form:{onSubmit:z,className:"p-5 space-y-4"},footer:e("div",{className:"pt-3 flex items-center justify-end gap-2 border-t border-ink/10",children:[e("button",{type:"button",onClick:l,className:"px-3.5 py-1.5 rounded-md border border-ink/20 text-xs font-medium text-ink hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"submit",disabled:!V,className:"px-3.5 py-1.5 rounded-md bg-ink text-canvas text-xs font-medium hover:opacity-90 transition-opacity cursor-pointer disabled:opacity-40 flex items-center gap-1.5",children:[e(yt,{size:13}),e("span",{children:N?"Saving…":"Save to models.yml"})]})]}),children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Endpoint URL"}),e("div",{className:"relative flex items-center",children:[e(Qe,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:p,onChange:(W)=>g(W.currentTarget.value),placeholder:"https://api.example.com/v1",className:`${Zt} pl-8 font-mono`})]})]}),_?e("div",{className:"flex items-start gap-2 px-3 py-2 rounded-md bg-ink/5 border border-ink/10 text-[11px] text-ink/60",children:[e(pe,{size:13,className:"mt-0.5 flex-shrink-0 text-ink/50"}),e("span",{children:["Registered with ",e("span",{className:"font-mono",children:["auth: ",k]})," — omp sends no API key for this provider. Switch Auth to “API key” if the endpoint starts requiring one."]})]}):e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:["API key",U&&e("span",{className:"font-normal text-ink/40",children:" (stored; leave empty to keep it)"})]}),e("div",{className:"relative flex items-center",children:[e(pt,{size:13,className:"absolute left-2.5 text-ink/40 pointer-events-none"}),e("input",{type:"text",value:h,onChange:(W)=>v(W.currentTarget.value),placeholder:U?nu:"sk-…",autoComplete:"off",spellcheck:!1,className:`${Zt} pl-8 font-mono`})]}),K&&e("p",{className:"text-[11px] text-error mt-1",children:K}),e("p",{className:"text-[10px] text-ink/40 mt-1 leading-relaxed",children:["A literal key, or ",e("span",{className:"font-mono",children:"!command"})," to have omp run a command for it — both are stored in ",e("span",{className:"font-mono",children:"models.yml"}),"."]})]}),e("div",{className:"grid grid-cols-2 gap-3",children:[e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Wire API"}),e("select",{value:x,onChange:(W)=>y(W.currentTarget.value),className:Zt,children:[e("option",{value:"",children:"Inherit omp's setting"}),Wt.map((W)=>e("option",{value:W,children:W},W))]})]}),e("div",{children:[e("label",{className:"block text-xs font-semibold text-ink mb-1",children:"Auth"}),e("select",{value:k,onChange:(W)=>T(W.currentTarget.value),className:Zt,children:Pt.map((W)=>e("option",{value:W.value,children:W.label},W.value))})]})]}),x&&e("p",{className:"text-[10px] text-ink/40 leading-relaxed -mt-2",children:qt[x]}),e(Da,{discovery:S,onDiscoveryChange:R,headers:P,onHeadersChange:L}),A&&e("div",{className:"flex items-start gap-2 text-[11px] text-error",children:[e(I,{size:13,className:"mt-0.5 shrink-0"}),e("span",{className:"select-text",children:A})]})]})}var Fa={status:"connecting",authUrl:null,launchUrl:null,instructions:null,prompt:null,notices:[],error:null};function Ka(t){if(!t)return null;return/^(.*\bcode:?\s+)([A-Za-z0-9][A-Za-z0-9-]{3,})\s*$/s.exec(t.trim())?.[2]??null}function Ba(t){let r=t.replace(/^\[|\]$/g,"");return r==="localhost"||r==="127.0.0.1"||r==="::1"||r.endsWith(".localhost")}function Gn(t){if(!t)return!1;let r;try{r=new URL(t)}catch{return!1}if(r.protocol!=="http:"&&r.protocol!=="https:")return!0;if(!Ba(r.hostname))return!0;return typeof window<"u"&&Ba(window.location.hostname)}function Ha({isOpen:t,providerId:r,onAuthenticated:l}){let[c,p]=n(Fa),[g,h]=n(""),v=o(null),x=o(l);x.current=l,i(()=>{if(!t)return;p(Fa),h("");let k=new AbortController,T=null,S=(R)=>{if(!T)return;fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...R,type:"extension_ui_response",loginId:T}),signal:k.signal}).catch(()=>{})};return v.current=S,fetch("/api/omp/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r}),signal:k.signal}).then(async(R)=>{if(!R.ok){let E=await R.json().catch(()=>null),A=E&&typeof E.error==="string"?E.error:`HTTP ${R.status}`;throw Error(A)}if(!R.body)throw Error("Streaming is not supported by this browser");let P=R.body.getReader(),L=new TextDecoder,N="";for(;;){let{done:E,value:A}=await P.read();if(E)break;N+=L.decode(A,{stream:!0});let O=N.split(`
|
|
3
3
|
|
|
4
4
|
`);N=O.pop()??"";for(let U of O){let _=U.split(`
|