@neuralnomads/codenomad 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/auth-store.js +134 -0
- package/dist/auth/http-auth.js +37 -0
- package/dist/auth/manager.js +87 -0
- package/dist/auth/password-hash.js +32 -0
- package/dist/auth/session-manager.js +17 -0
- package/dist/auth/token-manager.js +27 -0
- package/dist/background-processes/manager.js +52 -12
- package/dist/index.js +30 -2
- package/dist/opencode-config/package.json +1 -1
- package/dist/opencode-config/plugin/lib/background-process.ts +14 -70
- package/dist/opencode-config/plugin/lib/client.ts +22 -54
- package/dist/opencode-config/plugin/lib/request.ts +124 -0
- package/dist/server/http-server.js +102 -5
- package/dist/server/routes/auth-pages/login.html +134 -0
- package/dist/server/routes/auth-pages/token.html +93 -0
- package/dist/server/routes/auth.js +128 -0
- package/dist/workspaces/instance-events.js +6 -1
- package/dist/workspaces/manager.js +23 -1
- package/dist/workspaces/opencode-auth.js +16 -0
- package/dist/workspaces/runtime.js +13 -1
- package/package.json +3 -3
- package/public/assets/index-D4j6wgeo.js +1 -0
- package/public/assets/index-DhjiW0WU.css +1 -0
- package/public/assets/{loading-DDkv7He2.js → loading-A3c3OC91.js} +1 -1
- package/public/assets/main-ChQciNJ1.js +184 -0
- package/public/index.html +3 -3
- package/public/loading.html +3 -3
- package/public/assets/index-DByfuA7Q.css +0 -1
- package/public/assets/index-SWVRNzDr.js +0 -1
- package/public/assets/main-lEyCX2HE.js +0 -184
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { isLoopbackAddress } from "../../auth/http-auth";
|
|
4
|
+
const LoginSchema = z.object({
|
|
5
|
+
username: z.string().min(1),
|
|
6
|
+
password: z.string().min(1),
|
|
7
|
+
});
|
|
8
|
+
const TokenSchema = z.object({
|
|
9
|
+
token: z.string().min(1),
|
|
10
|
+
});
|
|
11
|
+
const PasswordSchema = z.object({
|
|
12
|
+
password: z.string().min(8),
|
|
13
|
+
});
|
|
14
|
+
const LOGIN_TEMPLATE_URL = new URL("./auth-pages/login.html", import.meta.url);
|
|
15
|
+
const TOKEN_TEMPLATE_URL = new URL("./auth-pages/token.html", import.meta.url);
|
|
16
|
+
let cachedLoginTemplate = null;
|
|
17
|
+
let cachedTokenTemplate = null;
|
|
18
|
+
function readTemplate(url, cache) {
|
|
19
|
+
if (cache)
|
|
20
|
+
return cache;
|
|
21
|
+
const content = fs.readFileSync(url, "utf-8");
|
|
22
|
+
return content;
|
|
23
|
+
}
|
|
24
|
+
function getLoginHtml(defaultUsername) {
|
|
25
|
+
if (!cachedLoginTemplate) {
|
|
26
|
+
cachedLoginTemplate = readTemplate(LOGIN_TEMPLATE_URL, null);
|
|
27
|
+
}
|
|
28
|
+
const escapedUsername = escapeHtml(defaultUsername);
|
|
29
|
+
return cachedLoginTemplate.replace(/\{\{DEFAULT_USERNAME\}\}/g, escapedUsername);
|
|
30
|
+
}
|
|
31
|
+
function getTokenHtml() {
|
|
32
|
+
if (!cachedTokenTemplate) {
|
|
33
|
+
cachedTokenTemplate = readTemplate(TOKEN_TEMPLATE_URL, null);
|
|
34
|
+
}
|
|
35
|
+
return cachedTokenTemplate;
|
|
36
|
+
}
|
|
37
|
+
export function registerAuthRoutes(app, deps) {
|
|
38
|
+
app.get("/login", async (_request, reply) => {
|
|
39
|
+
const status = deps.authManager.getStatus();
|
|
40
|
+
reply.type("text/html").send(getLoginHtml(status.username));
|
|
41
|
+
});
|
|
42
|
+
app.get("/auth/token", async (request, reply) => {
|
|
43
|
+
if (!deps.authManager.isTokenBootstrapEnabled()) {
|
|
44
|
+
reply.code(404).send({ error: "Not found" });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!isLoopbackAddress(request.socket.remoteAddress)) {
|
|
48
|
+
reply.code(404).send({ error: "Not found" });
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
reply.type("text/html").send(getTokenHtml());
|
|
52
|
+
});
|
|
53
|
+
app.get("/api/auth/status", async (request, reply) => {
|
|
54
|
+
const session = deps.authManager.getSessionFromRequest(request);
|
|
55
|
+
if (!session) {
|
|
56
|
+
reply.send({ authenticated: false });
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
reply.send({ authenticated: true, ...deps.authManager.getStatus() });
|
|
60
|
+
});
|
|
61
|
+
app.post("/api/auth/login", async (request, reply) => {
|
|
62
|
+
const body = LoginSchema.parse(request.body ?? {});
|
|
63
|
+
const ok = deps.authManager.validateLogin(body.username, body.password);
|
|
64
|
+
if (!ok) {
|
|
65
|
+
reply.code(401).send({ error: "Invalid credentials" });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const session = deps.authManager.createSession(body.username);
|
|
69
|
+
deps.authManager.setSessionCookie(reply, session.id);
|
|
70
|
+
reply.send({ ok: true });
|
|
71
|
+
});
|
|
72
|
+
app.post("/api/auth/token", async (request, reply) => {
|
|
73
|
+
if (!deps.authManager.isTokenBootstrapEnabled()) {
|
|
74
|
+
reply.code(404).send({ error: "Not found" });
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (!isLoopbackAddress(request.socket.remoteAddress)) {
|
|
78
|
+
reply.code(404).send({ error: "Not found" });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const body = TokenSchema.parse(request.body ?? {});
|
|
82
|
+
const ok = deps.authManager.consumeBootstrapToken(body.token);
|
|
83
|
+
if (!ok) {
|
|
84
|
+
reply.code(401).send({ error: "Invalid token" });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const username = deps.authManager.getStatus().username;
|
|
88
|
+
const session = deps.authManager.createSession(username);
|
|
89
|
+
deps.authManager.setSessionCookie(reply, session.id);
|
|
90
|
+
reply.send({ ok: true });
|
|
91
|
+
});
|
|
92
|
+
app.post("/api/auth/logout", async (_request, reply) => {
|
|
93
|
+
deps.authManager.clearSessionCookie(reply);
|
|
94
|
+
reply.send({ ok: true });
|
|
95
|
+
});
|
|
96
|
+
app.post("/api/auth/password", async (request, reply) => {
|
|
97
|
+
const session = deps.authManager.getSessionFromRequest(request);
|
|
98
|
+
if (!session) {
|
|
99
|
+
reply.code(401).send({ error: "Unauthorized" });
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
const body = PasswordSchema.parse(request.body ?? {});
|
|
103
|
+
try {
|
|
104
|
+
const status = deps.authManager.setPassword(body.password);
|
|
105
|
+
reply.send({ ok: true, ...status });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
109
|
+
reply.code(409).type("text/plain").send(message);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function escapeHtml(value) {
|
|
114
|
+
return value.replace(/[&<>"]/g, (char) => {
|
|
115
|
+
switch (char) {
|
|
116
|
+
case "&":
|
|
117
|
+
return "&";
|
|
118
|
+
case "<":
|
|
119
|
+
return "<";
|
|
120
|
+
case ">":
|
|
121
|
+
return ">";
|
|
122
|
+
case '"':
|
|
123
|
+
return """;
|
|
124
|
+
default:
|
|
125
|
+
return char;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
@@ -71,8 +71,13 @@ export class InstanceEventBridge {
|
|
|
71
71
|
}
|
|
72
72
|
async consumeStream(workspaceId, port, signal) {
|
|
73
73
|
const url = `http://${INSTANCE_HOST}:${port}/event`;
|
|
74
|
+
const headers = { Accept: "text/event-stream" };
|
|
75
|
+
const authHeader = this.options.workspaceManager.getInstanceAuthorizationHeader(workspaceId);
|
|
76
|
+
if (authHeader) {
|
|
77
|
+
headers["Authorization"] = authHeader;
|
|
78
|
+
}
|
|
74
79
|
const response = await fetch(url, {
|
|
75
|
-
headers
|
|
80
|
+
headers,
|
|
76
81
|
signal,
|
|
77
82
|
dispatcher: STREAM_AGENT,
|
|
78
83
|
});
|
|
@@ -6,11 +6,13 @@ import { searchWorkspaceFiles } from "../filesystem/search";
|
|
|
6
6
|
import { clearWorkspaceSearchCache } from "../filesystem/search-cache";
|
|
7
7
|
import { WorkspaceRuntime } from "./runtime";
|
|
8
8
|
import { getOpencodeConfigDir } from "../opencode-config.js";
|
|
9
|
+
import { buildOpencodeBasicAuthHeader, DEFAULT_OPENCODE_USERNAME, generateOpencodeServerPassword, OPENCODE_SERVER_PASSWORD_ENV, OPENCODE_SERVER_USERNAME_ENV, } from "./opencode-auth";
|
|
9
10
|
const STARTUP_STABILITY_DELAY_MS = 1500;
|
|
10
11
|
export class WorkspaceManager {
|
|
11
12
|
constructor(options) {
|
|
12
13
|
this.options = options;
|
|
13
14
|
this.workspaces = new Map();
|
|
15
|
+
this.opencodeAuth = new Map();
|
|
14
16
|
this.runtime = new WorkspaceRuntime(this.options.eventBus, this.options.logger);
|
|
15
17
|
this.opencodeConfigDir = getOpencodeConfigDir();
|
|
16
18
|
}
|
|
@@ -23,6 +25,9 @@ export class WorkspaceManager {
|
|
|
23
25
|
getInstancePort(id) {
|
|
24
26
|
return this.workspaces.get(id)?.port;
|
|
25
27
|
}
|
|
28
|
+
getInstanceAuthorizationHeader(id) {
|
|
29
|
+
return this.opencodeAuth.get(id)?.authorization;
|
|
30
|
+
}
|
|
26
31
|
listFiles(workspaceId, relativePath = ".") {
|
|
27
32
|
const workspace = this.requireWorkspace(workspaceId);
|
|
28
33
|
const browser = new FileSystemBrowser({ rootDir: workspace.path });
|
|
@@ -69,11 +74,20 @@ export class WorkspaceManager {
|
|
|
69
74
|
this.options.eventBus.publish({ type: "workspace.created", workspace: descriptor });
|
|
70
75
|
const preferences = this.options.configStore.get().preferences ?? {};
|
|
71
76
|
const userEnvironment = preferences.environmentVariables ?? {};
|
|
77
|
+
const opencodeUsername = DEFAULT_OPENCODE_USERNAME;
|
|
78
|
+
const opencodePassword = generateOpencodeServerPassword();
|
|
79
|
+
const authorization = buildOpencodeBasicAuthHeader({ username: opencodeUsername, password: opencodePassword });
|
|
80
|
+
if (!authorization) {
|
|
81
|
+
throw new Error("Failed to build OpenCode auth header");
|
|
82
|
+
}
|
|
83
|
+
this.opencodeAuth.set(id, { username: opencodeUsername, password: opencodePassword, authorization });
|
|
72
84
|
const environment = {
|
|
73
85
|
...userEnvironment,
|
|
74
86
|
OPENCODE_CONFIG_DIR: this.opencodeConfigDir,
|
|
75
87
|
CODENOMAD_INSTANCE_ID: id,
|
|
76
88
|
CODENOMAD_BASE_URL: this.options.getServerBaseUrl(),
|
|
89
|
+
[OPENCODE_SERVER_USERNAME_ENV]: opencodeUsername,
|
|
90
|
+
[OPENCODE_SERVER_PASSWORD_ENV]: opencodePassword,
|
|
77
91
|
};
|
|
78
92
|
try {
|
|
79
93
|
const { pid, port, exitPromise, getLastOutput } = await this.runtime.launch({
|
|
@@ -113,6 +127,7 @@ export class WorkspaceManager {
|
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
129
|
this.workspaces.delete(id);
|
|
130
|
+
this.opencodeAuth.delete(id);
|
|
116
131
|
clearWorkspaceSearchCache(workspace.path);
|
|
117
132
|
if (!wasRunning) {
|
|
118
133
|
this.options.eventBus.publish({ type: "workspace.stopped", workspaceId: id });
|
|
@@ -133,6 +148,7 @@ export class WorkspaceManager {
|
|
|
133
148
|
}
|
|
134
149
|
}
|
|
135
150
|
this.workspaces.clear();
|
|
151
|
+
this.opencodeAuth.clear();
|
|
136
152
|
this.options.logger.info("All workspaces cleared");
|
|
137
153
|
}
|
|
138
154
|
requireWorkspace(id) {
|
|
@@ -236,7 +252,12 @@ export class WorkspaceManager {
|
|
|
236
252
|
async probeInstance(workspaceId, port) {
|
|
237
253
|
const url = `http://127.0.0.1:${port}/project/current`;
|
|
238
254
|
try {
|
|
239
|
-
const
|
|
255
|
+
const headers = {};
|
|
256
|
+
const authHeader = this.opencodeAuth.get(workspaceId)?.authorization;
|
|
257
|
+
if (authHeader) {
|
|
258
|
+
headers["Authorization"] = authHeader;
|
|
259
|
+
}
|
|
260
|
+
const response = await fetch(url, { headers });
|
|
240
261
|
if (!response.ok) {
|
|
241
262
|
const reason = `health probe returned HTTP ${response.status}`;
|
|
242
263
|
this.options.logger.debug({ workspaceId, status: response.status }, "Health probe returned server error");
|
|
@@ -316,6 +337,7 @@ export class WorkspaceManager {
|
|
|
316
337
|
const workspace = this.workspaces.get(workspaceId);
|
|
317
338
|
if (!workspace)
|
|
318
339
|
return;
|
|
340
|
+
this.opencodeAuth.delete(workspaceId);
|
|
319
341
|
this.options.logger.info({ workspaceId, ...info }, "Workspace process exited");
|
|
320
342
|
workspace.pid = undefined;
|
|
321
343
|
workspace.port = undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
export const OPENCODE_SERVER_USERNAME_ENV = "OPENCODE_SERVER_USERNAME";
|
|
3
|
+
export const OPENCODE_SERVER_PASSWORD_ENV = "OPENCODE_SERVER_PASSWORD";
|
|
4
|
+
export const DEFAULT_OPENCODE_USERNAME = "codenomad";
|
|
5
|
+
export function generateOpencodeServerPassword() {
|
|
6
|
+
return crypto.randomBytes(32).toString("base64url");
|
|
7
|
+
}
|
|
8
|
+
export function buildOpencodeBasicAuthHeader(params) {
|
|
9
|
+
const username = params.username;
|
|
10
|
+
const password = params.password;
|
|
11
|
+
if (!username || !password) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
const token = Buffer.from(`${username}:${password}`, "utf8").toString("base64");
|
|
15
|
+
return `Basic ${token}`;
|
|
16
|
+
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
2
|
import { existsSync, statSync } from "fs";
|
|
3
3
|
import path from "path";
|
|
4
|
+
const SENSITIVE_ENV_KEY = /(PASSWORD|TOKEN|SECRET)/i;
|
|
5
|
+
function redactEnvironment(env) {
|
|
6
|
+
const redacted = {};
|
|
7
|
+
for (const [key, value] of Object.entries(env)) {
|
|
8
|
+
if (value === undefined) {
|
|
9
|
+
redacted[key] = value;
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
redacted[key] = SENSITIVE_ENV_KEY.test(key) ? "[REDACTED]" : value;
|
|
13
|
+
}
|
|
14
|
+
return redacted;
|
|
15
|
+
}
|
|
4
16
|
export class WorkspaceRuntime {
|
|
5
17
|
constructor(eventBus, logger) {
|
|
6
18
|
this.eventBus = eventBus;
|
|
@@ -39,7 +51,7 @@ export class WorkspaceRuntime {
|
|
|
39
51
|
binary: options.binaryPath,
|
|
40
52
|
args,
|
|
41
53
|
commandLine,
|
|
42
|
-
env,
|
|
54
|
+
env: redactEnvironment(env),
|
|
43
55
|
}, "Launching OpenCode process");
|
|
44
56
|
const child = spawn(options.binaryPath, args, {
|
|
45
57
|
cwd: options.folder,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuralnomads/codenomad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "CodeNomad Server",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Neural Nomads",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"codenomad": "dist/bin.js"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && npm run prepare-config",
|
|
19
|
+
"build": "npm run build:ui && npm run prepare-ui && tsc -p tsconfig.json && node ./scripts/copy-auth-pages.mjs && npm run prepare-config",
|
|
20
20
|
"build:ui": "npm run build --prefix ../ui",
|
|
21
21
|
"prepare-ui": "node ./scripts/copy-ui-dist.mjs",
|
|
22
22
|
"prepare-config": "node ./scripts/copy-opencode-config.mjs",
|
|
23
|
-
"dev": "cross-env CODENOMAD_DEV=1 CLI_UI_DEV_SERVER=http://localhost:3000 tsx src/index.ts",
|
|
23
|
+
"dev": "cross-env CODENOMAD_DEV=1 CODENOMAD_SERVER_PASSWORD=codenomad-dev CLI_UI_DEV_SERVER=http://localhost:3000 tsx src/index.ts",
|
|
24
24
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const g={context:void 0,registry:void 0,effects:void 0,done:!1,getContextId(){return be(this.context.count)},getNextContextId(){return be(this.context.count++)}};function be(e){const t=String(e),n=t.length-1;return g.context.id+(n?String.fromCharCode(96+n):"")+t}function Ve(e){g.context=e}const Be=!1,Ge=(e,t)=>e===t,Y=Symbol("solid-proxy"),Oe=typeof Proxy=="function",Pe=Symbol("solid-track"),Wt=Symbol("solid-dev-component"),Q={equals:Ge};let V=null,Ne=$e;const v=1,Z=2,ke={owned:null,cleanups:null,context:null,owner:null};var y=null;let oe=null,He=null,m=null,F=null,P=null,re=0;function L(e,t){const n=m,r=y,s=e.length===0,o=t===void 0?r:t,l=s?ke:{owned:null,cleanups:null,context:o?o.context:null,owner:o},i=s?e:()=>e(()=>A(()=>G(l)));y=l,m=null;try{return $(i,!0)}finally{m=n,y=r}}function K(e,t){t=t?Object.assign({},Q,t):Q;const n={value:e,observers:null,observerSlots:null,comparator:t.equals||void 0},r=s=>(typeof s=="function"&&(s=s(n.value)),Te(n,s));return[Le.bind(n),r]}function Xt(e,t,n){const r=q(e,t,!0,v);R(r)}function T(e,t,n){const r=q(e,t,!1,v);R(r)}function ve(e,t,n){Ne=We;const r=q(e,t,!1,v);(!n||!n.render)&&(r.user=!0),P?P.push(r):R(r)}function p(e,t,n){n=n?Object.assign({},Q,n):Q;const r=q(e,t,!0,0);return r.observers=null,r.observerSlots=null,r.comparator=n.equals||void 0,R(r),Le.bind(r)}function Yt(e){return $(e,!1)}function A(e){if(m===null)return e();const t=m;m=null;try{return e()}finally{m=t}}function Qt(e,t,n){const r=Array.isArray(e);let s,o=n&&n.defer;return l=>{let i;if(r){i=Array(e.length);for(let a=0;a<e.length;a++)i[a]=e[a]()}else i=e();if(o)return o=!1,l;const c=A(()=>t(i,s,l));return s=i,c}}function Zt(e){ve(()=>A(e))}function B(e){return y===null||(y.cleanups===null?y.cleanups=[e]:y.cleanups.push(e)),e}function Ke(e,t){V||(V=Symbol("error")),y=q(void 0,void 0,!0),y.context={...y.context,[V]:[t]};try{return e()}catch(n){z(n)}finally{y=y.owner}}function en(){return m}function Ce(){return y}function qe(e,t){const n=y,r=m;y=e,m=null;try{return $(t,!0)}catch(s){z(s)}finally{y=n,m=r}}const[tn,nn]=K(!1);function rn(e,t){const n=Symbol("context");return{id:n,Provider:Ye(n),defaultValue:e}}function sn(e){let t;return y&&y.context&&(t=y.context[e.id])!==void 0?t:e.defaultValue}function Ie(e){const t=p(e),n=p(()=>fe(t()));return n.toArray=()=>{const r=n();return Array.isArray(r)?r:r!=null?[r]:[]},n}function Le(){if(this.sources&&this.state)if(this.state===v)R(this);else{const e=F;F=null,$(()=>te(this),!1),F=e}if(m){const e=this.observers?this.observers.length:0;m.sources?(m.sources.push(this),m.sourceSlots.push(e)):(m.sources=[this],m.sourceSlots=[e]),this.observers?(this.observers.push(m),this.observerSlots.push(m.sources.length-1)):(this.observers=[m],this.observerSlots=[m.sources.length-1])}return this.value}function Te(e,t,n){let r=e.value;return(!e.comparator||!e.comparator(r,t))&&(e.value=t,e.observers&&e.observers.length&&$(()=>{for(let s=0;s<e.observers.length;s+=1){const o=e.observers[s],l=oe&&oe.running;l&&oe.disposed.has(o),(l?!o.tState:!o.state)&&(o.pure?F.push(o):P.push(o),o.observers&&Me(o)),l||(o.state=v)}if(F.length>1e6)throw F=[],new Error},!1)),t}function R(e){if(!e.fn)return;G(e);const t=re;ze(e,e.value,t)}function ze(e,t,n){let r;const s=y,o=m;m=y=e;try{r=e.fn(t)}catch(l){return e.pure&&(e.state=v,e.owned&&e.owned.forEach(G),e.owned=null),e.updatedAt=n+1,z(l)}finally{m=o,y=s}(!e.updatedAt||e.updatedAt<=n)&&(e.updatedAt!=null&&"observers"in e?Te(e,r):e.value=r,e.updatedAt=n)}function q(e,t,n,r=v,s){const o={fn:e,state:r,updatedAt:null,owned:null,sources:null,sourceSlots:null,cleanups:null,value:t,owner:y,context:y?y.context:null,pure:n};return y===null||y!==ke&&(y.owned?y.owned.push(o):y.owned=[o]),o}function ee(e){if(e.state===0)return;if(e.state===Z)return te(e);if(e.suspense&&A(e.suspense.inFallback))return e.suspense.effects.push(e);const t=[e];for(;(e=e.owner)&&(!e.updatedAt||e.updatedAt<re);)e.state&&t.push(e);for(let n=t.length-1;n>=0;n--)if(e=t[n],e.state===v)R(e);else if(e.state===Z){const r=F;F=null,$(()=>te(e,t[0]),!1),F=r}}function $(e,t){if(F)return e();let n=!1;t||(F=[]),P?n=!0:P=[],re++;try{const r=e();return Je(n),r}catch(r){n||(P=null),F=null,z(r)}}function Je(e){if(F&&($e(F),F=null),e)return;const t=P;P=null,t.length&&$(()=>Ne(t),!1)}function $e(e){for(let t=0;t<e.length;t++)ee(e[t])}function We(e){let t,n=0;for(t=0;t<e.length;t++){const r=e[t];r.user?e[n++]=r:ee(r)}if(g.context){if(g.count){g.effects||(g.effects=[]),g.effects.push(...e.slice(0,n));return}Ve()}for(g.effects&&(g.done||!g.count)&&(e=[...g.effects,...e],n+=g.effects.length,delete g.effects),t=0;t<n;t++)ee(e[t])}function te(e,t){e.state=0;for(let n=0;n<e.sources.length;n+=1){const r=e.sources[n];if(r.sources){const s=r.state;s===v?r!==t&&(!r.updatedAt||r.updatedAt<re)&&ee(r):s===Z&&te(r,t)}}}function Me(e){for(let t=0;t<e.observers.length;t+=1){const n=e.observers[t];n.state||(n.state=Z,n.pure?F.push(n):P.push(n),n.observers&&Me(n))}}function G(e){let t;if(e.sources)for(;e.sources.length;){const n=e.sources.pop(),r=e.sourceSlots.pop(),s=n.observers;if(s&&s.length){const o=s.pop(),l=n.observerSlots.pop();r<s.length&&(o.sourceSlots[l]=r,s[r]=o,n.observerSlots[r]=l)}}if(e.tOwned){for(t=e.tOwned.length-1;t>=0;t--)G(e.tOwned[t]);delete e.tOwned}if(e.owned){for(t=e.owned.length-1;t>=0;t--)G(e.owned[t]);e.owned=null}if(e.cleanups){for(t=e.cleanups.length-1;t>=0;t--)e.cleanups[t]();e.cleanups=null}e.state=0}function Xe(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"Unknown error",{cause:e})}function pe(e,t,n){try{for(const r of t)r(e)}catch(r){z(r,n&&n.owner||null)}}function z(e,t=y){const n=V&&t&&t.context&&t.context[V],r=Xe(e);if(!n)throw r;P?P.push({fn(){pe(r,n,t)},state:v}):pe(r,n,t)}function fe(e){if(typeof e=="function"&&!e.length)return fe(e());if(Array.isArray(e)){const t=[];for(let n=0;n<e.length;n++){const r=fe(e[n]);Array.isArray(r)?t.push.apply(t,r):t.push(r)}return t}return e}function Ye(e,t){return function(r){let s;return T(()=>s=A(()=>(y.context={...y.context,[e]:r.value},Ie(()=>r.children))),void 0),s}}const ue=Symbol("fallback");function ne(e){for(let t=0;t<e.length;t++)e[t]()}function Qe(e,t,n={}){let r=[],s=[],o=[],l=0,i=t.length>1?[]:null;return B(()=>ne(o)),()=>{let c=e()||[],a=c.length,u,f;return c[Pe],A(()=>{let h,b,w,C,x,E,O,S,I;if(a===0)l!==0&&(ne(o),o=[],r=[],s=[],l=0,i&&(i=[])),n.fallback&&(r=[ue],s[0]=L(U=>(o[0]=U,n.fallback())),l=1);else if(l===0){for(s=new Array(a),f=0;f<a;f++)r[f]=c[f],s[f]=L(d);l=a}else{for(w=new Array(a),C=new Array(a),i&&(x=new Array(a)),E=0,O=Math.min(l,a);E<O&&r[E]===c[E];E++);for(O=l-1,S=a-1;O>=E&&S>=E&&r[O]===c[S];O--,S--)w[S]=s[O],C[S]=o[O],i&&(x[S]=i[O]);for(h=new Map,b=new Array(S+1),f=S;f>=E;f--)I=c[f],u=h.get(I),b[f]=u===void 0?-1:u,h.set(I,f);for(u=E;u<=O;u++)I=r[u],f=h.get(I),f!==void 0&&f!==-1?(w[f]=s[u],C[f]=o[u],i&&(x[f]=i[u]),f=b[f],h.set(I,f)):o[u]();for(f=E;f<a;f++)f in w?(s[f]=w[f],o[f]=C[f],i&&(i[f]=x[f],i[f](f))):s[f]=L(d);s=s.slice(0,l=a),r=c.slice(0)}return s});function d(h){if(o[f]=h,i){const[b,w]=K(f);return i[f]=w,t(c[f],b)}return t(c[f])}}}function Ze(e,t,n={}){let r=[],s=[],o=[],l=[],i=0,c;return B(()=>ne(o)),()=>{const a=e()||[],u=a.length;return a[Pe],A(()=>{if(u===0)return i!==0&&(ne(o),o=[],r=[],s=[],i=0,l=[]),n.fallback&&(r=[ue],s[0]=L(d=>(o[0]=d,n.fallback())),i=1),s;for(r[0]===ue&&(o[0](),o=[],r=[],s=[],i=0),c=0;c<u;c++)c<r.length&&r[c]!==a[c]?l[c](()=>a[c]):c>=r.length&&(s[c]=L(f));for(;c<r.length;c++)o[c]();return i=l.length=o.length=u,r=a.slice(0),s=s.slice(0,i)});function f(d){o[c]=d;const[h,b]=K(a[c]);return l[c]=b,t(h,c)}}}function on(e,t){return A(()=>e(t||{}))}function W(){return!0}const ae={get(e,t,n){return t===Y?n:e.get(t)},has(e,t){return t===Y?!0:e.has(t)},set:W,deleteProperty:W,getOwnPropertyDescriptor(e,t){return{configurable:!0,enumerable:!0,get(){return e.get(t)},set:W,deleteProperty:W}},ownKeys(e){return e.keys()}};function ie(e){return(e=typeof e=="function"?e():e)?e:{}}function et(){for(let e=0,t=this.length;e<t;++e){const n=this[e]();if(n!==void 0)return n}}function ln(...e){let t=!1;for(let l=0;l<e.length;l++){const i=e[l];t=t||!!i&&Y in i,e[l]=typeof i=="function"?(t=!0,p(i)):i}if(Oe&&t)return new Proxy({get(l){for(let i=e.length-1;i>=0;i--){const c=ie(e[i])[l];if(c!==void 0)return c}},has(l){for(let i=e.length-1;i>=0;i--)if(l in ie(e[i]))return!0;return!1},keys(){const l=[];for(let i=0;i<e.length;i++)l.push(...Object.keys(ie(e[i])));return[...new Set(l)]}},ae);const n={},r=Object.create(null);for(let l=e.length-1;l>=0;l--){const i=e[l];if(!i)continue;const c=Object.getOwnPropertyNames(i);for(let a=c.length-1;a>=0;a--){const u=c[a];if(u==="__proto__"||u==="constructor")continue;const f=Object.getOwnPropertyDescriptor(i,u);if(!r[u])r[u]=f.get?{enumerable:!0,configurable:!0,get:et.bind(n[u]=[f.get.bind(i)])}:f.value!==void 0?f:void 0;else{const d=n[u];d&&(f.get?d.push(f.get.bind(i)):f.value!==void 0&&d.push(()=>f.value))}}}const s={},o=Object.keys(r);for(let l=o.length-1;l>=0;l--){const i=o[l],c=r[i];c&&c.get?Object.defineProperty(s,i,c):s[i]=c?c.value:void 0}return s}function tt(e,...t){const n=t.length;if(Oe&&Y in e){const s=n>1?t.flat():t[0],o=t.map(l=>new Proxy({get(i){return l.includes(i)?e[i]:void 0},has(i){return l.includes(i)&&i in e},keys(){return l.filter(i=>i in e)}},ae));return o.push(new Proxy({get(l){return s.includes(l)?void 0:e[l]},has(l){return s.includes(l)?!1:l in e},keys(){return Object.keys(e).filter(l=>!s.includes(l))}},ae)),o}const r=[];for(let s=0;s<=n;s++)r[s]={};for(const s of Object.getOwnPropertyNames(e)){let o=n;for(let c=0;c<t.length;c++)if(t[c].includes(s)){o=c;break}const l=Object.getOwnPropertyDescriptor(e,s);!l.get&&!l.set&&l.enumerable&&l.writable&&l.configurable?r[o][s]=l.value:Object.defineProperty(r[o],s,l)}return r}let nt=0;function cn(){return g.context?g.getNextContextId():`cl-${nt++}`}const De=e=>`Stale read from <${e}>.`;function fn(e){const t="fallback"in e&&{fallback:()=>e.fallback};return p(Qe(()=>e.each,e.children,t||void 0))}function un(e){const t="fallback"in e&&{fallback:()=>e.fallback};return p(Ze(()=>e.each,e.children,t||void 0))}function an(e){const t=e.keyed,n=p(()=>e.when,void 0,void 0),r=t?n:p(n,void 0,{equals:(s,o)=>!s==!o});return p(()=>{const s=r();if(s){const o=e.children;return typeof o=="function"&&o.length>0?A(()=>o(t?s:()=>{if(!A(r))throw De("Show");return n()})):o}return e.fallback},void 0,void 0)}function dn(e){const t=Ie(()=>e.children),n=p(()=>{const r=t(),s=Array.isArray(r)?r:[r];let o=()=>{};for(let l=0;l<s.length;l++){const i=l,c=s[l],a=o,u=p(()=>a()?void 0:c.when,void 0,void 0),f=c.keyed?u:p(u,void 0,{equals:(d,h)=>!d==!h});o=()=>a()||(f()?[i,u,c]:void 0)}return o});return p(()=>{const r=n()();if(!r)return e.fallback;const[s,o,l]=r,i=l.children;return typeof i=="function"&&i.length>0?A(()=>i(l.keyed?o():()=>{var a;if(((a=A(n)())==null?void 0:a[0])!==s)throw De("Match");return o()})):i},void 0,void 0)}function hn(e){return e}let X;function gn(e){let t;g.context&&g.load&&(t=g.load(g.getContextId()));const[n,r]=K(t,void 0);return X||(X=new Set),X.add(r),B(()=>X.delete(r)),p(()=>{let s;if(s=n()){const o=e.fallback;return typeof o=="function"&&o.length?A(()=>o(s,()=>r())):o}return Ke(()=>e.children,r)},void 0,void 0)}const rt=["allowfullscreen","async","alpha","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","hidden","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","adauctionheaders","browsingtopics","credentialless","defaultchecked","defaultmuted","defaultselected","defer","disablepictureinpicture","disableremoteplayback","preservespitch","shadowrootclonable","shadowrootcustomelementregistry","shadowrootdelegatesfocus","shadowrootserializable","sharedstoragewritable"],st=new Set(["className","value","readOnly","noValidate","formNoValidate","isMap","noModule","playsInline","adAuctionHeaders","allowFullscreen","browsingTopics","defaultChecked","defaultMuted","defaultSelected","disablePictureInPicture","disableRemotePlayback","preservesPitch","shadowRootClonable","shadowRootCustomElementRegistry","shadowRootDelegatesFocus","shadowRootSerializable","sharedStorageWritable",...rt]),ot=new Set(["innerHTML","textContent","innerText","children"]),it=Object.assign(Object.create(null),{className:"class",htmlFor:"for"}),lt=Object.assign(Object.create(null),{class:"className",novalidate:{$:"noValidate",FORM:1},formnovalidate:{$:"formNoValidate",BUTTON:1,INPUT:1},ismap:{$:"isMap",IMG:1},nomodule:{$:"noModule",SCRIPT:1},playsinline:{$:"playsInline",VIDEO:1},readonly:{$:"readOnly",INPUT:1,TEXTAREA:1},adauctionheaders:{$:"adAuctionHeaders",IFRAME:1},allowfullscreen:{$:"allowFullscreen",IFRAME:1},browsingtopics:{$:"browsingTopics",IMG:1},defaultchecked:{$:"defaultChecked",INPUT:1},defaultmuted:{$:"defaultMuted",AUDIO:1,VIDEO:1},defaultselected:{$:"defaultSelected",OPTION:1},disablepictureinpicture:{$:"disablePictureInPicture",VIDEO:1},disableremoteplayback:{$:"disableRemotePlayback",AUDIO:1,VIDEO:1},preservespitch:{$:"preservesPitch",AUDIO:1,VIDEO:1},shadowrootclonable:{$:"shadowRootClonable",TEMPLATE:1},shadowrootdelegatesfocus:{$:"shadowRootDelegatesFocus",TEMPLATE:1},shadowrootserializable:{$:"shadowRootSerializable",TEMPLATE:1},sharedstoragewritable:{$:"sharedStorageWritable",IFRAME:1,IMG:1}});function ct(e,t){const n=lt[e];return typeof n=="object"?n[t]?n.$:void 0:n}const ft=new Set(["beforeinput","click","dblclick","contextmenu","focusin","focusout","input","keydown","keyup","mousedown","mousemove","mouseout","mouseover","mouseup","pointerdown","pointermove","pointerout","pointerover","pointerup","touchend","touchmove","touchstart"]),ut=new Set(["altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","set","stop","svg","switch","symbol","text","textPath","tref","tspan","use","view","vkern"]),at={xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},yn=e=>p(()=>e());function dt(e,t,n){let r=n.length,s=t.length,o=r,l=0,i=0,c=t[s-1].nextSibling,a=null;for(;l<s||i<o;){if(t[l]===n[i]){l++,i++;continue}for(;t[s-1]===n[o-1];)s--,o--;if(s===l){const u=o<r?i?n[i-1].nextSibling:n[o-i]:c;for(;i<o;)e.insertBefore(n[i++],u)}else if(o===i)for(;l<s;)(!a||!a.has(t[l]))&&t[l].remove(),l++;else if(t[l]===n[o-1]&&n[i]===t[s-1]){const u=t[--s].nextSibling;e.insertBefore(n[i++],t[l++].nextSibling),e.insertBefore(n[--o],u),t[s]=n[o]}else{if(!a){a=new Map;let f=i;for(;f<o;)a.set(n[f],f++)}const u=a.get(t[l]);if(u!=null)if(i<u&&u<o){let f=l,d=1,h;for(;++f<s&&f<o&&!((h=a.get(t[f]))==null||h!==u+d);)d++;if(d>u-i){const b=t[l];for(;i<u;)e.insertBefore(n[i++],b)}else e.replaceChild(n[i++],t[l++])}else l++;else t[l++].remove()}}}const Ae="_$DX_DELEGATE";function mn(e,t,n,r={}){let s;return L(o=>{s=o,t===document?e():he(t,e(),t.firstChild?null:void 0,n)},r.owner),()=>{s(),t.textContent=""}}function wn(e,t,n,r){let s;const o=()=>{const i=r?document.createElementNS("http://www.w3.org/1998/Math/MathML","template"):document.createElement("template");return i.innerHTML=e,n?i.content.firstChild.firstChild:r?i.firstChild:i.content.firstChild},l=t?()=>A(()=>document.importNode(s||(s=o()),!0)):()=>(s||(s=o())).cloneNode(!0);return l.cloneNode=l,l}function ht(e,t=window.document){const n=t[Ae]||(t[Ae]=new Set);for(let r=0,s=e.length;r<s;r++){const o=e[r];n.has(o)||(n.add(o),t.addEventListener(o,xt))}}function de(e,t,n){M(e)||(n==null?e.removeAttribute(t):e.setAttribute(t,n))}function gt(e,t,n,r){M(e)||(r==null?e.removeAttributeNS(t,n):e.setAttributeNS(t,n,r))}function yt(e,t,n){M(e)||(n?e.setAttribute(t,""):e.removeAttribute(t))}function mt(e,t){M(e)||(t==null?e.removeAttribute("class"):e.className=t)}function wt(e,t,n,r){if(r)Array.isArray(n)?(e[`$$${t}`]=n[0],e[`$$${t}Data`]=n[1]):e[`$$${t}`]=n;else if(Array.isArray(n)){const s=n[0];e.addEventListener(t,n[0]=o=>s.call(e,n[1],o))}else e.addEventListener(t,n,typeof n!="function"&&n)}function bt(e,t,n={}){const r=Object.keys(t||{}),s=Object.keys(n);let o,l;for(o=0,l=s.length;o<l;o++){const i=s[o];!i||i==="undefined"||t[i]||(Fe(e,i,!1),delete n[i])}for(o=0,l=r.length;o<l;o++){const i=r[o],c=!!t[i];!i||i==="undefined"||n[i]===c||!c||(Fe(e,i,!0),n[i]=c)}return n}function Ct(e,t,n){if(!t)return n?de(e,"style"):t;const r=e.style;if(typeof t=="string")return r.cssText=t;typeof n=="string"&&(r.cssText=n=void 0),n||(n={}),t||(t={});let s,o;for(o in n)t[o]==null&&r.removeProperty(o),delete n[o];for(o in t)s=t[o],s!==n[o]&&(r.setProperty(o,s),n[o]=s);return n}function bn(e,t,n){n!=null?e.style.setProperty(t,n):e.style.removeProperty(t)}function pt(e,t={},n,r){const s={};return r||T(()=>s.children=H(e,t.children,s.children)),T(()=>typeof t.ref=="function"&&At(t.ref,e)),T(()=>Ft(e,t,n,!0,s,!0)),s}function At(e,t,n){return A(()=>e(t,n))}function he(e,t,n,r){if(n!==void 0&&!r&&(r=[]),typeof t!="function")return H(e,t,r,n);T(s=>H(e,t(),s,n),r)}function Ft(e,t,n,r,s={},o=!1){t||(t={});for(const l in s)if(!(l in t)){if(l==="children")continue;s[l]=Ee(e,l,null,s[l],n,o,t)}for(const l in t){if(l==="children")continue;const i=t[l];s[l]=Ee(e,l,i,s[l],n,o,t)}}function Et(e){let t,n;return!M()||!(t=g.registry.get(n=Ot()))?e():(g.completed&&g.completed.add(t),g.registry.delete(n),t)}function M(e){return!!g.context&&!g.done&&(!e||e.isConnected)}function St(e){return e.toLowerCase().replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}function Fe(e,t,n){const r=t.trim().split(/\s+/);for(let s=0,o=r.length;s<o;s++)e.classList.toggle(r[s],n)}function Ee(e,t,n,r,s,o,l){let i,c,a,u,f;if(t==="style")return Ct(e,n,r);if(t==="classList")return bt(e,n,r);if(n===r)return r;if(t==="ref")o||n(e);else if(t.slice(0,3)==="on:"){const d=t.slice(3);r&&e.removeEventListener(d,r,typeof r!="function"&&r),n&&e.addEventListener(d,n,typeof n!="function"&&n)}else if(t.slice(0,10)==="oncapture:"){const d=t.slice(10);r&&e.removeEventListener(d,r,!0),n&&e.addEventListener(d,n,!0)}else if(t.slice(0,2)==="on"){const d=t.slice(2).toLowerCase(),h=ft.has(d);if(!h&&r){const b=Array.isArray(r)?r[0]:r;e.removeEventListener(d,b)}(h||n)&&(wt(e,d,n,h),h&&ht([d]))}else if(t.slice(0,5)==="attr:")de(e,t.slice(5),n);else if(t.slice(0,5)==="bool:")yt(e,t.slice(5),n);else if((f=t.slice(0,5)==="prop:")||(a=ot.has(t))||!s&&((u=ct(t,e.tagName))||(c=st.has(t)))||(i=e.nodeName.includes("-")||"is"in l)){if(f)t=t.slice(5),c=!0;else if(M(e))return n;t==="class"||t==="className"?mt(e,n):i&&!c&&!a?e[St(t)]=n:e[u||t]=n}else{const d=s&&t.indexOf(":")>-1&&at[t.split(":")[0]];d?gt(e,d,t,n):de(e,it[t]||t,n)}return n}function xt(e){if(g.registry&&g.events&&g.events.find(([c,a])=>a===e))return;let t=e.target;const n=`$$${e.type}`,r=e.target,s=e.currentTarget,o=c=>Object.defineProperty(e,"target",{configurable:!0,value:c}),l=()=>{const c=t[n];if(c&&!t.disabled){const a=t[`${n}Data`];if(a!==void 0?c.call(t,a,e):c.call(t,e),e.cancelBubble)return}return t.host&&typeof t.host!="string"&&!t.host._$host&&t.contains(e.target)&&o(t.host),!0},i=()=>{for(;l()&&(t=t._$host||t.parentNode||t.host););};if(Object.defineProperty(e,"currentTarget",{configurable:!0,get(){return t||document}}),g.registry&&!g.done&&(g.done=_$HY.done=!0),e.composedPath){const c=e.composedPath();o(c[0]);for(let a=0;a<c.length-2&&(t=c[a],!!l());a++){if(t._$host){t=t._$host,i();break}if(t.parentNode===s)break}}else i();o(r)}function H(e,t,n,r,s){const o=M(e);if(o){!n&&(n=[...e.childNodes]);let c=[];for(let a=0;a<n.length;a++){const u=n[a];u.nodeType===8&&u.data.slice(0,2)==="!$"?u.remove():c.push(u)}n=c}for(;typeof n=="function";)n=n();if(t===n)return n;const l=typeof t,i=r!==void 0;if(e=i&&n[0]&&n[0].parentNode||e,l==="string"||l==="number"){if(o||l==="number"&&(t=t.toString(),t===n))return n;if(i){let c=n[0];c&&c.nodeType===3?c.data!==t&&(c.data=t):c=document.createTextNode(t),n=D(e,n,r,c)}else n!==""&&typeof n=="string"?n=e.firstChild.data=t:n=e.textContent=t}else if(t==null||l==="boolean"){if(o)return n;n=D(e,n,r)}else{if(l==="function")return T(()=>{let c=t();for(;typeof c=="function";)c=c();n=H(e,c,n,r)}),()=>n;if(Array.isArray(t)){const c=[],a=n&&Array.isArray(n);if(ge(c,t,n,s))return T(()=>n=H(e,c,n,r,!0)),()=>n;if(o){if(!c.length)return n;if(r===void 0)return n=[...e.childNodes];let u=c[0];if(u.parentNode!==e)return n;const f=[u];for(;(u=u.nextSibling)!==r;)f.push(u);return n=f}if(c.length===0){if(n=D(e,n,r),i)return n}else a?n.length===0?Se(e,c,r):dt(e,n,c):(n&&D(e),Se(e,c));n=c}else if(t.nodeType){if(o&&t.parentNode)return n=i?[t]:t;if(Array.isArray(n)){if(i)return n=D(e,n,r,t);D(e,n,null,t)}else n==null||n===""||!e.firstChild?e.appendChild(t):e.replaceChild(t,e.firstChild);n=t}}return n}function ge(e,t,n,r){let s=!1;for(let o=0,l=t.length;o<l;o++){let i=t[o],c=n&&n[e.length],a;if(!(i==null||i===!0||i===!1))if((a=typeof i)=="object"&&i.nodeType)e.push(i);else if(Array.isArray(i))s=ge(e,i,c)||s;else if(a==="function")if(r){for(;typeof i=="function";)i=i();s=ge(e,Array.isArray(i)?i:[i],Array.isArray(c)?c:[c])||s}else e.push(i),s=!0;else{const u=String(i);c&&c.nodeType===3&&c.data===u?e.push(c):e.push(document.createTextNode(u))}}return s}function Se(e,t,n=null){for(let r=0,s=t.length;r<s;r++)e.insertBefore(t[r],n)}function D(e,t,n,r){if(n===void 0)return e.textContent="";const s=r||document.createTextNode("");if(t.length){let o=!1;for(let l=t.length-1;l>=0;l--){const i=t[l];if(s!==i){const c=i.parentNode===e;!o&&!l?c?e.replaceChild(s,i):e.insertBefore(s,n):c&&i.remove()}else o=!0}}else e.insertBefore(s,n);return[s]}function Ot(){return g.getNextContextId()}const Pt="http://www.w3.org/2000/svg";function je(e,t=!1,n=void 0){return t?document.createElementNS(Pt,e):document.createElement(e,{is:n})}function Cn(e){const{useShadow:t}=e,n=document.createTextNode(""),r=()=>e.mount||document.body,s=Ce();let o,l=!!g.context;return ve(()=>{l&&(Ce().user=l=!1),o||(o=qe(s,()=>p(()=>e.children)));const i=r();if(i instanceof HTMLHeadElement){const[c,a]=K(!1),u=()=>a(!0);L(f=>he(i,()=>c()?f():o(),null)),B(u)}else{const c=je(e.isSVG?"g":"div",e.isSVG),a=t&&c.attachShadow?c.attachShadow({mode:"open"}):c;Object.defineProperty(c,"_$host",{get(){return n.parentNode},configurable:!0}),he(a,o),i.appendChild(c),e.ref&&e.ref(c),B(()=>i.removeChild(c))}},void 0,{render:!l}),n}function Nt(e,t){const n=p(e);return p(()=>{const r=n();switch(typeof r){case"function":return A(()=>r(t));case"string":const s=ut.has(r),o=g.context?Et():je(r,s,A(()=>t.is));return pt(o,t,s),o}})}function pn(e){const[,t]=tt(e,["component"]);return Nt(()=>e.component,t)}function kt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ye={exports:{}},le,xe;function vt(){if(xe)return le;xe=1;var e=1e3,t=e*60,n=t*60,r=n*24,s=r*7,o=r*365.25;le=function(u,f){f=f||{};var d=typeof u;if(d==="string"&&u.length>0)return l(u);if(d==="number"&&isFinite(u))return f.long?c(u):i(u);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(u))};function l(u){if(u=String(u),!(u.length>100)){var f=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(u);if(f){var d=parseFloat(f[1]),h=(f[2]||"ms").toLowerCase();switch(h){case"years":case"year":case"yrs":case"yr":case"y":return d*o;case"weeks":case"week":case"w":return d*s;case"days":case"day":case"d":return d*r;case"hours":case"hour":case"hrs":case"hr":case"h":return d*n;case"minutes":case"minute":case"mins":case"min":case"m":return d*t;case"seconds":case"second":case"secs":case"sec":case"s":return d*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return d;default:return}}}}function i(u){var f=Math.abs(u);return f>=r?Math.round(u/r)+"d":f>=n?Math.round(u/n)+"h":f>=t?Math.round(u/t)+"m":f>=e?Math.round(u/e)+"s":u+"ms"}function c(u){var f=Math.abs(u);return f>=r?a(u,f,r,"day"):f>=n?a(u,f,n,"hour"):f>=t?a(u,f,t,"minute"):f>=e?a(u,f,e,"second"):u+" ms"}function a(u,f,d,h){var b=f>=d*1.5;return Math.round(u/d)+" "+h+(b?"s":"")}return le}function It(e){n.debug=n,n.default=n,n.coerce=c,n.disable=l,n.enable=s,n.enabled=i,n.humanize=vt(),n.destroy=a,Object.keys(e).forEach(u=>{n[u]=e[u]}),n.names=[],n.skips=[],n.formatters={};function t(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,d=null,h,b;function w(...C){if(!w.enabled)return;const x=w,E=Number(new Date),O=E-(f||E);x.diff=O,x.prev=f,x.curr=E,f=E,C[0]=n.coerce(C[0]),typeof C[0]!="string"&&C.unshift("%O");let S=0;C[0]=C[0].replace(/%([a-zA-Z%])/g,(U,_e)=>{if(U==="%%")return"%";S++;const we=n.formatters[_e];if(typeof we=="function"){const Ue=C[S];U=we.call(x,Ue),C.splice(S,1),S--}return U}),n.formatArgs.call(x,C),(x.log||n.log).apply(x,C)}return w.namespace=u,w.useColors=n.useColors(),w.color=n.selectColor(u),w.extend=r,w.destroy=n.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(h!==n.namespaces&&(h=n.namespaces,b=n.enabled(u)),b),set:C=>{d=C}}),typeof n.init=="function"&&n.init(w),w}function r(u,f){const d=n(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];const f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const d of f)d[0]==="-"?n.skips.push(d.slice(1)):n.names.push(d)}function o(u,f){let d=0,h=0,b=-1,w=0;for(;d<u.length;)if(h<f.length&&(f[h]===u[d]||f[h]==="*"))f[h]==="*"?(b=h,w=d,h++):(d++,h++);else if(b!==-1)h=b+1,w++,d=w;else return!1;for(;h<f.length&&f[h]==="*";)h++;return h===f.length}function l(){const u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function i(u){for(const f of n.skips)if(o(u,f))return!1;for(const f of n.names)if(o(u,f))return!0;return!1}function c(u){return u instanceof Error?u.stack||u.message:u}function a(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}var Lt=It;(function(e,t){var n={};t.formatArgs=s,t.save=o,t.load=l,t.useColors=r,t.storage=i(),t.destroy=(()=>{let a=!1;return()=>{a||(a=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function r(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let a;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(a=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(a[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function s(a){if(a[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+a[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const u="color: "+this.color;a.splice(1,0,u,"color: inherit");let f=0,d=0;a[0].replace(/%[a-zA-Z%]/g,h=>{h!=="%%"&&(f++,h==="%c"&&(d=f))}),a.splice(d,0,u)}t.log=console.debug||console.log||(()=>{});function o(a){try{a?t.storage.setItem("debug",a):t.storage.removeItem("debug")}catch{}}function l(){let a;try{a=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch{}return!a&&typeof process<"u"&&"env"in process&&(a=n.DEBUG),a}function i(){try{return localStorage}catch{}}e.exports=Lt(t);const{formatters:c}=e.exports;c.j=function(a){try{return JSON.stringify(a)}catch(u){return"[UnexpectedJSONParseError]: "+u.message}}})(ye,ye.exports);var Tt=ye.exports;const me=kt(Tt),_=["sse","api","session","actions"],Re="opencode:logger:namespaces",ce=new Map,N=new Set,k=typeof globalThis<"u"?globalThis.console:void 0;function J(){N.size===0?me.disable():me.enable(Array.from(N).join(","))}function se(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{window.localStorage.setItem(Re,JSON.stringify(Array.from(N)))}catch(t){(e=k==null?void 0:k.warn)==null||e.call(k,"Failed to persist logger namespaces",t)}}function $t(){var e;if(!(typeof window>"u"||!(window!=null&&window.localStorage)))try{const t=window.localStorage.getItem(Re);if(!t)return;const n=JSON.parse(t);if(!Array.isArray(n))return;for(const r of n)_.includes(r)&&N.add(r)}catch(t){(e=k==null?void 0:k.warn)==null||e.call(k,"Failed to hydrate logger namespaces",t)}}$t();J();function Mt(e){const n=me(e),r=(s,o)=>{n(s,...o)};return{log:(...s)=>n(...s),info:(...s)=>n(...s),warn:(...s)=>r("[warn]",s),error:(...s)=>r("[error]",s)}}function Dt(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);return ce.has(e)||ce.set(e,Mt(e)),ce.get(e)}function jt(){return _.map(e=>({name:e,enabled:N.has(e)}))}function Rt(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);N.has(e)||(N.add(e),se(),J())}function _t(e){if(!_.includes(e))throw new Error(`Unknown logger namespace: ${e}`);N.has(e)&&(N.delete(e),se(),J())}function Ut(){N.clear(),se(),J()}function Vt(){_.forEach(e=>N.add(e)),se(),J()}const Bt={listLoggerNamespaces:jt,enableLogger:Rt,disableLogger:_t,enableAllLoggers:Vt,disableAllLoggers:Ut};function Gt(){typeof window>"u"||(window.codenomadLogger=Bt)}Gt();function Ht(){if(typeof window>"u")return"web";const e=window;return typeof e.electronAPI<"u"?"electron":typeof e.__TAURI__<"u"||typeof navigator<"u"&&/tauri/i.test(navigator.userAgent)?"tauri":"web"}function Kt(){if(typeof navigator>"u")return"desktop";const e=navigator.userAgentData;if(e!=null&&e.mobile)return"mobile";const t=navigator.userAgent.toLowerCase();return/android|iphone|ipad|ipod|blackberry|mini|windows phone|mobile|silk/.test(t)?"mobile":"desktop"}const qt=Dt("actions");let j=null;function zt(){return j||(j={host:Ht(),platform:Kt()},typeof window<"u"&&qt.info(`[runtime] host=${j.host} platform=${j.platform}`),j)}const Jt=zt(),An=()=>Jt.host==="tauri";export{Pe as $,de as A,ht as B,bn as C,pn as D,Dt as E,fn as F,wt as G,Jt as H,Xt as I,Ie as J,ut as K,Wt as L,hn as M,Et as N,g as O,Cn as P,kt as Q,gn as R,an as S,un as T,mn as U,An as V,T as a,p as b,ve as c,L as d,K as e,on as f,Zt as g,Qt as h,rn as i,sn as j,yn as k,cn as l,ln as m,Y as n,B as o,Yt as p,en as q,he as r,tt as s,wn as t,A as u,Ct as v,mt as w,dn as x,pt as y,At as z};
|