opencode-rag-plugin 1.18.2 → 1.19.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.
@@ -2,13 +2,13 @@
2
2
  * @fileoverview HTTP server for the OpenCodeRAG Web UI dashboard with static asset serving and REST API routing.
3
3
  */
4
4
  import { createServer } from "node:http";
5
- import { readFileSync } from "node:fs";
5
+ import { existsSync, readFileSync } from "node:fs";
6
6
  import { dirname, extname, join, sep } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { LanceDbStore } from "../vectorstore/lancedb.js";
9
9
  import { KeywordIndex } from "../retriever/keyword-index.js";
10
10
  import { createApiHandler } from "./api.js";
11
- import { getStaticHtml } from "./static.js";
11
+ import { getStaticHtml, resolveDistAsset } from "./static.js";
12
12
  const __dirname = dirname(fileURLToPath(import.meta.url));
13
13
  const uiDir = join(__dirname, "ui");
14
14
  const MIME_TYPES = {
@@ -59,8 +59,17 @@ function serveUiAsset(res, filePath) {
59
59
  export async function startWebUi(storePath, port, cwd, vectorDimension = 384, cfg) {
60
60
  const store = new LanceDbStore(storePath, vectorDimension);
61
61
  const keywordIndex = await KeywordIndex.load(storePath);
62
+ // Lazy embedder for /api/retrieve — initialized on first use
63
+ let embedderPromise = null;
64
+ async function getEmbedder() {
65
+ if (!embedderPromise) {
66
+ const { createEmbedder } = await import("../embedder/factory.js");
67
+ embedderPromise = Promise.resolve(createEmbedder(cfg));
68
+ }
69
+ return embedderPromise;
70
+ }
62
71
  const html = getStaticHtml();
63
- const apiHandler = createApiHandler(store, keywordIndex, storePath, cwd, cfg);
72
+ const apiHandler = createApiHandler(store, keywordIndex, storePath, cwd, cfg, getEmbedder);
64
73
  const server = createServer(async (req, res) => {
65
74
  const url = req.url ?? "/";
66
75
  if (url === "/" || url === "/index.html") {
@@ -74,13 +83,19 @@ export async function startWebUi(storePath, port, cwd, vectorDimension = 384, cf
74
83
  res.end("Forbidden");
75
84
  return;
76
85
  }
77
- const assetPath = join(uiDir, decoded);
78
- if (!assetPath.startsWith(uiDir + sep)) {
79
- res.writeHead(403, { "Content-Type": "text/plain" });
80
- res.end("Forbidden");
86
+ // Try production build output first, fall back to dev source
87
+ const distAsset = resolveDistAsset(decoded);
88
+ if (distAsset) {
89
+ serveUiAsset(res, distAsset);
90
+ return;
91
+ }
92
+ const devPath = join(uiDir, decoded);
93
+ if (devPath.startsWith(uiDir + sep) && existsSync(devPath)) {
94
+ serveUiAsset(res, devPath);
81
95
  return;
82
96
  }
83
- serveUiAsset(res, assetPath);
97
+ res.writeHead(404, { "Content-Type": "text/plain" });
98
+ res.end("Not Found");
84
99
  return;
85
100
  }
86
101
  if (url.startsWith("/api/")) {
@@ -1,9 +1,14 @@
1
1
  /**
2
2
  * Read and cache the Web UI `index.html` from disk.
3
3
  *
4
- * The HTML is read once from the `ui/` directory adjacent to this module
5
- * and cached in memory for subsequent calls.
4
+ * Reads from the Vite production build output (`dist/web/ui/index.html`) when available,
5
+ * falling back to the development source (`src/web/ui/index.html`).
6
6
  *
7
7
  * @returns The full HTML string of the Web UI entry page.
8
8
  */
9
9
  export declare function getStaticHtml(): string;
10
+ /**
11
+ * Resolve the path to a built UI asset from the Vite output directory.
12
+ * Returns null if the path escapes the dist directory or does not exist.
13
+ */
14
+ export declare function resolveDistAsset(path: string): string | null;
@@ -1,24 +1,48 @@
1
1
  /**
2
2
  * @fileoverview Static HTML file reader and cache for the Web UI entry page.
3
+ * Supports both the Vite production build output and the development source.
3
4
  */
4
- import { readFileSync } from "node:fs";
5
- import { dirname, join } from "node:path";
5
+ import { existsSync, readFileSync } from "node:fs";
6
+ import { dirname, join, resolve } from "node:path";
6
7
  import { fileURLToPath } from "node:url";
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ /**
10
+ * Resolve the project root directory regardless of whether running from source (tsx)
11
+ * or compiled output (dist/). The static.ts module lives at src/web/static.ts or
12
+ * dist/web/static.ts, so going up two directories reaches the project root.
13
+ */
14
+ function projectRoot() {
15
+ return resolve(__dirname, "..", "..");
16
+ }
7
17
  let cachedHtml = null;
8
18
  /**
9
19
  * Read and cache the Web UI `index.html` from disk.
10
20
  *
11
- * The HTML is read once from the `ui/` directory adjacent to this module
12
- * and cached in memory for subsequent calls.
21
+ * Reads from the Vite production build output (`dist/web/ui/index.html`) when available,
22
+ * falling back to the development source (`src/web/ui/index.html`).
13
23
  *
14
24
  * @returns The full HTML string of the Web UI entry page.
15
25
  */
16
26
  export function getStaticHtml() {
17
27
  if (cachedHtml)
18
28
  return cachedHtml;
19
- const __dirname = dirname(fileURLToPath(import.meta.url));
20
- const htmlPath = join(__dirname, "ui", "index.html");
21
- cachedHtml = readFileSync(htmlPath, "utf-8");
29
+ const root = projectRoot();
30
+ const prodPath = join(root, "dist", "web", "ui", "index.html");
31
+ const devPath = join(root, "src", "web", "ui", "index.html");
32
+ const targetPath = existsSync(prodPath) ? prodPath : devPath;
33
+ cachedHtml = readFileSync(targetPath, "utf-8");
22
34
  return cachedHtml;
23
35
  }
36
+ /**
37
+ * Resolve the path to a built UI asset from the Vite output directory.
38
+ * Returns null if the path escapes the dist directory or does not exist.
39
+ */
40
+ export function resolveDistAsset(path) {
41
+ const root = projectRoot();
42
+ const distDir = join(root, "dist", "web", "ui").replace(/\\/g, "/");
43
+ const resolved = join(distDir, path).replace(/\\/g, "/");
44
+ if (!resolved.startsWith(distDir + "/"))
45
+ return null;
46
+ return existsSync(resolved) ? resolved : null;
47
+ }
24
48
  //# sourceMappingURL=static.js.map
@@ -0,0 +1,3 @@
1
+ import{l as P,S as pe,C as re,t as Et,k as Ge,F as He,R as jt}from"./vendor-Dy7HKFCY.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))l(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const r of a.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&l(r)}).observe(document,{childList:!0,subtree:!0});function s(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function l(i){if(i.ep)return;i.ep=!0;const a=s(i);fetch(i.href,a)}})();var Ft=0;function t(e,n,s,l,i,a){n||(n={});var r,c,o=n;if("ref"in o)for(c in o={},n)c=="ref"?r=n[c]:o[c]=n[c];var d={type:e,props:o,key:s,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Ft,__i:-1,__u:0,__source:i,__self:a};if(typeof e=="function"&&(r=e.defaultProps))for(c in r)o[c]===void 0&&(o[c]=r[c]);return P.vnode&&P.vnode(d),d}var ve,T,Fe,Qe,$e=0,vt=[],I=P,Ze=I.__b,Je=I.__r,Xe=I.diffed,Ye=I.__c,et=I.unmount,tt=I.__;function Be(e,n){I.__h&&I.__h(T,e,$e||n),$e=0;var s=T.__H||(T.__H={__:[],__h:[]});return e>=s.__.length&&s.__.push({}),s.__[e]}function _(e){return $e=1,At(gt,e)}function At(e,n,s){var l=Be(ve++,2);if(l.t=e,!l.__c&&(l.__=[s?s(n):gt(void 0,n),function(c){var o=l.__N?l.__N[0]:l.__[0],d=l.t(o,c);o!==d&&(l.__N=[d,l.__[1]],l.__c.setState({}))}],l.__c=T,!T.__f)){var i=function(c,o,d){if(!l.__c.__H)return!0;var u=!1,h=l.__c.props!==c;if(l.__c.__H.__.some(function(m){if(m.__N){u=!0;var x=m.__[0];m.__=m.__N,m.__N=void 0,x!==m.__[0]&&(h=!0)}}),a){var p=a.call(this,c,o,d);return u?p||h:p}return!u||h};T.__f=!0;var a=T.shouldComponentUpdate,r=T.componentWillUpdate;T.componentWillUpdate=function(c,o,d){if(this.__e){var u=a;a=void 0,i(c,o,d),a=u}r&&r.call(this,c,o,d)},T.shouldComponentUpdate=i}return l.__N||l.__}function E(e,n){var s=Be(ve++,3);!I.__s&&xt(s.__H,n)&&(s.__=e,s.u=n,T.__H.__h.push(s))}function Ce(e){return $e=5,We(function(){return{current:e}},[])}function We(e,n){var s=Be(ve++,7);return xt(s.__H,n)&&(s.__=e(),s.__H=n,s.__h=e),s.__}function Ot(){for(var e;e=vt.shift();){var n=e.__H;if(e.__P&&n)try{n.__h.some(Se),n.__h.some(qe),n.__h=[]}catch(s){n.__h=[],I.__e(s,e.__v)}}}I.__b=function(e){T=null,Ze&&Ze(e)},I.__=function(e,n){e&&n.__k&&n.__k.__m&&(e.__m=n.__k.__m),tt&&tt(e,n)},I.__r=function(e){Je&&Je(e),ve=0;var n=(T=e.__c).__H;n&&(Fe===T?(n.__h=[],T.__h=[],n.__.some(function(s){s.__N&&(s.__=s.__N),s.u=s.__N=void 0})):(n.__h.some(Se),n.__h.some(qe),n.__h=[],ve=0)),Fe=T},I.diffed=function(e){Xe&&Xe(e);var n=e.__c;n&&n.__H&&(n.__H.__h.length&&(vt.push(n)!==1&&Qe===I.requestAnimationFrame||((Qe=I.requestAnimationFrame)||Dt)(Ot)),n.__H.__.some(function(s){s.u&&(s.__H=s.u,s.u=void 0)})),Fe=T=null},I.__c=function(e,n){n.some(function(s){try{s.__h.some(Se),s.__h=s.__h.filter(function(l){return!l.__||qe(l)})}catch(l){n.some(function(i){i.__h&&(i.__h=[])}),n=[],I.__e(l,s.__v)}}),Ye&&Ye(e,n)},I.unmount=function(e){et&&et(e);var n,s=e.__c;s&&s.__H&&(s.__H.__.some(function(l){try{Se(l)}catch(i){n=i}}),s.__H=void 0,n&&I.__e(n,s.__v))};var nt=typeof requestAnimationFrame=="function";function Dt(e){var n,s=function(){clearTimeout(l),nt&&cancelAnimationFrame(n),setTimeout(e)},l=setTimeout(s,35);nt&&(n=requestAnimationFrame(s))}function Se(e){var n=T,s=e.__c;typeof s=="function"&&(e.__c=void 0,s()),T=n}function qe(e){var n=T;e.__c=e.__(),T=n}function xt(e,n){return!e||e.length!==n.length||n.some(function(s,l){return s!==e[l]})}function gt(e,n){return typeof n=="function"?n(e):n}function st(){const e=location.hash.slice(1)||"dashboard",n=e.indexOf("?"),s=n>=0?e.slice(0,n):e,l={};if(n>=0){const i=e.slice(n+1);for(const a of i.split("&")){const r=a.indexOf("=");r>=0&&(l[decodeURIComponent(a.slice(0,r))]=decodeURIComponent(a.slice(r+1)))}}return{view:s||"dashboard",params:l}}function xe(){const[e,n]=_(st);return E(()=>{const s=()=>n(st());return addEventListener("hashchange",s),()=>removeEventListener("hashchange",s)},[]),e}var Ut=Symbol.for("preact-signals");function Ee(){if(G>1)G--;else{var e,n=!1;for(function(){var i=Te;for(Te=void 0;i!==void 0;){var a=i.S;if(a.v===i.v)for(var r=a.t;r!==void 0;r=r.x)r.i===i.i&&(r.i=a.i);i=i.o}}();fe!==void 0;){var s=fe;for(fe=void 0,Le++;s!==void 0;){var l=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&_t(s))try{s.c()}catch(i){n||(e=i,n=!0)}s=l}}if(Le=0,G--,n)throw e}}function Ht(e){if(G>0)return e();Ke=++qt,G++;try{return e()}finally{Ee()}}var he,k=void 0;function je(e){var n=k,s=he;k=void 0,he=void 0;try{return e()}finally{k=n,he=s}}var fe=void 0,G=0,Le=0,qt=0,Ke=0,Te=void 0,Ie=0;function bt(e){if(k!==void 0){var n=e.n;if(n===void 0||n.t!==k)return n={i:0,S:e,p:k.s,n:void 0,t:k,e:void 0,x:void 0,r:n},k.s!==void 0&&(k.s.n=n),k.s=n,e.n=n,32&k.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=k.s,n.n=void 0,k.s.n=n,k.s=n),n}}function j(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}j.prototype.brand=Ut;j.prototype.h=function(){return!0};j.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:je(function(){var l;(l=n.W)==null||l.call(n)}))};j.prototype.U=function(e){var n=this;if(this.t!==void 0){var s=e.e,l=e.x;s!==void 0&&(s.x=l,e.e=void 0),l!==void 0&&(l.e=s,e.x=void 0),e===this.t&&(this.t=l,l===void 0&&je(function(){var i;(i=n.Z)==null||i.call(n)}))}};j.prototype.subscribe=function(e){var n=this;return ge(function(){var s=n.value;je(function(){return e(s)})},{name:"sub"})};j.prototype.valueOf=function(){return this.value};j.prototype.toString=function(){return this.value+""};j.prototype.toJSON=function(){return this.value};j.prototype.peek=function(){var e=this;return je(function(){return e.value})};Object.defineProperty(j.prototype,"value",{get:function(){var e=bt(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Le>100)throw new Error("Cycle detected");(function(s){G!==0&&Le===0&&s.l!==Ke&&(s.l=Ke,Te={S:s,v:s.v,i:s.i,o:Te})})(this),this.v=e,this.i++,Ie++,G++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{Ee()}}}});function $(e,n){return new j(e,n)}function _t(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 yt(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 Nt(e){for(var n=e.s,s=void 0;n!==void 0;){var l=n.p;n.i===-1?(n.S.U(n),l!==void 0&&(l.n=n.n),n.n!==void 0&&(n.n.p=l)):s=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=l}e.s=s}function X(e,n){j.call(this,void 0,n),this.x=e,this.s=void 0,this.g=Ie-1,this.f=4}X.prototype=new j;X.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ie))return!0;if(this.g=Ie,this.f|=1,this.i>0&&!_t(this))return this.f&=-2,!0;var e=k;try{yt(this),k=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 k=e,Nt(this),this.f&=-2,!0};X.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)}j.prototype.S.call(this,e)};X.prototype.U=function(e){if(this.t!==void 0&&(j.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)}};X.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(X.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=bt(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function at(e,n){return new X(e,n)}function wt(e){var n=e.m;if(e.m=void 0,typeof n=="function"){G++;var s=k;k=void 0;try{n()}catch(l){throw e.f&=-2,e.f|=8,Ve(e),l}finally{k=s,Ee()}}}function Ve(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,wt(e)}function Kt(e){if(k!==this)throw new Error("Out-of-order effect");Nt(this),k=e,this.f&=-2,8&this.f&&Ve(this),Ee()}function ie(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,he&&he.push(this)}ie.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()}};ie.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,wt(this),yt(this),G++;var e=k;return k=this,Kt.bind(this,e)};ie.prototype.N=function(){2&this.f||(this.f|=2,this.u=fe,fe=this)};ie.prototype.d=function(){this.f|=8,1&this.f||Ve(this)};ie.prototype.dispose=function(){this.d()};function ge(e,n){var s=new ie(e,n);try{s.c()}catch(i){throw s.d(),i}var l=s.d.bind(s);return l[Symbol.dispose]=l,l}var kt,Ne,Bt=typeof window<"u"&&!!window.__PREACT_SIGNALS_DEVTOOLS__,St=[];ge(function(){kt=this.N})();function oe(e,n){P[e]=n.bind(null,P[e]||function(){})}function Pe(e){if(Ne){var n=Ne;Ne=void 0,n()}Ne=e&&e.S()}function $t(e){var n=this,s=e.data,l=Vt(s);l.name="ReactiveDom",l.value=s;var i=We(function(){for(var c=n,o=n.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}var d=at(function(){var m=l.value.value;return m===0?0:m===!0?"":m||""}),u=at(function(){return!Array.isArray(d.value)&&!Et(d.value)}),h=ge(function(){if(this.N=Ct,u.value){var m=d.value;c.__v&&c.__v.__e&&c.__v.__e.nodeType===3&&(c.__v.__e.data=m)}}),p=n.__$u.d;return n.__$u.d=function(){h(),p.call(this)},[u,d]},[]),a=i[0],r=i[1];return a.value?r.peek():r.value}$t.displayName="ReactiveTextNode";Object.defineProperties(j.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:$t},props:{configurable:!0,get:function(){var e=this;return{data:{get value(){return e.value}}}}},__b:{configurable:!0,value:1}});oe("__b",function(e,n){if(typeof n.type=="string"){var s,l=n.props;for(var i in l)if(i!=="children"){var a=l[i];a instanceof j&&(s||(n.__np=s={}),s[i]=a,l[i]=a.peek())}}e(n)});oe("__r",function(e,n){if(e(n),n.type!==pe){Pe();var s,l=n.__c;l&&(l.__$f&=-2,(s=l.__$u)===void 0&&(l.__$u=s=function(i,a){var r;return ge(function(){r=this},{name:a}),r.c=i,r}(function(){var i;Bt&&((i=s.y)==null||i.call(s)),l.__$f|=1,l.setState({})},typeof n.type=="function"?n.type.displayName||n.type.name:""))),Pe(s)}});oe("__e",function(e,n,s,l){Pe(),e(n,s,l)});oe("diffed",function(e,n){Pe();var s;if(typeof n.type=="string"&&(s=n.__e)){var l=n.__np,i=n.props,a=s.U;if(a)for(var r in a){var c=a[r];c===void 0||l&&r in l||(c.d(),a[r]=void 0)}if(l){a||(a={},s.U=a);for(var o in l){var d=a[o],u=l[o];d===void 0?(d=Wt(s,o,u,i),a[o]=d):d.o(u,i)}}}e(n)});function Wt(e,n,s,l){var i=n in e&&e.ownerSVGElement===void 0,a=$(s);return{o:function(r,c){a.value=r,l=c},d:ge(function(){this.N=Ct;var r=a.value.value;l[n]!==r&&(l[n]=r,i?e[n]=r:r!=null&&(r!==!1||n[4]==="-")?e.setAttribute(n,r):e.removeAttribute(n))})}}oe("unmount",function(e,n){if(typeof n.type=="string"){var s=n.__e;if(s){var l=s.U;if(l){s.U=void 0;for(var i in l){var a=l[i];a&&a.d()}}}var r=n.__np;if(r){var c=n.props;for(var o in r)c[o]=r[o]}n.__np=void 0}else{var d=n.__c;if(d){var u=d.__$u;u&&(d.__$u=void 0,u.d())}}e(n)});oe("__h",function(e,n,s,l){l<3&&(n.__$f|=2),e(n,s,l)});re.prototype.shouldComponentUpdate=function(e,n){if(this.__R)return!0;var s=this.__$u,l=s&&s.s!==void 0;for(var i in n)return!0;if(this.__f||typeof this.u=="boolean"&&this.u===!0){var a=2&this.__$f;if(!(l||a||4&this.__$f)||1&this.__$f)return!0}else if(!(l||4&this.__$f)||3&this.__$f)return!0;for(var r in e)if(r!=="__source"&&e[r]!==this.props[r])return!0;for(var c in this.props)if(!(c in e))return!0;return!1};function Vt(e,n){return We(function(){return $(e,n)},[])}var zt=function(e){queueMicrotask(function(){queueMicrotask(e)})};function Gt(){Ht(function(){for(var e;e=St.shift();)kt.call(e)})}function Ct(){St.push(this)===1&&(P.requestAnimationFrame||zt)(Gt)}const Ae=$("dashboard"),Z=$(null),ne=$(null),se=$(null),de=$(0),Qt=$(50),D=$(new Set),Oe=$(new Set),A=$(""),w=$({topK:10,minScore:.35,keywordWeight:.4,hybrid:!0,pathFilter:"",langFilter:""}),le=$([]),Re=$([]);$(!1);$(null);$([]);$(new Set);$(null);$(null);const z=$("dark"),we=$(!0),ue=$([]);let Zt=0;function J(e,n,s=4e3){const l=Zt++;ue.value=[...ue.value,{id:l,type:e,message:n,duration:s}],setTimeout(()=>{ue.value=ue.value.filter(i=>i.id!==l)},s)}function M(e){window.location.hash=e}function Jt(){E(()=>{const n=localStorage.getItem("theme");n&&(z.value=n)},[]),E(()=>{document.documentElement.classList.toggle("dark",z.value==="dark"),localStorage.setItem("theme",z.value)},[z.value]);const e=()=>{z.value=z.value==="dark"?"light":"dark"};return{theme:z.value,toggle:e}}function Xt(){E(()=>{const e=n=>{const s=n.target,l=s.tagName==="INPUT"||s.tagName==="TEXTAREA"||s.isContentEditable;if((n.metaKey||n.ctrlKey)&&n.key==="k"){n.preventDefault(),M("search");return}if(!l&&n.key==="g"){const i={d:()=>M("dashboard"),s:()=>M("search"),c:()=>M("chunks"),f:()=>M("files"),e:()=>M("evaluate"),q:()=>M("quirks")},a=r=>{var c;(c=i[r.key])==null||c.call(i),window.removeEventListener("keydown",a)};window.addEventListener("keydown",a),setTimeout(()=>window.removeEventListener("keydown",a),500);return}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[])}function Yt(){return t("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:ue.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 en(){const e=z.value==="dark";return t("button",{className:"p-2 rounded-lg transition-colors",style:{color:"var(--text-muted)"},onClick:()=>{z.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 ze(e,n){const[s,l]=_(e);return E(()=>{const i=setTimeout(()=>l(e),n);return()=>clearTimeout(i)},[e,n]),s}const tn="/api";function lt(e){const n=new URLSearchParams;for(const[s,l]of Object.entries(e))l!==void 0&&l!==""&&n.set(s,String(l));return n.toString()}async function L(e,n){const s=await fetch(tn+e,n),l=await s.json();if(!s.ok)throw new Error(l.error??s.statusText);return l}const C={stats:()=>L("/stats"),files:()=>L("/files"),chunks:e=>L(`/chunks?${lt(e)}`),chunk:e=>L(`/chunks/${encodeURIComponent(e)}`),search:(e,n=20)=>L(`/search?q=${encodeURIComponent(e)}&topK=${n}`),compare:e=>L(`/compare?ids=${e.join(",")}`),retrieve:e=>L(`/retrieve?${lt(e)}`),evalSessions:()=>L("/eval/sessions"),evalSession:e=>L(`/eval/sessions/${encodeURIComponent(e)}`),evalDeleteSession:e=>L(`/eval/sessions/${encodeURIComponent(e)}`,{method:"DELETE"}),evalCompare:(e,n)=>L(`/eval/compare?a=${e}&b=${n}`),evalTokenCompare:(e,n)=>L(`/eval/token-compare?a=${e}&b=${n}`),evalAnalysis:e=>L(`/eval/sessions/${encodeURIComponent(e)}/analysis`),evalProjectSavings:e=>L("/eval/project-savings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),quirks:()=>L("/quirks"),quirkLint:()=>L("/quirks/lint"),deleteQuirk:e=>L(`/quirks/${encodeURIComponent(e)}`,{method:"DELETE"}),indexStatus:()=>L("/indexing/status"),triggerReindex:()=>L("/indexing/reindex",{method:"POST"}),config:()=>L("/config"),embeddingProj:(e=5e3)=>L(`/embeddings/projection?maxChunks=${e}`)},nn={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 be(e){return nn[e]??"text-slate-400"}function ce(e){return`<span class="inline-block px-1.5 py-0.5 rounded text-xs font-mono ${be(e)} bg-slate-800">${sn(e)}</span>`}function sn(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function S(e){return typeof e!="string"?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function an(e,n=80){const s=typeof e=="string"?e:String(e??"");return s.length>n?s.slice(0,n)+"...":s}function ln(){const[e,n]=_(""),[s,l]=_([]),[i,a]=_(!1),r=Ce(null),c=Ce(null),o=ze(e,300);E(()=>{if(!o.trim()){l([]),a(!1);return}C.search(o,10).then(h=>{l((h==null?void 0:h.results)??[]),a(!0)})},[o]),E(()=>{const h=p=>{c.current&&!c.current.contains(p.target)&&a(!1)};return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[]);const d=h=>{h.key==="Escape"&&a(!1)},u=async h=>{a(!1),n(""),M("chunks")};return t("div",{ref:c,className:"relative",children:[t("input",{ref:r,type:"text",placeholder:"Search codebase...",value:e,onInput:h=>n(h.target.value),onKeyDown:d,className:"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":i}),i&&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(h=>t("div",{className:"search-result p-2 hover:bg-slate-700 cursor-pointer border-b border-slate-700 last:border-0",onClick:()=>u(h.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:[S(h.chunk.filePath),":",h.chunk.startLine,"-",h.chunk.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:ce(h.chunk.language)}}),t("span",{className:"ml-auto text-slate-500",children:h.score})]}),t("div",{className:"text-xs text-slate-400 mt-1 truncate",children:S(h.chunk.content??"").slice(0,80)})]},h.chunk.id))}),i&&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 q(e,n=[]){const[s,l]=_(null),[i,a]=_(!0),[r,c]=_(null),[o,d]=_(0);return E(()=>{let u=!1;return a(!0),c(null),e().then(h=>{u||(l(h),a(!1))}).catch(h=>{u||(c(h.message),a(!1))}),()=>{u=!0}},[...n,o]),{data:s,isLoading:i,error:r,refresh:()=>d(u=>u+1)}}function rn(){const{data:e}=q(()=>C.files()),n=e??[],[s,l]=_(""),i=ze(s,300),a=i?n.filter(r=>r.filePath.toLowerCase().includes(i.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:r=>l(r.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(on,{files:a})})]})}function on({files:e}){const n={};for(const s of e){const l=s.filePath.split("/");let i=n;for(let a=0;a<l.length-1;a++)i[l[a]]||(i[l[a]]={}),i=i[l[a]];i.__files||(i.__files=[]),i.__files.push(s)}return t(Tt,{obj:n,depth:0,parentPath:""})}function Lt(e){let n=(e.__files||[]).length;for(const[s,l]of Object.entries(e))s!=="__files"&&(n+=Lt(l));return n}function Tt({obj:e,depth:n,parentPath:s}){const l=Object.entries(e).filter(([a])=>a!=="__files").sort(([a],[r])=>a.localeCompare(r)),i=e.__files||[];return t(pe,{children:[l.map(([a,r])=>{const c=s?`${s}/${a}`:a,o=Lt(r),d=Oe.value.has(c),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 h=new Set(Oe.value);h.has(c)?h.delete(c):h.add(c),Oe.value=h},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:S(a)}),t("span",{className:"text-xs text-slate-600 ml-auto",children:o})]}),!d&&t("div",{className:"dir-children",children:t(Tt,{obj:r,depth:n+1,parentPath:c})})]},c)}),i.map(a=>{const r=a.filePath.split("/").pop()??a.filePath,c=Z.value===a.filePath;return t("div",{className:`file-item flex items-center gap-1 py-0.5 px-2 rounded cursor-pointer ${c?"active text-white":"text-slate-400 hover:text-white"}`,style:{paddingLeft:`${n*12+8}px`},onClick:()=>{Z.value=a.filePath,M(`chunks?file=${encodeURIComponent(a.filePath)}`)},role:"treeitem",tabIndex:0,children:[t("span",{className:`text-xs ${be(a.language)}`,children:"♦"}),t("span",{className:"text-xs truncate",children:S(r)}),t("span",{className:"text-xs text-slate-600 ml-auto",children:a.chunkCount})]},a.filePath)})]})}const U="bg-gradient-to-r from-slate-700 via-slate-600 to-slate-700 bg-[length:200%_100%]";function K({type:e="card"}){return t("div",{className:"animate-pulse space-y-4",children:[t("div",{className:`h-8 ${U} 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 ${U} rounded w-16 mb-2`}),t("div",{className:`h-6 ${U} rounded w-24`})]},n))}),e==="table"&&t("div",{className:"space-y-2",children:[t("div",{className:`h-10 ${U} rounded w-full`}),[1,2,3,4,5].map(n=>t("div",{className:`h-8 ${U} rounded w-full`},n))]}),e==="chart"&&t("div",{className:`h-64 ${U} 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 ${U} rounded w-48`}),t("div",{className:`h-4 ${U} rounded w-32`}),t("div",{className:`h-32 ${U} rounded-lg`})]}),t("div",{className:"flex-1 space-y-3",children:[t("div",{className:`h-6 ${U} rounded w-48`}),t("div",{className:`h-4 ${U} rounded w-32`}),t("div",{className:`h-32 ${U} rounded-lg`})]})]})]})}function B({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 Y({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 O({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 F(e){return e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(1)+"k":String(e)}function Me(e){return e===0?"$0.00":e<.01?"$"+e.toFixed(4):"$"+e.toFixed(2)}function cn(e){return e>=6e4?(e/6e4).toFixed(1)+"m":e>=1e3?(e/1e3).toFixed(1)+"s":e+"ms"}function It(e){if(!e)return"-";const n=new Date(e);return n.toLocaleDateString()+" "+n.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function dn(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 l=Math.floor(s/60);return l<24?`${l}h ago`:`${Math.floor(l/24)}d ago`}function un(){var h;const[e,n]=_(null),[s,l]=_(!0),[i,a]=_(!1),r=async()=>{try{const p=await C.indexStatus();n(p.body??p)}catch{}l(!1)};E(()=>{r()},[]);const c=async()=>{a(!0);try{await C.triggerReindex(),J("info","Reindex started in background");const p=setInterval(async()=>{var f,N;const m=await C.indexStatus(),x=m.body??m;((f=x.manifest)==null?void 0:f.lastIndexedAt)!==((N=e==null?void 0:e.manifest)==null?void 0:N.lastIndexedAt)&&(clearInterval(p),n(x),a(!1),J("success","Reindex complete!"))},2e3)}catch(p){J("error",`Reindex failed: ${p.message}`),a(!1)}};if(s)return null;const o=(h=e==null?void 0:e.manifest)!=null&&h.lastIndexedAt?dn(e.manifest.lastIndexedAt):"Never",d=(e==null?void 0:e.staleFileCount)??0,u=d===0?"text-green-400":d<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:o})]}),t("div",{children:[t("span",{className:"text-xs text-slate-500 block",children:"Total Chunks"}),t("span",{className:"text-sm font-mono",children:F(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:F(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 ${u}`,children:d===0?"✓ Up to date":`⚠ ${d} file${d!==1?"s":""} modified since last index`})]}),t("div",{className:"col-span-2 flex items-end",children:i?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 hn(){var p,m,x;const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.stats()),{data:i}=q(()=>C.files());if(n)return t(K,{type:"card"});if(s)return t(B,{message:s,onRetry:l});if(!e)return t(Y,{icon:"📊",message:"No dashboard data available."});const a=e,r=((p=i==null?void 0:i.body)==null?void 0:p.length)??a.totalFiles??0,c=a.totalChunks??0,o=((m=a.languages)==null?void 0:m.length)??0,d=r>0?(c/r).toFixed(1):"0",u=(a.languages??[]).slice(0,8),h=((x=u[0])==null?void 0:x.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(O,{label:"Total Chunks",value:c.toLocaleString(),icon:"🧩"}),t(O,{label:"Total Files",value:r.toLocaleString(),icon:"📄"}),t(O,{label:"Languages",value:o,icon:"🔤"}),t(O,{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(f=>t("div",{className:"flex items-center gap-3",children:[t("span",{className:`w-24 text-xs text-right ${be(f.language)}`,children:f.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,f.count/h*100)}%`},children:t("span",{className:"text-xs font-medium text-white",children:f.count})})}),t("span",{className:"text-xs text-slate-500 w-12 text-right",children:[(f.count/c*100).toFixed(0),"%"]})]},f.language))})]}),t(un,{}),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 fn(){const e=xe();E(()=>{e.params.file&&(Z.value=e.params.file),e.params.lang&&(ne.value=e.params.lang)},[e.params.file,e.params.lang]);const n=de.value,s=Qt.value,l=Z.value,i=ne.value,{data:a,isLoading:r,error:c,refresh:o}=q(()=>C.chunks({offset:n,limit:s,lang:i??"",file:l??""}),[n,s,l,i]);if(r)return t(K,{type:"detail"});if(c)return t(B,{message:c,onRetry:o});const d=(a==null?void 0:a.chunks)??[],u=(a==null?void 0:a.total)??d.length,h=Math.ceil(u/s),p=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:be(ne.value),onDismiss:()=>{ne.value=null,se.value=null,de.value=0}}),Z.value&&t(rt,{text:Z.value,onDismiss:()=>{Z.value=null,se.value=null,de.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(m=>D.value.has(m.id||`chunk-${d.indexOf(m)}`)),onChange:()=>{const m=d.map((N,b)=>N.id||`chunk-${b}`),x=m.every(N=>D.value.has(N)),f=new Set(D.value);for(const N of m)x?f.delete(N):f.add(N);D.value=f},"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((m,x)=>{const f=m.id||`chunk-${x}`,N=se.value===f,b=D.value.has(f);return t("tr",{className:`chunk-row border-t border-slate-800 cursor-pointer ${N?"selected":""}`,onClick:()=>{se.value=f},role:"row",tabIndex:0,children:[t("td",{className:"px-2 py-2",onClick:v=>v.stopPropagation(),children:t("input",{type:"checkbox",className:"accent-brand-500",checked:b,onChange:()=>{const v=new Set(D.value);v.has(f)?v.delete(f):v.add(f),D.value=v},"aria-label":`Select chunk ${f}`})}),t("td",{className:"px-3 py-2 text-yellow-400 font-mono text-xs",children:[S(m.filePath),":",m.startLine,"-",m.endLine]}),t("td",{className:"px-3 py-2",dangerouslySetInnerHTML:{__html:ce(m.language)}}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:S(m.description??"").slice(0,50)})]},f)})})]})}),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:p<=1,onClick:()=>{de.value=Math.max(0,n-s)},children:"Previous"}),t("span",{className:"text-sm text-slate-400",children:["Page ",p," of ",h||1]}),t("button",{className:"px-3 py-1 bg-slate-700 rounded text-sm hover:bg-slate-600 disabled:opacity-50",disabled:p>=h,onClick:()=>{de.value+=s},children:"Next"})]}),D.value.size>=2&&D.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 m=[...D.value];D.value=new Set,M(`compare?ids=${m.join(",")}`)},children:["Compare (",D.value.size,")"]})})]}),t("div",{className:"w-1/2 overflow-y-auto",children:se.value?t(mn,{chunkId:se.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 mn({chunkId:e,chunks:n}){const[s,l]=_(null),[i,a]=_(!1);if(E(()=>{const d=n.find(u=>u.id===e);d?l(d):C.chunk(e).then(u=>{l(u)})},[e,n]),!s)return t(K,{type:"detail"});const r=s,c=r.language==="image",o=()=>{navigator.clipboard.writeText(r.content).then(()=>{a(!0),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:S(r.filePath)})}),t("div",{className:"flex items-center gap-3 text-sm text-slate-400",children:[t("span",{children:["Lines ",r.startLine,"-",r.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:ce(r.language)}}),r.id&&t("span",{className:"text-xs text-slate-600 font-mono",children:r.id})]})]}),r.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:S(r.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(r.filePath)}`,alt:r.filePath,className:"max-w-full max-h-[60vh] object-contain rounded",onError:d=>{const u=d.currentTarget;u.style.display="none",u.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:o,children:i?"Copied!":"Copy"})]}),t("pre",{className:"p-3 overflow-x-auto text-sm max-h-[calc(100vh-220px)]",children:t("code",{className:`language-${c?"text":r.language}`,children:S(r.content)})})]})]})}function pn(){const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.files());if(n)return t(K,{type:"table"});if(s)return t(B,{message:s,onRetry:l});const i=e??[];if(i.length===0)return t(Y,{icon:"📂",message:"No files indexed yet."});const a=i.reduce((r,c)=>r+c.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:[i.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:i.map(r=>t("tr",{className:"border-t border-slate-800 hover:bg-slate-800 cursor-pointer",onClick:()=>M(`chunks?file=${encodeURIComponent(r.filePath)}`),role:"row",tabIndex:0,onKeyDown:c=>{c.key==="Enter"&&M(`chunks?file=${encodeURIComponent(r.filePath)}`)},children:[t("td",{className:"px-3 py-2 text-yellow-400 font-mono text-xs",children:r.filePath}),t("td",{className:"px-3 py-2",dangerouslySetInnerHTML:{__html:ce(r.language)}}),t("td",{className:"px-3 py-2 text-slate-300",children:r.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"})})]},r.filePath))})]})})]})}function vn({segments:e,size:n=180,innerRadius:s,centerLabel:l}){const i=n/2,a=n/2,r=n/2-10,c=s??r*.6,o=e.reduce((p,m)=>p+m.value,0);if(o===0)return t("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,children:[t("circle",{cx:i,cy:a,r,fill:"none",stroke:"#334155","stroke-width":r-c}),t("circle",{cx:i,cy:a,r:c,fill:"#0f172a"})]});let d=0;const u=e.map(p=>{const m=p.value/o*360,x=d,f=d+m;return d+=m,`<path d="${xn(i,a,r,x,f,c)}" fill="${p.color}" />`}).join(""),h=l??"";return t("svg",{width:n,height:n,viewBox:`0 0 ${n} ${n}`,className:"chart-svg",children:[t("g",{dangerouslySetInnerHTML:{__html:u}}),t("text",{x:i,y:a-6,"text-anchor":"middle",fill:"white","font-size":"22","font-weight":"bold",children:h}),t("text",{x:i,y:a+14,"text-anchor":"middle",fill:"#64748b","font-size":"11",children:"tokens"})]})}function xn(e,n,s,l,i,a){const r=i-l;if(r>=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 c=b=>(b-90)*Math.PI/180,o=e+s*Math.cos(c(l)),d=n+s*Math.sin(c(l)),u=e+s*Math.cos(c(i)),h=n+s*Math.sin(c(i)),p=e+a*Math.cos(c(i)),m=n+a*Math.sin(c(i)),x=e+a*Math.cos(c(l)),f=n+a*Math.sin(c(l)),N=r>180?1:0;return[`M${o},${d}`,`A${s},${s} 0 ${N} 1 ${u},${h}`,`L${p},${m}`,`A${a},${a} 0 ${N} 0 ${x},${f}`,"Z"].join(" ")}function gn(){const e=xe();return e.params.compare?t(yn,{ids:[e.params.a??"",e.params.b??""]}):e.params.session?t(_n,{sessionId:e.params.session}):t(bn,{})}function bn(){const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.evalSessions()),[i,a]=_(new Set);if(n)return t(K,{type:"table"});if(s)return t(B,{message:s,onRetry:l});const r=(e==null?void 0:e.sessions)??[];if(r.length===0)return t(Y,{icon:"📊",message:"No sessions recorded yet."});const c=o=>{const d=new Set(i);d.has(o)?d.delete(o):d.add(o),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:[i.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[o,d]=[...i];M(`evaluate?compare&a=${encodeURIComponent(o)}&b=${encodeURIComponent(d)}`)},children:"Compare Selected"}),i.size>0&&t("button",{className:"text-xs text-slate-400 hover:text-white",onClick:()=>a(new Set),children:["Clear (",i.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:r.map(o=>{var d,u,h,p;return t("tr",{className:"border-t border-slate-800 hover:bg-slate-800 cursor-pointer",onClick:()=>M(`evaluate?session=${encodeURIComponent(o.sessionID)}`),children:[t("td",{className:"px-2 py-2",onClick:m=>m.stopPropagation(),children:t("input",{type:"checkbox",className:"accent-brand-500",checked:i.has(o.sessionID),onChange:()=>c(o.sessionID),"aria-label":`Select session ${o.title??o.sessionID}`})}),t("td",{className:"px-3 py-2 text-slate-200 font-mono text-xs",children:o.title??o.sessionID.slice(0,8)}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:It(o.lastEventAt)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:o.messageCount}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:F((((d=o.totalTokens)==null?void 0:d.input)??0)+(((u=o.totalTokens)==null?void 0:u.cacheRead)??0))}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:F(((h=o.totalTokens)==null?void 0:h.output)??0)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:Me(o.totalCost??0)}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:o.ragContextCount??0}),t("td",{className:"px-3 py-2 text-slate-300 text-right",children:F(o.ragContextTokens??0)}),t("td",{className:"px-3 py-2 text-slate-400 text-xs",children:((p=o.models)==null?void 0:p[0])??"-"}),t("td",{className:"px-3 py-2",onClick:m=>m.stopPropagation(),children:t("button",{className:"text-slate-600 hover:text-red-400 text-xs",onClick:async()=>{if(confirm("Delete this session?"))try{await C.evalDeleteSession(o.sessionID),J("success","Session deleted"),l()}catch(m){J("error",`Delete failed: ${m.message}`)}},"aria-label":"Delete session",children:"🗑"})})]},o.sessionID)})})]})})]})}function _n({sessionId:e}){var h,p,m,x,f,N,b,v;const{data:n,isLoading:s,error:l,refresh:i}=q(()=>C.evalSession(e));if(s)return t(K,{type:"detail"});if(l)return t(B,{message:l,onRetry:i});const a=(n==null?void 0:n.summary)??n,r=(n==null?void 0:n.events)??[],c=a.toolCallCounts??{};["search_semantic","get_file_skeleton","find_usages","describe_image"].reduce((g,R)=>g+(c[R]??0),0);const d=[{label:"Input",value:(((h=a.totalTokens)==null?void 0:h.input)??0)+(((p=a.totalTokens)==null?void 0:p.cacheRead)??0),color:"#3b82f6"},{label:"Output",value:((m=a.totalTokens)==null?void 0:m.output)??0,color:"#a855f7"},{label:"RAG",value:a.ragContextTokens??0,color:"#06b6d4"},{label:"Reasoning",value:((x=a.totalTokens)==null?void 0:x.reasoning)??0,color:"#f59e0b"}].filter(g=>g.value>0),u=d.reduce((g,R)=>g+R.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:()=>M("evaluate"),children:"← Back"}),t("h1",{className:"text-xl font-bold",children:a.title??((f=a.sessionID)==null?void 0:f.slice(0,12))})]}),t("div",{className:"grid grid-cols-3 lg:grid-cols-5 gap-3 mb-6",children:[t(O,{label:"Total Tokens",value:F(u)}),t(O,{label:"Input",value:F((((N=a.totalTokens)==null?void 0:N.input)??0)+(((b=a.totalTokens)==null?void 0:b.cacheRead)??0))}),t(O,{label:"Output",value:F(((v=a.totalTokens)==null?void 0:v.output)??0)}),t(O,{label:"Cost",value:Me(a.totalCost??0)}),t(O,{label:"RAG Context",value:F(a.ragContextTokens??0)})]}),t("div",{className:"flex items-center gap-6 mb-6",children:[t(vn,{segments:d,centerLabel:F(u)}),t("div",{className:"flex flex-wrap gap-3",children:d.map(g=>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:g.color}}),g.label,": ",F(g.value)," (",(g.value/u*100).toFixed(1),"%)"]},g.label))})]}),t("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-6",children:[t(O,{label:"Messages",value:a.messageCount??0}),t(O,{label:"Steps",value:a.totalSteps??0}),t(O,{label:"RAG Injections",value:a.ragContextCount??0}),t(O,{label:"Avg Response",value:cn(a.avgResponseTimeMs??0)})]}),Object.keys(c).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(c).map(([g,R])=>t("div",{className:"flex justify-between text-xs text-slate-400",children:[t("span",{className:"font-mono",children:g}),t("span",{className:"text-white",children:String(R)})]},g))})]}),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(g=>t("span",{className:"px-2 py-0.5 rounded text-xs font-mono bg-slate-800 text-slate-300",children:g},g))})]}),r.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:r.map((g,R)=>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:It(g.ts)}),t("span",{className:"text-slate-400",children:g.event}),g.tool&&t("span",{className:"text-slate-500 font-mono",children:g.tool}),g.toolStatus&&t("span",{className:`text-xs ${g.toolStatus==="completed"?"text-green-400":g.toolStatus==="running"?"text-amber-400":"text-slate-500"}`,children:g.toolStatus})]},R))})]})]})}function yn({ids:e}){var h,p,m,x,f,N,b,v;const[n,s]=e,{data:l,isLoading:i,error:a}=q(()=>Promise.all([C.evalCompare(n,s),C.evalTokenCompare(n,s)]),[n,s]);if(i)return t(K,{type:"chart"});if(a)return t(B,{message:a});if(!l)return null;const r=l[0],c=l[1],o=((h=c.sessionA)==null?void 0:h.savings)??0,d=((p=c.sessionB)==null?void 0:p.savings)??0,u=o>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:()=>M("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 ${o>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:((m=r.sessionA)==null?void 0:m.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:F(((x=r.sessionA)==null?void 0:x.totalTokens)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Cost"}),t("span",{children:Me(((f=r.sessionA)==null?void 0:f.totalCost)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"RAG Savings"}),t("span",{className:o>0?"text-green-400":"text-red-400",children:[F(Math.abs(o))," (",o>0?"+":"",o>0?"+":"",")"]})]})]})]}),t("div",{className:"kpi-card p-4",children:[t("h3",{className:"text-sm font-semibold text-slate-300 mb-2",children:((N=r.sessionB)==null?void 0:N.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:F(((b=r.sessionB)==null?void 0:b.totalTokens)??0)})]}),t("div",{className:"flex justify-between",children:[t("span",{className:"text-slate-400",children:"Cost"}),t("span",{children:Me(((v=r.sessionB)==null?void 0:v.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:F(Math.abs(d))})]})]})]})]})]})}const Nn={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 wn(e){return`<span class="inline-block px-1.5 py-0.5 rounded text-xs font-mono ${Nn[e]??"text-slate-400 bg-slate-800"}">${S(e||"general")}</span>`}function kn(){const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.quirks()),[i,a]=_(null),[r,c]=_(null),[o,d]=_(!1);if(n)return t(K,{type:"card"});if(s)return t(B,{message:s,onRetry:l});const u=(e==null?void 0:e.quirks)??[],h=[...new Set(u.map(f=>f.type||"general"))],p=i?u.filter(f=>(f.type||"general")===i):u,m=async f=>{if(confirm("Delete this quirk?"))try{await C.deleteQuirk(f),J("success","Quirk deleted"),l()}catch(N){J("error",`Delete failed: ${N.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 f=await C.quirkLint();c(f)}catch(f){c({error:f.message})}d(!1)},disabled:o,children:o?"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 ${i===null?"bg-brand-600 text-white":"bg-slate-700 text-slate-300 hover:bg-slate-600"}`,onClick:()=>a(null),children:"All"}),h.map(f=>t("button",{className:`px-2 py-1 rounded text-xs font-medium transition-colors ${i===f?"bg-brand-600 text-white":"bg-slate-700 text-slate-300 hover:bg-slate-600"}`,onClick:()=>a(f),children:f},f))]}),r&&t("div",{className:`mb-4 p-3 rounded-lg border text-sm ${r.success?"bg-green-900/30 border-green-700 text-green-300":r.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(r,null,2)})}),p.length===0?t(Y,{icon:"💡",message:"No quirks stored yet."}):t("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3",children:p.map(f=>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:wn(f.type)}}),t("span",{className:`text-xs font-mono ${f.confidence>.7?"text-green-400":f.confidence>.4?"text-amber-400":"text-red-400"}`,children:[(f.confidence*100).toFixed(0),"%"]})]}),t("p",{className:"text-sm text-slate-200 mb-2 flex-1",children:S(f.content)}),f.tags&&f.tags.length>0&&t("div",{className:"flex gap-1 flex-wrap mb-2",children:f.tags.map(N=>t("span",{className:"text-xs bg-slate-800 text-slate-400 px-1.5 py-0.5 rounded",children:["#",N]},N))}),t("div",{className:"flex items-center justify-between text-xs text-slate-600 mt-auto",children:[f.sourceRef&&t("span",{className:"font-mono",children:S(f.sourceRef)}),t("span",{className:"font-mono",children:f.id})]}),t("button",{className:"self-end mt-2 text-xs text-slate-600 hover:text-red-400 transition-colors",onClick:()=>m(f.id),"aria-label":"Delete quirk",children:"Delete"})]},f.id))})]})}function Sn(){const[e,n]=_([]),[s,l]=_(!1),[i,a]=_(null),[r,c]=_(!1),o=ze(w.value,300);return E(()=>{const d=A.value.trim();if(!d){n([]);return}let u=!1;return(async()=>{var p,m;l(!0),a(null);try{const x=await C.retrieve({q:d,topK:o.topK,minScore:o.minScore,keywordWeight:o.keywordWeight,hybrid:o.hybrid?"true":"false",explain:"true"});if(u)return;if(x.status===503){a(((p=x.body)==null?void 0:p.error)??"Embedding model unavailable"),l(!1);return}c(!1);const f=((m=x.body)==null?void 0:m.results)??x.results??[];n(f);const N={query:d,params:{...o}};Re.value=[N,...Re.value.filter(b=>b.query!==d).slice(0,19)]}catch(x){u||a(x.message)}finally{u||l(!1)}})(),()=>{u=!0}},[A.value,o]),{results:e,isLoading:s,isInitializing:r,error:i,setResults:n}}function $n({explanation:e}){const{vectorScore:n,keywordScore:s,rawVectorScore:l,rawKeywordScore:i,keywordWeight:a,vectorRank:r,keywordRank:c}=e.scoreBreakdown,o=Math.max(n+s,.001),d=(n/o*100).toFixed(0),u=(s/o*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: ${l.toFixed(3)}${r!==void 0?`, rank #${r+1}`:""}`,children:["Vector ",d,"%"]}),t("span",{className:"text-amber-400",title:`Keyword: ${i.toFixed(3)}${c!==void 0?`, rank #${c+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 Cn(){const e=xe(),{results:n,isLoading:s,isInitializing:l,error:i}=Sn();return E(()=>{e.params.query&&(A.value=e.params.query,w.value={...w.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??""})},[]),E(()=>{if(A.value.trim()){const a=new URLSearchParams({query:A.value,topK:String(w.value.topK),minScore:String(w.value.minScore),keywordWeight:String(w.value.keywordWeight),hybrid:String(w.value.hybrid)});w.value.pathFilter&&a.set("path",w.value.pathFilter),w.value.langFilter&&a.set("lang",w.value.langFilter);const r=`search?${a.toString()}`;location.hash!==`#${r}`&&history.replaceState(null,"",`#${r}`)}},[A.value,w.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:A.value,onInput:a=>{A.value=a.target.value,le.value=[]},onKeyDown:a=>{a.key==="Enter"&&A.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(De,{label:"topK",min:1,max:25,step:1,value:w.value.topK,onChange:a=>{w.value={...w.value,topK:a}}}),t(De,{label:"minScore",min:0,max:1,step:.05,value:w.value.minScore,onChange:a=>{w.value={...w.value,minScore:a}}}),t(De,{label:"keywordWeight",min:0,max:1,step:.1,value:w.value.keywordWeight,onChange:a=>{w.value={...w.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:w.value.hybrid,onChange:a=>{w.value={...w.value,hybrid:a.target.checked}},className:"accent-brand-500"})]})]})]}),l&&t("div",{className:"text-center py-10 text-slate-400",children:[t("span",{className:"animate-spin inline-block mr-2",children:"⟳"}),"Initializing embedding model..."]}),i&&t(B,{message:i}),!s&&!i&&A.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 "',S(A.value),'"']})]}),!s&&!i&&!A.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"}),Re.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:Re.value.slice(0,10).map((a,r)=>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:()=>{A.value=a.query},children:S(a.query)},r))})]})]}),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(Ln,{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 Ln({result:e}){var l,i;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:()=>M(`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:[S(n.filePath),":",n.startLine,"-",n.endLine]}),t("span",{dangerouslySetInnerHTML:{__html:ce(n.language)}})]}),t("span",{className:"text-lg font-bold shrink-0 ml-2",style:{color:Tn(s)},children:s.toFixed(2)})]}),e.explanation&&t($n,{explanation:e.explanation}),((i=(l=e.explanation)==null?void 0:l.matchedTerms)==null?void 0:i.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:S(a)},a))}),n.description&&t("p",{className:"text-sm text-slate-400 mb-2 line-clamp-2",children:S(n.description)}),t("pre",{className:"text-xs overflow-x-auto max-h-32 rounded bg-slate-900/50 p-2",children:t("code",{children:S(n.content??"").slice(0,500)})})]})}function Tn(e){return e>=.8?"#22c55e":e>=.6?"#06b6d4":e>=.4?"#f59e0b":"#ef4444"}function De({label:e,min:n,max:s,step:l,value:i,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:l,value:i,onInput:r=>a(parseFloat(r.target.value)),className:"flex-1 accent-brand-500"}),t("span",{className:"text-xs text-slate-300 font-mono w-12 text-right",children:i})]})}function In(){var o;const n=((o=xe().params.ids)==null?void 0:o.split(",").filter(Boolean))??[],[s,l]=_([]),[i,a]=_(!0),[r,c]=_(null);return E(()=>{if(n.length<2){c("Select 2-3 chunks to compare."),a(!1);return}C.compare(n).then(d=>{var u;l(((u=d==null?void 0:d.body)==null?void 0:u.chunks)??(d==null?void 0:d.chunks)??[]),a(!1)}).catch(d=>{c(d.message),a(!1)})},[n.join(",")]),i?t(K,{type:"detail"}):r?t(B,{message:r}):s.length<2?t(Y,{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:()=>M("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(Pn,{chunk:d,index:u,baseChunk:u>0?s[0]:void 0},d.id))})]})}function Pn({chunk:e,index:n,baseChunk:s}){const l=e.content.split(`
2
+ `),i=(s==null?void 0:s.content.split(`
3
+ `))??[];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:[S(e.filePath),":",e.startLine,"-",e.endLine]}),t("span",{className:"shrink-0",dangerouslySetInnerHTML:{__html:ce(e.language)}})]}),e.description&&t("p",{className:"text-xs text-slate-400 truncate",children:S(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:l.map((a,r)=>{const c=(e.startLine??1)+r,o=i[r]===void 0?"bg-green-900/30":a===""&&i[r]!==""?"bg-red-900/30":a!==i[r]?"bg-amber-900/20":"";return t("tr",{className:o,children:[t("td",{className:"text-right text-slate-600 select-none px-2 w-10 border-r border-slate-700 align-top",children:c}),t("td",{className:"px-3 py-0 whitespace-pre-wrap break-all",children:S(a)||" "})]},r)})})})}),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 Rn(){var a;const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.config());if(n)return t(K,{type:"card"});if(s)return t(B,{message:s,onRetry:l});const i=((a=e==null?void 0:e.body)==null?void 0:a.config)??(e==null?void 0:e.config);return i?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(i).map(([r,c])=>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:r.replace(/([A-Z])/g," $1")}),t("div",{className:"px-4 pb-3",children:typeof c=="object"&&c!==null?Object.entries(c).map(([o,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:o}),t("span",{className:"text-slate-200 font-mono text-xs text-right ml-4",children:Mn(d)})]},o)):t("div",{className:"flex justify-between py-1 text-sm",children:t("span",{className:"text-slate-200 font-mono",children:String(c)})})})]},r))})]}):t(Y,{icon:"⚙",message:"No configuration available."})}function Mn(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)}function En(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 l in n)if(l!=="__source"&&e[l]!==n[l])return!0;return!1}function ot(e,n){this.props=e,this.context=n}(ot.prototype=new re).isPureReactComponent=!0,ot.prototype.shouldComponentUpdate=function(e,n){return it(this.props,e)||it(this.state,n)};var ct=P.__b;P.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),ct&&ct(e)};var jn=P.__e;P.__e=function(e,n,s,l){if(e.then){for(var i,a=n;a=a.__;)if((i=a.__c)&&i.__c)return n.__e==null&&(n.__e=s.__e,n.__k=s.__k||[]),i.__c(e,n)}jn(e,n,s,l)};var dt=P.unmount;function Pt(e,n,s){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(l){typeof l.__c=="function"&&l.__c()}),e.__c.__H=null),(e=En({},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(l){return Pt(l,n,s)})),e}function Rt(e,n,s){return e&&s&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(l){return Rt(l,n,s)}),e.__c&&e.__c.__P===n&&(e.__e&&s.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=s)),e}function Ue(){this.__u=0,this.o=null,this.__b=null}function Mt(e){var n=e.__&&e.__.__c;return n&&n.__a&&n.__a(e)}function ke(){this.i=null,this.l=null}P.unmount=function(e){var n=e.__c;n&&(n.__z=!0),n&&n.__R&&n.__R(),n&&32&e.__u&&(e.type=null),dt&&dt(e)},(Ue.prototype=new re).__c=function(e,n){var s=n.__c,l=this;l.o==null&&(l.o=[]),l.o.push(s);var i=Mt(l.__v),a=!1,r=function(){a||l.__z||(a=!0,s.__R=null,i?i(o):o())};s.__R=r;var c=s.__P;s.__P=null;var o=function(){if(!--l.__u){if(l.state.__a){var d=l.state.__a;l.__v.__k[0]=Rt(d,d.__c.__P,d.__c.__O)}var u;for(l.setState({__a:l.__b=null});u=l.o.pop();)u.__P=c,u.forceUpdate()}};l.__u++||32&n.__u||l.setState({__a:l.__b=l.__v.__k[0]}),e.then(r,r)},Ue.prototype.componentWillUnmount=function(){this.o=[]},Ue.prototype.render=function(e,n){if(this.__b){if(this.__v.__k){var s=document.createElement("div"),l=this.__v.__k[0].__c;this.__v.__k[0]=Pt(this.__b,s,l.__O=l.__P)}this.__b=null}var i=n.__a&&Ge(pe,null,e.fallback);return i&&(i.__u&=-33),[Ge(pe,null,n.__a?null:e.children),i]};var ut=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]}};(ke.prototype=new re).__a=function(e){var n=this,s=Mt(n.__v),l=n.l.get(e);return l[0]++,function(i){var a=function(){n.props.revealOrder?(l.push(i),ut(n,e,l)):i()};s?s(a):a()}},ke.prototype.render=function(e){this.i=null,this.l=new Map;var n=He(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},ke.prototype.componentDidUpdate=ke.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(n,s){ut(e,s,n)})};var Fn=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,An=/^(?: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]/,On=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,Dn=/[A-Z0-9]/g,Un=typeof document<"u",Hn=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};re.prototype.isReactComponent=!0,["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(re.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(n){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:n})}})});var ht=P.event;P.event=function(e){return ht&&(e=ht(e)),e.persist=function(){},e.isPropagationStopped=function(){return this.cancelBubble},e.isDefaultPrevented=function(){return this.defaultPrevented},e.nativeEvent=e};var qn={configurable:!0,get:function(){return this.class}},ft=P.vnode;P.vnode=function(e){typeof e.type=="string"&&function(n){var s=n.props,l=n.type,i={},a=l.indexOf("-")==-1;for(var r in s){var c=s[r];if(!(r==="value"&&"defaultValue"in s&&c==null||Un&&r==="children"&&l==="noscript"||r==="class"||r==="className")){var o=r.toLowerCase();r==="defaultValue"&&"value"in s&&s.value==null?r="value":r==="download"&&c===!0?c="":o==="translate"&&c==="no"?c=!1:o[0]==="o"&&o[1]==="n"?o==="ondoubleclick"?r="ondblclick":o!=="onchange"||l!=="input"&&l!=="textarea"||Hn(s.type)?o==="onfocus"?r="onfocusin":o==="onblur"?r="onfocusout":On.test(r)&&(r=o):o=r="oninput":a&&An.test(r)?r=r.replace(Dn,"-$&").toLowerCase():c===null&&(c=void 0),o==="oninput"&&i[r=o]&&(r="oninputCapture"),i[r]=c}}l=="select"&&(i.multiple&&Array.isArray(i.value)&&(i.value=He(s.children).forEach(function(d){d.props.selected=i.value.indexOf(d.props.value)!=-1})),i.defaultValue!=null&&(i.value=He(s.children).forEach(function(d){d.props.selected=i.multiple?i.defaultValue.indexOf(d.props.value)!=-1:i.defaultValue==d.props.value}))),s.class&&!s.className?(i.class=s.class,Object.defineProperty(i,"className",qn)):s.className&&(i.class=i.className=s.className),n.props=i}(e),e.$$typeof=Fn,ft&&ft(e)};var mt=P.__r;P.__r=function(e){mt&&mt(e),e.__c};var pt=P.diffed;P.diffed=function(e){pt&&pt(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)};function Kn({points:e,width:n=800,height:s=600,onPointClick:l,renderTooltip:i}){const a=Ce(null),[r,c]=_({x:0,y:0,scale:1}),[o,d]=_(null),[u,h]=_(!1),p=Ce({x:0,y:0});E(()=>{const b=a.current;if(!b)return;const v=b.getContext("2d");if(!v)return;const g=window.devicePixelRatio||1;b.width=n*g,b.height=s*g,v.scale(g,g),v.clearRect(0,0,n,s),v.save(),v.translate(r.x,r.y),v.scale(r.scale,r.scale);for(const R of e){const _e=R.x*n,ye=R.y*s,y=(R.radius??3)*(R.highlighted?2:1);v.beginPath(),v.arc(_e,ye,y,0,Math.PI*2),v.fillStyle=R.color,v.globalAlpha=R.highlighted?1:.6,v.fill(),R.highlighted&&(v.strokeStyle="#22d3ee",v.lineWidth=2,v.stroke())}v.restore()},[e,r,n,s]);const m=b=>{b.preventDefault();const v=b.deltaY>0?.9:1.1;c(g=>({...g,scale:Math.max(.5,Math.min(10,g.scale*v))}))},x=b=>{h(!0),p.current={x:b.clientX-r.x,y:b.clientY-r.y}},f=b=>{u&&c(v=>({...v,x:b.clientX-p.current.x,y:b.clientY-p.current.y}))},N=()=>h(!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:x,onMouseMove:f,onMouseUp:N,onMouseLeave:N,onWheel:m}),t("svg",{width:n,height:s,className:"absolute inset-0 pointer-events-none",children:e.map(b=>t("circle",{cx:b.x*n*r.scale+r.x,cy:b.y*s*r.scale+r.y,r:8,fill:"transparent",className:"pointer-events-auto cursor-pointer",onMouseEnter:()=>d(b),onMouseLeave:()=>d(null),onClick:()=>l==null?void 0:l(b.id)},b.id))}),o&&i&&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(o.x*n*r.scale+r.x+12,n-200),top:Math.min(o.y*s*r.scale+r.y-12,s-80)},children:i(o)}),r.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:()=>c({x:0,y:0,scale:1}),children:"Reset zoom"})]})}function me(e,n){return Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2)}function Bn(e,n=8,s=20){const l=e.length;if(l<=n)return e.map((r,c)=>c);const i=new Array(l).fill(0),a=[];a.push(e[Math.floor(Math.random()*l)]);for(let r=1;r<n;r++){const c=e.map(u=>Math.min(...a.map(h=>me(u,h)))),o=c.reduce((u,h)=>u+h*h,0);let d=Math.random()*o;for(let u=0;u<l;u++)if(d-=c[u]*c[u],d<=0){a.push(e[u]);break}}for(let r=0;r<s;r++){for(let o=0;o<l;o++){let d=0,u=me(e[o],a[0]);for(let h=1;h<a.length;h++){const p=me(e[o],a[h]);p<u&&(u=p,d=h)}i[o]=d}const c=a.map(()=>({x:0,y:0,count:0}));for(let o=0;o<l;o++){const d=i[o];c[d].x+=e[o].x,c[d].y+=e[o].y,c[d].count++}a.forEach((o,d)=>{c[d].count>0&&(o.x=c[d].x/c[d].count,o.y=c[d].y/c[d].count)})}return i}function Wn(e,n,s){const l=s.map((a,r)=>{const o=e.filter((h,p)=>n[p]===r).map(h=>me(h,a)),d=o.reduce((h,p)=>h+p,0)/o.length,u=o.reduce((h,p)=>h+(p-d)**2,0)/o.length;return Math.sqrt(u)}),i=new Set;for(let a=0;a<e.length;a++){const r=n[a];me(e[a],s[r])>2*(l[r]??0)&&i.add(a)}return i}const ae=["#3b82f6","#ef4444","#22c55e","#f59e0b","#a855f7","#06b6d4","#ec4899","#84cc16"];function Vn(){var _e,ye;const{data:e,isLoading:n,error:s,refresh:l}=q(()=>C.embeddingProj(5e3)),[i,a]=_("language"),[r,c]=_(!1),[o,d]=_(!1),[u,h]=_(!1),[p,m]=_(new Set),[x,f]=_(null),[N,b]=_(new Set),v=((_e=e==null?void 0:e.body)==null?void 0:_e.points)??(e==null?void 0:e.points)??[],g=((ye=e==null?void 0:e.body)==null?void 0:ye.totalChunks)??(e==null?void 0:e.totalChunks)??0;if(E(()=>{u&&le.value.length>0?m(new Set(le.value.map(y=>y.chunk.id))):m(new Set)},[u,le.value]),n)return t(K,{type:"chart"});if(s)return t(B,{message:s,onRetry:l});if(v.length===0)return t(Y,{icon:"🌐",message:"No embedding data available. Index some files first."});E(()=>{if(r&&v.length>0){const y=Math.min(8,Math.max(2,Math.floor(v.length/20))),H=Bn(v,y);if(f(H),o){const V=[];for(let ee=0;ee<y;ee++){const te=v.filter((Q,W)=>H[W]===ee);te.length>0&&V.push({x:te.reduce((Q,W)=>Q+W.x,0)/te.length,y:te.reduce((Q,W)=>Q+W.y,0)/te.length})}b(Wn(v,H,V))}}else f(null),b(new Set)},[r,o,v]);const R=v.map((y,H)=>{let V;if(i==="language")V=be(y.language)==="text-slate-400"?"#94a3b8":Gn(y.language);else if(i==="file"){const W=y.filePath.split("/")[0]??"root";V=ae[zn(W)%ae.length]}else{const W=(x==null?void 0:x[H])??0;V=ae[W%ae.length]}const ee=N.has(H),Q=p.has(y.id);return{id:y.id,x:y.x,y:y.y,color:Q?"#22d3ee":ee?"#f97316":V,label:`${y.filePath}:${y.startLine}-${y.endLine} [${y.language}]`,radius:Q?6:ee?5:3,highlighted:Q}});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("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:i,onChange:y=>a(y.target.value),children:[t("option",{value:"language",children:"Language"}),t("option",{value:"file",children:"File"}),t("option",{value:"cluster",children:"Cluster"})]}),t("label",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[t("input",{type:"checkbox",className:"accent-brand-500",checked:r,onChange:y=>c(y.target.checked)}),"Clusters"]}),t("label",{className:"flex items-center gap-1.5 text-xs text-slate-400",children:[t("input",{type:"checkbox",className:"accent-brand-500",checked:o,onChange:y=>d(y.target.checked)}),"Outliers"]}),le.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:u,onChange:y=>h(y.target.checked)}),"Search overlay (",le.value.length," results)"]})]}),i==="cluster"&&x&&t("div",{className:"flex flex-wrap gap-2 mb-3 text-xs",children:Array.from(new Set(x)).sort().map(y=>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:ae[y%ae.length]}}),"Cluster ",y+1]},y))}),t(Kn,{points:R,width:900,height:600,onPointClick:y=>M(`chunks?id=${encodeURIComponent(y)}`),renderTooltip:y=>{const H=v.find(V=>V.id===y.id);return t("div",{children:[t("div",{className:"text-yellow-400 font-mono text-xs",children:S(y.label)}),(H==null?void 0:H.description)&&t("div",{className:"text-slate-400 text-xs mt-1",children:S(an(H.description,80))})]})}}),t("p",{className:"text-xs text-slate-500 mt-2",children:[R.length," of ",g," chunks displayed",R.length<g&&" (chunks without embeddings omitted)"]})]})}function zn(e){let n=0;for(let s=0;s<e.length;s++)n=n*31+e.charCodeAt(s)|0;return Math.abs(n)}function Gn(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 Qn=[{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 Zn(){Jt(),Xt();const e=xe();Ae.value=e.view;const n=()=>{we.value=!we.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:Qn.map(s=>t("button",{id:`nav-${s.view}`,className:`nav-btn ${Ae.value===s.view?"active":""}`,onClick:()=>window.location.hash=s.view,role:"tab","aria-selected":Ae.value===s.view,children:[s.icon," ",s.label]},s.view))}),t(ln,{}),t(en,{}),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:[we.value&&t(pe,{children:[t("div",{className:"fixed inset-0 z-30 lg:hidden",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>{we.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(rn,{})})]}),t("main",{className:"flex-1 overflow-y-auto p-6",id:"main-content",tabIndex:-1,children:[e.view==="dashboard"&&t(hn,{}),e.view==="search"&&t(Cn,{}),e.view==="embeddings"&&t(Vn,{}),e.view==="compare"&&t(In,{}),e.view==="chunks"&&t(fn,{}),e.view==="files"&&t(pn,{}),e.view==="evaluate"&&t(gn,{}),e.view==="quirks"&&t(kn,{}),e.view==="config"&&t(Rn,{})]})]}),t(Yt,{})]})}jt(t(Zn,{}),document.getElementById("app"));
@@ -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}.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}.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-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.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-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%}.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-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-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-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-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-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.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-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))}.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-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\: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))}}
@@ -0,0 +1 @@
1
+ var R,h,ee,pe,x,Q,_e,te,B,N,D,ne,z,O,V,H={},I=[],fe=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,U=Array.isArray;function w(_,e){for(var t in e)_[t]=e[t];return _}function q(_){_&&_.parentNode&&_.parentNode.removeChild(_)}function ae(_,e,t){var l,o,r,i={};for(r in e)r=="key"?l=e[r]:r=="ref"?o=e[r]:i[r]=e[r];if(arguments.length>2&&(i.children=arguments.length>3?R.call(arguments,2):t),typeof _=="function"&&_.defaultProps!=null)for(r in _.defaultProps)i[r]===void 0&&(i[r]=_.defaultProps[r]);return A(_,i,l,o,null)}function A(_,e,t,l,o){var r={type:_,props:e,key:t,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++ee,__i:-1,__u:0};return o==null&&h.vnode!=null&&h.vnode(r),r}function $(_){return _.children}function F(_,e){this.props=_,this.context=e}function C(_,e){if(e==null)return _.__?C(_.__,_.__i+1):null;for(var t;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null)return t.__e;return typeof _.type=="function"?C(_):null}function he(_){if(_.__P&&_.__d){var e=_.__v,t=e.__e,l=[],o=[],r=w({},e);r.__v=e.__v+1,h.vnode&&h.vnode(r),G(_.__P,r,e,_.__n,_.__P.namespaceURI,32&e.__u?[t]:null,l,t??C(e),!!(32&e.__u),o),r.__v=e.__v,r.__.__k[r.__i]=r,se(l,r,o),e.__e=e.__=null,r.__e!=t&&re(r)}}function re(_){if((_=_.__)!=null&&_.__c!=null)return _.__e=_.__c.base=null,_.__k.some(function(e){if(e!=null&&e.__e!=null)return _.__e=_.__c.base=e.__e}),re(_)}function X(_){(!_.__d&&(_.__d=!0)&&x.push(_)&&!W.__r++||Q!=h.debounceRendering)&&((Q=h.debounceRendering)||_e)(W)}function W(){try{for(var _,e=1;x.length;)x.length>e&&x.sort(te),_=x.shift(),e=x.length,he(_)}finally{x.length=W.__r=0}}function oe(_,e,t,l,o,r,i,u,a,s,p){var y,n,c,d,k,m,v,f=l&&l.__k||I,g=e.length;for(a=de(t,e,f,a,g),y=0;y<g;y++)(c=t.__k[y])!=null&&(n=c.__i!=-1&&f[c.__i]||H,c.__i=y,m=G(_,c,n,o,r,i,u,a,s,p),d=c.__e,c.ref&&n.ref!=c.ref&&(n.ref&&J(n.ref,null,c),p.push(c.ref,c.__c||d,c)),k==null&&d!=null&&(k=d),(v=!!(4&c.__u))||n.__k===c.__k?(a=le(c,a,_,v),v&&n.__e&&(n.__e=null)):typeof c.type=="function"&&m!==void 0?a=m:d&&(a=d.nextSibling),c.__u&=-7);return t.__e=k,a}function de(_,e,t,l,o){var r,i,u,a,s,p=t.length,y=p,n=0;for(_.__k=new Array(o),r=0;r<o;r++)(i=e[r])!=null&&typeof i!="boolean"&&typeof i!="function"?(typeof i=="string"||typeof i=="number"||typeof i=="bigint"||i.constructor==String?i=_.__k[r]=A(null,i,null,null,null):U(i)?i=_.__k[r]=A($,{children:i},null,null,null):i.constructor===void 0&&i.__b>0?i=_.__k[r]=A(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):_.__k[r]=i,a=r+n,i.__=_,i.__b=_.__b+1,u=null,(s=i.__i=ye(i,t,a,y))!=-1&&(y--,(u=t[s])&&(u.__u|=2)),u==null||u.__v==null?(s==-1&&(o>p?n--:o<p&&n++),typeof i.type!="function"&&(i.__u|=4)):s!=a&&(s==a-1?n--:s==a+1?n++:(s>a?n--:n++,i.__u|=4))):_.__k[r]=null;if(y)for(r=0;r<p;r++)(u=t[r])!=null&&!(2&u.__u)&&(u.__e==l&&(l=C(u)),ce(u,u));return l}function le(_,e,t,l){var o,r;if(typeof _.type=="function"){for(o=_.__k,r=0;o&&r<o.length;r++)o[r]&&(o[r].__=_,e=le(o[r],e,t,l));return e}_.__e!=e&&(l&&(e&&_.type&&!e.parentNode&&(e=C(_)),t.insertBefore(_.__e,e||null)),e=_.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ve(_,e){return e=e||[],_==null||typeof _=="boolean"||(U(_)?_.some(function(t){ve(t,e)}):e.push(_)),e}function ye(_,e,t,l){var o,r,i,u=_.key,a=_.type,s=e[t],p=s!=null&&(2&s.__u)==0;if(s===null&&u==null||p&&u==s.key&&a==s.type)return t;if(l>(p?1:0)){for(o=t-1,r=t+1;o>=0||r<e.length;)if((s=e[i=o>=0?o--:r++])!=null&&!(2&s.__u)&&u==s.key&&a==s.type)return i}return-1}function Y(_,e,t){e[0]=="-"?_.setProperty(e,t??""):_[e]=t==null?"":typeof t!="number"||fe.test(e)?t:t+"px"}function L(_,e,t,l,o){var r,i;e:if(e=="style")if(typeof t=="string")_.style.cssText=t;else{if(typeof l=="string"&&(_.style.cssText=l=""),l)for(e in l)t&&e in t||Y(_.style,e,"");if(t)for(e in t)l&&t[e]==l[e]||Y(_.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")r=e!=(e=e.replace(ne,"$1")),i=e.toLowerCase(),e=i in _||e=="onFocusOut"||e=="onFocusIn"?i.slice(2):e.slice(2),_.l||(_.l={}),_.l[e+r]=t,t?l?t[D]=l[D]:(t[D]=z,_.addEventListener(e,r?V:O,r)):_.removeEventListener(e,r?V:O,r);else{if(o=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in _)try{_[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?_.removeAttribute(e):_.setAttribute(e,e=="popover"&&t==1?"":t))}}function Z(_){return function(e){if(this.l){var t=this.l[e.type+_];if(e[N]==null)e[N]=z++;else if(e[N]<t[D])return;return t(h.event?h.event(e):e)}}}function G(_,e,t,l,o,r,i,u,a,s){var p,y,n,c,d,k,m,v,f,g,T,S,M,K,E,j,b=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(a=!!(32&t.__u),r=[u=e.__e=t.__e]),(p=h.__b)&&p(e);e:if(typeof b=="function"){y=i.length;try{if(f=e.props,g=b.prototype&&b.prototype.render,T=(p=b.contextType)&&l[p.__c],S=p?T?T.props.value:p.__:l,t.__c?v=(n=e.__c=t.__c).__=n.__E:(g?e.__c=n=new b(f,S):(e.__c=n=new F(f,S),n.constructor=b,n.render=ge),T&&T.sub(n),n.state||(n.state={}),n.__n=l,c=n.__d=!0,n.__h=[],n._sb=[]),g&&n.__s==null&&(n.__s=n.state),g&&b.getDerivedStateFromProps!=null&&(n.__s==n.state&&(n.__s=w({},n.__s)),w(n.__s,b.getDerivedStateFromProps(f,n.__s))),d=n.props,k=n.state,n.__v=e,c)g&&b.getDerivedStateFromProps==null&&n.componentWillMount!=null&&n.componentWillMount(),g&&n.componentDidMount!=null&&n.__h.push(n.componentDidMount);else{if(g&&b.getDerivedStateFromProps==null&&f!==d&&n.componentWillReceiveProps!=null&&n.componentWillReceiveProps(f,S),e.__v==t.__v||!n.__e&&n.shouldComponentUpdate!=null&&n.shouldComponentUpdate(f,n.__s,S)===!1){e.__v!=t.__v&&(n.props=f,n.state=n.__s,n.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(P){P&&(P.__=e)}),I.push.apply(n.__h,n._sb),n._sb=[],n.__h.length&&i.push(n);break e}n.componentWillUpdate!=null&&n.componentWillUpdate(f,n.__s,S),g&&n.componentDidUpdate!=null&&n.__h.push(function(){n.componentDidUpdate(d,k,m)})}if(n.context=S,n.props=f,n.__P=_,n.__e=!1,M=h.__r,K=0,g)n.state=n.__s,n.__d=!1,M&&M(e),p=n.render(n.props,n.state,n.context),I.push.apply(n.__h,n._sb),n._sb=[];else do n.__d=!1,M&&M(e),p=n.render(n.props,n.state,n.context),n.state=n.__s;while(n.__d&&++K<25);n.state=n.__s,n.getChildContext!=null&&(l=w(w({},l),n.getChildContext())),g&&!c&&n.getSnapshotBeforeUpdate!=null&&(m=n.getSnapshotBeforeUpdate(d,k)),E=p!=null&&p.type===$&&p.key==null?ue(p.props.children):p,u=oe(_,U(E)?E:[E],e,t,l,o,r,i,u,a,s),n.base=e.__e,e.__u&=-161,n.__h.length&&i.push(n),v&&(n.__E=n.__=null)}catch(P){if(i.length=y,e.__v=null,a||r!=null){if(P.then){for(e.__u|=a?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;r!=null&&(r[r.indexOf(u)]=null),e.__e=u}else if(r!=null)for(j=r.length;j--;)q(r[j])}else e.__e=t.__e;e.__k==null&&(e.__k=t.__k||[]),P.then||ie(e),h.__e(P,e,t)}}else r==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):u=e.__e=me(t.__e,e,t,l,o,r,i,a,s);return(p=h.diffed)&&p(e),128&e.__u?void 0:u}function ie(_){_&&(_.__c&&(_.__c.__e=!0),_.__k&&_.__k.some(ie))}function se(_,e,t){for(var l=0;l<t.length;l++)J(t[l],t[++l],t[++l]);h.__c&&h.__c(e,_),_.some(function(o){try{_=o.__h,o.__h=[],_.some(function(r){r.call(o)})}catch(r){h.__e(r,o.__v)}})}function ue(_){return typeof _!="object"||_==null||_.__b>0?_:U(_)?_.map(ue):_.constructor!==void 0?null:w({},_)}function me(_,e,t,l,o,r,i,u,a){var s,p,y,n,c,d,k,m=t.props||H,v=e.props,f=e.type;if(f=="svg"?o="http://www.w3.org/2000/svg":f=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),r!=null){for(s=0;s<r.length;s++)if((c=r[s])&&"setAttribute"in c==!!f&&(f?c.localName==f:c.nodeType==3)){_=c,r[s]=null;break}}if(_==null){if(f==null)return document.createTextNode(v);_=document.createElementNS(o,f,v.is&&v),u&&(h.__m&&h.__m(e,r),u=!1),r=null}if(f==null)m===v||u&&_.data==v||(_.data=v);else{if(r=f=="textarea"&&v.defaultValue!=null?null:r&&R.call(_.childNodes),!u&&r!=null)for(m={},s=0;s<_.attributes.length;s++)m[(c=_.attributes[s]).name]=c.value;for(s in m)c=m[s],s=="dangerouslySetInnerHTML"?y=c:s=="children"||s in v||s=="value"&&"defaultValue"in v||s=="checked"&&"defaultChecked"in v||L(_,s,null,c,o);for(s in v)c=v[s],s=="children"?n=c:s=="dangerouslySetInnerHTML"?p=c:s=="value"?d=c:s=="checked"?k=c:u&&typeof c!="function"||m[s]===c||L(_,s,c,m[s],o);if(p)u||y&&(p.__html==y.__html||p.__html==_.innerHTML)||(_.innerHTML=p.__html),e.__k=[];else if(y&&(_.innerHTML=""),oe(e.type=="template"?_.content:_,U(n)?n:[n],e,t,l,f=="foreignObject"?"http://www.w3.org/1999/xhtml":o,r,i,r?r[0]:t.__k&&C(t,0),u,a),r!=null)for(s=r.length;s--;)q(r[s]);u&&f!="textarea"||(s="value",f=="progress"&&d==null?_.removeAttribute("value"):d!=null&&(d!==_[s]||f=="progress"&&!d||f=="option"&&d!=m[s])&&L(_,s,d,m[s],o),s="checked",k!=null&&k!=_[s]&&L(_,s,k,m[s],o))}return _}function J(_,e,t){try{if(typeof _=="function"){var l=typeof _.__u=="function";l&&_.__u(),l&&e==null||(_.__u=_(e))}else _.current=e}catch(o){h.__e(o,t)}}function ce(_,e,t){var l,o;if(h.unmount&&h.unmount(_),(l=_.ref)&&(l.current&&l.current!=_.__e||J(l,null,e)),(l=_.__c)!=null){if(l.componentWillUnmount)try{l.componentWillUnmount()}catch(r){h.__e(r,e)}l.base=l.__P=l.__n=null}if(l=_.__k)for(o=0;o<l.length;o++)l[o]&&ce(l[o],e,t||typeof _.type!="function");t||q(_.__e),_.__c=_.__=_.__e=void 0}function ge(_,e,t){return this.constructor(_,t)}function ke(_,e,t){var l,o,r,i;e==document&&(e=document.documentElement),h.__&&h.__(_,e),o=(l=!1)?null:e.__k,r=[],i=[],G(e,_=e.__k=ae($,null,[_]),o||H,H,e.namespaceURI,o?null:e.firstChild?R.call(e.childNodes):null,r,o?o.__e:e.firstChild,l,i),se(r,_,i),_.props.children=null}R=I.slice,h={__e:function(_,e,t,l){for(var o,r,i;e=e.__;)if((o=e.__c)&&!o.__)try{if((r=o.constructor)&&r.getDerivedStateFromError!=null&&(o.setState(r.getDerivedStateFromError(_)),i=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(_,l||{}),i=o.__d),i)return o.__E=o}catch(u){_=u}throw _}},ee=0,pe=function(_){return _!=null&&_.constructor===void 0},F.prototype.setState=function(_,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=w({},this.state),typeof _=="function"&&(_=_(w({},t),this.props)),_&&w(t,_),_!=null&&this.__v&&(e&&this._sb.push(e),X(this))},F.prototype.forceUpdate=function(_){this.__v&&(this.__e=!0,_&&this.__h.push(_),X(this))},F.prototype.render=$,x=[],_e=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,te=function(_,e){return _.__v.__b-e.__v.__b},W.__r=0,B=Math.random().toString(8),N="__d"+B,D="__a"+B,ne=/(PointerCapture)$|Capture$/i,z=0,O=Z(!1),V=Z(!0);export{F as C,ve as F,ke as R,$ as S,ae as k,h as l,pe as t};