opencode-rag-plugin 1.21.2 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/ui.js +5 -1
- package/dist/content/reader.d.ts +2 -2
- package/dist/content/reader.js +8 -6
- package/dist/core/config.d.ts +29 -0
- package/dist/core/config.js +34 -0
- package/dist/core/exclude.d.ts +14 -0
- package/dist/core/exclude.js +37 -0
- package/dist/core/runtime-overrides.d.ts +1 -0
- package/dist/core/runtime-overrides.js +1 -0
- package/dist/indexer/watch.d.ts +3 -1
- package/dist/indexer/watch.js +6 -3
- package/dist/retriever/context-optimizer.js +9 -2
- package/dist/tui.js +20 -32
- package/dist/web/api.d.ts +5 -2
- package/dist/web/api.js +126 -7
- package/dist/web/server.d.ts +2 -1
- package/dist/web/server.js +3 -2
- package/dist/web/ui/assets/{ScatterPlot3D-CzbmvDSQ.js → ScatterPlot3D-DQLl3sKN.js} +1 -1
- package/dist/web/ui/assets/index-BZh9MitV.js +4 -0
- package/dist/web/ui/assets/index-DKhjGsql.css +1 -0
- package/dist/web/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/ui/assets/index-BLzCza1W.css +0 -1
- package/dist/web/ui/assets/index-DOSfQsyL.js +0 -4
package/dist/web/api.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { readFileSync, statSync } from "node:fs";
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
2
|
import { extname, join, resolve as resolvePathModule } from "node:path";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { listSessions, getSession, deleteSession, compareSessions, validateSessionID } from "../eval/storage.js";
|
|
5
5
|
import { analyzeTokenUsage, compareTokenAnalyses, projectTokenSavings } from "../eval/token-analysis.js";
|
|
6
6
|
import { listQuirks, lintQuirks, removeQuirk } from "../quirks/quirk-store.js";
|
|
7
7
|
import { retrieve } from "../retriever/retriever.js";
|
|
8
|
+
import { updateConfigValue } from "../core/config.js";
|
|
9
|
+
import { createExcludeMatcher } from "../core/exclude.js";
|
|
8
10
|
import { CODE_SEARCH_FILTER } from "../core/interfaces.js";
|
|
9
11
|
const FILE_MIME_TYPES = {
|
|
10
12
|
".png": "image/png",
|
|
@@ -94,9 +96,16 @@ function sendJson(res, response, origin) {
|
|
|
94
96
|
* @param storePath - Filesystem path to the store directory (used by eval endpoints).
|
|
95
97
|
* @param cwd - Optional workspace root for resolving file paths.
|
|
96
98
|
* @param cfg - Active RAG configuration (used by quirk endpoints).
|
|
99
|
+
* @param getEmbedder - Lazily-created embedder for /api/retrieve and reindex passes.
|
|
100
|
+
* @param token - Per-run auth token required on every request.
|
|
101
|
+
* @param configPath - Path to the opencode-rag.json config file, used by PUT /api/config.
|
|
97
102
|
* @returns An async handler that returns `true` when a route matched or `false` otherwise.
|
|
98
103
|
*/
|
|
99
|
-
export function createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEmbedder, token) {
|
|
104
|
+
export function createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEmbedder, token, configPath) {
|
|
105
|
+
// Mutable config reference so PUT /api/config can update the in-memory
|
|
106
|
+
// config used by subsequent requests (retrieve, reindex, quirk endpoints).
|
|
107
|
+
const configRef = { current: cfg };
|
|
108
|
+
const effectiveConfig = () => configRef.current ?? cfg ?? {};
|
|
100
109
|
return async (req, res) => {
|
|
101
110
|
const url = req.url ?? "/";
|
|
102
111
|
const method = req.method ?? "GET";
|
|
@@ -138,7 +147,7 @@ export function createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEm
|
|
|
138
147
|
embedder: stubEmbedder,
|
|
139
148
|
store,
|
|
140
149
|
keywordIndex,
|
|
141
|
-
cfg:
|
|
150
|
+
cfg: effectiveConfig(),
|
|
142
151
|
storePath,
|
|
143
152
|
};
|
|
144
153
|
let response;
|
|
@@ -150,6 +159,9 @@ export function createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEm
|
|
|
150
159
|
else if (path === "/api/files") {
|
|
151
160
|
response = await handleFiles(store);
|
|
152
161
|
}
|
|
162
|
+
else if (path === "/api/tree" && method === "GET") {
|
|
163
|
+
response = handleTree(cwd, effectiveConfig());
|
|
164
|
+
}
|
|
153
165
|
else if (path === "/api/chunks" && !path.includes("/api/chunks/")) {
|
|
154
166
|
response = await handleChunks(store, params);
|
|
155
167
|
}
|
|
@@ -164,16 +176,20 @@ export function createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEm
|
|
|
164
176
|
response = await handleCompare(store, params);
|
|
165
177
|
}
|
|
166
178
|
else if (path === "/api/retrieve") {
|
|
167
|
-
response = await handleRetrieve(store, keywordIndex, getEmbedder,
|
|
179
|
+
response = await handleRetrieve(store, keywordIndex, getEmbedder, effectiveConfig(), params);
|
|
168
180
|
}
|
|
169
181
|
else if (path === "/api/indexing/status") {
|
|
170
182
|
response = await handleIndexingStatus(storePath, cwd);
|
|
171
183
|
}
|
|
172
184
|
else if (path === "/api/indexing/reindex" && method === "POST") {
|
|
173
|
-
response = await handleReindex(cwd,
|
|
185
|
+
response = await handleReindex(cwd, effectiveConfig(), storePath, store, getEmbedder);
|
|
186
|
+
}
|
|
187
|
+
else if (path === "/api/config" && method === "GET") {
|
|
188
|
+
response = await handleConfig(effectiveConfig());
|
|
174
189
|
}
|
|
175
|
-
else if (path === "/api/config") {
|
|
176
|
-
|
|
190
|
+
else if (path === "/api/config" && method === "PUT") {
|
|
191
|
+
const body = await readBody(req);
|
|
192
|
+
response = handleConfigUpdate(configPath, configRef, body);
|
|
177
193
|
}
|
|
178
194
|
else if (path === "/api/embeddings/projection") {
|
|
179
195
|
response = await handleEmbeddingProjection(store, params);
|
|
@@ -301,6 +317,47 @@ async function handleFiles(store) {
|
|
|
301
317
|
const files = await store.listFiles();
|
|
302
318
|
return { status: 200, body: files };
|
|
303
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Respond with the workspace **directory** tree (dirs only), used by the UI's
|
|
322
|
+
* indexing-scope folder selector. `indexing.excludeDirs` are pruned so the
|
|
323
|
+
* tree stays clean (node_modules, build output, ...); `includeDirs` are NOT
|
|
324
|
+
* applied — users must be able to see and select every selectable folder.
|
|
325
|
+
*/
|
|
326
|
+
function handleTree(cwd, cfg) {
|
|
327
|
+
if (!cwd) {
|
|
328
|
+
return { status: 400, body: { error: "Workspace path not configured" } };
|
|
329
|
+
}
|
|
330
|
+
const excludeMatcher = createExcludeMatcher(cfg.indexing.excludeDirs);
|
|
331
|
+
const MAX_DIRS = 10_000;
|
|
332
|
+
let visited = 0;
|
|
333
|
+
function walk(dir, rel) {
|
|
334
|
+
const children = [];
|
|
335
|
+
let entries;
|
|
336
|
+
try {
|
|
337
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
return children;
|
|
341
|
+
}
|
|
342
|
+
for (const entry of entries) {
|
|
343
|
+
if (!entry.isDirectory())
|
|
344
|
+
continue;
|
|
345
|
+
const childRel = rel ? `${rel}/${entry.name}` : entry.name;
|
|
346
|
+
if (excludeMatcher.excluded(childRel))
|
|
347
|
+
continue;
|
|
348
|
+
if (++visited > MAX_DIRS)
|
|
349
|
+
continue;
|
|
350
|
+
children.push({
|
|
351
|
+
name: entry.name,
|
|
352
|
+
path: childRel,
|
|
353
|
+
children: walk(join(dir, entry.name), childRel),
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
children.sort((a, b) => a.name.localeCompare(b.name));
|
|
357
|
+
return children;
|
|
358
|
+
}
|
|
359
|
+
return { status: 200, body: { tree: walk(cwd, "") } };
|
|
360
|
+
}
|
|
304
361
|
// ── Quirk Memory API ─────────────────────────────────────────────────
|
|
305
362
|
/** Respond with all stored quirks, sorted by last-observed time (most recent first). */
|
|
306
363
|
async function handleQuirks(deps) {
|
|
@@ -603,6 +660,68 @@ function redactKeys(obj) {
|
|
|
603
660
|
}
|
|
604
661
|
}
|
|
605
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Config keys under `indexing` that the UI may write. Values must be arrays
|
|
665
|
+
* of strings. Add keys here when the UI learns to edit more settings.
|
|
666
|
+
*/
|
|
667
|
+
const INDEXING_STRING_ARRAY_KEYS = new Set([
|
|
668
|
+
"includeExtensions",
|
|
669
|
+
"excludeDirs",
|
|
670
|
+
"excludeFiles",
|
|
671
|
+
"includeDirs",
|
|
672
|
+
]);
|
|
673
|
+
/**
|
|
674
|
+
* Apply a validated config patch (`{ indexing: { includeDirs: [...] } }`)
|
|
675
|
+
* to the on-disk config file and refresh the in-memory config used by
|
|
676
|
+
* subsequent API requests. Only known sections/keys with validated types
|
|
677
|
+
* are accepted; anything else is rejected with a 400.
|
|
678
|
+
*/
|
|
679
|
+
function handleConfigUpdate(configPath, configRef, body) {
|
|
680
|
+
if (!configPath) {
|
|
681
|
+
return {
|
|
682
|
+
status: 400,
|
|
683
|
+
body: { error: "Config file path unavailable — the UI server was started without a config file" },
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
const patch = body;
|
|
687
|
+
if (!patch || typeof patch !== "object" || Array.isArray(patch)) {
|
|
688
|
+
return { status: 400, body: { error: "Invalid config patch" } };
|
|
689
|
+
}
|
|
690
|
+
const otherSections = Object.keys(patch).filter((k) => k !== "indexing");
|
|
691
|
+
if (otherSections.length > 0) {
|
|
692
|
+
return { status: 400, body: { error: `Unsupported config section(s): ${otherSections.join(", ")}` } };
|
|
693
|
+
}
|
|
694
|
+
const indexingPatch = patch.indexing;
|
|
695
|
+
if (indexingPatch !== undefined) {
|
|
696
|
+
if (typeof indexingPatch !== "object" || indexingPatch === null || Array.isArray(indexingPatch)) {
|
|
697
|
+
return { status: 400, body: { error: "Invalid 'indexing' section" } };
|
|
698
|
+
}
|
|
699
|
+
for (const [key, value] of Object.entries(indexingPatch)) {
|
|
700
|
+
if (!INDEXING_STRING_ARRAY_KEYS.has(key)) {
|
|
701
|
+
return { status: 400, body: { error: `Unsupported indexing key '${key}'` } };
|
|
702
|
+
}
|
|
703
|
+
if (!Array.isArray(value) || value.some((v) => typeof v !== "string")) {
|
|
704
|
+
return { status: 400, body: { error: `'indexing.${key}' must be an array of strings` } };
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
if (indexingPatch) {
|
|
709
|
+
for (const [key, value] of Object.entries(indexingPatch)) {
|
|
710
|
+
const ok = updateConfigValue(configPath, ["indexing", key], value);
|
|
711
|
+
if (!ok) {
|
|
712
|
+
return { status: 500, body: { error: `Failed to write 'indexing.${key}' to ${configPath}` } };
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
const current = configRef.current ?? {};
|
|
716
|
+
configRef.current = {
|
|
717
|
+
...current,
|
|
718
|
+
indexing: { ...current.indexing, ...indexingPatch },
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
const redacted = JSON.parse(JSON.stringify(configRef.current));
|
|
722
|
+
redactKeys(redacted);
|
|
723
|
+
return { status: 200, body: { config: redacted } };
|
|
724
|
+
}
|
|
606
725
|
/**
|
|
607
726
|
* Project chunk embeddings to 2D/3D via PCA for the Embedding Space Explorer.
|
|
608
727
|
* Capped at 5000 chunks and memoized per (maxChunks, dims) so the
|
package/dist/web/server.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface WebUiServer {
|
|
|
18
18
|
* @param cwd - Optional workspace root used to resolve file paths for the file API.
|
|
19
19
|
* @param vectorDimension - Embedding vector dimension (default 384).
|
|
20
20
|
* @param cfg - Active RAG configuration (used by quirk endpoints).
|
|
21
|
+
* @param configPath - Path to the opencode-rag.json config file (used by PUT /api/config).
|
|
21
22
|
* @returns A {@link WebUiServer} handle for the running server.
|
|
22
23
|
*/
|
|
23
|
-
export declare function startWebUi(storePath: string, port: number, cwd?: string, vectorDimension?: number, cfg?: import("../core/config.js").RagConfig): Promise<WebUiServer>;
|
|
24
|
+
export declare function startWebUi(storePath: string, port: number, cwd?: string, vectorDimension?: number, cfg?: import("../core/config.js").RagConfig, configPath?: string): Promise<WebUiServer>;
|
package/dist/web/server.js
CHANGED
|
@@ -66,9 +66,10 @@ function serveUiAsset(res, filePath) {
|
|
|
66
66
|
* @param cwd - Optional workspace root used to resolve file paths for the file API.
|
|
67
67
|
* @param vectorDimension - Embedding vector dimension (default 384).
|
|
68
68
|
* @param cfg - Active RAG configuration (used by quirk endpoints).
|
|
69
|
+
* @param configPath - Path to the opencode-rag.json config file (used by PUT /api/config).
|
|
69
70
|
* @returns A {@link WebUiServer} handle for the running server.
|
|
70
71
|
*/
|
|
71
|
-
export async function startWebUi(storePath, port, cwd, vectorDimension = 384, cfg) {
|
|
72
|
+
export async function startWebUi(storePath, port, cwd, vectorDimension = 384, cfg, configPath) {
|
|
72
73
|
const store = new LanceDbStore(storePath, vectorDimension);
|
|
73
74
|
const keywordIndex = await KeywordIndex.load(storePath);
|
|
74
75
|
// Lazy embedder for /api/retrieve — initialized on first use
|
|
@@ -82,7 +83,7 @@ export async function startWebUi(storePath, port, cwd, vectorDimension = 384, cf
|
|
|
82
83
|
}
|
|
83
84
|
const html = getStaticHtml();
|
|
84
85
|
const token = randomBytes(24).toString("hex");
|
|
85
|
-
const apiHandler = createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEmbedder, token);
|
|
86
|
+
const apiHandler = createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEmbedder, token, configPath);
|
|
86
87
|
const server = createServer(async (req, res) => {
|
|
87
88
|
try {
|
|
88
89
|
// Strip the query string before routing — the auth token arrives as
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ScatterPlot3D-DQLl3sKN.js","assets/vendor-Dy7HKFCY.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{l as j,S as re,C as ke,t as hn,k as lt,F as it,R as fn}from"./vendor-Dy7HKFCY.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const a of l)if(a.type==="childList")for(const i of a.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function s(l){const a={};return l.integrity&&(a.integrity=l.integrity),l.referrerPolicy&&(a.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?a.credentials="include":l.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(l){if(l.ep)return;l.ep=!0;const a=s(l);fetch(l.href,a)}})();var mn=0;function t(e,n,s,r,l,a){n||(n={});var i,o,c=n;if("ref"in c)for(o in c={},n)o=="ref"?i=n[o]:c[o]=n[o];var d={type:e,props:c,key:s,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--mn,__i:-1,__u:0,__source:l,__self:a};if(typeof e=="function"&&(i=e.defaultProps))for(o in i)c[o]===void 0&&(c[o]=i[o]);return j.vnode&&j.vnode(d),d}var Ae,A,tt,pt,De=0,Kt=[],O=j,xt=O.__b,vt=O.__r,gt=O.diffed,bt=O.__c,_t=O.unmount,yt=O.__;function dt(e,n){O.__h&&O.__h(A,e,De||n),De=0;var s=A.__H||(A.__H={__:[],__h:[]});return e>=s.__.length&&s.__.push({}),s.__[e]}function g(e){return De=1,pn(Vt,e)}function pn(e,n,s){var r=dt(Ae++,2);if(r.t=e,!r.__c&&(r.__=[s?s(n):Vt(void 0,n),function(o){var c=r.__N?r.__N[0]:r.__[0],d=r.t(c,o);c!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=A,!A.__f)){var l=function(o,c,d){if(!r.__c.__H)return!0;var u=!1,f=r.__c.props!==o;if(r.__c.__H.__.some(function(h){if(h.__N){u=!0;var p=h.__[0];h.__=h.__N,h.__N=void 0,p!==h.__[0]&&(f=!0)}}),a){var x=a.call(this,o,c,d);return u?x||f:x}return!u||f};A.__f=!0;var a=A.shouldComponentUpdate,i=A.componentWillUpdate;A.componentWillUpdate=function(o,c,d){if(this.__e){var u=a;a=void 0,l(o,c,d),a=u}i&&i.call(this,o,c,d)},A.shouldComponentUpdate=l}return r.__N||r.__}function D(e,n){var s=dt(Ae++,3);!O.__s&&Bt(s.__H,n)&&(s.__=e,s.u=n,A.__H.__h.push(s))}function ae(e){return De=5,de(function(){return{current:e}},[])}function de(e,n){var s=dt(Ae++,7);return Bt(s.__H,n)&&(s.__=e(),s.__H=n,s.__h=e),s.__}function Nt(e,n){return De=8,de(function(){return e},n)}function xn(){for(var e;e=Kt.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(Ke),n.__h.some(ot),n.__h=[]}catch(s){n.__h=[],O.__e(s,e.__v)}}}O.__b=function(e){A=null,xt&&xt(e)},O.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),yt&&yt(e,n)},O.__r=function(e){vt&&vt(e),Ae=0;var n=(A=e.__c).__H;n&&(tt===A?(n.__h=[],A.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(Ke),n.__h.some(ot),n.__h=[],Ae=0)),tt=A},O.diffed=function(e){gt&>(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(Kt.push(n)!==1&&pt===O.requestAnimationFrame||((pt=O.requestAnimationFrame)||vn)(xn)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),tt=A=null},O.__c=function(e,n){n.some(function(s){try{s.__h.some(Ke),s.__h=s.__h.filter(function(r){return!r.__||ot(r)})}catch(r){n.some(function(l){l.__h&&(l.__h=[])}),n=[],O.__e(r,s.__v)}}),bt&&bt(e,n)},O.unmount=function(e){_t&&_t(e);var n,s=e.__c;s&&s.__H&&(s.__H.__.some(function(r){try{Ke(r)}catch(l){n=l}}),s.__H=void 0,n&&O.__e(n,s.__v))};var wt=typeof requestAnimationFrame=="function";function vn(e){var n,s=function(){clearTimeout(r),wt&&cancelAnimationFrame(n),setTimeout(e)},r=setTimeout(s,35);wt&&(n=requestAnimationFrame(s))}function Ke(e){var n=A,s=e.__c;typeof s=="function"&&(e.__c=void 0,s()),A=n}function ot(e){var n=A;e.__c=e.__(),A=n}function Bt(e,n){return!e||e.length!==n.length||n.some(function(s,r){return s!==e[r]})}function Vt(e,n){return typeof n=="function"?n(e):n}function kt(){const e=location.hash.slice(1)||"dashboard",n=e.indexOf("?"),s=n>=0?e.slice(0,n):e,r={};if(n>=0){const l=e.slice(n+1);for(const a of l.split("&")){const i=a.indexOf("=");if(i>=0)try{r[decodeURIComponent(a.slice(0,i))]=decodeURIComponent(a.slice(i+1))}catch{}}}return{view:s||"dashboard",params:r}}function Oe(){const[e,n]=g(kt);return D(()=>{const s=()=>n(kt());return addEventListener("hashchange",s),()=>removeEventListener("hashchange",s)},[]),e}var gn=Symbol.for("preact-signals");function Je(){if(ie>1)ie--;else{var e,n=!1;for(function(){var l=Ge;for(Ge=void 0;l!==void 0;){var a=l.S;if(a.v===l.v)for(var i=a.t;i!==void 0;i=i.x)i.i===l.i&&(i.i=a.i);l=l.o}}();Me!==void 0;){var s=Me;for(Me=void 0,Ve++;s!==void 0;){var r=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Qt(s))try{s.c()}catch(l){n||(e=l,n=!0)}s=r}}if(Ve=0,ie--,n)throw e}}function bn(e){if(ie>0)return e();ct=++_n,ie++;try{return e()}finally{Je()}}var Ee,R=void 0;function et(e){var n=R,s=Ee;R=void 0,Ee=void 0;try{return e()}finally{R=n,Ee=s}}var Me=void 0,ie=0,Ve=0,_n=0,ct=0,Ge=void 0,Qe=0;function Gt(e){if(R!==void 0){var n=e.n;if(n===void 0||n.t!==R)return n={i:0,S:e,p:R.s,n:void 0,t:R,e:void 0,x:void 0,r:n},R.s!==void 0&&(R.s.n=n),R.s=n,e.n=n,32&R.f&&e.S(n),n;if(n.i===-1)return n.i=0,n.n!==void 0&&(n.n.p=n.p,n.p!==void 0&&(n.p.n=n.n),n.p=R.s,n.n=void 0,R.s.n=n,R.s=n),n}}function H(e,n){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=n==null?void 0:n.watched,this.Z=n==null?void 0:n.unwatched,this.name=n==null?void 0:n.name}H.prototype.brand=gn;H.prototype.h=function(){return!0};H.prototype.S=function(e){var n=this,s=this.t;s!==e&&e.e===void 0&&(e.x=s,this.t=e,s!==void 0?s.e=e:et(function(){var r;(r=n.W)==null||r.call(n)}))};H.prototype.U=function(e){var n=this;if(this.t!==void 0){var s=e.e,r=e.x;s!==void 0&&(s.x=r,e.e=void 0),r!==void 0&&(r.e=s,e.x=void 0),e===this.t&&(this.t=r,r===void 0&&et(function(){var l;(l=n.Z)==null||l.call(n)}))}};H.prototype.subscribe=function(e){var n=this;return je(function(){var s=n.value;et(function(){return e(s)})},{name:"sub"})};H.prototype.valueOf=function(){return this.value};H.prototype.toString=function(){return this.value+""};H.prototype.toJSON=function(){return this.value};H.prototype.peek=function(){var e=this;return et(function(){return e.value})};Object.defineProperty(H.prototype,"value",{get:function(){var e=Gt(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Ve>100)throw new Error("Cycle detected");(function(s){ie!==0&&Ve===0&&s.l!==ct&&(s.l=ct,Ge={S:s,v:s.v,i:s.i,o:Ge})})(this),this.v=e,this.i++,Qe++,ie++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{Je()}}}});function E(e,n){return new H(e,n)}function Qt(e){for(var n=e.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function Xt(e){for(var n=e.s;n!==void 0;n=n.n){var s=n.S.n;if(s!==void 0&&(n.r=s),n.S.n=n,n.i=-1,n.n===void 0){e.s=n;break}}}function Zt(e){for(var n=e.s,s=void 0;n!==void 0;){var r=n.p;n.i===-1?(n.S.U(n),r!==void 0&&(r.n=n.n),n.n!==void 0&&(n.n.p=r)):s=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=r}e.s=s}function me(e,n){H.call(this,void 0,n),this.x=e,this.s=void 0,this.g=Qe-1,this.f=4}me.prototype=new H;me.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Qe))return!0;if(this.g=Qe,this.f|=1,this.i>0&&!Qt(this))return this.f&=-2,!0;var e=R;try{Xt(this),R=this;var n=this.x();(16&this.f||this.v!==n||this.i===0)&&(this.v=n,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return R=e,Zt(this),this.f&=-2,!0};me.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}H.prototype.S.call(this,e)};me.prototype.U=function(e){if(this.t!==void 0&&(H.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}};me.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}};Object.defineProperty(me.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Gt(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function St(e,n){return new me(e,n)}function Yt(e){var n=e.m;if(e.m=void 0,typeof n=="function"){ie++;var s=R;R=void 0;try{n()}catch(r){throw e.f&=-2,e.f|=8,ut(e),r}finally{R=s,Je()}}}function ut(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,Yt(e)}function yn(e){if(R!==this)throw new Error("Out-of-order effect");Zt(this),R=e,this.f&=-2,8&this.f&&ut(this),Je()}function Se(e,n){this.x=e,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=n==null?void 0:n.name,Ee&&Ee.push(this)}Se.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var n=this.x();typeof n=="function"&&(this.m=n)}finally{e()}};Se.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Yt(this),Xt(this),ie++;var e=R;return R=this,yn.bind(this,e)};Se.prototype.N=function(){2&this.f||(this.f|=2,this.u=Me,Me=this)};Se.prototype.d=function(){this.f|=8,1&this.f||ut(this)};Se.prototype.dispose=function(){this.d()};function je(e,n){var s=new Se(e,n);try{s.c()}catch(l){throw s.d(),l}var r=s.d.bind(s);return r[Symbol.dispose]=r,r}var Jt,ze,Nn=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,en=[];je(function(){Jt=this.N})();function Ce(e,n){j[e]=n.bind(null,j[e]||function(){})}function Xe(e){if(ze){var n=ze;ze=void 0,n()}ze=e&&e.S()}function tn(e){var n=this,s=e.data,r=kn(s);r.name="ReactiveDom",r.value=s;var l=de(function(){for(var o=n,c=n.__v;c=c.__;)if(c.__c){c.__c.__$f|=4;break}var d=St(function(){var h=r.value.value;return h===0?0:h===!0?"":h||""}),u=St(function(){return!Array.isArray(d.value)&&!hn(d.value)}),f=je(function(){if(this.N=nn,u.value){var h=d.value;o.__v&&o.__v.__e&&o.__v.__e.nodeType===3&&(o.__v.__e.data=h)}}),x=n.__$u.d;return n.__$u.d=function(){f(),x.call(this)},[u,d]},[]),a=l[0],i=l[1];return a.value?i.peek():i.value}tn.displayName="ReactiveTextNode";Object.defineProperties(H.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:tn},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});Ce("__b",function(e,n){if(typeof n.type=="string"){var s,r=n.props;for(var l in r)if(l!=="children"){var a=r[l];a instanceof H&&(s||(n.__np=s={}),s[l]=a,r[l]=a.peek())}}e(n)});Ce("__r",function(e,n){if(e(n),n.type!==re){Xe();var s,r=n.__c;r&&(r.__$f&=-2,(s=r.__$u)===void 0&&(r.__$u=s=function(l,a){var i;return je(function(){i=this},{name:a}),i.c=l,i}(function(){var l;Nn&&((l=s.y)==null||l.call(s)),r.__$f|=1,r.setState({})},typeof n.type=="function"?n.type.displayName||n.type.name:""))),Xe(s)}});Ce("__e",function(e,n,s,r){Xe(),e(n,s,r)});Ce("diffed",function(e,n){Xe();var s;if(typeof n.type=="string"&&(s=n.__e)){var r=n.__np,l=n.props,a=s.U;if(a)for(var i in a){var o=a[i];o===void 0||r&&i in r||(o.d(),a[i]=void 0)}if(r){a||(a={},s.U=a);for(var c in r){var d=a[c],u=r[c];d===void 0?(d=wn(s,c,u,l),a[c]=d):d.o(u,l)}}}e(n)});function wn(e,n,s,r){var l=n in e&&e.ownerSVGElement===void 0,a=E(s);return{o:function(i,o){a.value=i,r=o},d:je(function(){this.N=nn;var i=a.value.value;r[n]!==i&&(r[n]=i,l?e[n]=i:i!=null&&(i!==!1||n[4]==="-")?e.setAttribute(n,i):e.removeAttribute(n))})}}Ce("unmount",function(e,n){if(typeof n.type=="string"){var s=n.__e;if(s){var r=s.U;if(r){s.U=void 0;for(var l in r){var a=r[l];a&&a.d()}}}var i=n.__np;if(i){var o=n.props;for(var c in i)o[c]=i[c]}n.__np=void 0}else{var d=n.__c;if(d){var u=d.__$u;u&&(d.__$u=void 0,u.d())}}e(n)});Ce("__h",function(e,n,s,r){r<3&&(n.__$f|=2),e(n,s,r)});ke.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var s=this.__$u,r=s&&s.s!==void 0;for(var l in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(r||a||4&this.__$f)||1&this.__$f)return!0}else if(!(r||4&this.__$f)||3&this.__$f)return!0;for(var i in e)if(i!=="__source"&&e[i]!==this.props[i])return!0;for(var o in this.props)if(!(o in e))return!0;return!1};function kn(e,n){return de(function(){return E(e,n)},[])}var Sn=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Cn(){bn(function(){for(var e;e=en.shift();)Jt.call(e)})}function nn(){en.push(this)===1&&(j.requestAnimationFrame||Sn)(Cn)}const nt=E("dashboard"),fe=E(null),Ne=E(null),we=E(null),Pe=E(0),$n=E(50),te=E(new Set),st=E(new Set),Q=E(""),_=E({topK:10,minScore:.35,keywordWeight:.4,hybrid:!0,pathFilter:"",langFilter:"",extFilter:""}),ce=E([]),Ze=E([]);E(!1);E(null);E([]);E(new Set);E(null);E(null);const oe=E(typeof localStorage<"u"?localStorage.getItem("theme")??"dark":"dark"),qe=E(!0),Ie=E([]);let Ln=0;function Z(e,n,s=4e3){const r=Ln++;Ie.value=[...Ie.value,{id:r,type:e,message:n,duration:s}],setTimeout(()=>{Ie.value=Ie.value.filter(l=>l.id!==r)},s)}function U(e){window.location.hash=e}function Tn(){D(()=>{document.documentElement.classList.toggle("dark",oe.value==="dark"),localStorage.setItem("theme",oe.value)},[oe.value]);const e=()=>{oe.value=oe.value==="dark"?"light":"dark"};return{theme:oe.value,toggle:e}}function Rn(){D(()=>{let e=null,n=null;const s=()=>{e&&(clearTimeout(e),e=null),n&&(window.removeEventListener("keydown",n),n=null)},r=l=>{const a=l.target,i=a.tagName==="INPUT"||a.tagName==="TEXTAREA"||a.isContentEditable;if((l.metaKey||l.ctrlKey)&&l.key==="k"){l.preventDefault(),U("search"),setTimeout(()=>{var o;(o=document.querySelector(".global-search-input"))==null||o.focus()},0);return}if(!i&&l.key==="g"){const o={d:()=>U("dashboard"),s:()=>U("search"),c:()=>U("chunks"),f:()=>U("files"),e:()=>U("evaluate"),q:()=>U("quirks")};s();const c=d=>{var u;(u=o[d.key])==null||u.call(o),s()};n=c,window.addEventListener("keydown",c),e=setTimeout(s,500);return}};return window.addEventListener("keydown",r),()=>{window.removeEventListener("keydown",r),s()}},[])}function Pn(){return t("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:Ie.value.map(e=>t("div",{className:`pointer-events-auto px-4 py-2.5 rounded-lg shadow-lg text-sm font-medium transition-all duration-300 animate-slide-in ${e.type==="success"?"bg-green-600 text-white":e.type==="error"?"bg-red-600 text-white":"bg-brand-600 text-white"}`,children:e.message},e.id))})}function In(){const e=oe.value==="dark";return t("button",{className:"p-2 rounded-lg transition-colors",style:{color:"var(--text-muted)"},onClick:()=>{oe.value=e?"light":"dark"},"aria-label":e?"Switch to light mode":"Switch to dark mode",title:e?"Light mode":"Dark mode",children:[t("span",{className:"sr-only",children:e?"Switch to light mode":"Switch to dark mode"}),e?t("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})}):t("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","aria-hidden":"true",children:t("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"})})]})}function ht(e,n){const[s,r]=g(e);return D(()=>{const l=setTimeout(()=>r(e),n);return()=>clearTimeout(l)},[e,n]),s}const En="/api",Ct="opencode-rag-token";function Mn(){const e=new URLSearchParams(window.location.search).get("token");if(e){sessionStorage.setItem(Ct,e);const n=window.location.pathname+window.location.hash;return window.history.replaceState(null,"",n),e}return sessionStorage.getItem(Ct)}function Fn(){const e=Mn();return e?{Authorization:`Bearer ${e}`}:{}}function $t(e){const n=new URLSearchParams;for(const[s,r]of Object.entries(e))r!==void 0&&r!==""&&n.set(s,String(r));return n.toString()}async function I(e,n){const s={...(n==null?void 0:n.headers)??{},...Fn()},r=await fetch(En+e,{...n,headers:s}),l=await r.json();if(!r.ok)throw new Error(l.error??r.statusText);return l}const $={stats:()=>I("/stats"),files:()=>I("/files"),chunks:e=>I(`/chunks?${$t(e)}`),chunk:e=>I(`/chunks/${encodeURIComponent(e)}`),search:(e,n=20)=>I(`/search?q=${encodeURIComponent(e)}&topK=${n}`),compare:e=>I(`/compare?ids=${e.join(",")}`),retrieve:e=>I(`/retrieve?${$t(e)}`),evalSessions:()=>I("/eval/sessions"),evalSession:e=>I(`/eval/sessions/${encodeURIComponent(e)}`),evalDeleteSession:e=>I(`/eval/sessions/${encodeURIComponent(e)}`,{method:"DELETE"}),evalCompare:(e,n)=>I(`/eval/compare?a=${e}&b=${n}`),evalTokenCompare:(e,n)=>I(`/eval/token-compare?a=${e}&b=${n}`),evalAnalysis:e=>I(`/eval/sessions/${encodeURIComponent(e)}/analysis`),evalProjectSavings:e=>I("/eval/project-savings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),quirks:()=>I("/quirks"),quirkLint:()=>I("/quirks/lint"),deleteQuirk:e=>I(`/quirks/${encodeURIComponent(e)}`,{method:"DELETE"}),indexStatus:()=>I("/indexing/status"),triggerReindex:()=>I("/indexing/reindex",{method:"POST"}),config:()=>I("/config"),updateConfig:e=>I("/config",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),tree:()=>I("/tree"),embeddingProj:(e=5e3,n=2)=>I(`/embeddings/projection?maxChunks=${e}&dims=${n}`)},An={typescript:"text-blue-400",javascript:"text-yellow-400",python:"text-green-400",java:"text-red-400",go:"text-cyan-400",rust:"text-orange-400",ruby:"text-pink-400",csharp:"text-purple-400",cpp:"text-indigo-400",c:"text-gray-400",markdown:"text-gray-300",html:"text-orange-300",css:"text-blue-300",json:"text-yellow-300",kotlin:"text-purple-300",swift:"text-orange-400",tex:"text-emerald-400",sql:"text-cyan-300"};function Ue(e){return An[e]??"text-slate-400"}function pe(e){return`<span class="inline-block px-1.5 py-0.5 rounded text-xs font-mono ${Ue(e)} bg-slate-800">${Dn(e)}</span>`}function Dn(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function C(e){return typeof e!="string"?"":e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Lt(e,n=80){const s=typeof e=="string"?e:String(e??"");return s.length>n?s.slice(0,n)+"...":s}function On(){const[e,n]=g(""),[s,r]=g([]),[l,a]=g(!1),i=ae(null),o=ae(null),c=ht(e,300);D(()=>{if(!c.trim()){r([]),a(!1);return}let f=!1;return $.search(c,10).then(x=>{f||(r((x==null?void 0:x.results)??[]),a(!0))}).catch(()=>{f||a(!1)}),()=>{f=!0}},[c]),D(()=>{const f=x=>{o.current&&!o.current.contains(x.target)&&a(!1)};return document.addEventListener("click",f),()=>document.removeEventListener("click",f)},[]);const d=f=>{f.key==="Escape"&&a(!1)},u=async f=>{a(!1),n(""),U("chunks")};return t("div",{ref:o,className:"relative",children:[t("input",{ref:i,type:"text",placeholder:"Search codebase...",value:e,onInput:f=>n(f.target.value),onKeyDown:d,className:"global-search-input w-56 px-3 py-1.5 bg-slate-800 border border-slate-600 rounded text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-brand-400","aria-label":"Global search",role:"combobox","aria-expanded":l}),l&&s.length>0&&t("div",{className:"absolute top-full right-0 mt-1 w-96 bg-slate-800 border border-slate-600 rounded-lg shadow-xl z-50 max-h-80 overflow-y-auto",role:"listbox",children:s.map(f=>t("div",{className:"search-result p-2 hover:bg-slate-700 cursor-pointer border-b border-slate-700 last:border-0",onClick:()=>u(f.chunk.id),role:"option",children:[t("div",{className:"flex items-center gap-2 text-xs",children:[t("span",{className:"text-yellow-400 font-mono",children:[C(f.chunk.filePath),":",f.chunk.startLine,"-",f.chunk.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:pe(f.chunk.language)}}),t("span",{className:"ml-auto text-slate-500",children:f.score})]}),t("div",{className:"text-xs text-slate-400 mt-1 truncate",children:C(f.chunk.content??"").slice(0,80)})]},f.chunk.id))}),l&&e.trim()&&s.length===0&&t("div",{className:"absolute top-full right-0 mt-1 w-96 bg-slate-800 border border-slate-600 rounded-lg shadow-xl z-50 p-3 text-sm text-slate-500",children:"No results"})]})}function J(e,n=[]){const[s,r]=g(null),[l,a]=g(!0),[i,o]=g(null),[c,d]=g(0);return D(()=>{let u=!1;return a(!0),o(null),e().then(f=>{u||(r(f),a(!1))}).catch(f=>{u||(o(f.message),a(!1))}),()=>{u=!0}},[...n,c]),{data:s,isLoading:l,error:i,refresh:()=>d(u=>u+1)}}function jn(){const{data:e}=J(()=>$.files()),n=e??[],[s,r]=g(""),l=ht(s,300),a=l?n.filter(i=>i.filePath.toLowerCase().includes(l.toLowerCase())):n;return t("div",{className:"flex flex-col h-full",children:[t("div",{className:"flex items-center justify-between mb-2 px-3 pt-3",children:[t("h2",{className:"text-xs font-semibold text-slate-400 uppercase tracking-wide",children:"Files"}),t("span",{className:"text-xs text-slate-500",children:a.length})]}),t("div",{className:"px-3 mb-2",children:t("input",{type:"text",placeholder:"Filter files...",value:s,onInput:i=>r(i.target.value),className:"w-full px-2 py-1 bg-slate-900 border border-slate-700 rounded text-xs focus:outline-none focus:border-brand-400 text-slate-200 placeholder-slate-500"})}),t("div",{className:"flex-1 overflow-y-auto px-1",children:t(Un,{files:a})})]})}function Un({files:e}){const n={};for(const s of e){const r=s.filePath.split("/");let l=n;for(let a=0;a<r.length-1;a++)l[r[a]]||(l[r[a]]={}),l=l[r[a]];l.__files||(l.__files=[]),l.__files.push(s)}return t(an,{obj:n,depth:0,parentPath:""})}function sn(e){let n=(e.__files||[]).length;for(const[s,r]of Object.entries(e))s!=="__files"&&(n+=sn(r));return n}function an({obj:e,depth:n,parentPath:s}){const r=Object.entries(e).filter(([a])=>a!=="__files").sort(([a],[i])=>a.localeCompare(i)),l=e.__files||[];return t(re,{children:[r.map(([a,i])=>{const o=s?`${s}/${a}`:a,c=sn(i),d=st.value.has(o),u=d?"▸":"▾";return t("div",{children:[t("div",{className:"file-item flex items-center gap-1 py-0.5 px-2 rounded cursor-pointer text-slate-400 hover:text-white",style:{paddingLeft:`${n*12+8}px`},onClick:()=>{const f=new Set(st.value);f.has(o)?f.delete(o):f.add(o),st.value=f},role:"treeitem","aria-expanded":!d,children:[t("span",{className:"text-xs",children:u}),t("span",{className:"text-xs",children:"📁"}),t("span",{className:"text-xs",children:C(a)}),t("span",{className:"text-xs text-slate-600 ml-auto",children:c})]}),!d&&t("div",{className:"dir-children",children:t(an,{obj:i,depth:n+1,parentPath:o})})]},o)}),l.map(a=>{const i=a.filePath.split("/").pop()??a.filePath,o=fe.value===a.filePath;return t("div",{className:`file-item flex items-center gap-1 py-0.5 px-2 rounded cursor-pointer ${o?"active text-white":"text-slate-400 hover:text-white"}`,style:{paddingLeft:`${n*12+8}px`},onClick:()=>{fe.value=a.filePath,U(`chunks?file=${encodeURIComponent(a.filePath)}`)},role:"treeitem",tabIndex:0,children:[t("span",{className:`text-xs ${Ue(a.language)}`,children:"♦"}),t("span",{className:"text-xs truncate",children:C(i)}),t("span",{className:"text-xs text-slate-600 ml-auto",children:a.chunkCount})]},a.filePath)})]})}function Tt(e){const n=[...e].sort(),s=[];for(const r of n)s.some(l=>r.startsWith(`${l}/`))||s.push(r);return s}function rn(e,n){return n.includes(e)?"checked":n.some(s=>s.startsWith(`${e}/`))?"partial":"unchecked"}function zn(){var w,y,T,q,W,le;const e=J(()=>$.tree()),n=J(()=>$.config()),[s,r]=g(!1),[l,a]=g([]),[i,o]=g([]),[c,d]=g(!1),[u,f]=g(!1),[x,h]=g(!1),p=((y=(w=n.data)==null?void 0:w.body)==null?void 0:y.config)??((T=n.data)==null?void 0:T.config),m=((W=(q=e.data)==null?void 0:q.body)==null?void 0:W.tree)??((le=e.data)==null?void 0:le.tree);D(()=>{var F;if(p&&!c){const G=((F=p.indexing)==null?void 0:F.includeDirs)??[];a(G),o(G),d(!0)}},[p,c]);const b=Tt(l),L=Tt(i).join("|")!==b.join("|"),P=b.length===0;function N(F){const G=new Set(l);if(rn(F,l)==="checked")for(const S of l)(S===F||S.startsWith(`${F}/`))&&G.delete(S);else{G.add(F);for(const S of l)S.startsWith(`${F}/`)&&G.delete(S)}a([...G])}function V(){a([])}async function ve(){if(!u){f(!0);try{await $.updateConfig({indexing:{includeDirs:b}}),a(b),o(b),h(!0)}catch(F){Z("error",`Failed to save scope: ${F.message}`)}finally{f(!1)}}}async function z(){h(!1),Z("info","Scope saved — starting reindex…");try{await $.triggerReindex(),Z("success","Reindex started in the background.")}catch(F){Z("error",`Reindex failed to start: ${F.message}`)}}return t("div",{className:"border-b",style:{borderColor:"var(--border)"},children:[t("button",{type:"button",className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-semibold text-slate-400 uppercase tracking-wide hover:text-white",onClick:()=>r(F=>!F),"aria-expanded":s,children:[t("span",{className:"text-xs",children:s?"▾":"▸"}),t("span",{children:"Indexing scope"}),b.length>0&&t("span",{className:"ml-auto text-xs text-slate-500",children:[b.length," folder",b.length===1?"":"s"]})]}),s&&t("div",{className:"px-2 pb-3 text-xs",children:[e.error&&t("p",{className:"text-red-400 px-2 py-1",children:["Could not load workspace tree: ",e.error,t("button",{type:"button",className:"ml-2 underline",onClick:e.refresh,children:"Retry"})]}),!e.error&&!m&&t("p",{className:"px-2 py-1 text-slate-500",children:"Loading folders…"}),m&&t(re,{children:[t("label",{className:"flex items-center gap-1.5 py-1 px-2 rounded cursor-pointer text-slate-300 hover:text-white",children:[t("input",{type:"checkbox",checked:P,onChange:V}),t("span",{children:"Whole workspace"}),!P&&t("span",{className:"text-slate-500",children:"(include all folders)"})]}),t("p",{className:"px-2 py-1 text-slate-600",children:'Selecting a folder includes all of its subfolders. Files directly in the workspace root are only indexed with "Whole workspace".'}),t("div",{className:"max-h-48 overflow-y-auto border rounded",style:{borderColor:"var(--border)"},children:t(ln,{dirs:m,depth:0,selection:l,onToggle:N})}),t("button",{type:"button",disabled:!L||u,className:"mt-2 w-full px-3 py-1.5 rounded font-semibold disabled:opacity-40 disabled:cursor-not-allowed",style:{background:"var(--accent)",color:"#fff"},onClick:ve,children:u?"Saving…":L?"Save scope":"Saved"}),t("p",{className:"mt-1.5 px-2 text-slate-600",children:["Saved to ",t("code",{children:"opencode-rag.json"}),". The background watcher applies the new scope after an OpenCode restart."]})]})]}),x&&t("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.55)"},children:t("div",{className:"rounded-lg p-5 max-w-sm w-full shadow-xl",style:{background:"var(--bg-secondary)",border:"1px solid var(--border)"},children:[t("h3",{className:"text-base font-bold mb-2",children:"Scope saved"}),t("p",{className:"text-sm mb-4",style:{color:"var(--text-muted)"},children:"The includeDirs setting was written to opencode-rag.json. Reindex now so the index matches the new scope?"}),t("div",{className:"flex justify-end gap-2",children:[t("button",{type:"button",className:"px-3 py-1.5 rounded text-sm",style:{background:"var(--bg-primary)",border:"1px solid var(--border)"},onClick:()=>{h(!1),Z("success","Scope saved — applies on the next index pass.")},children:"Later"}),t("button",{type:"button",className:"px-3 py-1.5 rounded text-sm font-semibold text-white",style:{background:"var(--accent)"},onClick:z,children:"Reindex now"})]})]})})]})}function ln({dirs:e,depth:n,selection:s,onToggle:r}){return t(re,{children:e.map(l=>{const a=rn(l.path,s);return t("div",{children:[t("label",{className:"flex items-center gap-1.5 py-0.5 px-2 rounded cursor-pointer text-slate-400 hover:text-white",style:{paddingLeft:`${n*12+8}px`},children:[t("input",{type:"checkbox",checked:a==="checked",ref:i=>{i&&(i.indeterminate=a==="partial")},onChange:()=>r(l.path)}),t("span",{className:"text-xs",children:"📁"}),t("span",{className:"text-xs truncate",children:l.name})]}),l.children.length>0&&t(ln,{dirs:l.children,depth:n+1,selection:s,onToggle:r})]},l.path)})})}const ne="bg-gradient-to-r from-slate-700 via-slate-600 to-slate-700 bg-[length:200%_100%]";function Y({type:e="card"}){return t("div",{className:"animate-pulse space-y-4",children:[t("div",{className:`h-8 ${ne} rounded w-48`}),e==="card"&&t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(n=>t("div",{className:"h-24 bg-slate-800 rounded-lg border border-slate-700 p-4",children:[t("div",{className:`h-3 ${ne} rounded w-16 mb-2`}),t("div",{className:`h-6 ${ne} rounded w-24`})]},n))}),e==="table"&&t("div",{className:"space-y-2",children:[t("div",{className:`h-10 ${ne} rounded w-full`}),[1,2,3,4,5].map(n=>t("div",{className:`h-8 ${ne} rounded w-full`},n))]}),e==="chart"&&t("div",{className:`h-64 ${ne} rounded-lg`}),e==="detail"&&t("div",{className:"flex gap-4",children:[t("div",{className:"flex-1 space-y-3",children:[t("div",{className:`h-6 ${ne} rounded w-48`}),t("div",{className:`h-4 ${ne} rounded w-32`}),t("div",{className:`h-32 ${ne} rounded-lg`})]}),t("div",{className:"flex-1 space-y-3",children:[t("div",{className:`h-6 ${ne} rounded w-48`}),t("div",{className:`h-4 ${ne} rounded w-32`}),t("div",{className:`h-32 ${ne} rounded-lg`})]})]})]})}function se({message:e,onRetry:n}){return t("div",{className:"flex flex-col items-center justify-center py-12 text-center",role:"alert",children:[t("span",{className:"text-4xl mb-3",children:"⚠️"}),t("p",{className:"text-slate-400 mb-4",children:e}),n&&t("button",{className:"bg-brand-600 hover:bg-brand-500 text-white px-4 py-2 rounded transition-colors",onClick:n,children:"Retry"})]})}function xe({icon:e,message:n,action:s}){return t("div",{className:"flex flex-col items-center justify-center py-16 text-center",role:"status",children:[t("span",{className:"text-5xl mb-4",role:"img","aria-label":e,children:e}),t("p",{className:"text-slate-400 mb-4",children:n}),s&&t("button",{className:"bg-brand-600 hover:bg-brand-500 text-white px-4 py-2 rounded transition-colors",onClick:s.onClick,children:s.label})]})}function X({label:e,value:n,icon:s}){return t("div",{className:"kpi-card p-4",children:[s&&t("span",{className:"text-lg mb-1 block",children:s}),t("div",{className:"text-slate-400 text-xs mb-1",children:e}),t("div",{className:"text-3xl font-bold text-white",children:n})]})}function B(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function Ye(e){return e===0?"$0.00":e<.01?"$"+e.toFixed(4):"$"+e.toFixed(2)}function qn(e){return e>=6e4?(e/6e4).toFixed(1)+"m":e>=1e3?(e/1e3).toFixed(1)+"s":e+"ms"}function on(e){if(!e)return"-";const n=new Date(e);return n.toLocaleDateString()+" "+n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Hn(e){const n=Date.now()-new Date(e).getTime(),s=Math.floor(n/6e4);if(s<1)return"just now";if(s<60)return`${s}m ago`;const r=Math.floor(s/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Wn(){var x;const[e,n]=g(null),[s,r]=g(!0),[l,a]=g(!1),i=ae(null),o=async()=>{try{const h=await $.indexStatus();n(h.body??h)}catch{}r(!1)};D(()=>{o()},[]),D(()=>()=>{i.current&&clearInterval(i.current)},[]);const c=async()=>{var h;a(!0);try{await $.triggerReindex(),Z("info","Reindex started in background");const p=(h=e==null?void 0:e.manifest)==null?void 0:h.lastIndexedAt,m=Date.now();i.current=setInterval(async()=>{var b;if(Date.now()-m>10*6e4){i.current&&clearInterval(i.current),i.current=null,a(!1),Z("info","Reindex is still running — check back later");return}try{const L=await $.indexStatus(),P=L.body??L;((b=P.manifest)==null?void 0:b.lastIndexedAt)!==p&&(i.current&&clearInterval(i.current),i.current=null,n(P),a(!1),Z("success","Reindex complete!"))}catch{}},2e3)}catch(p){const m=p.message??"";Z("error",/already running/i.test(m)?"A reindex is already running":`Reindex failed: ${m}`),a(!1)}};if(s)return null;const d=(x=e==null?void 0:e.manifest)!=null&&x.lastIndexedAt?Hn(e.manifest.lastIndexedAt):"Never",u=(e==null?void 0:e.staleFileCount)??0,f=u===0?"text-green-400":u<50?"text-amber-400":"text-red-400";return t("div",{className:"kpi-card p-4 mb-6",children:[t("div",{className:"flex items-center justify-between mb-3",children:t("h2",{className:"text-lg font-semibold",children:"Index Status"})}),e!=null&&e.manifest?t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t("div",{children:[t("span",{className:"text-xs text-slate-500 block",children:"Last Indexed"}),t("span",{className:"text-sm font-mono",children:d})]}),t("div",{children:[t("span",{className:"text-xs text-slate-500 block",children:"Total Chunks"}),t("span",{className:"text-sm font-mono",children:B(e.manifest.totalChunks)})]}),t("div",{children:[t("span",{className:"text-xs text-slate-500 block",children:"Total Files"}),t("span",{className:"text-sm font-mono",children:B(e.manifest.totalFiles)})]}),t("div",{children:[t("span",{className:"text-xs text-slate-500 block",children:"Schema Version"}),t("span",{className:"text-sm font-mono",children:e.manifest.schemaVersion})]}),t("div",{className:"col-span-2",children:[t("span",{className:"text-xs text-slate-500 block",children:"Index Freshness"}),t("span",{className:`text-sm font-mono ${f}`,children:u===0?"✓ Up to date":`⚠ ${u} file${u!==1?"s":""} modified since last index`})]}),t("div",{className:"col-span-2 flex items-end",children:l?t("div",{className:"flex items-center gap-2",children:[t("span",{className:"animate-spin",children:"⟳"}),t("span",{className:"text-sm text-amber-400",children:"Reindexing..."})]}):t("button",{className:"bg-brand-600 hover:bg-brand-500 text-white px-4 py-1.5 rounded text-sm transition-colors",onClick:c,children:"Reindex Now"})})]}):t("div",{className:"text-sm text-slate-400",children:["No index found. Run ",t("code",{className:"text-brand-400",children:"opencode-rag index"})," first."]})]})}function Kn(){var x,h,p;const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.stats()),{data:l}=J(()=>$.files());if(n)return t(Y,{type:"card"});if(s)return t(se,{message:s,onRetry:r});if(!e)return t(xe,{icon:"📊",message:"No dashboard data available."});const a=e,i=((x=l==null?void 0:l.body)==null?void 0:x.length)??a.totalFiles??0,o=a.totalChunks??0,c=((h=a.languages)==null?void 0:h.length)??0,d=i>0?(o/i).toFixed(1):"0",u=(a.languages??[]).slice(0,8),f=((p=u[0])==null?void 0:p.count)??1;return t("div",{children:[t("h1",{className:"text-2xl font-bold mb-6",children:"Dashboard"}),t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-8",children:[t(X,{label:"Total Chunks",value:o.toLocaleString(),icon:"🧩"}),t(X,{label:"Total Files",value:i.toLocaleString(),icon:"📄"}),t(X,{label:"Languages",value:c,icon:"🔤"}),t(X,{label:"Avg Chunks/File",value:d,icon:"📊"})]}),t("div",{className:"kpi-card p-4",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-3",children:"Language Distribution"}),t("div",{className:"space-y-2",children:u.map(m=>t("div",{className:"flex items-center gap-3",children:[t("span",{className:`w-24 text-xs text-right ${Ue(m.language)}`,children:m.language}),t("div",{className:"flex-1 bg-slate-800 rounded-full h-5 overflow-hidden",children:t("div",{className:"h-full rounded-full bg-brand-500 flex items-center pl-2",style:{width:`${Math.max(8,m.count/f*100)}%`},children:t("span",{className:"text-xs font-medium text-white",children:m.count})})}),t("span",{className:"text-xs text-slate-500 w-12 text-right",children:[(m.count/o*100).toFixed(0),"%"]})]},m.language))})]}),t(Wn,{}),t("div",{className:"mt-6",children:t("h2",{className:"text-lg font-semibold mb-3",children:t("a",{href:"#config",className:"hover:text-brand-400 transition-colors",children:"Configuration"})})})]})}function Rt({text:e,color:n,onDismiss:s}){return t("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-xs font-mono bg-slate-800 ${n??"text-slate-400"}`,children:[e,s&&t("button",{className:"ml-0.5 text-slate-500 hover:text-white",onClick:s,"aria-label":`Dismiss ${e} filter`,children:"×"})]})}function Bn(){const e=Oe();D(()=>{e.params.file&&(fe.value=e.params.file),e.params.lang&&(Ne.value=e.params.lang)},[e.params.file,e.params.lang]);const n=Pe.value,s=$n.value,r=fe.value,l=Ne.value,{data:a,isLoading:i,error:o,refresh:c}=J(()=>$.chunks({offset:n,limit:s,lang:l??"",file:r??""}),[n,s,r,l]);if(i)return t(Y,{type:"detail"});if(o)return t(se,{message:o,onRetry:c});const d=(a==null?void 0:a.chunks)??[],u=(a==null?void 0:a.total)??d.length,f=Math.ceil(u/s),x=Math.floor(n/s)+1;return t("div",{className:"flex gap-4 h-full",children:[t("div",{className:"w-1/2 flex flex-col",children:[t("div",{className:"flex items-center gap-3 mb-3 flex-wrap",children:[t("h2",{className:"text-lg font-semibold text-white",children:"Chunks"}),t("span",{className:"text-sm text-slate-400",children:[u," total"]}),Ne.value&&t(Rt,{text:Ne.value,color:Ue(Ne.value),onDismiss:()=>{Ne.value=null,we.value=null,Pe.value=0}}),fe.value&&t(Rt,{text:fe.value,onDismiss:()=>{fe.value=null,we.value=null,Pe.value=0}})]}),t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 overflow-hidden flex-1",children:t("table",{className:"w-full text-sm",role:"table",children:[t("thead",{children:t("tr",{className:"bg-slate-800 text-slate-400 text-xs",children:[t("th",{className:"px-2 py-2 w-8",children:t("input",{type:"checkbox",className:"accent-brand-500",checked:d.length>0&&d.every(h=>te.value.has(h.id||`chunk-${d.indexOf(h)}`)),onChange:()=>{const h=d.map((b,L)=>b.id||`chunk-${L}`),p=h.every(b=>te.value.has(b)),m=new Set(te.value);for(const b of h)p?m.delete(b):m.add(b);te.value=m},"aria-label":"Select all chunks on this page"})}),t("th",{className:"px-3 py-2 text-left",children:"File"}),t("th",{className:"px-3 py-2 text-left w-20",children:"Lang"}),t("th",{className:"px-3 py-2 text-left",children:"Description"})]})}),t("tbody",{children:d.length===0?t("tr",{children:t("td",{colSpan:4,className:"px-3 py-8 text-center text-slate-500",children:[t("span",{className:"text-2xl block mb-2",children:"🔍"}),"No chunks found"]})}):d.map((h,p)=>{const m=h.id||`chunk-${p}`,b=we.value===m,L=te.value.has(m);return t("tr",{className:`chunk-row border-t border-slate-800 cursor-pointer ${b?"selected":""}`,onClick:()=>{we.value=m},role:"row",tabIndex:0,children:[t("td",{className:"px-2 py-2",onClick:P=>P.stopPropagation(),children:t("input",{type:"checkbox",className:"accent-brand-500",checked:L,onChange:()=>{const P=new Set(te.value);P.has(m)?P.delete(m):P.add(m),te.value=P},"aria-label":`Select chunk ${m}`})}),t("td",{className:"px-3 py-2 text-yellow-400 font-mono text-xs",children:[C(h.filePath),":",h.startLine,"-",h.endLine]}),t("td",{className:"px-3 py-2",dangerouslySetInnerHTML:{__html:pe(h.language)}}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:C(h.description??"").slice(0,50)})]},m)})})]})}),t("div",{className:"flex items-center justify-between mt-3",children:[t("button",{className:"px-3 py-1 bg-slate-700 rounded text-sm hover:bg-slate-600 disabled:opacity-50",disabled:x<=1,onClick:()=>{Pe.value=Math.max(0,n-s)},children:"Previous"}),t("span",{className:"text-sm text-slate-400",children:["Page ",x," of ",f||1]}),t("button",{className:"px-3 py-1 bg-slate-700 rounded text-sm hover:bg-slate-600 disabled:opacity-50",disabled:x>=f,onClick:()=>{Pe.value+=s},children:"Next"})]}),te.value.size>=2&&te.value.size<=3&&t("div",{className:"fixed bottom-6 right-6 z-50",children:t("button",{className:"bg-brand-600 hover:bg-brand-500 text-white px-6 py-3 rounded-full shadow-lg font-bold transition-all transform hover:scale-105",onClick:()=>{const h=[...te.value];te.value=new Set,U(`compare?ids=${h.join(",")}`)},children:["Compare (",te.value.size,")"]})})]}),t("div",{className:"w-1/2 overflow-y-auto",children:we.value?t(Vn,{chunkId:we.value,chunks:d}):t("div",{className:"flex items-center justify-center h-full text-slate-500",children:t("div",{className:"text-center",children:[t("div",{className:"text-4xl mb-2",children:"📄"}),t("div",{className:"text-sm",children:"Select a chunk to view details"})]})})})]})}function Vn({chunkId:e,chunks:n}){const[s,r]=g(null),[l,a]=g(!1),i=ae(null);if(D(()=>{let u=!1;const f=n.find(x=>x.id===e);return f?r(f):$.chunk(e).then(x=>{u||r(x)}).catch(()=>{u||r({id:e,content:"",filePath:"not found",language:"",startLine:0,endLine:0,description:""})}),()=>{u=!0}},[e,n]),D(()=>()=>{i.current&&clearTimeout(i.current)},[]),!s)return t(Y,{type:"detail"});const o=s,c=o.language==="image",d=()=>{navigator.clipboard.writeText(o.content).then(()=>{a(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>a(!1),1500)})};return t("div",{children:[t("div",{className:"mb-3",children:[t("div",{className:"flex items-center gap-3 mb-1",children:t("span",{className:"text-yellow-400 font-mono text-sm",children:C(o.filePath)})}),t("div",{className:"flex items-center gap-3 text-sm text-slate-400",children:[t("span",{children:["Lines ",o.startLine,"-",o.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:pe(o.language)}}),o.id&&t("span",{className:"text-xs text-slate-600 font-mono",children:o.id})]})]}),o.description&&t("div",{className:"kpi-card p-3 mb-3",children:[t("h3",{className:"text-xs font-semibold text-slate-400 mb-1",children:"Description"}),t("p",{className:"text-sm text-slate-300",children:C(o.description)})]}),c&&t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 overflow-hidden mb-3",children:[t("div",{className:"px-3 py-1.5 bg-slate-800 border-b border-slate-700",children:t("span",{className:"text-xs text-slate-400",children:"Image Preview"})}),t("div",{className:"p-3 flex items-center justify-center bg-slate-950",children:t("img",{src:`/api/file?path=${encodeURIComponent(o.filePath)}`,alt:o.filePath,className:"max-w-full max-h-[60vh] object-contain rounded",onError:u=>{const f=u.currentTarget;f.style.display="none",f.parentElement.innerHTML='<span class="text-slate-500 text-sm">Image not available</span>'}})})]}),t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 overflow-hidden",children:[t("div",{className:"px-3 py-1.5 bg-slate-800 border-b border-slate-700 flex items-center justify-between",children:[t("span",{className:"text-xs text-slate-400",children:c?"Vision Analysis":"Source Code"}),t("button",{className:"text-xs text-slate-500 hover:text-white transition-colors",onClick:d,children:l?"Copied!":"Copy"})]}),t("pre",{className:"p-3 overflow-x-auto text-sm max-h-[calc(100vh-220px)]",children:t("code",{className:`language-${c?"text":o.language}`,children:C(o.content)})})]})]})}function Gn(){const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.files());if(n)return t(Y,{type:"table"});if(s)return t(se,{message:s,onRetry:r});const l=e??[];if(l.length===0)return t(xe,{icon:"📂",message:"No files indexed yet."});const a=l.reduce((i,o)=>i+o.chunkCount,0);return t("div",{children:[t("div",{className:"flex items-center gap-3 mb-4",children:[t("h1",{className:"text-2xl font-bold",children:"Files"}),t("span",{className:"text-sm text-slate-400",children:[l.length," files, ",a," chunks"]})]}),t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 overflow-hidden",children:t("table",{className:"w-full text-sm",role:"table","aria-label":"Indexed files",children:[t("thead",{children:t("tr",{className:"bg-slate-800 text-slate-400 text-xs",children:[t("th",{className:"px-3 py-2 text-left",children:"File"}),t("th",{className:"px-3 py-2 text-left w-28",children:"Language"}),t("th",{className:"px-3 py-2 text-left w-20",children:"Chunks"}),t("th",{className:"px-3 py-2 text-left w-24"})]})}),t("tbody",{children:l.map(i=>t("tr",{className:"border-t border-slate-800 hover:bg-slate-800 cursor-pointer",onClick:()=>U(`chunks?file=${encodeURIComponent(i.filePath)}`),role:"row",tabIndex:0,onKeyDown:o=>{o.key==="Enter"&&U(`chunks?file=${encodeURIComponent(i.filePath)}`)},children:[t("td",{className:"px-3 py-2 text-yellow-400 font-mono text-xs",children:i.filePath}),t("td",{className:"px-3 py-2",dangerouslySetInnerHTML:{__html:pe(i.language)}}),t("td",{className:"px-3 py-2 text-slate-300",children:i.chunkCount}),t("td",{className:"px-3 py-2 text-slate-500 text-xs",children:t("span",{className:"hover:text-white transition-colors",children:"View chunks"})})]},i.filePath))})]})})]})}function Qn({segments:e,size:n=180,innerRadius:s,centerLabel:r}){const l=n/2,a=n/2,i=n/2-10,o=s??i*.6,c=e.reduce((x,h)=>x+h.value,0);if(c===0)return t("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,children:[t("circle",{cx:l,cy:a,r:i,fill:"none",stroke:"#334155","stroke-width":i-o}),t("circle",{cx:l,cy:a,r:o,fill:"#0f172a"})]});let d=0;const u=e.map(x=>{const h=x.value/c*360,p=d,m=d+h;return d+=h,`<path d="${Xn(l,a,i,p,m,o)}" fill="${x.color}" />`}).join(""),f=r??"";return t("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:"chart-svg",children:[t("g",{dangerouslySetInnerHTML:{__html:u}}),t("text",{x:l,y:a-6,"text-anchor":"middle",fill:"white","font-size":"22","font-weight":"bold",children:f}),t("text",{x:l,y:a+14,"text-anchor":"middle",fill:"#64748b","font-size":"11",children:"tokens"})]})}function Xn(e,n,s,r,l,a){const i=l-r;if(i>=359.99)return`M${e},${n-s} A${s},${s} 0 1,1 ${e-.01},${n-s} L${e-.01},${n-a} A${a},${a} 0 1,0 ${e},${n-a} Z`;const o=L=>(L-90)*Math.PI/180,c=e+s*Math.cos(o(r)),d=n+s*Math.sin(o(r)),u=e+s*Math.cos(o(l)),f=n+s*Math.sin(o(l)),x=e+a*Math.cos(o(l)),h=n+a*Math.sin(o(l)),p=e+a*Math.cos(o(r)),m=n+a*Math.sin(o(r)),b=i>180?1:0;return[`M${c},${d}`,`A${s},${s} 0 ${b} 1 ${u},${f}`,`L${x},${h}`,`A${a},${a} 0 ${b} 0 ${p},${m}`,"Z"].join(" ")}function Zn(){const e=Oe();return e.params.compare?t(es,{ids:[e.params.a??"",e.params.b??""]}):e.params.session?t(Jn,{sessionId:e.params.session}):t(Yn,{})}function Yn(){const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.evalSessions()),[l,a]=g(new Set);if(n)return t(Y,{type:"table"});if(s)return t(se,{message:s,onRetry:r});const i=(e==null?void 0:e.sessions)??[];if(i.length===0)return t(xe,{icon:"📊",message:"No sessions recorded yet."});const o=c=>{const d=new Set(l);d.has(c)?d.delete(c):d.add(c),a(d)};return t("div",{children:[t("div",{className:"flex items-center justify-between mb-4",children:[t("h1",{className:"text-2xl font-bold",children:"Evaluate"}),t("div",{className:"flex gap-2",children:[l.size===2&&t("button",{className:"bg-brand-600 hover:bg-brand-500 text-white px-3 py-1 rounded text-sm transition-colors",onClick:()=>{const[c,d]=[...l];U(`evaluate?compare&a=${encodeURIComponent(c)}&b=${encodeURIComponent(d)}`)},children:"Compare Selected"}),l.size>0&&t("button",{className:"text-xs text-slate-400 hover:text-white",onClick:()=>a(new Set),children:["Clear (",l.size,")"]})]})]}),t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 overflow-x-auto",children:t("table",{className:"w-full text-sm",role:"table",children:[t("thead",{children:t("tr",{className:"bg-slate-800 text-slate-400 text-xs",children:[t("th",{className:"px-2 py-2 w-8"}),t("th",{className:"px-3 py-2 text-left",children:"Session"}),t("th",{className:"px-3 py-2 text-left",children:"Last Activity"}),t("th",{className:"px-3 py-2 text-right",children:"Messages"}),t("th",{className:"px-3 py-2 text-right",children:"Input Tokens"}),t("th",{className:"px-3 py-2 text-right",children:"Output Tokens"}),t("th",{className:"px-3 py-2 text-right",children:"Cost"}),t("th",{className:"px-3 py-2 text-right",children:"RAG Calls"}),t("th",{className:"px-3 py-2 text-right",children:"RAG Tokens"}),t("th",{className:"px-3 py-2 text-left",children:"Model"}),t("th",{className:"px-3 py-2 w-8"})]})}),t("tbody",{children:i.map(c=>{var d,u,f,x;return t("tr",{className:"border-t border-slate-800 hover:bg-slate-800 cursor-pointer",onClick:()=>U(`evaluate?session=${encodeURIComponent(c.sessionID)}`),children:[t("td",{className:"px-2 py-2",onClick:h=>h.stopPropagation(),children:t("input",{type:"checkbox",className:"accent-brand-500",checked:l.has(c.sessionID),onChange:()=>o(c.sessionID),"aria-label":`Select session ${c.title??c.sessionID}`})}),t("td",{className:"px-3 py-2 text-slate-200 font-mono text-xs",children:c.title??c.sessionID.slice(0,8)}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:on(c.lastEventAt)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:c.messageCount}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:B((((d=c.totalTokens)==null?void 0:d.input)??0)+(((u=c.totalTokens)==null?void 0:u.cacheRead)??0))}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:B(((f=c.totalTokens)==null?void 0:f.output)??0)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:Ye(c.totalCost??0)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:c.ragContextCount??0}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:B(c.ragContextTokens??0)}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:((x=c.models)==null?void 0:x[0])??"-"}),t("td",{className:"px-3 py-2",onClick:h=>h.stopPropagation(),children:t("button",{className:"text-slate-600 hover:text-red-400 text-xs",onClick:async()=>{if(confirm("Delete this session?"))try{await $.evalDeleteSession(c.sessionID),Z("success","Session deleted"),r()}catch(h){Z("error",`Delete failed: ${h.message}`)}},"aria-label":"Delete session",children:"🗑"})})]},c.sessionID)})})]})})]})}function Jn({sessionId:e}){var f,x,h,p,m,b,L,P;const{data:n,isLoading:s,error:r,refresh:l}=J(()=>$.evalSession(e));if(s)return t(Y,{type:"detail"});if(r)return t(se,{message:r,onRetry:l});const a=(n==null?void 0:n.summary)??n,i=(n==null?void 0:n.events)??[],o=a.toolCallCounts??{};["search_semantic","get_file_skeleton","find_usages","describe_image"].reduce((N,V)=>N+(o[V]??0),0);const d=[{label:"Input",value:(((f=a.totalTokens)==null?void 0:f.input)??0)+(((x=a.totalTokens)==null?void 0:x.cacheRead)??0),color:"#3b82f6"},{label:"Output",value:((h=a.totalTokens)==null?void 0:h.output)??0,color:"#a855f7"},{label:"RAG",value:a.ragContextTokens??0,color:"#06b6d4"},{label:"Reasoning",value:((p=a.totalTokens)==null?void 0:p.reasoning)??0,color:"#f59e0b"}].filter(N=>N.value>0),u=d.reduce((N,V)=>N+V.value,0);return t("div",{children:[t("div",{className:"flex items-center gap-3 mb-4",children:[t("button",{className:"text-sm text-slate-400 hover:text-white",onClick:()=>U("evaluate"),children:"← Back"}),t("h1",{className:"text-xl font-bold",children:a.title??((m=a.sessionID)==null?void 0:m.slice(0,12))})]}),t("div",{className:"grid grid-cols-3 lg:grid-cols-5 gap-3 mb-6",children:[t(X,{label:"Total Tokens",value:B(u)}),t(X,{label:"Input",value:B((((b=a.totalTokens)==null?void 0:b.input)??0)+(((L=a.totalTokens)==null?void 0:L.cacheRead)??0))}),t(X,{label:"Output",value:B(((P=a.totalTokens)==null?void 0:P.output)??0)}),t(X,{label:"Cost",value:Ye(a.totalCost??0)}),t(X,{label:"RAG Context",value:B(a.ragContextTokens??0)})]}),t("div",{className:"flex items-center gap-6 mb-6",children:[t(Qn,{segments:d,centerLabel:B(u)}),t("div",{className:"flex flex-wrap gap-3",children:d.map(N=>t("div",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[t("span",{className:"inline-block w-3 h-3 rounded-sm",style:{background:N.color}}),N.label,": ",B(N.value)," (",(N.value/u*100).toFixed(1),"%)"]},N.label))})]}),t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:[t(X,{label:"Messages",value:a.messageCount??0}),t(X,{label:"Steps",value:a.totalSteps??0}),t(X,{label:"RAG Injections",value:a.ragContextCount??0}),t(X,{label:"Avg Response",value:qn(a.avgResponseTimeMs??0)})]}),Object.keys(o).length>0&&t("div",{className:"kpi-card p-4 mb-6",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-3",children:"Tool Calls"}),t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:Object.entries(o).map(([N,V])=>t("div",{className:"flex justify-between text-xs text-slate-400",children:[t("span",{className:"font-mono",children:N}),t("span",{className:"text-white",children:String(V)})]},N))})]}),a.models&&a.models.length>0&&t("div",{className:"kpi-card p-4 mb-6",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-2",children:"Models"}),t("div",{className:"flex flex-wrap gap-2",children:a.models.map(N=>t("span",{className:"px-2 py-0.5 rounded text-xs font-mono bg-slate-800 text-slate-300",children:N},N))})]}),i.length>0&&t("div",{className:"kpi-card p-4",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-3",children:"Event Timeline"}),t("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:i.map((N,V)=>t("div",{className:"flex gap-2 text-xs border-b border-slate-700/50 py-1",children:[t("span",{className:"text-slate-500 shrink-0 w-16",children:on(N.ts)}),t("span",{className:"text-slate-400",children:N.event}),N.tool&&t("span",{className:"text-slate-500 font-mono",children:N.tool}),N.toolStatus&&t("span",{className:`text-xs ${N.toolStatus==="completed"?"text-green-400":N.toolStatus==="running"?"text-amber-400":"text-slate-500"}`,children:N.toolStatus})]},V))})]})]})}function es({ids:e}){var f,x,h,p,m,b,L,P;const[n,s]=e,{data:r,isLoading:l,error:a}=J(()=>Promise.all([$.evalCompare(n,s),$.evalTokenCompare(n,s)]),[n,s]);if(l)return t(Y,{type:"chart"});if(a)return t(se,{message:a});if(!r)return null;const i=r[0],o=r[1],c=((f=o.sessionA)==null?void 0:f.savings)??0,d=((x=o.sessionB)==null?void 0:x.savings)??0,u=c>0&&d>0?"RAG saves tokens":"Mixed results";return t("div",{children:[t("div",{className:"flex items-center gap-3 mb-4",children:[t("button",{className:"text-sm text-slate-400 hover:text-white",onClick:()=>U("evaluate"),children:"← Back"}),t("h1",{className:"text-xl font-bold",children:"Session Comparison"})]}),t("div",{className:`px-4 py-3 rounded-lg mb-4 font-semibold text-sm ${c>0&&d>0?"bg-green-900/50 text-green-300 border border-green-700":"bg-amber-900/50 text-amber-300 border border-amber-700"}`,children:u}),t("div",{className:"grid grid-cols-2 gap-4",children:[t("div",{className:"kpi-card p-4",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-2",children:((h=i.sessionA)==null?void 0:h.title)??"Session A"}),t("div",{className:"space-y-1 text-sm",children:[t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Total Tokens"}),t("span",{children:B(((p=i.sessionA)==null?void 0:p.totalTokens)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Cost"}),t("span",{children:Ye(((m=i.sessionA)==null?void 0:m.totalCost)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"RAG Savings"}),t("span",{className:c>0?"text-green-400":"text-red-400",children:[B(Math.abs(c))," (",c>0?"+":"",c>0?"+":"",")"]})]})]})]}),t("div",{className:"kpi-card p-4",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-2",children:((b=i.sessionB)==null?void 0:b.title)??"Session B"}),t("div",{className:"space-y-1 text-sm",children:[t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Total Tokens"}),t("span",{children:B(((L=i.sessionB)==null?void 0:L.totalTokens)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Cost"}),t("span",{children:Ye(((P=i.sessionB)==null?void 0:P.totalCost)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"RAG Savings"}),t("span",{className:d>0?"text-green-400":"text-red-400",children:B(Math.abs(d))})]})]})]})]})]})}const ts={gotcha:"text-amber-400 bg-amber-900/20",preference:"text-emerald-400 bg-emerald-900/20",decision:"text-sky-400 bg-sky-900/20","environment-constraint":"text-rose-400 bg-rose-900/20"};function ns(e){return`<span class="inline-block px-1.5 py-0.5 rounded text-xs font-mono ${ts[e]??"text-slate-400 bg-slate-800"}">${C(e||"general")}</span>`}function ss(){const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.quirks()),[l,a]=g(null),[i,o]=g(null),[c,d]=g(!1);if(n)return t(Y,{type:"card"});if(s)return t(se,{message:s,onRetry:r});const u=(e==null?void 0:e.quirks)??[],f=[...new Set(u.map(m=>m.type||"general"))],x=l?u.filter(m=>(m.type||"general")===l):u,h=async m=>{if(confirm("Delete this quirk?"))try{await $.deleteQuirk(m),Z("success","Quirk deleted"),r()}catch(b){Z("error",`Delete failed: ${b.message}`)}};return t("div",{children:[t("div",{className:"flex items-center justify-between mb-4",children:[t("h1",{className:"text-2xl font-bold",children:"Quirks"}),t("button",{className:"bg-slate-700 hover:bg-slate-600 text-white px-3 py-1 rounded text-sm transition-colors",onClick:async()=>{d(!0);try{const m=await $.quirkLint();o(m)}catch(m){o({error:m.message})}d(!1)},disabled:c,children:c?"Linting...":"Lint"})]}),t("div",{className:"flex gap-2 mb-4 flex-wrap",children:[t("button",{className:`px-2 py-1 rounded text-xs font-medium transition-colors ${l===null?"bg-brand-600 text-white":"bg-slate-700 text-slate-300 hover:bg-slate-600"}`,onClick:()=>a(null),children:"All"}),f.map(m=>t("button",{className:`px-2 py-1 rounded text-xs font-medium transition-colors ${l===m?"bg-brand-600 text-white":"bg-slate-700 text-slate-300 hover:bg-slate-600"}`,onClick:()=>a(m),children:m},m))]}),i&&t("div",{className:`mb-4 p-3 rounded-lg border text-sm ${i.success?"bg-green-900/30 border-green-700 text-green-300":i.error?"bg-red-900/30 border-red-700 text-red-300":"bg-amber-900/30 border-amber-700 text-amber-300"}`,children:t("pre",{className:"text-xs whitespace-pre-wrap",children:JSON.stringify(i,null,2)})}),x.length===0?t(xe,{icon:"💡",message:"No quirks stored yet."}):t("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:x.map(m=>t("div",{className:"bg-slate-900 rounded-lg border border-slate-700 p-3 flex flex-col",children:[t("div",{className:"flex items-center justify-between mb-2",children:[t("span",{dangerouslySetInnerHTML:{__html:ns(m.type)}}),t("span",{className:`text-xs font-mono ${m.confidence>.7?"text-green-400":m.confidence>.4?"text-amber-400":"text-red-400"}`,children:[(m.confidence*100).toFixed(0),"%"]})]}),t("p",{className:"text-sm text-slate-200 mb-2 flex-1",children:C(m.content)}),m.tags&&m.tags.length>0&&t("div",{className:"flex gap-1 flex-wrap mb-2",children:m.tags.map(b=>t("span",{className:"text-xs bg-slate-800 text-slate-400 px-1.5 py-0.5 rounded",children:["#",b]},b))}),t("div",{className:"flex items-center justify-between text-xs text-slate-600 mt-auto",children:[m.sourceRef&&t("span",{className:"font-mono",children:C(m.sourceRef)}),t("span",{className:"font-mono",children:m.id})]}),t("button",{className:"self-end mt-2 text-xs text-slate-600 hover:text-red-400 transition-colors",onClick:()=>h(m.id),"aria-label":"Delete quirk",children:"Delete"})]},m.id))})]})}function as(){const[e,n]=g([]),[s,r]=g(!1),[l,a]=g(null),[i,o]=g(!1),c=ht(_.value,300);return D(()=>{const d=Q.value.trim();if(!d){n([]),a(null),r(!1),ce.value=[];return}let u=!1;return(async()=>{var x,h;r(!0),a(null);try{const p=await $.retrieve({q:d,topK:c.topK,minScore:c.minScore,keywordWeight:c.keywordWeight,hybrid:c.hybrid?"true":"false",path:c.pathFilter||void 0,lang:c.langFilter||void 0,ext:c.extFilter||void 0,explain:"true"});if(u)return;if(p.status===503){a(((x=p.body)==null?void 0:x.error)??"Embedding model unavailable"),r(!1);return}o(!1);const m=((h=p.body)==null?void 0:h.results)??p.results??[];n(m),ce.value=m;const b={query:d,params:{...c}};Ze.value=[b,...Ze.value.filter(L=>L.query!==d).slice(0,19)]}catch(p){u||a(p.message)}finally{u||r(!1)}})(),()=>{u=!0}},[Q.value,c]),{results:e,isLoading:s,isInitializing:i,error:l,setResults:n}}function rs({explanation:e}){const{vectorScore:n,keywordScore:s,rawVectorScore:r,rawKeywordScore:l,keywordWeight:a,vectorRank:i,keywordRank:o}=e.scoreBreakdown,c=Math.max(n+s,.001),d=(n/c*100).toFixed(0),u=(s/c*100).toFixed(0);return t("div",{className:"mb-2",children:[t("div",{className:"flex items-center gap-2 text-xs mb-1",children:[t("span",{className:"text-cyan-400",title:`Vector: ${r.toFixed(3)}${i!==void 0?`, rank #${i+1}`:""}`,children:["Vector ",d,"%"]}),t("span",{className:"text-amber-400",title:`Keyword: ${l.toFixed(3)}${o!==void 0?`, rank #${o+1}`:""}`,children:["Keyword ",u,"%"]}),t("span",{className:"text-slate-500 ml-auto",children:["kw=",a.toFixed(1)]})]}),t("div",{className:"h-2 bg-slate-700 rounded-full overflow-hidden flex",children:[t("div",{className:"h-full bg-cyan-500 transition-all duration-200",style:{width:`${d}%`}}),t("div",{className:"h-full bg-amber-500 transition-all duration-200",style:{width:`${u}%`}})]})]})}function ls(){const e=Oe(),{results:n,isLoading:s,isInitializing:r,error:l}=as();return D(()=>{e.params.query&&(Q.value=e.params.query,_.value={..._.value,topK:parseInt(e.params.topK??"10",10),minScore:parseFloat(e.params.minScore??"0.35"),keywordWeight:parseFloat(e.params.keywordWeight??"0.4"),hybrid:e.params.hybrid!=="false",pathFilter:e.params.path??"",langFilter:e.params.lang??"",extFilter:e.params.ext??""})},[]),D(()=>{if(Q.value.trim()){const a=new URLSearchParams({query:Q.value,topK:String(_.value.topK),minScore:String(_.value.minScore),keywordWeight:String(_.value.keywordWeight),hybrid:String(_.value.hybrid)});_.value.pathFilter&&a.set("path",_.value.pathFilter),_.value.langFilter&&a.set("lang",_.value.langFilter),_.value.extFilter&&a.set("ext",_.value.extFilter);const i=`search?${a.toString()}`;location.hash!==`#${i}`&&history.replaceState(null,"",`#${i}`)}},[Q.value,_.value]),t("div",{children:[t("h1",{className:"text-2xl font-bold mb-4",children:"Semantic Search"}),t("div",{className:"flex gap-3 mb-4",children:t("input",{type:"text",value:Q.value,onInput:a=>{Q.value=a.target.value,ce.value=[]},onKeyDown:a=>{a.key==="Enter"&&Q.value.trim()},placeholder:"Search your codebase semantically... (e.g., 'how does authentication work?')",className:"flex-1 px-4 py-2 bg-slate-800 border border-slate-600 rounded-lg text-sm text-slate-200 placeholder-slate-500 focus:outline-none focus:border-brand-400",autoFocus:!0,"aria-label":"Semantic search query"})}),t("details",{className:"mb-4 bg-slate-800 rounded-lg border border-slate-700",children:[t("summary",{className:"px-3 py-2 text-xs text-slate-400 cursor-pointer hover:text-white font-medium",children:"Search Parameters"}),t("div",{className:"px-3 pb-3 space-y-3",children:[t(at,{label:"topK",min:1,max:25,step:1,value:_.value.topK,onChange:a=>{_.value={..._.value,topK:a}}}),t(at,{label:"minScore",min:0,max:1,step:.05,value:_.value.minScore,onChange:a=>{_.value={..._.value,minScore:a}}}),t(at,{label:"keywordWeight",min:0,max:1,step:.1,value:_.value.keywordWeight,onChange:a=>{_.value={..._.value,keywordWeight:a}}}),t("div",{className:"flex items-center gap-2",children:[t("label",{className:"text-xs text-slate-400 w-28",children:"Hybrid mode"}),t("input",{type:"checkbox",checked:_.value.hybrid,onChange:a=>{_.value={..._.value,hybrid:a.target.checked}},className:"accent-brand-500"})]}),t("div",{className:"flex items-center gap-3",children:[t("label",{className:"text-xs text-slate-400 w-28 shrink-0",children:"Extensions"}),t("input",{type:"text",value:_.value.extFilter,onInput:a=>{_.value={..._.value,extFilter:a.target.value}},placeholder:".ts, .py (comma-separated)",className:"flex-1 px-2 py-1 bg-slate-900 border border-slate-600 rounded text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-brand-400","aria-label":"File extension filter"})]}),t("div",{className:"flex items-center gap-3",children:[t("label",{className:"text-xs text-slate-400 w-28 shrink-0",children:"Languages"}),t("input",{type:"text",value:_.value.langFilter,onInput:a=>{_.value={..._.value,langFilter:a.target.value}},placeholder:"typescript, python (comma-separated)",className:"flex-1 px-2 py-1 bg-slate-900 border border-slate-600 rounded text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-brand-400","aria-label":"Language filter"})]}),t("div",{className:"flex items-center gap-3",children:[t("label",{className:"text-xs text-slate-400 w-28 shrink-0",children:"Path"}),t("input",{type:"text",value:_.value.pathFilter,onInput:a=>{_.value={..._.value,pathFilter:a.target.value}},placeholder:"src/** (comma-separated)",className:"flex-1 px-2 py-1 bg-slate-900 border border-slate-600 rounded text-xs text-slate-200 placeholder-slate-500 focus:outline-none focus:border-brand-400","aria-label":"Path filter"})]})]})]}),r&&t("div",{className:"text-center py-10 text-slate-400",children:[t("span",{className:"animate-spin inline-block mr-2",children:"⟳"}),"Initializing embedding model..."]}),l&&t(se,{message:l}),!s&&!l&&Q.value.trim()&&n.length===0&&t("div",{className:"text-center py-16 text-slate-500",children:[t("div",{className:"text-4xl mb-2",children:"🔍"}),t("div",{children:['No results found for "',C(Q.value),'"']})]}),!s&&!l&&!Q.value.trim()&&t("div",{className:"text-center py-16 text-slate-500",children:[t("div",{className:"text-4xl mb-2",children:"🔍"}),t("div",{children:"Enter a query to search your codebase"}),Ze.value.length>0&&t("div",{className:"mt-6",children:[t("p",{className:"text-xs text-slate-600 mb-2",children:"Recent queries:"}),t("div",{className:"flex flex-wrap gap-2 justify-center",children:Ze.value.slice(0,10).map((a,i)=>t("button",{className:"px-2 py-1 bg-slate-800 rounded text-xs text-slate-400 hover:text-white hover:bg-slate-700 transition-colors",onClick:()=>{Q.value=a.query},children:C(a.query)},i))})]})]}),n.length>0&&t("div",{className:"space-y-3",children:[t("div",{className:"flex items-center justify-between text-sm text-slate-400 mb-2",children:[t("span",{children:[n.length," result",n.length!==1?"s":""]}),s&&t("span",{className:"text-xs text-brand-400 animate-pulse",children:"Searching..."})]}),n.map(a=>t(is,{result:a},a.chunk.id))]}),s&&n.length===0&&t("div",{className:"text-center py-10 text-slate-400",children:[t("span",{className:"animate-spin inline-block mr-2",children:"⟳"}),"Searching..."]})]})}function is({result:e}){var r,l;const n=e.chunk,s=e.score;return t("div",{className:"bg-slate-800 rounded-lg p-4 border border-slate-700 hover:border-brand-500/50 transition-colors cursor-pointer",onClick:()=>U(`chunks?id=${encodeURIComponent(n.id)}`),children:[t("div",{className:"flex items-center justify-between mb-2",children:[t("div",{className:"flex items-center gap-2 min-w-0",children:[t("span",{className:"text-sm text-yellow-400 font-mono truncate",children:[C(n.filePath),":",n.startLine,"-",n.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:pe(n.language)}})]}),t("span",{className:"text-lg font-bold shrink-0 ml-2",style:{color:os(s)},children:s.toFixed(2)})]}),e.explanation&&t(rs,{explanation:e.explanation}),((l=(r=e.explanation)==null?void 0:r.matchedTerms)==null?void 0:l.length)>0&&t("div",{className:"flex gap-1 flex-wrap mb-2",children:e.explanation.matchedTerms.map(a=>t("span",{className:"text-xs bg-amber-500/20 text-amber-300 px-1.5 py-0.5 rounded",children:C(a)},a))}),n.description&&t("p",{className:"text-sm text-slate-400 mb-2 line-clamp-2",children:C(n.description)}),t("pre",{className:"text-xs overflow-x-auto max-h-32 rounded bg-slate-900/50 p-2",children:t("code",{children:C(n.content??"").slice(0,500)})})]})}function os(e){return e>=.8?"#22c55e":e>=.6?"#06b6d4":e>=.4?"#f59e0b":"#ef4444"}function at({label:e,min:n,max:s,step:r,value:l,onChange:a}){return t("div",{className:"flex items-center gap-3",children:[t("label",{className:"text-xs text-slate-400 w-28 shrink-0",children:e}),t("input",{type:"range",min:n,max:s,step:r,value:l,onInput:i=>a(parseFloat(i.target.value)),className:"flex-1 accent-brand-500"}),t("span",{className:"text-xs text-slate-300 font-mono w-12 text-right",children:l})]})}function cs(){var c;const n=((c=Oe().params.ids)==null?void 0:c.split(",").filter(Boolean))??[],[s,r]=g([]),[l,a]=g(!0),[i,o]=g(null);return D(()=>{let d=!1;if(n.length<2){o("Select 2-3 chunks to compare."),a(!1);return}return $.compare(n).then(u=>{var f;d||(r(((f=u==null?void 0:u.body)==null?void 0:f.chunks)??(u==null?void 0:u.chunks)??[]),a(!1))}).catch(u=>{d||(o(u.message),a(!1))}),()=>{d=!0}},[n.join(",")]),l?t(Y,{type:"detail"}):i?t(se,{message:i}):s.length<2?t(xe,{icon:"📋",message:"Select 2-3 chunks from the Chunks view to compare them."}):t("div",{children:[t("div",{className:"flex items-center justify-between mb-4",children:[t("h1",{className:"text-2xl font-bold",children:"Chunk Comparison"}),t("button",{className:"text-sm text-slate-400 hover:text-white transition-colors",onClick:()=>U("chunks"),children:"← Back to Chunks"})]}),t("div",{className:`grid gap-4 ${s.length===2?"grid-cols-2":"grid-cols-3"}`,children:s.map((d,u)=>t(ds,{chunk:d,index:u,baseChunk:u>0?s[0]:void 0},d.id))})]})}function ds({chunk:e,index:n,baseChunk:s}){const r=e.content.split(`
|
|
3
|
+
`),l=(s==null?void 0:s.content.split(`
|
|
4
|
+
`))??[];return t("div",{className:"bg-slate-800 rounded-lg border border-slate-700 overflow-hidden flex flex-col",children:[t("div",{className:"p-3 border-b border-slate-700 bg-slate-800/80",children:[t("div",{className:"flex items-center justify-between mb-1",children:[t("span",{className:"text-sm font-mono text-brand-400 truncate mr-2",children:[C(e.filePath),":",e.startLine,"-",e.endLine]}),t("span",{className:"shrink-0",dangerouslySetInnerHTML:{__html:pe(e.language)}})]}),e.description&&t("p",{className:"text-xs text-slate-400 truncate",children:C(e.description)})]}),t("div",{className:"overflow-x-auto flex-1 max-h-[70vh]",children:t("table",{className:"w-full text-xs font-mono border-collapse",children:t("tbody",{children:r.map((a,i)=>{const o=(e.startLine??1)+i,c=l[i]===void 0?"bg-green-900/30":a===""&&l[i]!==""?"bg-red-900/30":a!==l[i]?"bg-amber-900/20":"";return t("tr",{className:c,children:[t("td",{className:"text-right text-slate-600 select-none px-2 w-10 border-r border-slate-700 align-top",children:o}),t("td",{className:"px-3 py-0 whitespace-pre-wrap break-all",children:C(a)||" "})]},i)})})})}),t("div",{className:"px-3 py-1.5 bg-slate-900 border-t border-slate-700 text-xs text-slate-500",children:["Chunk ",n+1,n===0&&t("span",{className:"text-slate-600 ml-1",children:"(reference)"})]})]})}function us(){var a;const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.config());if(n)return t(Y,{type:"card"});if(s)return t(se,{message:s,onRetry:r});const l=((a=e==null?void 0:e.body)==null?void 0:a.config)??(e==null?void 0:e.config);return l?t("div",{children:[t("h1",{className:"text-2xl font-bold mb-6",children:"Configuration"}),t("p",{className:"text-sm text-slate-400 mb-4",children:["Effective configuration from ",t("code",{className:"text-brand-400",children:"opencode-rag.json"}),". API keys are redacted."]}),t("div",{className:"space-y-4",children:Object.entries(l).map(([i,o])=>t("details",{className:"bg-slate-800 rounded-lg border border-slate-700",open:!0,children:[t("summary",{className:"px-4 py-2 cursor-pointer hover:bg-slate-700 font-mono text-sm font-semibold capitalize text-slate-300",children:i.replace(/([A-Z])/g," $1")}),t("div",{className:"px-4 pb-3",children:typeof o=="object"&&o!==null?Object.entries(o).map(([c,d])=>t("div",{className:"flex justify-between py-1 border-b border-slate-700/50 text-sm",children:[t("span",{className:"text-slate-400 font-mono",children:c}),t("span",{className:"text-slate-200 font-mono text-xs text-right ml-4",children:hs(d)})]},c)):t("div",{className:"flex justify-between py-1 text-sm",children:t("span",{className:"text-slate-200 font-mono",children:String(o)})})})]},i))})]}):t(xe,{icon:"⚙",message:"No configuration available."})}function hs(e){return e===null?"null":e===void 0?"undefined":typeof e=="boolean"?e?"true":"false":Array.isArray(e)?`[${e.join(", ")}]`:typeof e=="object"?JSON.stringify(e).slice(0,150):String(e)}const fs="modulepreload",ms=function(e){return"/ui/"+e},Pt={},ps=function(n,s,r){let l=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),o=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));l=Promise.allSettled(s.map(c=>{if(c=ms(c),c in Pt)return;Pt[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":fs,d||(f.as="script"),f.crossOrigin="",f.href=c,o&&f.setAttribute("nonce",o),document.head.appendChild(f),d)return new Promise((x,h)=>{f.addEventListener("load",x),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=i,window.dispatchEvent(o),!o.defaultPrevented)throw i}return l.then(i=>{for(const o of i||[])o.status==="rejected"&&a(o.reason);return n().catch(a)})};function xs(e,n){for(var s in n)e[s]=n[s];return e}function It(e,n){for(var s in e)if(s!=="__source"&&!(s in n))return!0;for(var r in n)if(r!=="__source"&&e[r]!==n[r])return!0;return!1}function Et(e,n){this.props=e,this.context=n}(Et.prototype=new ke).isPureReactComponent=!0,Et.prototype.shouldComponentUpdate=function(e,n){return It(this.props,e)||It(this.state,n)};var Mt=j.__b;j.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),Mt&&Mt(e)};var vs=j.__e;j.__e=function(e,n,s,r){if(e.then){for(var l,a=n;a=a.__;)if((l=a.__c)&&l.__c)return n.__e==null&&(n.__e=s.__e,n.__k=s.__k||[]),l.__c(e,n)}vs(e,n,s,r)};var Ft=j.unmount;function cn(e,n,s){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(r){typeof r.__c=="function"&&r.__c()}),e.__c.__H=null),(e=xs({},e)).__c!=null&&(e.__c.__P===s&&(e.__c.__P=n),e.__c.__e=!0,e.__c=null),e.__k=e.__k&&e.__k.map(function(r){return cn(r,n,s)})),e}function dn(e,n,s){return e&&s&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(r){return dn(r,n,s)}),e.__c&&e.__c.__P===n&&(e.__e&&s.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=s)),e}function Be(){this.__u=0,this.o=null,this.__b=null}function un(e){var n=e.__&&e.__.__c;return n&&n.__a&&n.__a(e)}function gs(e){var n,s,r,l=null;function a(i){if(n||(n=e()).then(function(o){o&&(l=o.default||o),r=!0},function(o){s=o,r=!0}),s)throw s;if(!r)throw n;return l?lt(l,i):null}return a.displayName="Lazy",a.__f=!0,a}function He(){this.i=null,this.l=null}j.unmount=function(e){var n=e.__c;n&&(n.__z=!0),n&&n.__R&&n.__R(),n&&32&e.__u&&(e.type=null),Ft&&Ft(e)},(Be.prototype=new ke).__c=function(e,n){var s=n.__c,r=this;r.o==null&&(r.o=[]),r.o.push(s);var l=un(r.__v),a=!1,i=function(){a||r.__z||(a=!0,s.__R=null,l?l(c):c())};s.__R=i;var o=s.__P;s.__P=null;var c=function(){if(!--r.__u){if(r.state.__a){var d=r.state.__a;r.__v.__k[0]=dn(d,d.__c.__P,d.__c.__O)}var u;for(r.setState({__a:r.__b=null});u=r.o.pop();)u.__P=o,u.forceUpdate()}};r.__u++||32&n.__u||r.setState({__a:r.__b=r.__v.__k[0]}),e.then(i,i)},Be.prototype.componentWillUnmount=function(){this.o=[]},Be.prototype.render=function(e,n){if(this.__b){if(this.__v.__k){var s=document.createElement("div"),r=this.__v.__k[0].__c;this.__v.__k[0]=cn(this.__b,s,r.__O=r.__P)}this.__b=null}var l=n.__a&<(re,null,e.fallback);return l&&(l.__u&=-33),[lt(re,null,n.__a?null:e.children),l]};var At=function(e,n,s){if(++s[1]===s[0]&&e.l.delete(n),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(s=e.i;s;){for(;s.length>3;)s.pop()();if(s[1]<s[0])break;e.i=s=s[2]}};(He.prototype=new ke).__a=function(e){var n=this,s=un(n.__v),r=n.l.get(e);return r[0]++,function(l){var a=function(){n.props.revealOrder?(r.push(l),At(n,e,r)):l()};s?s(a):a()}},He.prototype.render=function(e){this.i=null,this.l=new Map;var n=it(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&n.reverse();for(var s=n.length;s--;)this.l.set(n[s],this.i=[1,0,this.i]);return e.children},He.prototype.componentDidUpdate=He.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(n,s){At(e,s,n)})};var bs=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,_s=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,ys=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Ns=/[A-Z0-9]/g,ws=typeof document<"u",ks=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};ke.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(ke.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})});var Dt=j.event;j.event=function(e){return Dt&&(e=Dt(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var Ss={configurable:!0,get:function(){return this.class}},Ot=j.vnode;j.vnode=function(e){typeof e.type=="string"&&function(n){var s=n.props,r=n.type,l={},a=r.indexOf("-")==-1;for(var i in s){var o=s[i];if(!(i==="value"&&"defaultValue"in s&&o==null||ws&&i==="children"&&r==="noscript"||i==="class"||i==="className")){var c=i.toLowerCase();i==="defaultValue"&&"value"in s&&s.value==null?i="value":i==="download"&&o===!0?o="":c==="translate"&&o==="no"?o=!1:c[0]==="o"&&c[1]==="n"?c==="ondoubleclick"?i="ondblclick":c!=="onchange"||r!=="input"&&r!=="textarea"||ks(s.type)?c==="onfocus"?i="onfocusin":c==="onblur"?i="onfocusout":ys.test(i)&&(i=c):c=i="oninput":a&&_s.test(i)?i=i.replace(Ns,"-$&").toLowerCase():o===null&&(o=void 0),c==="oninput"&&l[i=c]&&(i="oninputCapture"),l[i]=o}}r=="select"&&(l.multiple&&Array.isArray(l.value)&&(l.value=it(s.children).forEach(function(d){d.props.selected=l.value.indexOf(d.props.value)!=-1})),l.defaultValue!=null&&(l.value=it(s.children).forEach(function(d){d.props.selected=l.multiple?l.defaultValue.indexOf(d.props.value)!=-1:l.defaultValue==d.props.value}))),s.class&&!s.className?(l.class=s.class,Object.defineProperty(l,"className",Ss)):s.className&&(l.class=l.className=s.className),n.props=l}(e),e.$$typeof=bs,Ot&&Ot(e)};var jt=j.__r;j.__r=function(e){jt&&jt(e),e.__c};var Ut=j.diffed;j.diffed=function(e){Ut&&Ut(e);var n=e.props,s=e.__e;s!=null&&e.type==="textarea"&&"value"in n&&n.value!==s.value&&(s.value=n.value==null?"":n.value)};const Cs=10;function $s({points:e,width:n=800,height:s=600,onPointClick:r,renderTooltip:l}){const a=ae(null),[i,o]=g({x:0,y:0,scale:1}),[c,d]=g(null),[u,f]=g(!1),x=ae({x:0,y:0}),h=ae(null),p=ae(null),m=ae(e);m.current=e;const b=Nt(w=>{h.current=w(h.current??i),p.current===null&&(p.current=requestAnimationFrame(()=>{p.current=null,h.current&&(o(h.current),h.current=null)}))},[i]);D(()=>()=>{p.current!==null&&cancelAnimationFrame(p.current)},[]);const L=Nt((w,y)=>{const T=a.current;if(!T)return null;const q=T.getBoundingClientRect(),W=h.current??i,le=w-q.left,F=y-q.top;let G=null,S=Cs;for(const ge of m.current){const be=ge.x*n*W.scale+W.x,_e=ge.y*s*W.scale+W.y,ue=le-be,$e=F-_e,Le=Math.sqrt(ue*ue+$e*$e);Le<=S&&(S=Le,G=ge)}return G},[i,n,s]);D(()=>{const w=a.current;if(!w)return;const y=w.getContext("2d");if(!y)return;const T=window.devicePixelRatio||1;w.width=n*T,w.height=s*T,y.scale(T,T),y.clearRect(0,0,n,s),y.save(),y.translate(i.x,i.y),y.scale(i.scale,i.scale);for(const q of e){const W=q.x*n,le=q.y*s,F=(q.radius??3)*(q.highlighted?2:1);y.beginPath(),y.arc(W,le,F,0,Math.PI*2),y.fillStyle=q.color,y.globalAlpha=q.highlighted?1:.6,y.fill(),q.highlighted&&(y.strokeStyle="#22d3ee",y.lineWidth=2,y.stroke())}y.restore()},[e,i,n,s]);const P=w=>{w.preventDefault();const y=w.deltaY>0?.9:1.1;b(T=>({...T,scale:Math.max(.5,Math.min(10,T.scale*y))}))},N=w=>{f(!0),x.current={x:w.clientX-i.x,y:w.clientY-i.y}},V=w=>{if(u){b(T=>({...T,x:w.clientX-x.current.x,y:w.clientY-x.current.y}));return}const y=L(w.clientX,w.clientY);d(T=>(T==null?void 0:T.id)===(y==null?void 0:y.id)?T:y)},ve=()=>f(!1);return t("div",{className:"relative overflow-hidden rounded-lg border border-slate-700 bg-slate-900",style:{width:n,height:s},children:[t("canvas",{ref:a,className:"absolute inset-0 cursor-grab active:cursor-grabbing",onMouseDown:N,onMouseMove:V,onMouseUp:ve,onMouseLeave:ve,onClick:w=>{if(u)return;const y=L(w.clientX,w.clientY);y&&(r==null||r(y.id))},onWheel:P}),c&&l&&t("div",{className:"absolute bg-slate-800 border border-slate-600 rounded-lg p-3 shadow-xl text-sm z-10 pointer-events-none",style:{left:Math.min(c.x*n*i.scale+i.x+12,n-200),top:Math.min(c.y*s*i.scale+i.y-12,s-80)},children:l(c)}),i.scale!==1&&t("button",{className:"absolute bottom-3 right-3 px-2 py-1 bg-slate-700 hover:bg-slate-600 rounded text-xs text-white transition-colors z-20",onClick:()=>{o({x:0,y:0,scale:1}),h.current=null},children:"Reset zoom"})]})}function Fe(e,n){const s=e.x-n.x,r=e.y-n.y,l=(e.z??0)-(n.z??0);return Math.sqrt(s*s+r*r+l*l)}function Ls(e,n=8,s=20){const r=e.length;if(r<=n)return e.map((i,o)=>o);const l=new Array(r).fill(0),a=[];a.push(e[Math.floor(Math.random()*r)]);for(let i=1;i<n;i++){const o=e.map(u=>Math.min(...a.map(f=>Fe(u,f)))),c=o.reduce((u,f)=>u+f*f,0);let d=Math.random()*c;for(let u=0;u<r;u++)if(d-=o[u]*o[u],d<=0){a.push(e[u]);break}}for(let i=0;i<s;i++){for(let c=0;c<r;c++){let d=0,u=Fe(e[c],a[0]);for(let f=1;f<a.length;f++){const x=Fe(e[c],a[f]);x<u&&(u=x,d=f)}l[c]=d}const o=a.map(()=>({x:0,y:0,z:0,count:0}));for(let c=0;c<r;c++){const d=l[c];o[d].x+=e[c].x,o[d].y+=e[c].y,o[d].z+=e[c].z??0,o[d].count++}a.forEach((c,d)=>{o[d].count>0&&(c.x=o[d].x/o[d].count,c.y=o[d].y/o[d].count,c.z!==void 0&&(c.z=o[d].z/o[d].count))})}return l}function Ts(e,n,s){const r=s.map((a,i)=>{const c=e.filter((f,x)=>n[x]===i).map(f=>Fe(f,a)),d=c.reduce((f,x)=>f+x,0)/c.length,u=c.reduce((f,x)=>f+(x-d)**2,0)/c.length;return Math.sqrt(u)}),l=new Set;for(let a=0;a<e.length;a++){const i=n[a];Fe(e[a],s[i])>2*(r[i]??0)&&l.add(a)}return l}const Rs=gs(()=>ps(()=>import("./ScatterPlot3D-DQLl3sKN.js"),__vite__mapDeps([0,1])).then(e=>({default:e.ScatterPlot3D}))),We=["#3b82f6","#ef4444","#22c55e","#f59e0b","#a855f7","#06b6d4","#ec4899","#84cc16","#f97316","#14b8a6","#8b5cf6","#e11d48","#65a30d","#0ea5e9","#d946ef","#ca8a04","#64748b","#4ade80","#fb7185","#38bdf8"],rt=2,zt=50,qt=5,Ht=200,Ps=20,Is=12;function Es(){var ft,mt;const{data:e,isLoading:n,error:s,refresh:r}=J(()=>$.embeddingProj(5e3,3)),[l,a]=g("language"),[i,o]=g("3d"),[c,d]=g(!1),[u,f]=g(8),[x,h]=g(20),[p,m]=g(!1),[b,L]=g(new Set),[P,N]=g(5),[V,ve]=g(0),[z,w]=g(null),[y,T]=g(!1),q=ae(0),[W,le]=g(null),[F,G]=g(new Set),S=((ft=e==null?void 0:e.body)==null?void 0:ft.points)??(e==null?void 0:e.points)??[],ge=((mt=e==null?void 0:e.body)==null?void 0:mt.totalChunks)??(e==null?void 0:e.totalChunks)??0;if(D(()=>{var v;if(l==="cluster"&&S.length>0){const M=Math.max(rt,Math.min(u,S.length)),k=Ls(S,M,x);if(le(k),c){const K=[];for(let ye=0;ye<M;ye++){const ee=S.filter((Te,he)=>k[he]===ye);if(ee.length>0){const Te=((v=ee[0])==null?void 0:v.z)!==void 0;K.push({x:ee.reduce((he,Re)=>he+Re.x,0)/ee.length,y:ee.reduce((he,Re)=>he+Re.y,0)/ee.length,...Te?{z:ee.reduce((he,Re)=>he+(Re.z??0),0)/ee.length}:{}})}}G(Ts(S,k,K))}}else le(null),G(new Set)},[l,c,u,x,S]),D(()=>{p&&ce.value.length>0?L(new Set(ce.value.map(v=>v.chunk.id))):L(new Set)},[p,ce.value]),n)return t(Y,{type:"chart"});if(s)return t(se,{message:s,onRetry:r});if(S.length===0)return t(xe,{icon:"🌐",message:"No embedding data available. Index some files first."});const be=de(()=>Fs(S),[S]),_e=de(()=>S.map((v,M)=>{let k;if(l==="language")k=Ue(v.language)==="text-slate-400"?"#94a3b8":As(v.language);else if(l==="file")k=be.get(v.filePath)??"#94a3b8";else{const Te=(W==null?void 0:W[M])??0;k=We[Te%We.length]}const K=F.has(M),ee=b.has(v.id);return{id:v.id,x:v.x,y:v.y,z:v.z??.5,color:ee?"#22d3ee":K?"#f97316":k,label:`${v.filePath}:${v.startLine}-${v.endLine} [${v.language}]`,radius:ee?6:K?5:3,highlighted:ee}}),[S,l,W,F,b,be]),ue=de(()=>{if(l!=="file")return[];const v=Ms(S.map(k=>k.filePath)),M=new Map;for(const k of S)M.set(k.filePath,(M.get(k.filePath)??0)+1);return[...M.entries()].sort((k,K)=>K[1]-k[1]).slice(0,Is).map(([k,K])=>({label:k.slice(v.length)||k,count:K,color:be.get(k)??"#94a3b8"}))},[l,S,be]),$e=de(()=>l!=="file"?0:new Set(S.map(v=>v.filePath)).size-ue.length,[l,S,ue]),Le=v=>{const M=++q.current;w(null),T(!0),$.chunk(v).then(k=>{M===q.current&&(w(k),T(!1))}).catch(()=>{M===q.current&&(w({id:v,content:"",filePath:"not found",language:"",startLine:0,endLine:0,description:"Error loading chunk details."}),T(!1))})};return t("div",{children:[t("h1",{className:"text-2xl font-bold mb-4",children:"Embedding Space Explorer"}),t("div",{className:"flex flex-wrap gap-3 mb-4 items-center",children:[t("div",{className:"flex items-center gap-1 bg-slate-800 border border-slate-600 rounded-lg p-0.5",children:["2d","3d"].map(v=>t("button",{className:`px-2 py-0.5 rounded text-xs transition-colors ${i===v?"bg-slate-600 text-white":"text-slate-400 hover:text-slate-200"}`,onClick:()=>o(v),children:v.toUpperCase()},v))}),t("label",{className:"text-xs text-slate-400",children:"Color by:"}),t("select",{className:"bg-slate-800 border border-slate-600 rounded text-xs text-slate-200 px-2 py-1",value:l,onChange:v=>a(v.target.value),children:[t("option",{value:"language",children:"Language"}),t("option",{value:"file",children:"File"}),t("option",{value:"cluster",children:"Cluster"})]}),l==="cluster"&&t(re,{children:[t("label",{className:"text-xs text-slate-400",children:"K:"}),t("input",{type:"number",min:rt,max:zt,value:u,onChange:v=>f(Wt(v.target,rt,zt,8)),className:"bg-slate-800 border border-slate-600 rounded text-xs text-slate-200 px-2 py-1 w-16",title:"Number of clusters"}),t("label",{className:"text-xs text-slate-400",children:"Iterations:"}),t("input",{type:"number",min:qt,max:Ht,value:x,onChange:v=>h(Wt(v.target,qt,Ht,20)),className:"bg-slate-800 border border-slate-600 rounded text-xs text-slate-200 px-2 py-1 w-20",title:"Maximum k-means iterations"})]}),t("label",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[t("input",{type:"checkbox",className:"accent-brand-500",checked:c,onChange:v=>d(v.target.checked)}),"Outliers"]}),ce.value.length>0&&t("label",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[t("input",{type:"checkbox",className:"accent-brand-500",checked:p,onChange:v=>m(v.target.checked)}),"Search overlay (",ce.value.length," results)"]}),i==="3d"&&t(re,{children:[t("label",{className:"text-xs text-slate-400",children:"Point size:"}),t("input",{type:"range",min:1,max:20,value:P,onChange:v=>N(Number(v.target.value)),className:"w-24 accent-brand-500"}),t("button",{className:"px-2 py-1 bg-slate-700 hover:bg-slate-600 rounded text-xs text-white transition-colors",onClick:()=>ve(v=>v+1),children:"Reset camera"})]})]}),l==="cluster"&&W&&t("div",{className:"flex flex-wrap gap-2 mb-3 text-xs",children:(()=>{const v=Array.from(new Set(W)).sort((K,ye)=>K-ye),M=v.slice(0,Ps),k=v.length-M.length;return t(re,{children:[M.map(K=>t("span",{className:"flex items-center gap-1 text-slate-400",children:[t("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:We[K%We.length]}}),"Cluster ",K+1]},K)),k>0&&t("span",{className:"text-slate-500",children:["+",k," more"]})]})})()}),l==="file"&&ue.length>0&&t("div",{className:"flex flex-wrap gap-2 mb-3 text-xs",children:[ue.map(({label:v,count:M,color:k})=>t("span",{className:"flex items-center gap-1 text-slate-400",title:v,children:[t("span",{className:"inline-block w-2 h-2 rounded-full",style:{background:k}}),C(Lt(v,40))," (",M,")"]},v)),$e>0&&t("span",{className:"text-slate-500",children:["+",$e," more files"]})]}),i==="3d"?t(Be,{fallback:t(Y,{type:"chart"}),children:t(Rs,{points:_e,width:900,height:600,onPointClick:Le,pointSize:P,resetKey:V,selectedId:(z==null?void 0:z.id)??null})}):t($s,{points:_e,width:900,height:600,onPointClick:Le,renderTooltip:v=>{const M=S.find(k=>k.id===v.id);return t("div",{children:[t("div",{className:"text-yellow-400 font-mono text-xs",children:C(v.label)}),(M==null?void 0:M.description)&&t("div",{className:"text-slate-400 text-xs mt-1",children:C(Lt(M.description,80))})]})}}),y&&t(Y,{type:"detail"}),z&&!y&&t("div",{className:"kpi-card p-4 mt-4",children:[t("div",{className:"flex items-center gap-3 mb-1 flex-wrap",children:[t("span",{className:"text-yellow-400 font-mono text-sm",children:C(z.filePath)}),t("span",{className:"text-slate-400 text-xs",children:["Lines ",z.startLine,"-",z.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:pe(z.language)}}),z.id&&t("span",{className:"text-xs text-slate-600 font-mono",children:z.id}),t("button",{className:"ml-auto px-2 py-1 bg-slate-700 hover:bg-slate-600 rounded text-xs text-white transition-colors",onClick:()=>U(`chunks?id=${encodeURIComponent(z.id)}`),children:"Open in Chunks"})]}),z.description&&t("div",{className:"mb-3",children:[t("h3",{className:"text-xs font-semibold text-slate-400 mb-1",children:"Description"}),t("p",{className:"text-sm text-slate-300",children:C(z.description)})]}),z.content&&t("div",{children:[t("h3",{className:"text-xs font-semibold text-slate-400 mb-1",children:"Content"}),t("pre",{className:"text-xs text-slate-300 bg-slate-900 border border-slate-700 rounded p-3 overflow-auto max-h-64 font-mono whitespace-pre",children:C(z.content)})]})]}),t("p",{className:"text-xs text-slate-500 mt-2",children:[_e.length," of ",ge," chunks displayed",_e.length<ge&&" (chunks without embeddings omitted)"]})]})}function Wt(e,n,s,r){const l=parseInt((e==null?void 0:e.value)??"",10);return Number.isNaN(l)?r:Math.max(n,Math.min(s,l))}function Ms(e){if(e.length===0)return"";let n=e[0]??"";for(const r of e)for(;r&&n&&!r.startsWith(n);)n=n.slice(0,-1);const s=n.lastIndexOf("/");return s>=0?n.slice(0,s+1):""}function Fs(e){const n=new Map;for(const h of e){const p=n.get(h.filePath)??{x:0,y:0,z:0,n:0};p.x+=h.x,p.y+=h.y,p.z+=h.z??0,p.n++,n.set(h.filePath,p)}const s=[];for(const[h,p]of n)s.push({file:h,x:p.x/p.n,y:p.y/p.n,z:p.z/p.n});const r=s.reduce((h,p)=>h+p.x,0)/s.length,l=s.reduce((h,p)=>h+p.y,0)/s.length,a=s.reduce((h,p)=>h+p.z,0)/s.length,i=s.reduce((h,p)=>h+(p.x-r)**2,0),o=s.reduce((h,p)=>h+(p.y-l)**2,0),c=s.reduce((h,p)=>h+(p.z-a)**2,0),d=i>=o&&i>=c?"x":o>=c?"y":"z",u=["x","y","z"].filter(h=>h!==d);s.sort((h,p)=>h[d]-p[d]||h[u[0]]-p[u[0]]||h[u[1]]-p[u[1]]);const f=new Map,x=137.508;for(let h=0;h<s.length;h++){const p=h*x%360,m=h%2===0?55:40;f.set(s[h].file,`hsl(${p.toFixed(1)}, 80%, ${m}%)`)}return f}function As(e){return{typescript:"#60a5fa",javascript:"#facc15",python:"#4ade80",java:"#f87171",go:"#22d3ee",rust:"#fb923c",ruby:"#f472b6",csharp:"#a78bfa",cpp:"#818cf8",c:"#9ca3af",markdown:"#d1d5db",html:"#fdba74",css:"#60a5fa",json:"#fde047",kotlin:"#c084fc",swift:"#fb923c",tex:"#34d399",sql:"#67e8f9",text:"#94a3b8",image:"#a78bfa",quirk:"#fbbf24"}[e]??"#94a3b8"}const Ds=[{view:"dashboard",label:"Dashboard",icon:"📊"},{view:"search",label:"Search",icon:"🔍"},{view:"embeddings",label:"Embeddings",icon:"🌐"},{view:"chunks",label:"Chunks",icon:"🧩"},{view:"files",label:"Files",icon:"📄"},{view:"evaluate",label:"Evaluate",icon:"📈"},{view:"quirks",label:"Quirks",icon:"💡"}];function Os(){Tn(),Rn();const e=Oe();nt.value=e.view;const n=()=>{qe.value=!qe.value};return t("div",{className:"h-screen flex flex-col overflow-hidden",children:[t("header",{className:"flex items-center gap-3 px-4 py-2 border-b shrink-0",style:{borderColor:"var(--border)"},children:[t("h1",{className:"text-lg font-bold shrink-0",style:{color:"var(--accent)"},children:"OpenCodeRAG"}),t("nav",{className:"flex gap-1 flex-1",role:"navigation","aria-label":"Main navigation",children:Ds.map(s=>t("button",{id:`nav-${s.view}`,className:`nav-btn ${nt.value===s.view?"active":""}`,onClick:()=>window.location.hash=s.view,role:"tab","aria-selected":nt.value===s.view,children:[s.icon," ",s.label]},s.view))}),t(On,{}),t(In,{}),t("button",{className:"p-2 rounded-lg transition-colors hidden lg:block",style:{color:"var(--text-muted)"},onClick:n,"aria-label":"Toggle file tree",title:"Toggle file tree",children:"☰"}),t("button",{className:"p-2 rounded-lg transition-colors lg:hidden",style:{color:"var(--text-muted)"},onClick:n,"aria-label":"Toggle file tree",title:"Toggle file tree",children:"☰"})]}),t("div",{className:"flex flex-1 overflow-hidden",children:[qe.value&&t(re,{children:[t("div",{className:"fixed inset-0 z-30 lg:hidden",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>{qe.value=!1}}),t("aside",{className:"w-64 overflow-y-auto shrink-0 border-r z-40 fixed lg:relative inset-y-0 left-0",style:{background:"var(--bg-secondary)",borderColor:"var(--border)"},role:"tree","aria-label":"File tree",children:[t(zn,{}),t(jn,{})]})]}),t("main",{className:"flex-1 overflow-y-auto p-6",id:"main-content",tabIndex:-1,children:[e.view==="dashboard"&&t(Kn,{}),e.view==="search"&&t(ls,{}),e.view==="embeddings"&&t(Es,{}),e.view==="compare"&&t(cs,{}),e.view==="chunks"&&t(Bn,{}),e.view==="files"&&t(Gn,{}),e.view==="evaluate"&&t(Zn,{}),e.view==="quirks"&&t(ss,{}),e.view==="config"&&t(us,{})]})]}),t(Pn,{})]})}fn(t(Os,{}),document.getElementById("app"));export{ae as A,D as h,t as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media (min-width: 640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media (min-width: 768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media (min-width: 1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media (min-width: 1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media (min-width: 1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.chunk-row.selected{background:color-mix(in srgb,var(--accent) 10%,transparent);border-left:2px solid var(--accent)}.chunk-row:hover{background:var(--bg-tertiary)}.file-item.active{background:color-mix(in srgb,var(--accent) 20%,transparent);color:var(--text-primary)}.file-item:hover{background:var(--bg-tertiary)}.kpi-card{background:var(--bg-card);border:1px solid var(--border);border-radius:.75rem}.nav-btn{padding:.375rem .75rem;border-radius:.25rem;font-size:.875rem;color:var(--text-muted);transition:color .15s,background-color .15s}.nav-btn:hover{background:var(--bg-tertiary);color:var(--text-primary)}.nav-btn.active{background:color-mix(in srgb,var(--accent) 20%,transparent);color:var(--accent)}pre,code{background:var(--bg-code)}table thead{background:var(--bg-secondary)}table tbody tr{border-top:1px solid var(--border)}table tbody tr:hover{background:var(--bg-tertiary)}input,select,textarea{background:var(--bg-secondary);border-color:var(--border);color:var(--text-primary)}input::-moz-placeholder,textarea::-moz-placeholder{color:var(--text-muted)}input::placeholder,textarea::placeholder{color:var(--text-muted)}.chart-svg rect{transition:opacity .15s}.chart-svg rect:hover{opacity:.85}.chart-svg circle:hover{r:5}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.pointer-events-auto{pointer-events:auto}.visible{visibility:visible}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-y-0{top:0;bottom:0}.bottom-3{bottom:.75rem}.bottom-6{bottom:1.5rem}.left-0{left:0}.right-0{right:0}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-4{top:1rem}.top-full{top:100%}.z-10{z-index:10}.z-20{z-index:20}.z-30{z-index:30}.z-40{z-index:40}.z-50{z-index:50}.z-\[9999\]{z-index:9999}.col-span-2{grid-column:span 2 / span 2}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-0\.5{margin-left:.125rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-auto{margin-left:auto}.mr-2{margin-right:.5rem}.mt-1{margin-top:.25rem}.mt-1\.5{margin-top:.375rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-6{margin-top:1.5rem}.mt-auto{margin-top:auto}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-10{height:2.5rem}.h-2{height:.5rem}.h-24{height:6rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-64{height:16rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-48{max-height:12rem}.max-h-64{max-height:16rem}.max-h-80{max-height:20rem}.max-h-\[60vh\]{max-height:60vh}.max-h-\[70vh\]{max-height:70vh}.max-h-\[calc\(100vh-220px\)\]{max-height:calc(100vh - 220px)}.w-1\/2{width:50%}.w-10{width:2.5rem}.w-12{width:3rem}.w-16{width:4rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-28{width:7rem}.w-3{width:.75rem}.w-32{width:8rem}.w-48{width:12rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-64{width:16rem}.w-8{width:2rem}.w-96{width:24rem}.w-full{width:100%}.min-w-0{min-width:0px}.max-w-full{max-width:100%}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.border-collapse{border-collapse:collapse}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-grab{cursor:grab}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.self-end{align-self:flex-end}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre{white-space:pre}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-sm{border-radius:.125rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-amber-700{--tw-border-opacity: 1;border-color:rgb(180 83 9 / var(--tw-border-opacity, 1))}.border-green-700{--tw-border-opacity: 1;border-color:rgb(21 128 61 / var(--tw-border-opacity, 1))}.border-red-700{--tw-border-opacity: 1;border-color:rgb(185 28 28 / var(--tw-border-opacity, 1))}.border-slate-600{--tw-border-opacity: 1;border-color:rgb(71 85 105 / var(--tw-border-opacity, 1))}.border-slate-700{--tw-border-opacity: 1;border-color:rgb(51 65 85 / var(--tw-border-opacity, 1))}.border-slate-700\/50{border-color:#33415580}.border-slate-800{--tw-border-opacity: 1;border-color:rgb(30 41 59 / var(--tw-border-opacity, 1))}.bg-amber-500{--tw-bg-opacity: 1;background-color:rgb(245 158 11 / var(--tw-bg-opacity, 1))}.bg-amber-500\/20{background-color:#f59e0b33}.bg-amber-900\/20{background-color:#78350f33}.bg-amber-900\/30{background-color:#78350f4d}.bg-amber-900\/50{background-color:#78350f80}.bg-brand-500{--tw-bg-opacity: 1;background-color:rgb(6 182 212 / var(--tw-bg-opacity, 1))}.bg-brand-600{--tw-bg-opacity: 1;background-color:rgb(8 145 178 / var(--tw-bg-opacity, 1))}.bg-cyan-500{--tw-bg-opacity: 1;background-color:rgb(6 182 212 / var(--tw-bg-opacity, 1))}.bg-emerald-900\/20{background-color:#064e3b33}.bg-green-600{--tw-bg-opacity: 1;background-color:rgb(22 163 74 / var(--tw-bg-opacity, 1))}.bg-green-900\/30{background-color:#14532d4d}.bg-green-900\/50{background-color:#14532d80}.bg-red-600{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.bg-red-900\/30{background-color:#7f1d1d4d}.bg-rose-900\/20{background-color:#88133733}.bg-sky-900\/20{background-color:#0c4a6e33}.bg-slate-600{--tw-bg-opacity: 1;background-color:rgb(71 85 105 / var(--tw-bg-opacity, 1))}.bg-slate-700{--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity, 1))}.bg-slate-800{--tw-bg-opacity: 1;background-color:rgb(30 41 59 / var(--tw-bg-opacity, 1))}.bg-slate-800\/80{background-color:#1e293bcc}.bg-slate-900{--tw-bg-opacity: 1;background-color:rgb(15 23 42 / var(--tw-bg-opacity, 1))}.bg-slate-900\/50{background-color:#0f172a80}.bg-slate-950{--tw-bg-opacity: 1;background-color:rgb(2 6 23 / var(--tw-bg-opacity, 1))}.bg-gradient-to-r{background-image:linear-gradient(to right,var(--tw-gradient-stops))}.from-slate-700{--tw-gradient-from: #334155 var(--tw-gradient-from-position);--tw-gradient-to: rgb(51 65 85 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to)}.via-slate-600{--tw-gradient-to: rgb(71 85 105 / 0) var(--tw-gradient-to-position);--tw-gradient-stops: var(--tw-gradient-from), #475569 var(--tw-gradient-via-position), var(--tw-gradient-to)}.to-slate-700{--tw-gradient-to: #334155 var(--tw-gradient-to-position)}.bg-\[length\:200\%_100\%\]{background-size:200% 100%}.object-contain{-o-object-fit:contain;object-fit:contain}.p-0\.5{padding:.125rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-5{padding:1.25rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.py-0{padding-top:0;padding-bottom:0}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-10{padding-top:2.5rem;padding-bottom:2.5rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-3{padding-bottom:.75rem}.pl-2{padding-left:.5rem}.pt-3{padding-top:.75rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.align-top{vertical-align:top}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-3xl{font-size:1.875rem;line-height:2.25rem}.text-4xl{font-size:2.25rem;line-height:2.5rem}.text-5xl{font-size:3rem;line-height:1}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.tracking-wide{letter-spacing:.025em}.text-amber-300{--tw-text-opacity: 1;color:rgb(252 211 77 / var(--tw-text-opacity, 1))}.text-amber-400{--tw-text-opacity: 1;color:rgb(251 191 36 / var(--tw-text-opacity, 1))}.text-blue-300{--tw-text-opacity: 1;color:rgb(147 197 253 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-brand-400{--tw-text-opacity: 1;color:rgb(34 211 238 / var(--tw-text-opacity, 1))}.text-cyan-300{--tw-text-opacity: 1;color:rgb(103 232 249 / var(--tw-text-opacity, 1))}.text-cyan-400{--tw-text-opacity: 1;color:rgb(34 211 238 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-gray-300{--tw-text-opacity: 1;color:rgb(209 213 219 / var(--tw-text-opacity, 1))}.text-gray-400{--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.text-green-300{--tw-text-opacity: 1;color:rgb(134 239 172 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-indigo-400{--tw-text-opacity: 1;color:rgb(129 140 248 / var(--tw-text-opacity, 1))}.text-orange-300{--tw-text-opacity: 1;color:rgb(253 186 116 / var(--tw-text-opacity, 1))}.text-orange-400{--tw-text-opacity: 1;color:rgb(251 146 60 / var(--tw-text-opacity, 1))}.text-pink-400{--tw-text-opacity: 1;color:rgb(244 114 182 / var(--tw-text-opacity, 1))}.text-purple-300{--tw-text-opacity: 1;color:rgb(216 180 254 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-rose-400{--tw-text-opacity: 1;color:rgb(251 113 133 / var(--tw-text-opacity, 1))}.text-sky-400{--tw-text-opacity: 1;color:rgb(56 189 248 / var(--tw-text-opacity, 1))}.text-slate-200{--tw-text-opacity: 1;color:rgb(226 232 240 / var(--tw-text-opacity, 1))}.text-slate-300{--tw-text-opacity: 1;color:rgb(203 213 225 / var(--tw-text-opacity, 1))}.text-slate-400{--tw-text-opacity: 1;color:rgb(148 163 184 / var(--tw-text-opacity, 1))}.text-slate-500{--tw-text-opacity: 1;color:rgb(100 116 139 / var(--tw-text-opacity, 1))}.text-slate-600{--tw-text-opacity: 1;color:rgb(71 85 105 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-300{--tw-text-opacity: 1;color:rgb(253 224 71 / var(--tw-text-opacity, 1))}.text-yellow-400{--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}.underline{text-decoration-line:underline}.placeholder-slate-500::-moz-placeholder{--tw-placeholder-opacity: 1;color:rgb(100 116 139 / var(--tw-placeholder-opacity, 1))}.placeholder-slate-500::placeholder{--tw-placeholder-opacity: 1;color:rgb(100 116 139 / var(--tw-placeholder-opacity, 1))}.accent-brand-500{accent-color:#06b6d4}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #f8fafc;--bg-tertiary: #f1f5f9;--bg-card: #ffffff;--bg-code: #f8fafc;--bg-surface: #ffffff;--text-primary: #0f172a;--text-secondary: #475569;--text-muted: #94a3b8;--border: #e2e8f0;--border-hover: #cbd5e1;--accent: #0891b2;--accent-hover: #0e7490;--chart-grid: #e2e8f0;--skeleton-from: #e2e8f0;--skeleton-to: #cbd5e1;color-scheme:light}.dark{--bg-primary: #0f172a;--bg-secondary: #1e293b;--bg-tertiary: #334155;--bg-card: #1e293b;--bg-code: #0f172a;--bg-surface: #0f172a;--text-primary: #e2e8f0;--text-secondary: #94a3b8;--text-muted: #64748b;--border: #334155;--border-hover: #475569;--accent: #06b6d4;--accent-hover: #22d3ee;--chart-grid: #334155;--skeleton-from: #334155;--skeleton-to: #475569;color-scheme:dark}body{background:var(--bg-primary);color:var(--text-primary);transition:background-color .2s,color .2s}.scrollbar-thin::-webkit-scrollbar{width:6px}.scrollbar-thin::-webkit-scrollbar-track{background:transparent}.scrollbar-thin::-webkit-scrollbar-thumb{background:var(--text-muted);border-radius:3px}.scrollbar-thin::-webkit-scrollbar-thumb:hover{background:var(--text-secondary)}:focus-visible{outline:2px solid var(--accent);outline-offset:2px}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,[tabindex]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@keyframes slide-in{0%{transform:translate(100%);opacity:0}to{transform:translate(0);opacity:1}}.animate-slide-in{animation:slide-in .2s ease-out}@keyframes shimmer{0%{background-position:200% 0}to{background-position:-200% 0}}.animate-shimmer{background-size:200% 100%;background-image:linear-gradient(to right,var(--skeleton-from),var(--skeleton-to),var(--skeleton-from));animation:shimmer 1.5s ease-in-out infinite}@media (max-width: 768px){.kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.sidebar-overlay{position:fixed;top:0;right:0;bottom:0;left:0;z-index:40;background:#00000080}}@media (max-width: 640px){.kpi-grid{grid-template-columns:repeat(1,minmax(0,1fr))}}.last\:border-0:last-child{border-width:0px}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:border-brand-500\/50:hover{border-color:#06b6d480}.hover\:bg-brand-500:hover{--tw-bg-opacity: 1;background-color:rgb(6 182 212 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-600:hover{--tw-bg-opacity: 1;background-color:rgb(71 85 105 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-700:hover{--tw-bg-opacity: 1;background-color:rgb(51 65 85 / var(--tw-bg-opacity, 1))}.hover\:bg-slate-800:hover{--tw-bg-opacity: 1;background-color:rgb(30 41 59 / var(--tw-bg-opacity, 1))}.hover\:text-brand-400:hover{--tw-text-opacity: 1;color:rgb(34 211 238 / var(--tw-text-opacity, 1))}.hover\:text-red-400:hover{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.hover\:text-slate-200:hover{--tw-text-opacity: 1;color:rgb(226 232 240 / var(--tw-text-opacity, 1))}.hover\:text-white:hover{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.focus\:border-brand-400:focus{--tw-border-opacity: 1;border-color:rgb(34 211 238 / var(--tw-border-opacity, 1))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.active\:cursor-grabbing:active{cursor:grabbing}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-40:disabled{opacity:.4}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 1024px){.lg\:relative{position:relative}.lg\:block{display:block}.lg\:hidden{display:none}.lg\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.lg\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.lg\:grid-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}}
|
package/dist/web/ui/index.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>OpenCodeRAG</title>
|
|
7
7
|
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔎</text></svg>">
|
|
8
|
-
<script type="module" crossorigin src="/ui/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/ui/assets/index-BZh9MitV.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/ui/assets/vendor-Dy7HKFCY.js">
|
|
10
|
-
<link rel="stylesheet" crossorigin href="/ui/assets/index-
|
|
10
|
+
<link rel="stylesheet" crossorigin href="/ui/assets/index-DKhjGsql.css">
|
|
11
11
|
</head>
|
|
12
12
|
<body class="h-screen flex flex-col overflow-hidden bg-slate-900 text-slate-200">
|
|
13
13
|
<div id="app"></div>
|