@makuja/peek 1.9.0 → 1.10.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.
Files changed (3) hide show
  1. package/README.md +14 -0
  2. package/dist/index.mjs +326 -101
  3. package/package.json +5 -5
package/README.md CHANGED
@@ -56,6 +56,20 @@ peek README.md --no-open
56
56
  | `--css` | `-c` | - | Path to a custom CSS file (Markdown only) |
57
57
  | `--open` / `--no-open` | - | `true` | Auto-open browser on start |
58
58
 
59
+ ## Relative assets
60
+
61
+ Relative paths resolve against the directory of the previewed file:
62
+
63
+ - **HTML** - Any relative URL, such as `<img src="./img.png">`, `<link href="style.css">`, or `url(fonts/a.woff2)` in a stylesheet
64
+ - **Markdown** - Image paths, such as `![](./img.png)` and reference-style images
65
+
66
+ peek serves these files from the browsed directory (directory mode) or from the previewed file's directory (file mode), including their subdirectories. When the previewed file is a symlink, its real location is used. peek serves only the following extensions and refuses paths outside that directory, including through symlinks:
67
+
68
+ - Images: `png`, `jpg`, `jpeg`, `gif`, `webp`, `svg`, `avif`, `ico`, `bmp`
69
+ - Styles and scripts: `css`, `js`, `mjs`
70
+ - Fonts: `woff`, `woff2`, `ttf`, `otf`
71
+ - HTML: `html`, `htm`
72
+
59
73
  ## Custom CSS
60
74
 
61
75
  Content styles for Markdown files can be customized in three ways (in priority order):
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { execFile } from "node:child_process";
4
4
  import { access, readFile, readdir, realpath, stat } from "node:fs/promises";
5
5
  import { homedir, platform } from "node:os";
6
- import { basename, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
6
+ import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
7
7
  import { cancel, intro, log, outro, spinner } from "@clack/prompts";
8
8
  import { cli, define } from "gunshi";
9
9
  import pc from "picocolors";
@@ -18,6 +18,7 @@ import { constants, watch } from "node:fs";
18
18
  import renderToString from "preact-render-to-string";
19
19
  import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
20
20
  import { createHash } from "node:crypto";
21
+ import { setTimeout as setTimeout$1 } from "node:timers/promises";
21
22
  import { streamSSE } from "hono/streaming";
22
23
  //#region src/core/content-type.ts
23
24
  const EXTENSION_MAP = new Map([
@@ -47,9 +48,50 @@ const logger = {
47
48
  error: (...args) => console.error(PREFIX, ...args)
48
49
  };
49
50
  //#endregion
51
+ //#region src/core/url.ts
52
+ /**
53
+ * Prefix of the route that serves files under the base directory as-is.
54
+ * `__peek` keeps it from colliding with the user's own paths, which
55
+ * directory mode maps straight onto the URL (`/<relative path>`).
56
+ */
57
+ const RAW_FILE_PREFIX = "/__peek/raw/";
58
+ const SCHEME_PATTERN = /^[a-z][a-z\d+.-]*:/i;
59
+ /** Percent-encodes each `/`-separated segment, keeping the separators. */
60
+ function encodeUrlPath(relativePath) {
61
+ return relativePath.split("/").map(encodeURIComponent).join("/");
62
+ }
63
+ /** URL under which `/__peek/raw/` serves `relativePath` (relative to the base directory). */
64
+ function rawFileUrl(relativePath) {
65
+ return `${RAW_FILE_PREFIX}${encodeUrlPath(relativePath)}`;
66
+ }
67
+ /**
68
+ * Rewrites a relative image `src` of the Markdown file at `markdownPath` into
69
+ * an absolute `/__peek/raw/` URL, since the rendered Markdown is embedded in a
70
+ * page whose URL does not contain the file's directory.
71
+ *
72
+ * `src` is expected to be already percent-encoded (markdown-it normalizes it),
73
+ * so it is resolved rather than re-encoded. Absolute URLs, root-relative
74
+ * paths and fragments are returned unchanged.
75
+ */
76
+ function resolveMarkdownImageSrc(src, markdownPath) {
77
+ if (src === "" || SCHEME_PATTERN.test(src) || src.startsWith("/") || src.startsWith("#")) return src;
78
+ const directory = markdownPath.slice(0, markdownPath.lastIndexOf("/") + 1);
79
+ const base = new URL(rawFileUrl(directory), "http://peek.invalid");
80
+ const url = new URL(src, base);
81
+ return `${url.pathname}${url.search}${url.hash}`;
82
+ }
83
+ //#endregion
50
84
  //#region src/lib/markdown.ts
51
85
  let md = null;
52
86
  let initPromise = null;
87
+ function withResolvedImageSrc(defaultRule) {
88
+ return (tokens, idx, options, env, self) => {
89
+ const token = tokens[idx];
90
+ const src = token?.attrGet("src");
91
+ if (token && src) token.attrSet("src", resolveMarkdownImageSrc(src, env.markdownPath));
92
+ return defaultRule(tokens, idx, options, env, self);
93
+ };
94
+ }
53
95
  function initMarkdown() {
54
96
  if (!initPromise) initPromise = (async () => {
55
97
  const instance = createMarkdownItAsync();
@@ -61,6 +103,9 @@ function initMarkdown() {
61
103
  },
62
104
  defaultColor: false
63
105
  }));
106
+ const defaultImageRule = instance.renderer.rules.image;
107
+ if (!defaultImageRule) throw new Error("markdown-it has no default image render rule");
108
+ instance.renderer.rules.image = withResolvedImageSrc(defaultImageRule);
64
109
  md = instance;
65
110
  })().catch((e) => {
66
111
  initPromise = null;
@@ -68,16 +113,34 @@ function initMarkdown() {
68
113
  });
69
114
  return initPromise;
70
115
  }
71
- async function renderMarkdown(content) {
116
+ /**
117
+ * Renders `content`, rewriting relative image paths against `markdownPath`
118
+ * (the file's path relative to the base directory) so that they load through
119
+ * `/__peek/raw/`.
120
+ */
121
+ async function renderMarkdown(content, markdownPath) {
72
122
  if (!md) throw new Error("Markdown renderer not initialized. Call initMarkdown() first.");
73
123
  if (content === "") return "";
74
- return md.renderAsync(content);
124
+ const env = { markdownPath };
125
+ return md.renderAsync(content, env);
75
126
  }
76
127
  //#endregion
77
128
  //#region src/lib/node-error.ts
78
129
  function isNodeError(e) {
79
130
  return e instanceof Error && "code" in e && typeof e.code === "string" && typeof e.message === "string";
80
131
  }
132
+ const NOT_FOUND_CODES = new Set([
133
+ "ENOENT",
134
+ "ENOTDIR",
135
+ "EISDIR"
136
+ ]);
137
+ /**
138
+ * Whether `e` means there is no readable file at the path: it does not exist,
139
+ * a parent segment is a file, or the path is a directory.
140
+ */
141
+ function isNotFoundError(e) {
142
+ return isNodeError(e) && e.code !== void 0 && NOT_FOUND_CODES.has(e.code);
143
+ }
81
144
  //#endregion
82
145
  //#region src/core/result.ts
83
146
  function ok(value) {
@@ -336,6 +399,46 @@ function createFileWatcher(debounceMs = 100) {
336
399
  };
337
400
  }
338
401
  //#endregion
402
+ //#region src/lib/with-timeout.ts
403
+ /**
404
+ * Waits for `promise` for at most `timeoutMs`.
405
+ *
406
+ * - `{ status: "completed", value }` — `promise` fulfilled inside the budget.
407
+ * - `{ status: "timed-out" }` — the budget elapsed first.
408
+ * - Rejects only when `promise` rejects *inside* the budget. A rejection after
409
+ * the budget elapsed (or under a zero budget) is subscribed to so that it is
410
+ * never unhandled, but it is discarded — nothing reports it.
411
+ *
412
+ * A zero budget (`!(timeoutMs > 0)`, which also covers `NaN`) means "always
413
+ * timed out", whatever `promise` does. That is what makes the timeout branch
414
+ * deterministically testable.
415
+ *
416
+ * The timer is deliberately **not** `unref()`-ed: an unref-ed timer never fires
417
+ * when nothing else keeps the event loop alive, which would silently skip the
418
+ * timeout branch and its warning. See `.issue/102/adr.md` ADR-001.
419
+ */
420
+ function withTimeout(promise, timeoutMs) {
421
+ if (!(timeoutMs > 0)) {
422
+ promise.catch(() => {});
423
+ return Promise.resolve({ status: "timed-out" });
424
+ }
425
+ return new Promise((resolve, reject) => {
426
+ const timer = setTimeout(() => {
427
+ resolve({ status: "timed-out" });
428
+ }, timeoutMs);
429
+ promise.then((value) => {
430
+ clearTimeout(timer);
431
+ resolve({
432
+ status: "completed",
433
+ value
434
+ });
435
+ }, (error) => {
436
+ clearTimeout(timer);
437
+ reject(error);
438
+ });
439
+ });
440
+ }
441
+ //#endregion
339
442
  //#region src/server/renderer/favicon.js
340
443
  const faviconBase64 = "AAABAAMAMDAAAAEAIACoJQAANgAAACAgAAABACAAqBAAAN4lAAAQEAAAAQAgAGgEAACGNgAAKAAAADAAAABgAAAAAQAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////Kv///3H///+r////1/////P/////////////////////////////////////////////////////////////////////////////////////////8////9f///+r////cf///yoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///1n////B///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////B////WQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8+////xP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8T///8+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///3r/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////egAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////mf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5kAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///+Z//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+ZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///3r/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////egAAAAAAAAAAAAAAAAAAAAAAAAAA////Pv///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////z4AAAAAAAAAAAAAAAAAAAAA////xP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8QAAAAAAAAAAAAAAAD///9Z////////////////////////////////////////////////////////////////////////////////+/v7//X19f/9/f3/////////////////////////////////9PT0//r6+v/+/v7///////////////////////////////////////////////////////////////////////////////////////////////9ZAAAAAAAAAAD////B///////////////////////////////////////////////////////////////////////////29vb/nJ+e/19kY/+6vLz////////////////////////////U1dX/YWZl/3yAf//19fX////////////////////////////////////////////////////////////////////////////////////////////////BAAAAAP///yr////////////////////////////////////////////////////////////////////////////////s7e3/U1hY/zY8O/9dYmH///////////////////////////+lp6f/Oj8+/z9EQ//u7u7/////////////////////////////////////////////////////////////////////////////////////////////////////Kv///3H////////////////////////////////////////////////////////////////////////////////w8PD/Wl9f/zQ6Of9HTUz/+vr6//////////////////////+xs7P/Oj8//zU7Ov/g4eD//v7+////////////////////////////////////////////////////////////////////////////////////////////////cf///6v////////////////////////////////////////////////////////////////////////////////z8/P/dnp5/zQ6Of9FSkn/7+/v///////////////////////DxMT/O0FA/zQ6Of/DxcT//Pz8////////////////////////////////////////////////////////////////////////////////////////////////q////9f////////////////////////////////////////////////////////////////////////////////39/f/kZSU/zQ6Of9CSEf/4+Pj///////////////////////U1dX/PEJB/zQ6Of+lp6f/+fn5////////////////////////////////////////////////////////////////////////////////////////////////1/////P////////////////////////////////////////////////////////////////////////////////6+vr/ra+v/zQ6Of9ARkX/19jY///////////////////////l5ub/PUNC/zQ6Of+Hi4r/9/f3////////////////////////////////////////////////////////////////////////////////////////////////8//////////////////////////////////////////////////////////////////////////////////////9/f3/yMrK/zU7Ov8+REP/yszM///////////////////////29vb/P0VE/zQ6Of9pbm7/9PT0/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v7+//v7+//4+Pj/+Pj4//j4+P/4+Pj/09XU/zc9PP88QkH/srSz//j4+P/4+Pj/+Pj4//j4+P/4+Pj/S1BP/zU7Ov9XXFz/7Ozs//j4+P/4+Pj/+Pj4//j4+P/4+Pj/+/v7//7+/v//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8vLy/7W3tv+doKD/naCg/52goP+doKD/i46O/zg+Pf84Pj3/a29v/52goP+doKD/naCg/52goP+doKD/S1BP/zU7Ov9FSkr/lZiX/52goP+doKD/naCg/52goP+doKD/tLe2//Ly8v//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////nJ+f/z1DQv80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/PUNC/5ygn///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////vsC//0lOTf8/RUT/P0VE/z9FRP8/RUT/PkNC/zg+Pf80Ojn/Njw7/z9FRP8/RUT/P0VE/z9FRP8/RUT/OkA//zU7Ov80Ojn/PEJB/z9FRP8/RUT/P0VE/z9FRP8/RUT/SU5N/77Av////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/+jo6P/d3t3/3d7e/93e3v/d3t7/0dPS/05TUv80Ojn/QUdG/9vc3P/d3t7/3d7e/93e3v/d3t7/oqSk/zpAP/81Ozr/xsfH/9zd3f/d3t7/3d7e/93e3v/d3t3/6Ojo//39/f//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9PT0/21ycf80Ojn/QkdG//Ly8v//////////////////////xsfH/z1DQv80Ojn/ycrK//z9/P//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9vf3/4yPjv80Ojn/QEZF/+Pk4///////////////////////1NXV/z5EQ/80Ojn/qq2s//n5+f//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+fn5/6qtrP80Ojn/PkRD/9TV1f//////////////////////4+Tj/0BGRf80Ojn/jI+O//b39////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////P39/8nKyv80Ojn/PUNC/8bHx///////////////////////8vLy/0JHRv80Ojn/bXJx//T09P///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////f39/+jo6P/d3t3/3d7e/93e3v/d3t7/3N3d/8bHx/81Ozr/OkA//6KkpP/d3t7/3d7e/93e3v/d3t7/29zc/0FHRv80Ojn/TlNS/9HT0v/d3t7/3d7e/93e3v/d3t3/6Ojo//39/f//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////vsC//0lOTf8/RUT/P0VE/z9FRP8/RUT/P0VE/zxCQf80Ojn/NTs6/zpAP/8/RUT/P0VE/z9FRP8/RUT/P0VE/zY8O/80Ojn/OD49/z5DQv8/RUT/P0VE/z9FRP8/RUT/SU5N/77Av///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////nKCf/z1DQv80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/NDo5/zQ6Of80Ojn/PUNC/5yfn///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8vLy/7S3tv+doKD/naCg/52goP+doKD/naCg/5WYl/9FSkr/NTs6/0tQT/+doKD/naCg/52goP+doKD/naCg/2tvb/84Pj3/OD49/4uOjv+doKD/naCg/52goP+doKD/tbe2//Ly8v///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////v7+//v7+//4+Pj/+Pj4//j4+P/4+Pj/+Pj4/+zs7P9XXFz/NTs6/0tQT//4+Pj/+Pj4//j4+P/4+Pj/+Pj4/7K0tP88QkH/Nz08/9PV1P/4+Pj/+Pj4//j4+P/4+Pj/+/v7//7+/v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////T09P9pbm7/NDo5/z9FRP/29vb//////////////////////8rMzP8+REP/NTs6/8jKyf/9/f3///////////////////////////////////////////////////////////////////////////////////////////P///////////////////////////////////////////////////////////////////////////////////////////f39/+Hi4r/NDo5/z1DQv/l5ub//////////////////////9fY2P9ARkX/NDo5/62vr//6+vr/////////////////////////////////////////////////////////////////////////////////////8////9f///////////////////////////////////////////////////////////////////////////////////////////n5+f+lp6f/NDo5/zxCQf/U1dX//////////////////////+Pj4/9CSEf/NDo5/5GUlP/39/f/////////////////////////////////////////////////////////////////////////////////////1////6v///////////////////////////////////////////////////////////////////////////////////////////z8/P/DxcT/NDo5/ztBQP/DxMT//////////////////////+/v7/9FSkn/NDo5/3Z6ef/z8/P/////////////////////////////////////////////////////////////////////////////////////q////3H///////////////////////////////////////////////////////////////////////////////////////////7+/v/g4eH/NTs6/zo/P/+xs7P///////////////////////r6+v9HTUz/NDo5/1pfX//w8PD/////////////////////////////////////////////////////////////////////////////////////cf///yr////////////////////////////////////////////////////////////////////////////////////////////////u7u7/P0RD/zo/Pv+lp6f///////////////////////////9dYmH/Njw7/1NYWP/s7e3/////////////////////////////////////////////////////////////////////////////////////KgAAAAD////B///////////////////////////////////////////////////////////////////////////////////////////19fX/fIB//2FmZf/U1dX///////////////////////////+6vLz/X2Rj/5yfnv/29vb////////////////////////////////////////////////////////////////////////////////BAAAAAAAAAAD///9Z///////////////////////////////////////////////////////////////////////////////////////////+/v7/+vr6//T09P/////////////////////////////////9/f3/9fX1//v7+/////////////////////////////////////////////////////////////////////////////////////9ZAAAAAAAAAAAAAAAA////xP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8QAAAAAAAAAAAAAAAAAAAAA////Pv///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////z4AAAAAAAAAAAAAAAAAAAAAAAAAAP///3r/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////egAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///+Z//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+ZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////mf///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5kAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///3r/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////egAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8+////xP///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8T///8+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///1n////B///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////B////WQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////Kv///3H///+r////1/////P/////////////////////////////////////////////////////////////////////////////////////////8////9f///+r////cf///yoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/gAAAH/wAA/4AAAAH/AAD+AAAAAH8AAPwAAAAAPwAA+AAAAAAfAADwAAAAAA8AAOAAAAAABwAAwAAAAAADAADAAAAAAAMAAIAAAAAAAQAAgAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAABAACAAAAAAAEAAMAAAAAAAwAAwAAAAAADAADgAAAAAAcAAPAAAAAADwAA+AAAAAAfAAD8AAAAAD8AAP4AAAAAfwAA/4AAAAH/AAD/4AAAB/8AACgAAAAgAAAAQAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8G////Yf///6r////e/////P/////////////////////////////////////////////////////////8////3v///6r///9h////BgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////cv///+3////////////////////////////////////////////////////////////////////////////////////////////////////t////cgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////FP///7j/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////uP///xQAAAAAAAAAAAAAAAAAAAAAAAAAAP///xT////Q////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0P///xQAAAAAAAAAAAAAAAAAAAAA////uP//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////uAAAAAAAAAAAAAAAAP///3L/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////cgAAAAD///8G////7f////////////////////////////////////////////////v8/P/m5ub//v7+/////////////////+Xm5v/19fX////////////////////////////////////////////////////////////////t////Bv///2H////////////////////////////////////////////////+/v7/mZyb/0VLSv/y8vL////////////q6+v/XGFg/2JmZv////////////////////////////////////////////////////////////////////9h////qv////////////////////////////////////////////////7+/v+coKD/NTs6/+Lk4////////////+vs7P9dYmH/Q0lI//j4+P///////////////////////////////////////////////////////////////6r////e/////////////////////////////////////////////////////7q8vP80Ojn/xsfH////////////8vLy/2hsbP9ARkX/6Onp////////////////////////////////////////////////////////////////3v////z/////////////////////////////////////////////////////2NnZ/zQ6Of+pq6v//v7+///////5+fn/c3h3/z5EQ//Y2dn////////////////////////////////////////////////////////////////8//////////////////////////////////////7+/v/7+/v/+/v7//r7+//r7Oz/Nz08/4mMjP/6+vr/+/v7//r6+v9+goH/O0FA/8XGxv/6+vr/+/v7//v7+//7+/v//v7+////////////////////////////////////////////////////////////////////////////4eLi/4qOjf+BhIT/gISD/3t/fv85Pj3/TlNT/4CEg/+AhIP/gISD/1VaWf82PDv/aG1s/4CEg/+AhIP/gYSE/4qOjf/h4uL////////////////////////////////////////////////////////////////////////////Iysn/QEZF/zY8O/82PDv/Njw7/zQ6Of81Ozr/Njw7/zY8O/82PDv/NTs6/zU7Ov81Ozr/Njw7/zY8O/82PDv/QEZF/8jKyf////////////////////////////////////////////////////////////////////////////z8/P/j5OT/3t7e/97e3v/X2Nj/YGVk/zc9PP/Y2dn/3t7e/97e3v+pq6v/NTs6/4aJif/d3d3/3t7e/97e3v/j5OT//Pz8//////////////////////////////////////////////////////////////////////////////////////////////////n5+f94e3v/Njw7/+fn5////////////9LT0/82PDv/h4uK//z8/P///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Pz8/4eLiv82PDv/0tPT////////////5+fn/zY8O/94e3v/+fn5//////////////////////////////////////////////////////////////////////////////////////////////////z8/P/j5OT/3t7e/97e3v/d3d3/homJ/zU7Ov+pq6v/3t7e/97e3v/Y2dn/Nz08/2BlZP/X2Nj/3t7e/97e3v/j5OT//Pz8////////////////////////////////////////////////////////////////////////////yMrJ/0BGRf82PDv/Njw7/zY8O/81Ozr/NTs6/zU7Ov82PDv/Njw7/zY8O/81Ozr/NDo5/zY8O/82PDv/Njw7/0BGRf/Iysn////////////////////////////////////////////////////////////////////////////h4uL/io6N/4GEhP+AhIP/gISD/2htbP82PDv/VVpZ/4CEg/+AhIP/gISD/05TU/85Pj3/e39+/4CEg/+BhIT/io6N/+Hi4v////////////////////////////////////////////////////////////////////////////7+/v/7+/v/+/v7//v7+//6+vr/xcbG/ztBQP9+goH/+vr6//v7+//6+vr/iYyM/zc9PP/r7Oz/+vv7//v7+//7+/v//v7+///////////////////////////////////////////8///////////////////////////////////////////////////////////Y2dn/PkRD/3N4d//5+fn///////7+/v+pq6v/NDo5/9jZ2P///////////////////////////////////////////////////////////P///97//////////////////////////////////////////////////////////+jp6f9ARkX/aGxs//Ly8v///////////8bHx/80Ojn/ury8///////////////////////////////////////////////////////////e////qv//////////////////////////////////////////////////////////+Pj4/0NJSP9dYmH/6+zs////////////4uTk/zU7Ov+coKD//v7+/////////////////////////////////////////////////////6r///9h////////////////////////////////////////////////////////////////YmZm/1xhYP/q6+v////////////y8vL/RUtK/5mcm//+/v7/////////////////////////////////////////////////////Yf///wb////t///////////////////////////////////////////////////////////19fX/5ebm//////////////////7+/v/m5ub/+/z8/////////////////////////////////////////////////////+3///8GAAAAAP///3L/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////cgAAAAAAAAAAAAAAAP///7j//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7gAAAAAAAAAAAAAAAAAAAAA////FP///9D////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Q////FAAAAAAAAAAAAAAAAAAAAAAAAAAA////FP///7j/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////uP///xQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///3L////t////////////////////////////////////////////////////////////////////////////////////////////////////7f///3IAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///wb///9h////qv///97////8//////////////////////////////////////////////////////////z////e////qv///2H///8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AAAP/gAAB/gAAAHwAAAA8AAAAOAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAABwAAAA8AAAAPgAAAH+AAAH/wAAD8oAAAAEAAAACAAAAABACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8h////lf///+X////////////////////////////////////l////lf///yEAAAAAAAAAAAAAAAD///9N////+v/////////////////////////////////////////////////////////6////TQAAAAD///8h////+v////////////////////////////////////////////////////////////////////r///8h////lf/////////////////////o6en/ubu7///////U1tb/2NnZ////////////////////////////////lf///+X/////////////////////29zc/3l9ff/7+/v/tri4/62wr////////////////////////////////+X//////////////////////v7+//j4+P9ucnL/9PT0/87Pz/+ZnJv//v7+//7+/v//////////////////////////////////////9/f3/4yQj/+AhIP/TFFR/3t/fv9ydnX/V1xb/4GFhP+MkI//9/f3//////////////////////////////////39/f/l5ub/4uPj/3N3dv/Nz87/yMrJ/3l9fP/i4+P/5ebm//39/f/////////////////////////////////9/f3/5ebm/+Lj4/95fXz/yMrJ/83Pzv9zd3b/4uPj/+Xm5v/9/f3/////////////////////////////////9/f3/4yQj/+BhYT/V1xb/3J2df97f37/TFFR/4CEg/+MkI//9/f3///////////////////////////////////////+/v7//v7+/5mcm//Oz8//9PT0/25ycv/4+Pj//v7+///////////////////////////l//////////////////////////+tsK//tri4//v7+/95fX3/29zc///////////////////////////l////lf//////////////////////////2NnZ/9TW1v//////ubu7/+jp6f//////////////////////////lf///yH////6////////////////////////////////////////////////////////////////////+v///yEAAAAA////Tf////r/////////////////////////////////////////////////////////+v///00AAAAAAAAAAAAAAAD///8h////lf///+X////////////////////////////////////l////lf///yEAAAAAAAAAAMADAACAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAEAAMADAAA=";
341
444
  //#endregion
@@ -356,6 +459,52 @@ function isWithinBase(base, target) {
356
459
  const prefix = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
357
460
  return resolvedTarget === resolvedBase || resolvedTarget.startsWith(prefix);
358
461
  }
462
+ /**
463
+ * Whether `relativePath`, resolved against `base` without touching the file
464
+ * system, stays inside `base`.
465
+ */
466
+ function isRelativePathWithinBase(base, relativePath) {
467
+ return isWithinBase(base, resolve(base, normalize(relativePath)));
468
+ }
469
+ //#endregion
470
+ //#region src/lib/real-path.ts
471
+ /**
472
+ * Resolves `relativePath` against `base`, following symlinks, and checks that
473
+ * the real path is still inside the real `base`, so that neither `..` nor a
474
+ * symlink can lead outside of it.
475
+ */
476
+ async function realPathWithinBase(base, relativePath) {
477
+ try {
478
+ const [realBase, realTarget] = await Promise.all([realpath(base), realpath(resolve(base, relativePath))]);
479
+ return isWithinBase(realBase, realTarget) ? ok(realTarget) : err({ type: "outside-base" });
480
+ } catch (e) {
481
+ return err(isNotFoundError(e) ? { type: "not-found" } : {
482
+ type: "io-error",
483
+ cause: e
484
+ });
485
+ }
486
+ }
487
+ //#endregion
488
+ //#region src/server/routes/real-path-error.ts
489
+ /** Maps a failed path lookup to the HTTP response every route returns for it. */
490
+ function realPathErrorResponse(error) {
491
+ switch (error.type) {
492
+ case "outside-base": return {
493
+ status: 403,
494
+ message: "Forbidden"
495
+ };
496
+ case "not-found": return {
497
+ status: 404,
498
+ message: "File not found"
499
+ };
500
+ case "io-error":
501
+ logger.error("Failed to read file:", error.cause);
502
+ return {
503
+ status: 500,
504
+ message: "Failed to read file"
505
+ };
506
+ }
507
+ }
359
508
  //#endregion
360
509
  //#region src/server/routes/api.tsx
361
510
  function renderRawHtmlIframe(rawUrl, title) {
@@ -371,8 +520,7 @@ function resolveAndValidatePath(basePath, query) {
371
520
  status: 400,
372
521
  message: "Missing path parameter"
373
522
  };
374
- const fullPath = resolve(basePath, normalize(query));
375
- if (!isWithinBase(basePath, fullPath)) return {
523
+ if (!isRelativePathWithinBase(basePath, query)) return {
376
524
  ok: false,
377
525
  status: 403,
378
526
  message: "Forbidden"
@@ -387,7 +535,6 @@ function resolveAndValidatePath(basePath, query) {
387
535
  ok: true,
388
536
  value: {
389
537
  relativePath: query,
390
- fullPath,
391
538
  contentType
392
539
  }
393
540
  };
@@ -397,50 +544,31 @@ function createApiRoutes(config) {
397
544
  const fileContentType = config.mode === "file" ? getContentType(config.targetPath) : null;
398
545
  app.get("/api/content", async (c) => {
399
546
  if (config.mode === "file") {
400
- if (fileContentType === "html") return c.html(renderRawHtmlIframe("/api/raw", basename(config.targetPath)));
547
+ if (fileContentType === "html") return c.html(renderRawHtmlIframe(rawFileUrl(basename(config.targetPath)), basename(config.targetPath)));
401
548
  const result = await readTextFile(config.targetPath);
402
549
  if (!result.ok) {
403
550
  if (result.error.type === "file-not-found") return c.text("File not found", 404);
404
551
  logger.error("Failed to read file:", result.error);
405
552
  return c.text("Failed to read file", 500);
406
553
  }
407
- return c.html(await renderMarkdown(result.value));
554
+ return c.html(await renderMarkdown(result.value, basename(config.targetPath)));
408
555
  }
409
556
  const resolved = resolveAndValidatePath(config.targetPath, c.req.query("path"));
410
557
  if (!resolved.ok) return c.text(resolved.message, resolved.status);
411
- const { relativePath, fullPath, contentType } = resolved.value;
412
- if (contentType === "html") return c.html(renderRawHtmlIframe(`/api/raw?path=${encodeURIComponent(relativePath)}`, basename(relativePath)));
413
- const result = await readTextFile(fullPath);
414
- if (!result.ok) {
415
- if (result.error.type === "file-not-found") return c.text("File not found", 404);
416
- logger.error("Failed to read file:", result.error);
417
- return c.text("Failed to read file", 500);
418
- }
419
- return c.html(await renderMarkdown(result.value));
420
- });
421
- app.get("/api/raw", async (c) => {
422
- if (config.mode === "file") {
423
- if (fileContentType !== "html") return c.text("Not found", 404);
424
- const result = await readTextFile(config.targetPath);
425
- if (!result.ok) {
426
- if (result.error.type === "file-not-found") return c.text("File not found", 404);
427
- logger.error("Failed to read file:", result.error);
428
- return c.text("Failed to read file", 500);
429
- }
430
- c.header("X-Content-Type-Options", "nosniff");
431
- return c.html(result.value);
558
+ const { relativePath, contentType } = resolved.value;
559
+ if (contentType === "html") return c.html(renderRawHtmlIframe(rawFileUrl(relativePath), basename(relativePath)));
560
+ const realPath = await realPathWithinBase(config.targetPath, relativePath);
561
+ if (!realPath.ok) {
562
+ const { status, message } = realPathErrorResponse(realPath.error);
563
+ return c.text(message, status);
432
564
  }
433
- const resolved = resolveAndValidatePath(config.targetPath, c.req.query("path"));
434
- if (!resolved.ok) return c.text(resolved.message, resolved.status);
435
- if (resolved.value.contentType !== "html") return c.text("Not found", 404);
436
- const result = await readTextFile(resolved.value.fullPath);
565
+ const result = await readTextFile(realPath.value);
437
566
  if (!result.ok) {
438
567
  if (result.error.type === "file-not-found") return c.text("File not found", 404);
439
568
  logger.error("Failed to read file:", result.error);
440
569
  return c.text("Failed to read file", 500);
441
570
  }
442
- c.header("X-Content-Type-Options", "nosniff");
443
- return c.html(result.value);
571
+ return c.html(await renderMarkdown(result.value, relativePath));
444
572
  });
445
573
  app.get("/api/tree", async (c) => {
446
574
  if (config.mode === "file") return c.json([]);
@@ -473,12 +601,12 @@ function MarkdownContent({ htmlContent }) {
473
601
  }
474
602
  //#endregion
475
603
  //#region src/components/content-view.tsx
476
- function ContentView({ contentType, fileTitle, rawUrl, htmlContent, htmlReloadKey, markdownClass = "px-5 sm:px-10 py-5 sm:py-10" }) {
604
+ function ContentView({ contentType, fileTitle, filePath, htmlContent, htmlReloadKey, markdownClass = "px-5 sm:px-10 py-5 sm:py-10" }) {
477
605
  if (contentType === "html") return /* @__PURE__ */ jsx(MainContent, {
478
606
  class: "relative flex-1 overflow-hidden",
479
607
  children: /* @__PURE__ */ jsx("iframe", {
480
608
  title: fileTitle,
481
- src: rawUrl,
609
+ src: rawFileUrl(filePath),
482
610
  style: FULLSCREEN_IFRAME_STYLE
483
611
  }, htmlReloadKey)
484
612
  });
@@ -887,10 +1015,10 @@ function createProjectId(absolutePath) {
887
1015
  }
888
1016
  //#endregion
889
1017
  //#region src/server/renderer/client-bundle.js
890
- const clientBundle = "\"use strict\";(()=>{var Z,y,Ze,Wt,R,Xe,Ge,et,de,V,O,tt,me,_e,pe,Kt,q={},Q=[],Vt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,G=Array.isArray;function A(e,t){for(var n in t)e[n]=t[n];return e}function he(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function Yt(e,t,n){var r,s,o,l={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?s=t[o]:l[o]=t[o];if(arguments.length>2&&(l.children=arguments.length>3?Z.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)l[o]===void 0&&(l[o]=e.defaultProps[o]);return Y(e,l,r,s,null)}function Y(e,t,n,r,s){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Ze,__i:-1,__u:0};return s==null&&y.vnode!=null&&y.vnode(o),o}function w(e){return e.children}function X(e,t){this.props=e,this.context=t}function D(e,t){if(t==null)return e.__?D(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?D(e):null}function Xt(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],s=[],o=A({},t);o.__v=t.__v+1,y.vnode&&y.vnode(o),ye(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??D(t),!!(32&t.__u),s),o.__v=t.__v,o.__.__k[o.__i]=o,it(r,o,s),t.__e=t.__=null,o.__e!=n&&nt(o)}}function nt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),nt(e)}function qe(e){(!e.__d&&(e.__d=!0)&&R.push(e)&&!J.__r++||Xe!=y.debounceRendering)&&((Xe=y.debounceRendering)||Ge)(J)}function J(){try{for(var e,t=1;R.length;)R.length>t&&R.sort(et),e=R.shift(),t=R.length,Xt(e)}finally{R.length=J.__r=0}}function rt(e,t,n,r,s,o,l,u,d,c,_){var a,f,p,g,k,x,h,m=r&&r.__k||Q,C=t.length;for(d=qt(n,t,m,d,C),a=0;a<C;a++)(p=n.__k[a])!=null&&(f=p.__i!=-1&&m[p.__i]||q,p.__i=a,x=ye(e,p,f,s,o,l,u,d,c,_),g=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&ge(f.ref,null,p),_.push(p.ref,p.__c||g,p)),k==null&&g!=null&&(k=g),(h=!!(4&p.__u))||f.__k===p.__k?(d=ot(p,d,e,h),h&&f.__e&&(f.__e=null)):typeof p.type==\"function\"&&x!==void 0?d=x:g&&(d=g.nextSibling),p.__u&=-7);return n.__e=k,d}function qt(e,t,n,r,s){var o,l,u,d,c,_=n.length,a=_,f=0;for(e.__k=new Array(s),o=0;o<s;o++)(l=t[o])!=null&&typeof l!=\"boolean\"&&typeof l!=\"function\"?(typeof l==\"string\"||typeof l==\"number\"||typeof l==\"bigint\"||l.constructor==String?l=e.__k[o]=Y(null,l,null,null,null):G(l)?l=e.__k[o]=Y(w,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=Y(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[o]=l,d=o+f,l.__=e,l.__b=e.__b+1,u=null,(c=l.__i=Qt(l,n,d,a))!=-1&&(a--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(s>_?f--:s<_&&f++),typeof l.type!=\"function\"&&(l.__u|=4)):c!=d&&(c==d-1?f--:c==d+1?f++:(c>d?f--:f++,l.__u|=4))):e.__k[o]=null;if(a)for(o=0;o<_;o++)(u=n[o])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=D(u)),lt(u,u));return r}function ot(e,t,n,r){var s,o;if(typeof e.type==\"function\"){for(s=e.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=e,t=ot(s[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=D(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Qt(e,t,n,r){var s,o,l,u=e.key,d=e.type,c=t[n],_=c!=null&&(2&c.__u)==0;if(c===null&&u==null||_&&u==c.key&&d==c.type)return n;if(r>(_?1:0)){for(s=n-1,o=n+1;s>=0||o<t.length;)if((c=t[l=s>=0?s--:o++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return l}return-1}function Qe(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Vt.test(t)?n:n+\"px\"}function K(e,t,n,r,s){var o,l;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||Qe(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Qe(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(tt,\"$1\")),l=t.toLowerCase(),t=l in e||t==\"onFocusOut\"||t==\"onFocusIn\"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[O]=r[O]:(n[O]=me,e.addEventListener(t,o?pe:_e,o)):e.removeEventListener(t,o?pe:_e,o);else{if(s==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Je(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[V]==null)t[V]=me++;else if(t[V]<n[O])return;return n(y.event?y.event(t):t)}}}function ye(e,t,n,r,s,o,l,u,d,c){var _,a,f,p,g,k,x,h,m,C,P,F,W,H,B,T=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[u=t.__e=n.__e]),(_=y.__b)&&_(t);e:if(typeof T==\"function\")try{if(h=t.props,m=T.prototype&&T.prototype.render,C=(_=T.contextType)&&r[_.__c],P=_?C?C.props.value:_.__:r,n.__c?x=(a=t.__c=n.__c).__=a.__E:(m?t.__c=a=new T(h,P):(t.__c=a=new X(h,P),a.constructor=T,a.render=Zt),C&&C.sub(a),a.state||(a.state={}),a.__n=r,f=a.__d=!0,a.__h=[],a._sb=[]),m&&a.__s==null&&(a.__s=a.state),m&&T.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=A({},a.__s)),A(a.__s,T.getDerivedStateFromProps(h,a.__s))),p=a.props,g=a.state,a.__v=t,f)m&&T.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),m&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(m&&T.getDerivedStateFromProps==null&&h!==p&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(h,P),t.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(h,a.__s,P)===!1){t.__v!=n.__v&&(a.props=h,a.state=a.__s,a.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(L){L&&(L.__=t)}),Q.push.apply(a.__h,a._sb),a._sb=[],a.__h.length&&l.push(a);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(h,a.__s,P),m&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(p,g,k)})}if(a.context=P,a.props=h,a.__P=e,a.__e=!1,F=y.__r,W=0,m)a.state=a.__s,a.__d=!1,F&&F(t),_=a.render(a.props,a.state,a.context),Q.push.apply(a.__h,a._sb),a._sb=[];else do a.__d=!1,F&&F(t),_=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++W<25);a.state=a.__s,a.getChildContext!=null&&(r=A(A({},r),a.getChildContext())),m&&!f&&a.getSnapshotBeforeUpdate!=null&&(k=a.getSnapshotBeforeUpdate(p,g)),H=_!=null&&_.type===w&&_.key==null?st(_.props.children):_,u=rt(e,G(H)?H:[H],t,n,r,s,o,l,u,d,c),a.base=t.__e,t.__u&=-161,a.__h.length&&l.push(a),x&&(a.__E=a.__=null)}catch(L){if(t.__v=null,d||o!=null)if(L.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;o[o.indexOf(u)]=null,t.__e=u}else{for(B=o.length;B--;)he(o[B]);fe(t)}else t.__e=n.__e,t.__k=n.__k,L.then||fe(t);y.__e(L,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=Jt(n.__e,t,n,r,s,o,l,d,c);return(_=y.diffed)&&_(t),128&t.__u?void 0:u}function fe(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(fe))}function it(e,t,n){for(var r=0;r<n.length;r++)ge(n[r],n[++r],n[++r]);y.__c&&y.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(o){o.call(s)})}catch(o){y.__e(o,s.__v)}})}function st(e){return typeof e!=\"object\"||e==null||e.__b>0?e:G(e)?e.map(st):e.constructor!==void 0?null:A({},e)}function Jt(e,t,n,r,s,o,l,u,d){var c,_,a,f,p,g,k,x=n.props||q,h=t.props,m=t.type;if(m==\"svg\"?s=\"http://www.w3.org/2000/svg\":m==\"math\"?s=\"http://www.w3.org/1998/Math/MathML\":s||(s=\"http://www.w3.org/1999/xhtml\"),o!=null){for(c=0;c<o.length;c++)if((p=o[c])&&\"setAttribute\"in p==!!m&&(m?p.localName==m:p.nodeType==3)){e=p,o[c]=null;break}}if(e==null){if(m==null)return document.createTextNode(h);e=document.createElementNS(s,m,h.is&&h),u&&(y.__m&&y.__m(t,o),u=!1),o=null}if(m==null)x===h||u&&e.data==h||(e.data=h);else{if(o=m==\"textarea\"&&h.defaultValue!=null?null:o&&Z.call(e.childNodes),!u&&o!=null)for(x={},c=0;c<e.attributes.length;c++)x[(p=e.attributes[c]).name]=p.value;for(c in x)p=x[c],c==\"dangerouslySetInnerHTML\"?a=p:c==\"children\"||c in h||c==\"value\"&&\"defaultValue\"in h||c==\"checked\"&&\"defaultChecked\"in h||K(e,c,null,p,s);for(c in h)p=h[c],c==\"children\"?f=p:c==\"dangerouslySetInnerHTML\"?_=p:c==\"value\"?g=p:c==\"checked\"?k=p:u&&typeof p!=\"function\"||x[c]===p||K(e,c,p,x[c],s);if(_)u||a&&(_.__html==a.__html||_.__html==e.innerHTML)||(e.innerHTML=_.__html),t.__k=[];else if(a&&(e.innerHTML=\"\"),rt(t.type==\"template\"?e.content:e,G(f)?f:[f],t,n,r,m==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":s,o,l,o?o[0]:n.__k&&D(n,0),u,d),o!=null)for(c=o.length;c--;)he(o[c]);u&&m!=\"textarea\"||(c=\"value\",m==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[c]||m==\"progress\"&&!g||m==\"option\"&&g!=x[c])&&K(e,c,g,x[c],s),c=\"checked\",k!=null&&k!=e[c]&&K(e,c,k,x[c],s))}return e}function ge(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(s){y.__e(s,n)}}function lt(e,t,n){var r,s;if(y.unmount&&y.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ge(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){y.__e(o,t)}r.base=r.__P=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&lt(r[s],t,n||typeof e.type!=\"function\");n||he(e.__e),e.__c=e.__=e.__e=void 0}function Zt(e,t,n){return this.constructor(e,n)}function Gt(e,t,n){var r,s,o,l;t==document&&(t=document.documentElement),y.__&&y.__(e,t),s=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],l=[],ye(t,e=(!r&&n||t).__k=Yt(w,null,[e]),s||q,q,t.namespaceURI,!r&&n?[n]:s?null:t.firstChild?Z.call(t.childNodes):null,o,!r&&n?n:s?s.__e:t.firstChild,r,l),it(o,e,l)}function ee(e,t){Gt(e,t,ee)}Z=Q.slice,y={__e:function(e,t,n,r){for(var s,o,l;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(e)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,r||{}),l=s.__d),l)return s.__E=s}catch(u){e=u}throw e}},Ze=0,Wt=function(e){return e!=null&&e.constructor===void 0},X.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=A({},this.state),typeof e==\"function\"&&(e=e(A({},n),this.props)),e&&A(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qe(this))},X.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qe(this))},X.prototype.render=w,R=[],Ge=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,et=function(e,t){return e.__v.__b-t.__v.__b},J.__r=0,de=Math.random().toString(8),V=\"__d\"+de,O=\"__a\"+de,tt=/(PointerCapture)$|Capture$/i,me=0,_e=Je(!1),pe=Je(!0),Kt=0;var U,v,ve,at,$=0,ht=[],b=y,ct=b.__b,ut=b.__r,dt=b.diffed,_t=b.__c,pt=b.unmount,ft=b.__;function ne(e,t){b.__h&&b.__h(v,e,$||t),$=0;var n=v.__H||(v.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return $=1,en(yt,e)}function en(e,t,n){var r=ne(U++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):yt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=v,!v.__f)){var s=function(u,d,c){if(!r.__c.__H)return!0;var _=r.__c.__H.__.filter(function(f){return f.__c});if(_.every(function(f){return!f.__N}))return!o||o.call(this,u,d,c);var a=r.__c.props!==u;return _.some(function(f){if(f.__N){var p=f.__[0];f.__=f.__N,f.__N=void 0,p!==f.__[0]&&(a=!0)}}),o&&o.call(this,u,d,c)||a};v.__f=!0;var o=v.shouldComponentUpdate,l=v.componentWillUpdate;v.componentWillUpdate=function(u,d,c){if(this.__e){var _=o;o=void 0,s(u,d,c),o=_}l&&l.call(this,u,d,c)},v.shouldComponentUpdate=s}return r.__N||r.__}function N(e,t){var n=ne(U++,3);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,v.__H.__h.push(n))}function re(e,t){var n=ne(U++,4);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,v.__h.push(n))}function I(e){return $=5,oe(function(){return{current:e}},[])}function oe(e,t){var n=ne(U++,7);return Se(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function M(e,t){return $=8,oe(function(){return e},t)}function tn(){for(var e;e=ht.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(te),t.__h.some(be),t.__h=[]}catch(n){t.__h=[],b.__e(n,e.__v)}}}b.__b=function(e){v=null,ct&&ct(e)},b.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ft&&ft(e,t)},b.__r=function(e){ut&&ut(e),U=0;var t=(v=e.__c).__H;t&&(ve===v?(t.__h=[],v.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(te),t.__h.some(be),t.__h=[],U=0)),ve=v},b.diffed=function(e){dt&&dt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(ht.push(t)!==1&&at===b.requestAnimationFrame||((at=b.requestAnimationFrame)||nn)(tn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ve=v=null},b.__c=function(e,t){t.some(function(n){try{n.__h.some(te),n.__h=n.__h.filter(function(r){return!r.__||be(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],b.__e(r,n.__v)}}),_t&&_t(e,t)},b.unmount=function(e){pt&&pt(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{te(r)}catch(s){t=s}}),n.__H=void 0,t&&b.__e(t,n.__v))};var mt=typeof requestAnimationFrame==\"function\";function nn(e){var t,n=function(){clearTimeout(r),mt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);mt&&(t=requestAnimationFrame(n))}function te(e){var t=v,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),v=t}function be(e){var t=v;e.__c=e.__(),v=t}function Se(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function yt(e,t){return typeof t==\"function\"?t(e):t}var gt={border:\"none\",width:\"100%\",height:\"100%\",position:\"absolute\",top:\"0\",left:\"0\"};var rn=0;function i(e,t,n,r,s,o){t||(t={});var l,u,d=t;if(\"ref\"in d)for(u in d={},t)u==\"ref\"?l=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--rn,__i:-1,__u:0,__source:s,__self:o};if(typeof e==\"function\"&&(l=e.defaultProps))for(u in l)d[u]===void 0&&(d[u]=l[u]);return y.vnode&&y.vnode(c),c}function xe({class:e,children:t}){return i(\"main\",{id:\"main-content\",class:e??\"\",children:t})}function ie({htmlContent:e}){return i(\"div\",{id:\"markdown-content\",class:\"markdown-body\",dangerouslySetInnerHTML:{__html:e}})}function vt({contentType:e,fileTitle:t,rawUrl:n,htmlContent:r,htmlReloadKey:s,markdownClass:o=\"px-5 sm:px-10 py-5 sm:py-10\"}){return e===\"html\"?i(xe,{class:\"relative flex-1 overflow-hidden\",children:i(\"iframe\",{title:t,src:n,style:gt},s)}):i(xe,{class:o,children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(ie,{htmlContent:r})})})}function S({class:e,children:t,width:n=\"24\",height:r=\"24\",viewBox:s=\"0 0 24 24\",...o}){return i(\"svg\",{...o,class:e,\"aria-hidden\":\"true\",xmlns:\"http://www.w3.org/2000/svg\",width:n,height:r,viewBox:s,fill:\"none\",stroke:\"currentColor\",\"stroke-width\":\"2\",\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",children:t})}function Te(e){return i(S,{...e,children:i(\"path\",{d:\"m6 9 6 6 6-6\"})})}function we({class:e}){return i(S,{class:e,children:[i(\"path\",{d:\"M15 3h6v6\"}),i(\"path\",{d:\"M10 14 21 3\"}),i(\"path\",{d:\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"})]})}function ke(e){return i(S,{...e,children:[i(\"path\",{d:\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\"}),i(\"path\",{d:\"M14 2v4a2 2 0 0 0 2 2h4\"})]})}function Ee(e){return i(S,{...e,children:i(\"path\",{d:\"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 0-1.69.9L9.6 8H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2Z\"})})}function Ce({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\"})})}function Ie({class:e,...t}){return i(S,{class:e,...t,children:[i(\"polyline\",{points:\"7 8 3 12 7 16\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"12\",y2:\"12\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"6\",y2:\"6\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"18\",y2:\"18\"})]})}function Pe({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M17 8L21 12L17 16M3 12H13M3 6H13M3 18H13\"})})}function Fe(e){return i(S,{...e,width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",children:i(\"path\",{d:\"M6 13L10 3\",\"stroke-linecap\":\"round\"})})}function Ae({class:e,...t}){return i(S,{class:e,...t,children:[i(\"circle\",{cx:\"12\",cy:\"12\",r:\"4\"}),i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M12 20v2\"}),i(\"path\",{d:\"m4.93 4.93 1.41 1.41\"}),i(\"path\",{d:\"m17.66 17.66 1.41 1.41\"}),i(\"path\",{d:\"M2 12h2\"}),i(\"path\",{d:\"M20 12h2\"}),i(\"path\",{d:\"m6.34 17.66-1.41 1.41\"}),i(\"path\",{d:\"m19.07 4.93-1.41 1.41\"})]})}function Me({class:e,...t}){return i(S,{class:e,...t,children:[i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715\"}),i(\"path\",{d:\"M16 12a4 4 0 0 0-4-4\"}),i(\"path\",{d:\"m19 5-1.256 1.256\"}),i(\"path\",{d:\"M20 12h2\"})]})}var Le={dirItem:\"inline-flex items-center shrink-0\",dirLink:\"text-sm text-muted-foreground hover:text-foreground\",fileItem:\"inline-flex items-center text-sm font-semibold text-foreground truncate\"},on=\"shrink-0 mx-1 size-4 text-muted-foreground\";function bt({items:e}){return i(\"nav\",{\"aria-label\":\"Breadcrumb\",children:i(\"ol\",{class:\"flex items-center min-w-0\",children:e.map((t,n)=>{let r=n===e.length-1;return i(\"li\",{class:r?Le.fileItem:Le.dirItem,\"aria-current\":r?\"page\":void 0,children:r?t.label:i(w,{children:[i(\"a\",{class:Le.dirLink,href:t.href??\"#\",children:t.label}),i(Fe,{class:on})]})},n)})})})}function St({href:e}){return i(\"a\",{href:e,target:\"_blank\",rel:\"noopener noreferrer\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Open in new tab\",children:i(we,{class:\"size-4\"})})}function xt(){return i(\"button\",{type:\"button\",id:\"theme-toggle\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Toggle theme\",children:[i(Ae,{class:\"hidden size-4\",id:\"icon-theme-light\"}),i(Ce,{class:\"hidden size-4\",id:\"icon-theme-dark\"}),i(Me,{class:\"hidden size-4\",id:\"icon-theme-system\"})]})}function Tt({id:e,breadcrumbs:t,showSidebarToggle:n,onToggleSidebar:r,externalLinkHref:s}){return i(\"header\",{id:e,class:\"sticky top-0 z-50 bg-background border-b border-border\",children:i(\"div\",{class:\"flex items-center justify-between w-full py-2 px-2 sm:px-5\",children:[i(\"div\",{class:\"flex items-center gap-1 min-w-0\",children:[n&&i(\"button\",{type:\"button\",id:\"sidebar-toggle\",onClick:r,class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:bg-sidebar-accent cursor-pointer\",children:[i(Pe,{class:\"shrink-0 size-4\",id:\"icon-sidebar-open\"}),i(Ie,{class:\"shrink-0 size-4 hidden\",id:\"icon-sidebar-close\"})]}),i(bt,{items:t})]}),i(\"div\",{class:\"flex items-center gap-1\",children:[i(xt,{}),s!==void 0&&i(St,{href:s})]})]})})}var sn=20;function ln({node:e,currentPath:t,depth:n,isOpen:r,onToggle:s}){let o=r?r(e.path):!0;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:[i(\"button\",{type:\"button\",\"aria-expanded\":o,onClick:()=>s?.(e.path),class:\"flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-lg overflow-hidden\",children:[i(Ee,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:e.name}),i(Te,{class:`${o?\"\":\"-rotate-180 \"}shrink-0 size-3.5 ms-auto transition-transform`})]}),o&&i(\"ul\",{class:\"ps-7 mt-1 flex flex-col gap-y-1 relative before:absolute before:top-0 before:start-[1.125rem] before:w-px before:h-full before:bg-sidebar-border\",children:e.children&&n<sn?i(Re,{nodes:e.children,currentPath:t,depth:n+1,isOpen:r,onToggle:s}):null})]})}function Re({nodes:e,currentPath:t,depth:n=0,isOpen:r,onToggle:s}){return i(w,{children:e.map(o=>{if(o.type===\"directory\")return i(ln,{node:o,currentPath:t,depth:n,isOpen:r,onToggle:s},o.path);let l=t===o.path;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:i(\"a\",{href:`/view?path=${encodeURIComponent(o.path)}`,class:`flex items-center gap-x-3 py-2 px-3 text-sm rounded-lg overflow-hidden ${l?\"bg-sidebar-accent text-sidebar-primary font-medium\":\"hover:bg-sidebar-accent text-sidebar-foreground\"}`,children:[i(ke,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:o.name})]})},o.path)})})}function wt({nodes:e,currentPath:t,isOpen:n,onToggle:r}){return i(\"ul\",{id:\"file-tree\",class:\"flex flex-col gap-y-1\",children:i(Re,{nodes:e,currentPath:t,isOpen:n,onToggle:r})})}function kt({title:e,tree:t,currentPath:n,onClose:r,isOpen:s,onToggle:o,searchQuery:l,onSearchChange:u,isSearching:d}){return i(w,{children:[i(\"div\",{role:\"none\",id:\"sidebar-overlay\",class:\"fixed inset-0 z-50 bg-black/50 hidden\",onClick:r}),i(\"aside\",{id:\"sidebar\",\"aria-label\":\"File navigation\",class:\"fixed inset-y-0 start-0 z-60 w-72 lg:w-auto overflow-hidden bg-sidebar border-e border-sidebar-border -translate-x-full\",children:[i(\"div\",{class:\"relative flex flex-col h-full max-h-full pt-3\",children:[i(\"header\",{class:\"flex-none h-11.5 ps-5 pe-2 lg:ps-8 flex items-center\",children:i(\"a\",{href:\"/\",class:\"flex-none text-sm font-semibold text-sidebar-foreground hover:text-sidebar-primary\",children:e})}),i(\"div\",{class:\"flex-none px-2 lg:px-5 mt-1.5 mb-1\",children:i(\"input\",{id:\"sidebar-search\",type:\"search\",\"aria-label\":\"Search files\",placeholder:\"Search files\\u2026\",value:l??\"\",onInput:c=>u?.(c.target.value),onKeyDown:c=>{c.key===\"Escape\"&&!c.isComposing&&(u?.(\"\"),c.currentTarget.blur())},class:\"w-full py-1.5 px-3 text-sm text-sidebar-foreground bg-sidebar-accent border border-sidebar-border rounded-lg outline-none focus:border-sidebar-primary placeholder:text-sidebar-foreground/50\"})}),i(\"div\",{class:\"flex-1 min-h-0 overflow-x-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb\",children:i(\"nav\",{class:\"pb-3 w-full flex flex-col\",children:d&&t.length===0?i(\"p\",{class:\"px-5 py-3 text-sm text-sidebar-foreground/60\",children:\"No matches found\"}):i(wt,{nodes:t,currentPath:n,isOpen:s,onToggle:o})})})]}),i(\"div\",{id:\"sidebar-resize\",class:\"absolute inset-y-0 end-0 w-1 cursor-col-resize hover:bg-sidebar-border hidden lg:block pointer-events-auto\"})]})]})}var an=new Map([[\".md\",\"markdown\"],[\".html\",\"html\"],[\".htm\",\"html\"]]);function cn(e){let t=Math.max(e.lastIndexOf(\"/\"),e.lastIndexOf(\"\\\\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(\".\");return r===-1||r===n.length-1?\"\":n.slice(r).toLowerCase()}function Et(e){return an.get(cn(e))??null}function Ct(e,t){return e.name.toLowerCase().includes(t)}function It(e,t){let n=t.trim().toLowerCase();return n===\"\"?e:Pt(e,n)}function Pt(e,t){let n=[];for(let r of e){if(r.type===\"directory\"){if(Ct(r,t)){n.push(r);continue}let s=r.children?Pt(r.children,t):[];s.length>0&&n.push({...r,children:s});continue}Ct(r,t)&&n.push(r)}return n}var Ne=\"file-tree-state\";function Ft(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!=\"object\"||Array.isArray(t))return{};let n={};for(let[r,s]of Object.entries(t)){if(!s||typeof s!=\"object\"||Array.isArray(s))continue;let{collapsed:o,lastAccess:l}=s;typeof l!=\"number\"||!Array.isArray(o)||(n[r]={collapsed:o.filter(u=>typeof u==\"string\"),lastAccess:l})}return n}catch{return{}}}function At(e,t,n){let r={};for(let[s,o]of Object.entries(e))t-o.lastAccess<=n&&(r[s]=o);return r}function He(e,t){return new Set(e[t]?.collapsed??[])}function Be(e,t,n,r){return{...e,[t]:{collapsed:Array.from(n),lastAccess:r}}}function Mt(e){return JSON.stringify(e)}function Lt(e){let[t,n]=E(()=>new Set),r=I(!0),s=I(t);s.current=t;function o(){try{return Ft(localStorage.getItem(Ne))}catch{return{}}}function l(c){try{localStorage.setItem(Ne,Mt(c))}catch{}}re(()=>{if(!r.current)return;r.current=!1;let c=Date.now(),_=At(o(),c,2592e6),a=Be(_,e,He(_,e),c);l(a),n(He(a,e))},[e]);let u=M(c=>{let _=new Set(s.current);_.has(c)?_.delete(c):_.add(c),s.current=_,n(_);let a=Be(o(),e,_,Date.now());l(a)},[e]);return{isOpen:M(c=>!t.has(c),[t]),toggle:u}}async function z(e,t){try{let n=e?`/api/content?path=${encodeURIComponent(e)}`:\"/api/content\",r=await fetch(n,t?.signal?{signal:t.signal}:void 0);return r.ok?await r.text():(console.error(`[peek] Failed to fetch content: HTTP ${r.status}`),null)}catch(n){if(n instanceof DOMException&&n.name===\"AbortError\")throw n;return console.error(\"[peek] Failed to fetch content:\",n),null}}async function Rt(e){try{let t=await fetch(\"/api/tree\",e?.signal?{signal:e.signal}:void 0);if(!t.ok)return console.error(`[peek] Failed to fetch tree: HTTP ${t.status}`),null;let n=await t.json();return Array.isArray(n)?n:(console.error(\"[peek] Unexpected tree response format\"),null)}catch(t){if(t instanceof DOMException&&t.name===\"AbortError\")throw t;return console.error(\"[peek] Failed to fetch tree:\",t),null}}function j(e){return e&&e.replace(/\\\\/g,\"/\")}function se(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function Nt(e){let t=I(null),n=I(e);n.current=e;let r=M(async(s,o)=>{t.current&&t.current.abort();let l=new AbortController;t.current=l;try{let u=await z(s,{signal:l.signal});if(u===null)return;n.current(s,u),document.title=`${se(s)} - peek`;let d=`/view?path=${encodeURIComponent(s)}`;o&&history.pushState({path:s},\"\",d)}catch(u){if(u instanceof DOMException&&u.name===\"AbortError\")return;console.error(\"[peek] Failed to navigate:\",u)}},[]);return N(()=>{let s=new URLSearchParams(window.location.search).get(\"path\");s&&history.replaceState({path:s},\"\");function o(u){if(u.ctrlKey||u.metaKey||u.shiftKey||u.altKey)return;let d=u.target.closest(\"a[href]\");if(!d)return;let c;try{c=new URL(d.href,window.location.origin)}catch{return}if(c.origin!==window.location.origin||c.pathname!==\"/view\")return;let _=c.searchParams.get(\"path\");_&&(u.preventDefault(),r(_,!0))}function l(u){let c=u.state?.path??new URLSearchParams(window.location.search).get(\"path\");c?r(c,!1):window.location.reload()}return document.addEventListener(\"click\",o),window.addEventListener(\"popstate\",l),()=>{document.removeEventListener(\"click\",o),window.removeEventListener(\"popstate\",l)}},[r]),r}var dn=\"sidebar-search\";function _n(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===\"INPUT\"||t===\"TEXTAREA\"||t===\"SELECT\"||e.isContentEditable}function Ht(e){N(()=>{function t(n){n.key===\"/\"&&(n.isComposing||_n(n.target)||(n.preventDefault(),e?.(),document.getElementById(dn)?.focus()))}return window.addEventListener(\"keydown\",t),()=>window.removeEventListener(\"keydown\",t)},[e])}var le=\"sidebar-open\",Bt=\"sidebar-width\",De=200,Ue=480,pn=1024;function ae(){return window.innerWidth>=pn}function Dt(){let[e,t]=E(!1),n=I(!0);re(()=>{if(n.current){n.current=!1;let l=localStorage.getItem(Bt);if(l){let u=Number(l);u>=De&&u<=Ue&&document.documentElement.style.setProperty(\"--sidebar-width\",`${u}px`)}if(ae()&&localStorage.getItem(le)!==\"false\"){let u=[document.getElementById(\"sidebar\"),document.getElementById(\"header-bar\"),document.getElementById(\"main-content\")];for(let d of u)d&&(d.style.transition=\"none\");document.body.setAttribute(\"data-sidebar-open\",\"\"),document.body.offsetHeight,requestAnimationFrame(()=>{for(let d of u)d&&d.style.removeProperty(\"transition\")}),t(!0)}return}e?document.body.setAttribute(\"data-sidebar-open\",\"\"):document.body.removeAttribute(\"data-sidebar-open\")},[e]),N(()=>{let l=document.getElementById(\"sidebar-resize\");if(!l)return;function u(d){d.preventDefault(),l.setPointerCapture(d.pointerId);let c=document.getElementById(\"sidebar\");document.body.style.setProperty(\"user-select\",\"none\"),c?.style.setProperty(\"transition\",\"none\");function _(f){let p=Math.min(Math.max(f.clientX,De),Ue);document.documentElement.style.setProperty(\"--sidebar-width\",`${p}px`)}function a(f){if(l.releasePointerCapture(f.pointerId),l.removeEventListener(\"pointermove\",_),l.removeEventListener(\"pointerup\",a),l.removeEventListener(\"pointercancel\",a),document.body.style.removeProperty(\"user-select\"),c?.style.removeProperty(\"transition\"),f.type===\"pointerup\"){let p=Math.min(Math.max(f.clientX,De),Ue);localStorage.setItem(Bt,String(p))}}l.addEventListener(\"pointermove\",_),l.addEventListener(\"pointerup\",a),l.addEventListener(\"pointercancel\",a)}return l.addEventListener(\"pointerdown\",u),()=>l.removeEventListener(\"pointerdown\",u)},[]);let r=M(()=>{t(l=>{let u=!l;return ae()&&localStorage.setItem(le,String(u)),u})},[]),s=M(()=>{t(!1),ae()&&localStorage.setItem(le,\"false\")},[]),o=M(()=>{t(!0),ae()&&localStorage.setItem(le,\"true\")},[]);return{toggle:r,close:s,open:o}}var Oe=\"[peek]\",$e={info:(...e)=>console.log(Oe,...e),warn:(...e)=>console.warn(Oe,...e),error:(...e)=>console.error(Oe,...e)};function yn(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=\"object\")return null;let n=t;return typeof n.path!=\"string\"?null:{path:n.path}}function Ut(e){let t=0,n=null,r=null,s=null;function o(){r&&(clearTimeout(r),r=null);let l=new EventSource(\"/sse\");if(s=l,l.addEventListener(\"file-changed\",u=>{let d=yn(u.data);e.onFileChanged(d?j(d.path):null)}),e.onTreeChanged){let u=e.onTreeChanged;l.addEventListener(\"tree-changed\",()=>{u()})}l.onerror=()=>{if(l.close(),s=null,r&&(clearTimeout(r),r=null),t++,t>10){$e.warn(`SSE connection lost after ${10} retries, giving up.`);return}let u=Math.min(1e3*2**(t-1),3e4);$e.info(`SSE reconnecting in ${u}ms (${t}/${10})...`),n=setTimeout(o,u)},r=setTimeout(()=>{t=0,r=null},5e3)}return o(),()=>{n&&clearTimeout(n),r&&clearTimeout(r),s&&s.close()}}function ce(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:s,onTreeUpdate:o}=e;N(()=>{let l=null,u=null,d=Ut({onFileChanged:c=>{if(n){if(c===null)return;let _=n();if(j(c)!==j(_))return;if(r?.()===\"html\"){s?.();return}l?.abort(),l=new AbortController,z(_,{signal:l.signal}).then(a=>{a!==null&&t(a)}).catch(a=>{a instanceof DOMException&&a.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",a)})}else l?.abort(),l=new AbortController,z(void 0,{signal:l.signal}).then(_=>{_!==null&&t(_)}).catch(_=>{_ instanceof DOMException&&_.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",_)})},onTreeChanged:o?()=>{u?.abort(),u=new AbortController,Rt({signal:u.signal}).then(c=>{c&&o(c)}).catch(c=>{c instanceof DOMException&&c.name===\"AbortError\"||console.error(\"[peek] Failed to refresh tree:\",c)})}:void 0});return()=>{l?.abort(),u?.abort(),d()}},[])}function Ot({projectId:e,dirTitle:t,currentPath:n,contentType:r,content:s,tree:o}){let[l,u]=E(n),[d,c]=E(r),[_,a]=E(s),[f,p]=E(o),[g,k]=E(\"\"),[x,h]=E(0),m=I(l);m.current=l;let C=Dt(),P=Lt(e),F=g.trim()!==\"\",W=oe(()=>It(f,g),[f,g]);Ht(C.open),Nt((T,L)=>{let Ye=Et(T);if(!Ye){console.error(`Unexpected unsupported file type: ${T}`);return}m.current=T,u(T),c(Ye),a(L),h(0)});let H=I(d);H.current=d,ce({getCurrentPath:()=>m.current,getCurrentContentType:()=>H.current,onContentUpdate:a,onHtmlReload:()=>h(T=>T+1),onTreeUpdate:p});let B=se(l);return i(w,{children:[i(kt,{title:t,tree:W,currentPath:l,onClose:C.close,isOpen:F?()=>!0:P.isOpen,onToggle:F?void 0:P.toggle,searchQuery:g,onSearchChange:k,isSearching:F}),i(Tt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:B}],showSidebarToggle:!0,onToggleSidebar:C.toggle,externalLinkHref:`/${l.split(\"/\").map(encodeURIComponent).join(\"/\")}`}),i(vt,{contentType:d,fileTitle:B,rawUrl:`/api/raw?path=${encodeURIComponent(l)}`,htmlContent:_,htmlReloadKey:x})]})}function $t({content:e}){let[t,n]=E(e);return ce({onContentUpdate:n}),i(\"main\",{class:\"px-2 sm:px-5 py-5 sm:py-15\",children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(ie,{htmlContent:t})})})}var Ke=\"theme\";function je(){let e=localStorage.getItem(Ke);return e===\"light\"||e===\"dark\"?e:\"system\"}function We(e){let t=document.documentElement;e===\"dark\"?t.classList.add(\"dark\"):e===\"light\"?t.classList.remove(\"dark\"):window.matchMedia(\"(prefers-color-scheme: dark)\").matches?t.classList.add(\"dark\"):t.classList.remove(\"dark\")}function zt(e){let t=document.getElementById(\"icon-theme-light\"),n=document.getElementById(\"icon-theme-dark\"),r=document.getElementById(\"icon-theme-system\");!t||!n||!r||(t.classList.add(\"hidden\"),n.classList.add(\"hidden\"),r.classList.add(\"hidden\"),e===\"light\"?t.classList.remove(\"hidden\"):e===\"dark\"?n.classList.remove(\"hidden\"):r.classList.remove(\"hidden\"))}function gn(e){return e===\"light\"?\"dark\":e===\"dark\"?\"system\":\"light\"}function jt(){let e=je();We(e),zt(e);let t=document.getElementById(\"theme-toggle\");t&&t.addEventListener(\"click\",()=>{let n=gn(je());n===\"system\"?localStorage.removeItem(Ke):localStorage.setItem(Ke,n),We(n),zt(n)}),window.matchMedia(\"(prefers-color-scheme: dark)\").addEventListener(\"change\",()=>{je()===\"system\"&&We(\"system\")})}var ue=window.__INITIAL_STATE__,Ve=document.getElementById(\"app\");Ve&&ue?ue.mode===\"directory\"?ee(i(Ot,{...ue}),Ve):ee(i($t,{...ue}),Ve):console.error(\"[peek] hydration failed: missing #app or initial state\");jt();})();\n";
1018
+ const clientBundle = "\"use strict\";(()=>{var G,h,Ze,Vt,N,Ye,Ge,et,pe,X,z,tt,me,_e,fe,Xt,Q={},J=[],Yt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ee=Array.isArray;function M(e,t){for(var n in t)e[n]=t[n];return e}function he(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function qt(e,t,n){var r,s,o,l={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?s=t[o]:l[o]=t[o];if(arguments.length>2&&(l.children=arguments.length>3?G.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)l[o]===void 0&&(l[o]=e.defaultProps[o]);return Y(e,l,r,s,null)}function Y(e,t,n,r,s){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Ze,__i:-1,__u:0};return s==null&&h.vnode!=null&&h.vnode(o),o}function k(e){return e.children}function q(e,t){this.props=e,this.context=t}function U(e,t){if(t==null)return e.__?U(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==\"function\"?U(e):null}function Qt(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],s=[],o=M({},t);o.__v=t.__v+1,h.vnode&&h.vnode(o),ge(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??U(t),!!(32&t.__u),s),o.__v=t.__v,o.__.__k[o.__i]=o,st(r,o,s),t.__e=t.__=null,o.__e!=n&&nt(o)}}function nt(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),nt(e)}function qe(e){(!e.__d&&(e.__d=!0)&&N.push(e)&&!Z.__r++||Ye!=h.debounceRendering)&&((Ye=h.debounceRendering)||Ge)(Z)}function Z(){try{for(var e,t=1;N.length;)N.length>t&&N.sort(et),e=N.shift(),t=N.length,Qt(e)}finally{N.length=Z.__r=0}}function rt(e,t,n,r,s,o,l,u,d,c,p){var f,a,_,g,T,x,v=r&&r.__k||J,m=t.length;for(d=Jt(n,t,v,d,m),f=0;f<m;f++)(_=n.__k[f])!=null&&(a=_.__i!=-1&&v[_.__i]||Q,_.__i=f,x=ge(e,_,a,s,o,l,u,d,c,p),g=_.__e,_.ref&&a.ref!=_.ref&&(a.ref&&ye(a.ref,null,_),p.push(_.ref,_.__c||g,_)),T==null&&g!=null&&(T=g),4&_.__u?(d=ot(_,d,e),a.__e&&(a.__e=null)):typeof _.type==\"function\"&&x!==void 0?d=x:g&&(d=g.nextSibling),_.__u&=-7);return n.__e=T,d}function Jt(e,t,n,r,s){var o,l,u,d,c,p=n.length,f=p,a=0;for(e.__k=new Array(s),o=0;o<s;o++)(l=t[o])!=null&&typeof l!=\"boolean\"&&typeof l!=\"function\"?(typeof l==\"string\"||typeof l==\"number\"||typeof l==\"bigint\"||l.constructor==String?l=e.__k[o]=Y(null,l,null,null,null):ee(l)?l=e.__k[o]=Y(k,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=Y(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[o]=l,d=o+a,l.__=e,l.__b=e.__b+1,u=null,(c=l.__i=Zt(l,n,d,f))!=-1&&(f--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(s>p?a--:s<p&&a++),typeof l.type!=\"function\"&&(l.__u|=4)):c!=d&&(c==d-1?a--:c==d+1?a++:(c>d?a--:a++,l.__u|=4))):e.__k[o]=null;if(f)for(o=0;o<p;o++)(u=n[o])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=U(u)),at(u,u));return r}function ot(e,t,n){var r,s;if(typeof e.type==\"function\"){for(r=e.__k,s=0;r&&s<r.length;s++)r[s]&&(r[s].__=e,t=ot(r[s],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=U(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function Zt(e,t,n,r){var s,o,l,u=e.key,d=e.type,c=t[n],p=c!=null&&(2&c.__u)==0;if(c===null&&u==null||p&&u==c.key&&d==c.type)return n;if(r>(p?1:0)){for(s=n-1,o=n+1;s>=0||o<t.length;)if((c=t[l=s>=0?s--:o++])!=null&&(2&c.__u)==0&&u==c.key&&d==c.type)return l}return-1}function Qe(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Yt.test(t)?n:n+\"px\"}function V(e,t,n,r,s){var o,l;e:if(t==\"style\")if(typeof n==\"string\")e.style.cssText=n;else{if(typeof r==\"string\"&&(e.style.cssText=r=\"\"),r)for(t in r)n&&t in n||Qe(e.style,t,\"\");if(n)for(t in n)r&&n[t]==r[t]||Qe(e.style,t,n[t])}else if(t[0]==\"o\"&&t[1]==\"n\")o=t!=(t=t.replace(tt,\"$1\")),l=t.toLowerCase(),t=l in e||t==\"onFocusOut\"||t==\"onFocusIn\"?l.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[z]=r[z]:(n[z]=me,e.addEventListener(t,o?fe:_e,o)):e.removeEventListener(t,o?fe:_e,o);else{if(s==\"http://www.w3.org/2000/svg\")t=t.replace(/xlink(H|:h)/,\"h\").replace(/sName$/,\"s\");else if(t!=\"width\"&&t!=\"height\"&&t!=\"href\"&&t!=\"list\"&&t!=\"form\"&&t!=\"tabIndex\"&&t!=\"download\"&&t!=\"rowSpan\"&&t!=\"colSpan\"&&t!=\"role\"&&t!=\"popover\"&&t in e)try{e[t]=n??\"\";break e}catch{}typeof n==\"function\"||(n==null||n===!1&&t[4]!=\"-\"?e.removeAttribute(t):e.setAttribute(t,t==\"popover\"&&n==1?\"\":n))}}function Je(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[X]==null)t[X]=me++;else if(t[X]<n[z])return;return n(h.event?h.event(t):t)}}}function ge(e,t,n,r,s,o,l,u,d,c){var p,f,a,_,g,T,x,v,m,w,R,I,B,$,D,F,C=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(d=!!(32&n.__u),o=[u=t.__e=n.__e]),(p=h.__b)&&p(t);e:if(typeof C==\"function\"){f=l.length;try{if(m=t.props,w=C.prototype&&C.prototype.render,R=(p=C.contextType)&&r[p.__c],I=p?R?R.props.value:p.__:r,n.__c?v=(a=t.__c=n.__c).__=a.__E:(w?t.__c=a=new C(m,I):(t.__c=a=new q(m,I),a.constructor=C,a.render=en),R&&R.sub(a),a.state||(a.state={}),a.__n=r,_=a.__d=!0,a.__h=[],a._sb=[]),w&&a.__s==null&&(a.__s=a.state),w&&C.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=M({},a.__s)),M(a.__s,C.getDerivedStateFromProps(m,a.__s))),g=a.props,T=a.state,a.__v=t,_)w&&C.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),w&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(w&&C.getDerivedStateFromProps==null&&m!==g&&a.componentWillReceiveProps!=null&&a.componentWillReceiveProps(m,I),t.__v==n.__v||!a.__e&&a.shouldComponentUpdate!=null&&a.shouldComponentUpdate(m,a.__s,I)===!1){t.__v!=n.__v&&(a.props=m,a.state=a.__s,a.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(A){A&&(A.__=t)}),J.push.apply(a.__h,a._sb),a._sb=[],a.__h.length&&l.push(a),u=U(n);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(m,a.__s,I),w&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(g,T,x)})}if(a.context=I,a.props=m,a.__P=e,a.__e=!1,B=h.__r,$=0,w)a.state=a.__s,a.__d=!1,B&&B(t),p=a.render(a.props,a.state,a.context),J.push.apply(a.__h,a._sb),a._sb=[];else do a.__d=!1,B&&B(t),p=a.render(a.props,a.state,a.context),a.state=a.__s;while(a.__d&&++$<25);a.state=a.__s,a.getChildContext!=null&&(r=M(M({},r),a.getChildContext())),w&&!_&&a.getSnapshotBeforeUpdate!=null&&(x=a.getSnapshotBeforeUpdate(g,T)),D=p!=null&&p.type===k&&p.key==null?lt(p.props.children):p,u=rt(e,ee(D)?D:[D],t,n,r,s,o,l,u,d,c),a.base=t.__e,t.__u&=-161,a.__h.length&&l.push(a),v&&(a.__E=a.__=null)}catch(A){if(l.length=f,t.__v=null,d||o!=null){if(A.then){for(t.__u|=d?160:128;u&&u.nodeType==8&&u.nextSibling;)u=u.nextSibling;o!=null&&(o[o.indexOf(u)]=null),t.__e=u}else if(o!=null)for(F=o.length;F--;)he(o[F])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),A.then||it(t),h.__e(A,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):u=t.__e=Gt(n.__e,t,n,r,s,o,l,d,c);return(p=h.diffed)&&p(t),128&t.__u?void 0:u}function it(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(it))}function st(e,t,n){for(var r=0;r<n.length;r++)ye(n[r],n[++r],n[++r]);h.__c&&h.__c(t,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(o){o.call(s)})}catch(o){h.__e(o,s.__v)}})}function lt(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ee(e)?e.map(lt):e.constructor!==void 0?null:M({},e)}function Gt(e,t,n,r,s,o,l,u,d){var c,p,f,a,_,g,T,x=n.props||Q,v=t.props,m=t.type;if(m==\"svg\"?s=\"http://www.w3.org/2000/svg\":m==\"math\"?s=\"http://www.w3.org/1998/Math/MathML\":s||(s=\"http://www.w3.org/1999/xhtml\"),o!=null){for(c=0;c<o.length;c++)if((_=o[c])&&\"setAttribute\"in _==!!m&&(m?_.localName==m:_.nodeType==3)){e=_,o[c]=null;break}}if(e==null){if(m==null)return document.createTextNode(v);e=document.createElementNS(s,m,v.is&&v),u&&(h.__m&&h.__m(t,o),u=!1),o=null}if(m==null)x===v||u&&e.data==v||(e.data=v);else{if(o=m==\"textarea\"&&v.defaultValue!=null?null:o&&G.call(e.childNodes),!u&&o!=null)for(x={},c=0;c<e.attributes.length;c++)x[(_=e.attributes[c]).name]=_.value;for(c in x)_=x[c],c==\"dangerouslySetInnerHTML\"?f=_:c==\"children\"||c in v||c==\"value\"&&\"defaultValue\"in v||c==\"checked\"&&\"defaultChecked\"in v||V(e,c,null,_,s);for(c in v)_=v[c],c==\"children\"?a=_:c==\"dangerouslySetInnerHTML\"?p=_:c==\"value\"?g=_:c==\"checked\"?T=_:u&&typeof _!=\"function\"||x[c]===_||V(e,c,_,x[c],s);if(p)u||f&&(p.__html==f.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),rt(t.type==\"template\"?e.content:e,ee(a)?a:[a],t,n,r,m==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":s,o,l,o?o[0]:n.__k&&U(n,0),u,d),o!=null)for(c=o.length;c--;)he(o[c]);u&&m!=\"textarea\"||(c=\"value\",m==\"progress\"&&g==null?e.removeAttribute(\"value\"):g!=null&&(g!==e[c]||m==\"progress\"&&!g||m==\"option\"&&g!=x[c])&&V(e,c,g,x[c],s),c=\"checked\",T!=null&&T!=e[c]&&V(e,c,T,x[c],s))}return e}function ye(e,t,n){try{if(typeof e==\"function\"){var r=typeof e.__u==\"function\";r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(s){h.__e(s,n)}}function at(e,t,n){var r,s;if(h.unmount&&h.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||ye(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(o){h.__e(o,t)}r.base=r.__P=r.__n=null}if(r=e.__k)for(s=0;s<r.length;s++)r[s]&&at(r[s],t,n||typeof e.type!=\"function\");n||he(e.__e),e.__c=e.__=e.__e=void 0}function en(e,t,n){return this.constructor(e,n)}function tn(e,t,n){var r,s,o,l;t==document&&(t=document.documentElement),h.__&&h.__(e,t),s=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],l=[],ge(t,e=(!r&&n||t).__k=qt(k,null,[e]),s||Q,Q,t.namespaceURI,!r&&n?[n]:s?null:t.firstChild?G.call(t.childNodes):null,o,!r&&n?n:s?s.__e:t.firstChild,r,l),st(o,e,l),e.props.children=null}function te(e,t){tn(e,t,te)}G=J.slice,h={__e:function(e,t,n,r){for(var s,o,l;t=t.__;)if((s=t.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(e)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,r||{}),l=s.__d),l)return s.__E=s}catch(u){e=u}throw e}},Ze=0,Vt=function(e){return e!=null&&e.constructor===void 0},q.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=M({},this.state),typeof e==\"function\"&&(e=e(M({},n),this.props)),e&&M(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),qe(this))},q.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),qe(this))},q.prototype.render=k,N=[],Ge=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,et=function(e,t){return e.__v.__b-t.__v.__b},Z.__r=0,pe=Math.random().toString(8),X=\"__d\"+pe,z=\"__a\"+pe,tt=/(PointerCapture)$|Capture$/i,me=0,_e=Je(!1),fe=Je(!0),Xt=0;var O,y,ve,ct,j=0,gt=[],b=h,ut=b.__b,dt=b.__r,pt=b.diffed,_t=b.__c,ft=b.unmount,mt=b.__;function re(e,t){b.__h&&b.__h(y,e,j||t),j=0;var n=y.__H||(y.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return j=1,nn(yt,e)}function nn(e,t,n){var r=re(O++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):yt(void 0,t),function(u){var d=r.__N?r.__N[0]:r.__[0],c=r.t(d,u);d!==c&&(r.__N=[c,r.__[1]],r.__c.setState({}))}],r.__c=y,!y.__f)){var s=function(u,d,c){if(!r.__c.__H)return!0;var p=!1,f=r.__c.props!==u;if(r.__c.__H.__.some(function(_){if(_.__N){p=!0;var g=_.__[0];_.__=_.__N,_.__N=void 0,g!==_.__[0]&&(f=!0)}}),o){var a=o.call(this,u,d,c);return p?a||f:a}return!p||f};y.__f=!0;var o=y.shouldComponentUpdate,l=y.componentWillUpdate;y.componentWillUpdate=function(u,d,c){if(this.__e){var p=o;o=void 0,s(u,d,c),o=p}l&&l.call(this,u,d,c)},y.shouldComponentUpdate=s}return r.__N||r.__}function H(e,t){var n=re(O++,3);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,y.__H.__h.push(n))}function oe(e,t){var n=re(O++,4);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,y.__h.push(n))}function P(e){return j=5,ie(function(){return{current:e}},[])}function ie(e,t){var n=re(O++,7);return Se(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function L(e,t){return j=8,ie(function(){return e},t)}function rn(){for(var e;e=gt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ne),t.__h.some(be),t.__h=[]}catch(n){t.__h=[],b.__e(n,e.__v)}}}b.__b=function(e){y=null,ut&&ut(e)},b.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),mt&&mt(e,t)},b.__r=function(e){dt&&dt(e),O=0;var t=(y=e.__c).__H;t&&(ve===y?(t.__h=[],y.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(ne),t.__h.some(be),t.__h=[],O=0)),ve=y},b.diffed=function(e){pt&&pt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(gt.push(t)!==1&&ct===b.requestAnimationFrame||((ct=b.requestAnimationFrame)||on)(rn)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),ve=y=null},b.__c=function(e,t){t.some(function(n){try{n.__h.some(ne),n.__h=n.__h.filter(function(r){return!r.__||be(r)})}catch(r){t.some(function(s){s.__h&&(s.__h=[])}),t=[],b.__e(r,n.__v)}}),_t&&_t(e,t)},b.unmount=function(e){ft&&ft(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(r){try{ne(r)}catch(s){t=s}}),n.__H=void 0,t&&b.__e(t,n.__v))};var ht=typeof requestAnimationFrame==\"function\";function on(e){var t,n=function(){clearTimeout(r),ht&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);ht&&(t=requestAnimationFrame(n))}function ne(e){var t=y,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),y=t}function be(e){var t=y;e.__c=e.__(),y=t}function Se(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function yt(e,t){return typeof t==\"function\"?t(e):t}var vt={border:\"none\",width:\"100%\",height:\"100%\",position:\"absolute\",top:\"0\",left:\"0\"};var sn=\"/__peek/raw/\";function xe(e){return e.split(\"/\").map(encodeURIComponent).join(\"/\")}function bt(e){return`${sn}${xe(e)}`}var ln=0;function i(e,t,n,r,s,o){t||(t={});var l,u,d=t;if(\"ref\"in d)for(u in d={},t)u==\"ref\"?l=t[u]:d[u]=t[u];var c={type:e,props:d,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ln,__i:-1,__u:0,__source:s,__self:o};if(typeof e==\"function\"&&(l=e.defaultProps))for(u in l)d[u]===void 0&&(d[u]=l[u]);return h.vnode&&h.vnode(c),c}function Te({class:e,children:t}){return i(\"main\",{id:\"main-content\",class:e??\"\",children:t})}function se({htmlContent:e}){return i(\"div\",{id:\"markdown-content\",class:\"markdown-body\",dangerouslySetInnerHTML:{__html:e}})}function St({contentType:e,fileTitle:t,filePath:n,htmlContent:r,htmlReloadKey:s,markdownClass:o=\"px-5 sm:px-10 py-5 sm:py-10\"}){return e===\"html\"?i(Te,{class:\"relative flex-1 overflow-hidden\",children:i(\"iframe\",{title:t,src:bt(n),style:vt},s)}):i(Te,{class:o,children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(se,{htmlContent:r})})})}function S({class:e,children:t,width:n=\"24\",height:r=\"24\",viewBox:s=\"0 0 24 24\",...o}){return i(\"svg\",{...o,class:e,\"aria-hidden\":\"true\",xmlns:\"http://www.w3.org/2000/svg\",width:n,height:r,viewBox:s,fill:\"none\",stroke:\"currentColor\",\"stroke-width\":\"2\",\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",children:t})}function we(e){return i(S,{...e,children:i(\"path\",{d:\"m6 9 6 6 6-6\"})})}function ke({class:e}){return i(S,{class:e,children:[i(\"path\",{d:\"M15 3h6v6\"}),i(\"path\",{d:\"M10 14 21 3\"}),i(\"path\",{d:\"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6\"})]})}function Ee(e){return i(S,{...e,children:[i(\"path\",{d:\"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z\"}),i(\"path\",{d:\"M14 2v4a2 2 0 0 0 2 2h4\"})]})}function Ce(e){return i(S,{...e,children:i(\"path\",{d:\"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 0-1.69.9L9.6 8H4a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2Z\"})})}function Ie({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z\"})})}function Pe({class:e,...t}){return i(S,{class:e,...t,children:[i(\"polyline\",{points:\"7 8 3 12 7 16\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"12\",y2:\"12\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"6\",y2:\"6\"}),i(\"line\",{x1:\"21\",x2:\"11\",y1:\"18\",y2:\"18\"})]})}function Fe({class:e,...t}){return i(S,{class:e,...t,children:i(\"path\",{d:\"M17 8L21 12L17 16M3 12H13M3 6H13M3 18H13\"})})}function Ae(e){return i(S,{...e,width:\"16\",height:\"16\",viewBox:\"0 0 16 16\",children:i(\"path\",{d:\"M6 13L10 3\",\"stroke-linecap\":\"round\"})})}function Me({class:e,...t}){return i(S,{class:e,...t,children:[i(\"circle\",{cx:\"12\",cy:\"12\",r:\"4\"}),i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M12 20v2\"}),i(\"path\",{d:\"m4.93 4.93 1.41 1.41\"}),i(\"path\",{d:\"m17.66 17.66 1.41 1.41\"}),i(\"path\",{d:\"M2 12h2\"}),i(\"path\",{d:\"M20 12h2\"}),i(\"path\",{d:\"m6.34 17.66-1.41 1.41\"}),i(\"path\",{d:\"m19.07 4.93-1.41 1.41\"})]})}function Le({class:e,...t}){return i(S,{class:e,...t,children:[i(\"path\",{d:\"M12 2v2\"}),i(\"path\",{d:\"M14.837 16.385a6 6 0 1 1-7.223-7.222c.624-.147.97.66.715 1.248a4 4 0 0 0 5.26 5.259c.589-.255 1.396.09 1.248.715\"}),i(\"path\",{d:\"M16 12a4 4 0 0 0-4-4\"}),i(\"path\",{d:\"m19 5-1.256 1.256\"}),i(\"path\",{d:\"M20 12h2\"})]})}var Re={dirItem:\"inline-flex items-center shrink-0\",dirLink:\"text-sm text-muted-foreground hover:text-foreground\",fileItem:\"inline-flex items-center text-sm font-semibold text-foreground truncate\"},an=\"shrink-0 mx-1 size-4 text-muted-foreground\";function xt({items:e}){return i(\"nav\",{\"aria-label\":\"Breadcrumb\",children:i(\"ol\",{class:\"flex items-center min-w-0\",children:e.map((t,n)=>{let r=n===e.length-1;return i(\"li\",{class:r?Re.fileItem:Re.dirItem,\"aria-current\":r?\"page\":void 0,children:r?t.label:i(k,{children:[i(\"a\",{class:Re.dirLink,href:t.href??\"#\",children:t.label}),i(Ae,{class:an})]})},n)})})})}function Tt({href:e}){return i(\"a\",{href:e,target:\"_blank\",rel:\"noopener noreferrer\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Open in new tab\",children:i(ke,{class:\"size-4\"})})}function wt(){return i(\"button\",{type:\"button\",id:\"theme-toggle\",class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:text-foreground cursor-pointer\",\"aria-label\":\"Toggle theme\",children:[i(Me,{class:\"hidden size-4\",id:\"icon-theme-light\"}),i(Ie,{class:\"hidden size-4\",id:\"icon-theme-dark\"}),i(Le,{class:\"hidden size-4\",id:\"icon-theme-system\"})]})}function kt({id:e,breadcrumbs:t,showSidebarToggle:n,onToggleSidebar:r,externalLinkHref:s}){return i(\"header\",{id:e,class:\"sticky top-0 z-50 bg-background border-b border-border\",children:i(\"div\",{class:\"flex items-center justify-between w-full py-2 px-2 sm:px-5\",children:[i(\"div\",{class:\"flex items-center gap-1 min-w-0\",children:[n&&i(\"button\",{type:\"button\",id:\"sidebar-toggle\",onClick:r,class:\"shrink-0 w-7 h-7 inline-flex justify-center items-center rounded-lg text-muted-foreground hover:bg-sidebar-accent cursor-pointer\",children:[i(Fe,{class:\"shrink-0 size-4\",id:\"icon-sidebar-open\"}),i(Pe,{class:\"shrink-0 size-4 hidden\",id:\"icon-sidebar-close\"})]}),i(xt,{items:t})]}),i(\"div\",{class:\"flex items-center gap-1\",children:[i(wt,{}),s!==void 0&&i(Tt,{href:s})]})]})})}var cn=20;function un({node:e,currentPath:t,depth:n,isOpen:r,onToggle:s}){let o=r?r(e.path):!0;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:[i(\"button\",{type:\"button\",\"aria-expanded\":o,onClick:()=>s?.(e.path),class:\"flex items-center gap-x-3 w-full py-2 px-3 text-left text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-lg overflow-hidden\",children:[i(Ce,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:e.name}),i(we,{class:`${o?\"\":\"-rotate-180 \"}shrink-0 size-3.5 ms-auto transition-transform`})]}),o&&i(\"ul\",{class:\"ps-7 mt-1 flex flex-col gap-y-1 relative before:absolute before:top-0 before:start-[1.125rem] before:w-px before:h-full before:bg-sidebar-border\",children:e.children&&n<cn?i(Ne,{nodes:e.children,currentPath:t,depth:n+1,isOpen:r,onToggle:s}):null})]})}function Ne({nodes:e,currentPath:t,depth:n=0,isOpen:r,onToggle:s}){return i(k,{children:e.map(o=>{if(o.type===\"directory\")return i(un,{node:o,currentPath:t,depth:n,isOpen:r,onToggle:s},o.path);let l=t===o.path;return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:i(\"a\",{href:`/view?path=${encodeURIComponent(o.path)}`,class:`flex items-center gap-x-3 py-2 px-3 text-sm rounded-lg overflow-hidden ${l?\"bg-sidebar-accent text-sidebar-primary font-medium\":\"hover:bg-sidebar-accent text-sidebar-foreground\"}`,children:[i(Ee,{class:\"shrink-0 size-4\"}),i(\"span\",{class:\"min-w-0 truncate\",children:o.name})]})},o.path)})})}function Et({nodes:e,currentPath:t,isOpen:n,onToggle:r}){return i(\"ul\",{id:\"file-tree\",class:\"flex flex-col gap-y-1\",children:i(Ne,{nodes:e,currentPath:t,isOpen:n,onToggle:r})})}function Ct({title:e,tree:t,currentPath:n,onClose:r,isOpen:s,onToggle:o,searchQuery:l,onSearchChange:u,isSearching:d}){return i(k,{children:[i(\"div\",{role:\"none\",id:\"sidebar-overlay\",class:\"fixed inset-0 z-50 bg-black/50 hidden\",onClick:r}),i(\"aside\",{id:\"sidebar\",\"aria-label\":\"File navigation\",class:\"fixed inset-y-0 start-0 z-60 w-72 lg:w-auto overflow-hidden bg-sidebar border-e border-sidebar-border -translate-x-full\",children:[i(\"div\",{class:\"relative flex flex-col h-full max-h-full pt-3\",children:[i(\"header\",{class:\"flex-none h-11.5 ps-5 pe-2 lg:ps-8 flex items-center\",children:i(\"a\",{href:\"/\",class:\"flex-none text-sm font-semibold text-sidebar-foreground hover:text-sidebar-primary\",children:e})}),i(\"div\",{class:\"flex-none px-2 lg:px-5 mt-1.5 mb-1\",children:i(\"input\",{id:\"sidebar-search\",type:\"search\",\"aria-label\":\"Search files\",placeholder:\"Search files\\u2026\",value:l??\"\",onInput:c=>u?.(c.target.value),onKeyDown:c=>{c.key===\"Escape\"&&!c.isComposing&&(u?.(\"\"),c.currentTarget.blur())},class:\"w-full py-1.5 px-3 text-sm text-sidebar-foreground bg-sidebar-accent border border-sidebar-border rounded-lg outline-none focus:border-sidebar-primary placeholder:text-sidebar-foreground/50\"})}),i(\"div\",{class:\"flex-1 min-h-0 overflow-x-hidden overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb\",children:i(\"nav\",{class:\"pb-3 w-full flex flex-col\",children:d&&t.length===0?i(\"p\",{class:\"px-5 py-3 text-sm text-sidebar-foreground/60\",children:\"No matches found\"}):i(Et,{nodes:t,currentPath:n,isOpen:s,onToggle:o})})})]}),i(\"div\",{id:\"sidebar-resize\",class:\"absolute inset-y-0 end-0 w-1 cursor-col-resize hover:bg-sidebar-border hidden lg:block pointer-events-auto\"})]})]})}var dn=new Map([[\".md\",\"markdown\"],[\".html\",\"html\"],[\".htm\",\"html\"]]);function pn(e){let t=Math.max(e.lastIndexOf(\"/\"),e.lastIndexOf(\"\\\\\")),n=t===-1?e:e.slice(t+1),r=n.lastIndexOf(\".\");return r===-1||r===n.length-1?\"\":n.slice(r).toLowerCase()}function It(e){return dn.get(pn(e))??null}function Pt(e,t){return e.name.toLowerCase().includes(t)}function Ft(e,t){let n=t.trim().toLowerCase();return n===\"\"?e:At(e,n)}function At(e,t){let n=[];for(let r of e){if(r.type===\"directory\"){if(Pt(r,t)){n.push(r);continue}let s=r.children?At(r.children,t):[];s.length>0&&n.push({...r,children:s});continue}Pt(r,t)&&n.push(r)}return n}var He=\"file-tree-state\";function Mt(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!=\"object\"||Array.isArray(t))return{};let n={};for(let[r,s]of Object.entries(t)){if(!s||typeof s!=\"object\"||Array.isArray(s))continue;let{collapsed:o,lastAccess:l}=s;typeof l!=\"number\"||!Array.isArray(o)||(n[r]={collapsed:o.filter(u=>typeof u==\"string\"),lastAccess:l})}return n}catch{return{}}}function Lt(e,t,n){let r={};for(let[s,o]of Object.entries(e))t-o.lastAccess<=n&&(r[s]=o);return r}function Be(e,t){return new Set(e[t]?.collapsed??[])}function De(e,t,n,r){return{...e,[t]:{collapsed:Array.from(n),lastAccess:r}}}function Rt(e){return JSON.stringify(e)}function Nt(e){let[t,n]=E(()=>new Set),r=P(!0),s=P(t);s.current=t;function o(){try{return Mt(localStorage.getItem(He))}catch{return{}}}function l(c){try{localStorage.setItem(He,Rt(c))}catch{}}oe(()=>{if(!r.current)return;r.current=!1;let c=Date.now(),p=Lt(o(),c,2592e6),f=De(p,e,Be(p,e),c);l(f),n(Be(f,e))},[e]);let u=L(c=>{let p=new Set(s.current);p.has(c)?p.delete(c):p.add(c),s.current=p,n(p);let f=De(o(),e,p,Date.now());l(f)},[e]);return{isOpen:L(c=>!t.has(c),[t]),toggle:u}}async function W(e,t){try{let n=e?`/api/content?path=${encodeURIComponent(e)}`:\"/api/content\",r=await fetch(n,t?.signal?{signal:t.signal}:void 0);return r.ok?await r.text():(console.error(`[peek] Failed to fetch content: HTTP ${r.status}`),null)}catch(n){if(n instanceof DOMException&&n.name===\"AbortError\")throw n;return console.error(\"[peek] Failed to fetch content:\",n),null}}async function Ht(e){try{let t=await fetch(\"/api/tree\",e?.signal?{signal:e.signal}:void 0);if(!t.ok)return console.error(`[peek] Failed to fetch tree: HTTP ${t.status}`),null;let n=await t.json();return Array.isArray(n)?n:(console.error(\"[peek] Unexpected tree response format\"),null)}catch(t){if(t instanceof DOMException&&t.name===\"AbortError\")throw t;return console.error(\"[peek] Failed to fetch tree:\",t),null}}function K(e){return e&&e.replace(/\\\\/g,\"/\")}function le(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function Bt(e){let t=P(null),n=P(e);n.current=e;let r=L(async(s,o)=>{t.current&&t.current.abort();let l=new AbortController;t.current=l;try{let u=await W(s,{signal:l.signal});if(u===null)return;n.current(s,u),document.title=`${le(s)} - peek`;let d=`/view?path=${encodeURIComponent(s)}`;o&&history.pushState({path:s},\"\",d)}catch(u){if(u instanceof DOMException&&u.name===\"AbortError\")return;console.error(\"[peek] Failed to navigate:\",u)}},[]);return H(()=>{let s=new URLSearchParams(window.location.search).get(\"path\");s&&history.replaceState({path:s},\"\");function o(u){if(u.ctrlKey||u.metaKey||u.shiftKey||u.altKey)return;let d=u.target.closest(\"a[href]\");if(!d)return;let c;try{c=new URL(d.href,window.location.origin)}catch{return}if(c.origin!==window.location.origin||c.pathname!==\"/view\")return;let p=c.searchParams.get(\"path\");p&&(u.preventDefault(),r(p,!0))}function l(u){let c=u.state?.path??new URLSearchParams(window.location.search).get(\"path\");c?r(c,!1):window.location.reload()}return document.addEventListener(\"click\",o),window.addEventListener(\"popstate\",l),()=>{document.removeEventListener(\"click\",o),window.removeEventListener(\"popstate\",l)}},[r]),r}var fn=\"sidebar-search\";function mn(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===\"INPUT\"||t===\"TEXTAREA\"||t===\"SELECT\"||e.isContentEditable}function Dt(e){H(()=>{function t(n){n.key===\"/\"&&(n.isComposing||mn(n.target)||(n.preventDefault(),e?.(),document.getElementById(fn)?.focus()))}return window.addEventListener(\"keydown\",t),()=>window.removeEventListener(\"keydown\",t)},[e])}var ae=\"sidebar-open\",Ut=\"sidebar-width\",Ue=200,Oe=480,hn=1024;function ce(){return window.innerWidth>=hn}function Ot(){let[e,t]=E(!1),n=P(!0);oe(()=>{if(n.current){n.current=!1;let l=localStorage.getItem(Ut);if(l){let u=Number(l);u>=Ue&&u<=Oe&&document.documentElement.style.setProperty(\"--sidebar-width\",`${u}px`)}if(ce()&&localStorage.getItem(ae)!==\"false\"){let u=[document.getElementById(\"sidebar\"),document.getElementById(\"header-bar\"),document.getElementById(\"main-content\")];for(let d of u)d&&(d.style.transition=\"none\");document.body.setAttribute(\"data-sidebar-open\",\"\"),document.body.offsetHeight,requestAnimationFrame(()=>{for(let d of u)d&&d.style.removeProperty(\"transition\")}),t(!0)}return}e?document.body.setAttribute(\"data-sidebar-open\",\"\"):document.body.removeAttribute(\"data-sidebar-open\")},[e]),H(()=>{let l=document.getElementById(\"sidebar-resize\");if(!l)return;function u(d){d.preventDefault(),l.setPointerCapture(d.pointerId);let c=document.getElementById(\"sidebar\");document.body.style.setProperty(\"user-select\",\"none\"),c?.style.setProperty(\"transition\",\"none\");function p(a){let _=Math.min(Math.max(a.clientX,Ue),Oe);document.documentElement.style.setProperty(\"--sidebar-width\",`${_}px`)}function f(a){if(l.releasePointerCapture(a.pointerId),l.removeEventListener(\"pointermove\",p),l.removeEventListener(\"pointerup\",f),l.removeEventListener(\"pointercancel\",f),document.body.style.removeProperty(\"user-select\"),c?.style.removeProperty(\"transition\"),a.type===\"pointerup\"){let _=Math.min(Math.max(a.clientX,Ue),Oe);localStorage.setItem(Ut,String(_))}}l.addEventListener(\"pointermove\",p),l.addEventListener(\"pointerup\",f),l.addEventListener(\"pointercancel\",f)}return l.addEventListener(\"pointerdown\",u),()=>l.removeEventListener(\"pointerdown\",u)},[]);let r=L(()=>{t(l=>{let u=!l;return ce()&&localStorage.setItem(ae,String(u)),u})},[]),s=L(()=>{t(!1),ce()&&localStorage.setItem(ae,\"false\")},[]),o=L(()=>{t(!0),ce()&&localStorage.setItem(ae,\"true\")},[]);return{toggle:r,close:s,open:o}}var $e=\"[peek]\",ze={info:(...e)=>console.log($e,...e),warn:(...e)=>console.warn($e,...e),error:(...e)=>console.error($e,...e)};function bn(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=\"object\")return null;let n=t;return typeof n.path!=\"string\"?null:{path:n.path}}function $t(e){let t=0,n=null,r=null,s=null;function o(){r&&(clearTimeout(r),r=null);let l=new EventSource(\"/sse\");if(s=l,l.addEventListener(\"file-changed\",u=>{let d=bn(u.data);e.onFileChanged(d?K(d.path):null)}),e.onTreeChanged){let u=e.onTreeChanged;l.addEventListener(\"tree-changed\",()=>{u()})}l.onerror=()=>{if(l.close(),s=null,r&&(clearTimeout(r),r=null),t++,t>10){ze.warn(`SSE connection lost after ${10} retries, giving up.`);return}let u=Math.min(1e3*2**(t-1),3e4);ze.info(`SSE reconnecting in ${u}ms (${t}/${10})...`),n=setTimeout(o,u)},r=setTimeout(()=>{t=0,r=null},5e3)}return o(),()=>{n&&clearTimeout(n),r&&clearTimeout(r),s&&s.close()}}function ue(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:s,onTreeUpdate:o}=e;H(()=>{let l=null,u=null,d=$t({onFileChanged:c=>{if(n){if(c===null)return;let p=n();if(K(c)!==K(p))return;if(r?.()===\"html\"){s?.();return}l?.abort(),l=new AbortController,W(p,{signal:l.signal}).then(f=>{f!==null&&t(f)}).catch(f=>{f instanceof DOMException&&f.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",f)})}else l?.abort(),l=new AbortController,W(void 0,{signal:l.signal}).then(p=>{p!==null&&t(p)}).catch(p=>{p instanceof DOMException&&p.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",p)})},onTreeChanged:o?()=>{u?.abort(),u=new AbortController,Ht({signal:u.signal}).then(c=>{c&&o(c)}).catch(c=>{c instanceof DOMException&&c.name===\"AbortError\"||console.error(\"[peek] Failed to refresh tree:\",c)})}:void 0});return()=>{l?.abort(),u?.abort(),d()}},[])}function zt({projectId:e,dirTitle:t,currentPath:n,contentType:r,content:s,tree:o}){let[l,u]=E(n),[d,c]=E(r),[p,f]=E(s),[a,_]=E(o),[g,T]=E(\"\"),[x,v]=E(0),m=P(l);m.current=l;let w=Ot(),R=Nt(e),I=g.trim()!==\"\",B=ie(()=>Ft(a,g),[a,g]);Dt(w.open),Bt((F,C)=>{let A=It(F);if(!A){console.error(`Unexpected unsupported file type: ${F}`);return}m.current=F,u(F),c(A),f(C),v(0)});let $=P(d);$.current=d,ue({getCurrentPath:()=>m.current,getCurrentContentType:()=>$.current,onContentUpdate:f,onHtmlReload:()=>v(F=>F+1),onTreeUpdate:_});let D=le(l);return i(k,{children:[i(Ct,{title:t,tree:B,currentPath:l,onClose:w.close,isOpen:I?()=>!0:R.isOpen,onToggle:I?void 0:R.toggle,searchQuery:g,onSearchChange:T,isSearching:I}),i(kt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:D}],showSidebarToggle:!0,onToggleSidebar:w.toggle,externalLinkHref:`/${xe(l)}`}),i(St,{contentType:d,fileTitle:D,filePath:l,htmlContent:p,htmlReloadKey:x})]})}function jt({content:e}){let[t,n]=E(e);return ue({onContentUpdate:n}),i(\"main\",{class:\"px-2 sm:px-5 py-5 sm:py-15\",children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(se,{htmlContent:t})})})}var Ve=\"theme\";function We(){let e=localStorage.getItem(Ve);return e===\"light\"||e===\"dark\"?e:\"system\"}function Ke(e){let t=document.documentElement;e===\"dark\"?t.classList.add(\"dark\"):e===\"light\"?t.classList.remove(\"dark\"):window.matchMedia(\"(prefers-color-scheme: dark)\").matches?t.classList.add(\"dark\"):t.classList.remove(\"dark\")}function Wt(e){let t=document.getElementById(\"icon-theme-light\"),n=document.getElementById(\"icon-theme-dark\"),r=document.getElementById(\"icon-theme-system\");!t||!n||!r||(t.classList.add(\"hidden\"),n.classList.add(\"hidden\"),r.classList.add(\"hidden\"),e===\"light\"?t.classList.remove(\"hidden\"):e===\"dark\"?n.classList.remove(\"hidden\"):r.classList.remove(\"hidden\"))}function Sn(e){return e===\"light\"?\"dark\":e===\"dark\"?\"system\":\"light\"}function Kt(){let e=We();Ke(e),Wt(e);let t=document.getElementById(\"theme-toggle\");t&&t.addEventListener(\"click\",()=>{let n=Sn(We());n===\"system\"?localStorage.removeItem(Ve):localStorage.setItem(Ve,n),Ke(n),Wt(n)}),window.matchMedia(\"(prefers-color-scheme: dark)\").addEventListener(\"change\",()=>{We()===\"system\"&&Ke(\"system\")})}var de=window.__INITIAL_STATE__,Xe=document.getElementById(\"app\");Xe&&de?de.mode===\"directory\"?te(i(zt,{...de}),Xe):te(i(jt,{...de}),Xe):console.error(\"[peek] hydration failed: missing #app or initial state\");Kt();})();\n";
891
1019
  //#endregion
892
1020
  //#region src/server/renderer/global.css?inline
893
- var global_default = "/*! tailwindcss v4.2.2 | MIT License | https://tailwindcss.com */\n@layer properties {\n @supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {\n *, :before, :after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-font-weight: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ease: initial;\n --tw-content: \"\";\n }\n }\n}\n\n@layer theme {\n :root, :host {\n --font-sans: ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n --color-black: #000;\n --spacing: .25rem;\n --container-4xl: 56rem;\n --text-sm: .875rem;\n --text-sm--line-height: calc(1.25 / .875);\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-lg: .5rem;\n --radius-xl: .75rem;\n --ease-in-out: cubic-bezier(.4, 0, .2, 1);\n --animate-spin: spin 1s linear infinite;\n --animate-pulse: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;\n --default-transition-duration: .15s;\n --default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --color-background: var(--background);\n --color-foreground: var(--foreground);\n --color-card: var(--card);\n --color-muted-foreground: var(--muted-foreground);\n --color-border: var(--border);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-border: var(--sidebar-border);\n --color-scrollbar-track: var(--scrollbar-track);\n --color-scrollbar-thumb: var(--scrollbar-thumb);\n }\n}\n\n@layer base {\n *, :after, :before, ::backdrop {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n ::file-selector-button {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n html, :host {\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n line-height: 1.5;\n font-family: var(--default-font-family, ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n b, strong {\n font-weight: bolder;\n }\n\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub, sup {\n vertical-align: baseline;\n font-size: 75%;\n line-height: 0;\n position: relative;\n }\n\n sub {\n bottom: -.25em;\n }\n\n sup {\n top: -.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n :-moz-focusring {\n outline: auto;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n summary {\n display: list-item;\n }\n\n ol, ul, menu {\n list-style: none;\n }\n\n img, svg, video, canvas, audio, iframe, embed, object {\n vertical-align: middle;\n display: block;\n }\n\n img, video {\n max-width: 100%;\n height: auto;\n }\n\n button, input, select, optgroup, textarea {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n ::placeholder {\n opacity: 1;\n }\n\n @supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentColor;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n\n textarea {\n resize: vertical;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-year-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-month-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-day-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-hour-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-minute-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-second-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-millisecond-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]) {\n appearance: button;\n }\n\n ::file-selector-button {\n appearance: button;\n }\n\n ::-webkit-inner-spin-button {\n height: auto;\n }\n\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n\n@layer components;\n\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n\n .collapse {\n visibility: collapse;\n }\n\n .visible {\n visibility: visible;\n }\n\n .absolute {\n position: absolute;\n }\n\n .fixed {\n position: fixed;\n }\n\n .relative {\n position: relative;\n }\n\n .sticky {\n position: sticky;\n }\n\n .inset-0 {\n inset: calc(var(--spacing) * 0);\n }\n\n .inset-y-0 {\n inset-block: calc(var(--spacing) * 0);\n }\n\n .start {\n inset-inline-start: var(--spacing);\n }\n\n .start-0 {\n inset-inline-start: calc(var(--spacing) * 0);\n }\n\n .end-0 {\n inset-inline-end: calc(var(--spacing) * 0);\n }\n\n .top-0 {\n top: calc(var(--spacing) * 0);\n }\n\n .z-50 {\n z-index: 50;\n }\n\n .z-60 {\n z-index: 60;\n }\n\n .container {\n width: 100%;\n }\n\n @media (width >= 40rem) {\n .container {\n max-width: 40rem;\n }\n }\n\n @media (width >= 48rem) {\n .container {\n max-width: 48rem;\n }\n }\n\n @media (width >= 64rem) {\n .container {\n max-width: 64rem;\n }\n }\n\n @media (width >= 80rem) {\n .container {\n max-width: 80rem;\n }\n }\n\n @media (width >= 96rem) {\n .container {\n max-width: 96rem;\n }\n }\n\n .mx-1 {\n margin-inline: calc(var(--spacing) * 1);\n }\n\n .mx-auto {\n margin-inline: auto;\n }\n\n .ms-auto {\n margin-inline-start: auto;\n }\n\n .mt-1 {\n margin-top: calc(var(--spacing) * 1);\n }\n\n .mt-1\\.5 {\n margin-top: calc(var(--spacing) * 1.5);\n }\n\n .mb-1 {\n margin-bottom: calc(var(--spacing) * 1);\n }\n\n .block {\n display: block;\n }\n\n .contents {\n display: contents;\n }\n\n .flex {\n display: flex;\n }\n\n .hidden {\n display: none;\n }\n\n .inline {\n display: inline;\n }\n\n .inline-flex {\n display: inline-flex;\n }\n\n .table {\n display: table;\n }\n\n .size-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n height: calc(var(--spacing) * 3.5);\n }\n\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n\n .h-7 {\n height: calc(var(--spacing) * 7);\n }\n\n .h-11\\.5 {\n height: calc(var(--spacing) * 11.5);\n }\n\n .h-full {\n height: 100%;\n }\n\n .max-h-full {\n max-height: 100%;\n }\n\n .min-h-0 {\n min-height: calc(var(--spacing) * 0);\n }\n\n .min-h-dvh {\n min-height: 100dvh;\n }\n\n .min-h-screen {\n min-height: 100vh;\n }\n\n .w-1 {\n width: calc(var(--spacing) * 1);\n }\n\n .w-7 {\n width: calc(var(--spacing) * 7);\n }\n\n .w-72 {\n width: calc(var(--spacing) * 72);\n }\n\n .w-full {\n width: 100%;\n }\n\n .max-w-4xl {\n max-width: var(--container-4xl);\n }\n\n .min-w-0 {\n min-width: calc(var(--spacing) * 0);\n }\n\n .flex-1 {\n flex: 1;\n }\n\n .flex-none {\n flex: none;\n }\n\n .shrink-0 {\n flex-shrink: 0;\n }\n\n .border-collapse {\n border-collapse: collapse;\n }\n\n .-translate-x-full {\n --tw-translate-x: -100%;\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n\n .-rotate-180 {\n rotate: -180deg;\n }\n\n .transform {\n transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );\n }\n\n .animate-pulse {\n animation: var(--animate-pulse);\n }\n\n .animate-spin {\n animation: var(--animate-spin);\n }\n\n .cursor-col-resize {\n cursor: col-resize;\n }\n\n .cursor-pointer {\n cursor: pointer;\n }\n\n .resize {\n resize: both;\n }\n\n .flex-col {\n flex-direction: column;\n }\n\n .flex-wrap {\n flex-wrap: wrap;\n }\n\n .items-center {\n align-items: center;\n }\n\n .justify-between {\n justify-content: space-between;\n }\n\n .justify-center {\n justify-content: center;\n }\n\n .gap-1 {\n gap: calc(var(--spacing) * 1);\n }\n\n .gap-x-3 {\n column-gap: calc(var(--spacing) * 3);\n }\n\n .gap-y-1 {\n row-gap: calc(var(--spacing) * 1);\n }\n\n .truncate {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n }\n\n .overflow-hidden {\n overflow: hidden;\n }\n\n .overflow-x-hidden {\n overflow-x: hidden;\n }\n\n .overflow-y-auto {\n overflow-y: auto;\n }\n\n .rounded-lg {\n border-radius: var(--radius-lg);\n }\n\n .rounded-xl {\n border-radius: var(--radius-xl);\n }\n\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n\n .border-e {\n border-inline-end-style: var(--tw-border-style);\n border-inline-end-width: 1px;\n }\n\n .border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n\n .border-border {\n border-color: var(--color-border);\n }\n\n .border-sidebar-border {\n border-color: var(--color-sidebar-border);\n }\n\n .bg-background {\n background-color: var(--color-background);\n }\n\n .bg-black\\/50 {\n background-color: #00000080;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .bg-black\\/50 {\n background-color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n\n .bg-card {\n background-color: var(--color-card);\n }\n\n .bg-sidebar {\n background-color: var(--color-sidebar);\n }\n\n .bg-sidebar-accent {\n background-color: var(--color-sidebar-accent);\n }\n\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n\n .px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .px-6 {\n padding-inline: calc(var(--spacing) * 6);\n }\n\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n\n .py-3 {\n padding-block: calc(var(--spacing) * 3);\n }\n\n .py-5 {\n padding-block: calc(var(--spacing) * 5);\n }\n\n .py-8 {\n padding-block: calc(var(--spacing) * 8);\n }\n\n .ps-5 {\n padding-inline-start: calc(var(--spacing) * 5);\n }\n\n .ps-7 {\n padding-inline-start: calc(var(--spacing) * 7);\n }\n\n .pe-2 {\n padding-inline-end: calc(var(--spacing) * 2);\n }\n\n .pt-3 {\n padding-top: calc(var(--spacing) * 3);\n }\n\n .pb-3 {\n padding-bottom: calc(var(--spacing) * 3);\n }\n\n .text-left {\n text-align: left;\n }\n\n .text-sm {\n font-size: var(--text-sm);\n line-height: var(--tw-leading, var(--text-sm--line-height));\n }\n\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n\n .text-foreground {\n color: var(--color-foreground);\n }\n\n .text-muted-foreground {\n color: var(--color-muted-foreground);\n }\n\n .text-sidebar-foreground, .text-sidebar-foreground\\/60 {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .text-sidebar-foreground\\/60 {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 60%, transparent);\n }\n }\n\n .text-sidebar-primary {\n color: var(--color-sidebar-primary);\n }\n\n .italic {\n font-style: italic;\n }\n\n .shadow-2xs {\n --tw-shadow: 0 1px var(--tw-shadow-color, #0000000d);\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .ease-in-out {\n --tw-ease: var(--ease-in-out);\n transition-timing-function: var(--ease-in-out);\n }\n\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 50%, transparent);\n }\n }\n\n .before\\:absolute:before {\n content: var(--tw-content);\n position: absolute;\n }\n\n .before\\:start-\\[1\\.125rem\\]:before {\n content: var(--tw-content);\n inset-inline-start: 1.125rem;\n }\n\n .before\\:top-0:before {\n content: var(--tw-content);\n top: calc(var(--spacing) * 0);\n }\n\n .before\\:h-full:before {\n content: var(--tw-content);\n height: 100%;\n }\n\n .before\\:w-px:before {\n content: var(--tw-content);\n width: 1px;\n }\n\n .before\\:bg-sidebar-border:before {\n content: var(--tw-content);\n background-color: var(--color-sidebar-border);\n }\n\n @media (hover: hover) {\n .hover\\:bg-sidebar-accent:hover {\n background-color: var(--color-sidebar-accent);\n }\n\n .hover\\:bg-sidebar-border:hover {\n background-color: var(--color-sidebar-border);\n }\n\n .hover\\:text-foreground:hover {\n color: var(--color-foreground);\n }\n\n .hover\\:text-sidebar-primary:hover {\n color: var(--color-sidebar-primary);\n }\n }\n\n .focus\\:border-sidebar-primary:focus {\n border-color: var(--color-sidebar-primary);\n }\n\n @media (width >= 40rem) {\n .sm\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .sm\\:px-10 {\n padding-inline: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-10 {\n padding-block: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-15 {\n padding-block: calc(var(--spacing) * 15);\n }\n }\n\n @media (width >= 64rem) {\n .lg\\:block {\n display: block;\n }\n\n .lg\\:w-auto {\n width: auto;\n }\n\n .lg\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .lg\\:ps-8 {\n padding-inline-start: calc(var(--spacing) * 8);\n }\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar\\]\\:w-2::-webkit-scrollbar {\n width: calc(var(--spacing) * 2);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:rounded-none::-webkit-scrollbar-thumb {\n border-radius: 0;\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:bg-scrollbar-thumb::-webkit-scrollbar-thumb {\n background-color: var(--color-scrollbar-thumb);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-track\\]\\:bg-scrollbar-track::-webkit-scrollbar-track {\n background-color: var(--color-scrollbar-track);\n }\n}\n\n:root {\n --background: #fff;\n --foreground: #393a34;\n --card: #fff;\n --card-foreground: #393a34;\n --primary: #1c6b48;\n --primary-foreground: #fff;\n --muted: #f7f7f7;\n --muted-foreground: #6a737d;\n --border: #f0f0f0;\n --sidebar: #fff;\n --sidebar-foreground: #4e4f47;\n --sidebar-primary: #1c6b48;\n --sidebar-accent: #f7f7f7;\n --sidebar-accent-foreground: #393a34;\n --sidebar-border: #f0f0f0;\n --font-sans: ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n --scrollbar-track: #f7f7f7;\n --scrollbar-thumb: #393a3450;\n --radius: .5rem;\n}\n\n.dark {\n --background: #121212;\n --foreground: #dbd7caee;\n --card: #181818;\n --card-foreground: #dbd7caee;\n --primary: #4d9375;\n --primary-foreground: #121212;\n --muted: #181818;\n --muted-foreground: #959da5;\n --border: #191919;\n --sidebar: #121212;\n --sidebar-foreground: #bfbaaa;\n --sidebar-primary: #4d9375;\n --sidebar-accent: #181818;\n --sidebar-accent-foreground: #dbd7caee;\n --sidebar-border: #191919;\n --scrollbar-track: #181818;\n --scrollbar-thumb: #dedcd550;\n}\n\n#sidebar {\n transition: translate .3s;\n}\n\nbody[data-sidebar-open] #sidebar {\n translate: 0;\n}\n\nbody[data-sidebar-open] #sidebar-overlay {\n display: block;\n}\n\nbody[data-sidebar-open] #icon-sidebar-open {\n display: none;\n}\n\nbody[data-sidebar-open] #icon-sidebar-close {\n display: inline;\n}\n\n@media (width >= 1024px) {\n #sidebar {\n width: var(--sidebar-width, 18rem);\n }\n\n #header-bar, #main-content {\n transition: margin .3s;\n }\n\n body[data-sidebar-open] #sidebar-overlay {\n display: none;\n }\n\n body[data-sidebar-open] #header-bar, body[data-sidebar-open] #main-content {\n margin-inline-start: var(--sidebar-width, 18rem);\n }\n}\n\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ease {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-content {\n syntax: \"*\";\n inherits: false;\n initial-value: \"\";\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@keyframes pulse {\n 50% {\n opacity: .5;\n }\n}\n";
1021
+ var global_default = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties {\n @supports (((-webkit-hyphens: none)) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color: rgb(from red r g b)))) {\n *, :before, :after, ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-rotate-x: initial;\n --tw-rotate-y: initial;\n --tw-rotate-z: initial;\n --tw-skew-x: initial;\n --tw-skew-y: initial;\n --tw-border-style: solid;\n --tw-font-weight: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ease: initial;\n --tw-content: \"\";\n }\n }\n}\n\n@layer theme {\n :root, :host {\n --font-sans: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n --color-black: #000;\n --spacing: .25rem;\n --container-4xl: 56rem;\n --text-sm: .875rem;\n --text-sm--line-height: calc(1.25 / .875);\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n --radius-lg: .5rem;\n --radius-xl: .75rem;\n --ease-in-out: cubic-bezier(.4, 0, .2, 1);\n --animate-spin: spin 1s linear infinite;\n --animate-pulse: pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;\n --default-transition-duration: .15s;\n --default-transition-timing-function: cubic-bezier(.4, 0, .2, 1);\n --default-font-family: var(--font-sans);\n --default-mono-font-family: var(--font-mono);\n --color-background: var(--background);\n --color-foreground: var(--foreground);\n --color-card: var(--card);\n --color-muted-foreground: var(--muted-foreground);\n --color-border: var(--border);\n --color-sidebar: var(--sidebar);\n --color-sidebar-foreground: var(--sidebar-foreground);\n --color-sidebar-primary: var(--sidebar-primary);\n --color-sidebar-accent: var(--sidebar-accent);\n --color-sidebar-border: var(--sidebar-border);\n --color-scrollbar-track: var(--scrollbar-track);\n --color-scrollbar-thumb: var(--scrollbar-thumb);\n }\n}\n\n@layer base {\n *, :after, :before, ::backdrop {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n ::file-selector-button {\n box-sizing: border-box;\n border: 0 solid;\n margin: 0;\n padding: 0;\n }\n\n html, :host {\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n line-height: 1.5;\n font-family: var(--default-font-family, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\");\n font-feature-settings: var(--default-font-feature-settings, normal);\n font-variation-settings: var(--default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1, h2, h3, h4, h5, h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n\n b, strong {\n font-weight: bolder;\n }\n\n code, kbd, samp, pre {\n font-family: var(--default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace);\n font-feature-settings: var(--default-mono-font-feature-settings, normal);\n font-variation-settings: var(--default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub, sup {\n vertical-align: baseline;\n font-size: 75%;\n line-height: 0;\n position: relative;\n }\n\n sub {\n bottom: -.25em;\n }\n\n sup {\n top: -.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n summary {\n display: list-item;\n }\n\n ol, ul, menu {\n list-style: none;\n }\n\n img, svg, video, canvas, audio, iframe, embed, object {\n vertical-align: middle;\n display: block;\n }\n\n img, video {\n max-width: 100%;\n height: auto;\n }\n\n button, input, select, optgroup, textarea {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n opacity: 1;\n background-color: #0000;\n border-radius: 0;\n }\n\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n\n ::placeholder {\n opacity: 1;\n }\n\n @supports (not ((-webkit-appearance: -apple-pay-button))) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentColor;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n ::placeholder {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n\n textarea {\n resize: vertical;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n\n ::-webkit-datetime-edit {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-year-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-month-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-day-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-hour-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-minute-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-second-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-millisecond-field {\n padding-block: 0;\n }\n\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n button, input:where([type=\"button\"], [type=\"reset\"], [type=\"submit\"]) {\n appearance: button;\n }\n\n ::file-selector-button {\n appearance: button;\n }\n\n ::-webkit-inner-spin-button {\n height: auto;\n }\n\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [hidden]:where(:not([hidden=\"until-found\"])) {\n display: none !important;\n }\n}\n\n@layer components;\n\n@layer utilities {\n .pointer-events-auto {\n pointer-events: auto;\n }\n\n .collapse {\n visibility: collapse;\n }\n\n .visible {\n visibility: visible;\n }\n\n .absolute {\n position: absolute;\n }\n\n .fixed {\n position: fixed;\n }\n\n .relative {\n position: relative;\n }\n\n .sticky {\n position: sticky;\n }\n\n .inset-0 {\n inset: 0;\n }\n\n .inset-y-0 {\n inset-block: 0;\n }\n\n .start-0 {\n inset-inline-start: calc(var(--spacing) * 0);\n }\n\n .end-0 {\n inset-inline-end: calc(var(--spacing) * 0);\n }\n\n .top-0 {\n top: 0;\n }\n\n .z-50 {\n z-index: 50;\n }\n\n .z-60 {\n z-index: 60;\n }\n\n .container {\n width: 100%;\n }\n\n @media (width >= 40rem) {\n .container {\n max-width: 40rem;\n }\n }\n\n @media (width >= 48rem) {\n .container {\n max-width: 48rem;\n }\n }\n\n @media (width >= 64rem) {\n .container {\n max-width: 64rem;\n }\n }\n\n @media (width >= 80rem) {\n .container {\n max-width: 80rem;\n }\n }\n\n @media (width >= 96rem) {\n .container {\n max-width: 96rem;\n }\n }\n\n .mx-1 {\n margin-inline: var(--spacing);\n }\n\n .mx-auto {\n margin-inline: auto;\n }\n\n .ms-auto {\n margin-inline-start: auto;\n }\n\n .mt-1 {\n margin-top: var(--spacing);\n }\n\n .mt-1\\.5 {\n margin-top: calc(var(--spacing) * 1.5);\n }\n\n .mb-1 {\n margin-bottom: var(--spacing);\n }\n\n .block {\n display: block;\n }\n\n .contents {\n display: contents;\n }\n\n .flex {\n display: flex;\n }\n\n .hidden {\n display: none;\n }\n\n .inline {\n display: inline;\n }\n\n .inline-flex {\n display: inline-flex;\n }\n\n .table {\n display: table;\n }\n\n .size-3\\.5 {\n width: calc(var(--spacing) * 3.5);\n height: calc(var(--spacing) * 3.5);\n }\n\n .size-4 {\n width: calc(var(--spacing) * 4);\n height: calc(var(--spacing) * 4);\n }\n\n .h-7 {\n height: calc(var(--spacing) * 7);\n }\n\n .h-11\\.5 {\n height: calc(var(--spacing) * 11.5);\n }\n\n .h-full {\n height: 100%;\n }\n\n .max-h-full {\n max-height: 100%;\n }\n\n .min-h-0 {\n min-height: 0;\n }\n\n .min-h-dvh {\n min-height: 100dvh;\n }\n\n .min-h-screen {\n min-height: 100vh;\n }\n\n .w-1 {\n width: var(--spacing);\n }\n\n .w-7 {\n width: calc(var(--spacing) * 7);\n }\n\n .w-72 {\n width: calc(var(--spacing) * 72);\n }\n\n .w-full {\n width: 100%;\n }\n\n .max-w-4xl {\n max-width: var(--container-4xl);\n }\n\n .min-w-0 {\n min-width: 0;\n }\n\n .flex-1 {\n flex: 1;\n }\n\n .flex-none {\n flex: none;\n }\n\n .shrink-0 {\n flex-shrink: 0;\n }\n\n .border-collapse {\n border-collapse: collapse;\n }\n\n .-translate-x-full {\n --tw-translate-x: -100%;\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n\n .-rotate-180 {\n rotate: -180deg;\n }\n\n .transform {\n transform: var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, );\n }\n\n .animate-pulse {\n animation: var(--animate-pulse);\n }\n\n .animate-spin {\n animation: var(--animate-spin);\n }\n\n .cursor-col-resize {\n cursor: col-resize;\n }\n\n .cursor-pointer {\n cursor: pointer;\n }\n\n .resize {\n resize: both;\n }\n\n .flex-col {\n flex-direction: column;\n }\n\n .flex-wrap {\n flex-wrap: wrap;\n }\n\n .items-center {\n align-items: center;\n }\n\n .justify-between {\n justify-content: space-between;\n }\n\n .justify-center {\n justify-content: center;\n }\n\n .gap-1 {\n gap: var(--spacing);\n }\n\n .gap-x-3 {\n column-gap: calc(var(--spacing) * 3);\n }\n\n .gap-y-1 {\n row-gap: var(--spacing);\n }\n\n .truncate {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n }\n\n .overflow-hidden {\n overflow: hidden;\n }\n\n .overflow-x-hidden {\n overflow-x: hidden;\n }\n\n .overflow-y-auto {\n overflow-y: auto;\n }\n\n .rounded-lg {\n border-radius: var(--radius-lg);\n }\n\n .rounded-xl {\n border-radius: var(--radius-xl);\n }\n\n .border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n\n .border-e {\n border-inline-end-style: var(--tw-border-style);\n border-inline-end-width: 1px;\n }\n\n .border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n\n .border-border {\n border-color: var(--color-border);\n }\n\n .border-sidebar-border {\n border-color: var(--color-sidebar-border);\n }\n\n .bg-background {\n background-color: var(--color-background);\n }\n\n .bg-black\\/50 {\n background-color: #00000080;\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .bg-black\\/50 {\n background-color: color-mix(in oklab, var(--color-black) 50%, transparent);\n }\n }\n\n .bg-card {\n background-color: var(--color-card);\n }\n\n .bg-sidebar {\n background-color: var(--color-sidebar);\n }\n\n .bg-sidebar-accent {\n background-color: var(--color-sidebar-accent);\n }\n\n .px-2 {\n padding-inline: calc(var(--spacing) * 2);\n }\n\n .px-3 {\n padding-inline: calc(var(--spacing) * 3);\n }\n\n .px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .px-6 {\n padding-inline: calc(var(--spacing) * 6);\n }\n\n .py-1\\.5 {\n padding-block: calc(var(--spacing) * 1.5);\n }\n\n .py-2 {\n padding-block: calc(var(--spacing) * 2);\n }\n\n .py-3 {\n padding-block: calc(var(--spacing) * 3);\n }\n\n .py-5 {\n padding-block: calc(var(--spacing) * 5);\n }\n\n .py-8 {\n padding-block: calc(var(--spacing) * 8);\n }\n\n .ps-5 {\n padding-inline-start: calc(var(--spacing) * 5);\n }\n\n .ps-7 {\n padding-inline-start: calc(var(--spacing) * 7);\n }\n\n .pe-2 {\n padding-inline-end: calc(var(--spacing) * 2);\n }\n\n .pt-3 {\n padding-top: calc(var(--spacing) * 3);\n }\n\n .pb-3 {\n padding-bottom: calc(var(--spacing) * 3);\n }\n\n .text-left {\n text-align: left;\n }\n\n .text-sm {\n font-size: var(--text-sm);\n line-height: var(--tw-leading, var(--text-sm--line-height));\n }\n\n .font-medium {\n --tw-font-weight: var(--font-weight-medium);\n font-weight: var(--font-weight-medium);\n }\n\n .font-semibold {\n --tw-font-weight: var(--font-weight-semibold);\n font-weight: var(--font-weight-semibold);\n }\n\n .text-foreground {\n color: var(--color-foreground);\n }\n\n .text-muted-foreground {\n color: var(--color-muted-foreground);\n }\n\n .text-sidebar-foreground, .text-sidebar-foreground\\/60 {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .text-sidebar-foreground\\/60 {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 60%, transparent);\n }\n }\n\n .text-sidebar-primary {\n color: var(--color-sidebar-primary);\n }\n\n .italic {\n font-style: italic;\n }\n\n .shadow-2xs {\n --tw-shadow: 0 1px var(--tw-shadow-color, #0000000d);\n box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);\n }\n\n .transition {\n transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, content-visibility, overlay, pointer-events;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .transition-transform {\n transition-property: transform, translate, scale, rotate;\n transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--default-transition-duration));\n }\n\n .ease-in-out {\n --tw-ease: var(--ease-in-out);\n transition-timing-function: var(--ease-in-out);\n }\n\n .outline-none {\n --tw-outline-style: none;\n outline-style: none;\n }\n\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: var(--color-sidebar-foreground);\n }\n\n @supports (color: color-mix(in lab, red, red)) {\n .placeholder\\:text-sidebar-foreground\\/50::placeholder {\n color: color-mix(in oklab, var(--color-sidebar-foreground) 50%, transparent);\n }\n }\n\n .before\\:absolute:before {\n content: var(--tw-content);\n position: absolute;\n }\n\n .before\\:start-\\[1\\.125rem\\]:before {\n content: var(--tw-content);\n inset-inline-start: 1.125rem;\n }\n\n .before\\:top-0:before {\n content: var(--tw-content);\n top: 0;\n }\n\n .before\\:h-full:before {\n content: var(--tw-content);\n height: 100%;\n }\n\n .before\\:w-px:before {\n content: var(--tw-content);\n width: 1px;\n }\n\n .before\\:bg-sidebar-border:before {\n content: var(--tw-content);\n background-color: var(--color-sidebar-border);\n }\n\n @media (hover: hover) {\n .hover\\:bg-sidebar-accent:hover {\n background-color: var(--color-sidebar-accent);\n }\n\n .hover\\:bg-sidebar-border:hover {\n background-color: var(--color-sidebar-border);\n }\n\n .hover\\:text-foreground:hover {\n color: var(--color-foreground);\n }\n\n .hover\\:text-sidebar-primary:hover {\n color: var(--color-sidebar-primary);\n }\n }\n\n .focus\\:border-sidebar-primary:focus {\n border-color: var(--color-sidebar-primary);\n }\n\n @media (width >= 40rem) {\n .sm\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .sm\\:px-10 {\n padding-inline: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-10 {\n padding-block: calc(var(--spacing) * 10);\n }\n\n .sm\\:py-15 {\n padding-block: calc(var(--spacing) * 15);\n }\n }\n\n @media (width >= 64rem) {\n .lg\\:block {\n display: block;\n }\n\n .lg\\:w-auto {\n width: auto;\n }\n\n .lg\\:px-5 {\n padding-inline: calc(var(--spacing) * 5);\n }\n\n .lg\\:ps-8 {\n padding-inline-start: calc(var(--spacing) * 8);\n }\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar\\]\\:w-2::-webkit-scrollbar {\n width: calc(var(--spacing) * 2);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:rounded-none::-webkit-scrollbar-thumb {\n border-radius: 0;\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-thumb\\]\\:bg-scrollbar-thumb::-webkit-scrollbar-thumb {\n background-color: var(--color-scrollbar-thumb);\n }\n\n .\\[\\&\\:\\:-webkit-scrollbar-track\\]\\:bg-scrollbar-track::-webkit-scrollbar-track {\n background-color: var(--color-scrollbar-track);\n }\n}\n\n:root {\n --background: #fff;\n --foreground: #393a34;\n --card: #fff;\n --card-foreground: #393a34;\n --primary: #1c6b48;\n --primary-foreground: #fff;\n --muted: #f7f7f7;\n --muted-foreground: #6a737d;\n --border: #f0f0f0;\n --sidebar: #fff;\n --sidebar-foreground: #4e4f47;\n --sidebar-primary: #1c6b48;\n --sidebar-accent: #f7f7f7;\n --sidebar-accent-foreground: #393a34;\n --sidebar-border: #f0f0f0;\n --font-sans: ui-sans-serif, system-ui, sans-serif;\n --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n --scrollbar-track: #f7f7f7;\n --scrollbar-thumb: #393a3450;\n --radius: .5rem;\n}\n\n.dark {\n --background: #121212;\n --foreground: #dbd7caee;\n --card: #181818;\n --card-foreground: #dbd7caee;\n --primary: #4d9375;\n --primary-foreground: #121212;\n --muted: #181818;\n --muted-foreground: #959da5;\n --border: #191919;\n --sidebar: #121212;\n --sidebar-foreground: #bfbaaa;\n --sidebar-primary: #4d9375;\n --sidebar-accent: #181818;\n --sidebar-accent-foreground: #dbd7caee;\n --sidebar-border: #191919;\n --scrollbar-track: #181818;\n --scrollbar-thumb: #dedcd550;\n}\n\n#sidebar {\n transition: translate .3s;\n}\n\nbody[data-sidebar-open] #sidebar {\n translate: 0;\n}\n\nbody[data-sidebar-open] #sidebar-overlay {\n display: block;\n}\n\nbody[data-sidebar-open] #icon-sidebar-open {\n display: none;\n}\n\nbody[data-sidebar-open] #icon-sidebar-close {\n display: inline;\n}\n\n@media (width >= 1024px) {\n #sidebar {\n width: var(--sidebar-width, 18rem);\n }\n\n #header-bar, #main-content {\n transition: margin .3s;\n }\n\n body[data-sidebar-open] #sidebar-overlay {\n display: none;\n }\n\n body[data-sidebar-open] #header-bar, body[data-sidebar-open] #main-content {\n margin-inline-start: var(--sidebar-width, 18rem);\n }\n}\n\n@property --tw-translate-x {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-y {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-translate-z {\n syntax: \"*\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-rotate-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-rotate-z {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-x {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-skew-y {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-border-style {\n syntax: \"*\";\n inherits: false;\n initial-value: solid;\n}\n\n@property --tw-font-weight {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-inset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-shadow-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-shadow-alpha {\n syntax: \"<percentage>\";\n inherits: false;\n initial-value: 100%;\n}\n\n@property --tw-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-inset-ring-color {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-inset-ring-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ring-inset {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-ring-offset-width {\n syntax: \"<length>\";\n inherits: false;\n initial-value: 0;\n}\n\n@property --tw-ring-offset-color {\n syntax: \"*\";\n inherits: false;\n initial-value: #fff;\n}\n\n@property --tw-ring-offset-shadow {\n syntax: \"*\";\n inherits: false;\n initial-value: 0 0 #0000;\n}\n\n@property --tw-ease {\n syntax: \"*\";\n inherits: false\n}\n\n@property --tw-content {\n syntax: \"*\";\n inherits: false;\n initial-value: \"\";\n}\n\n@keyframes spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n@keyframes pulse {\n 50% {\n opacity: .5;\n }\n}\n";
894
1022
  //#endregion
895
1023
  //#region src/server/renderer/document.tsx
896
1024
  const themeInitScript = `(function(){var t=localStorage.getItem("theme");if(t==="dark"||(t!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches))document.documentElement.classList.add("dark")})()`;
@@ -1033,23 +1161,28 @@ function renderDirectoryView(params) {
1033
1161
  href: "/"
1034
1162
  }, { label: fileTitle }],
1035
1163
  showSidebarToggle: true,
1036
- externalLinkHref: `/${currentPath.split("/").map(encodeURIComponent).join("/")}`
1164
+ externalLinkHref: `/${encodeUrlPath(currentPath)}`
1037
1165
  }),
1038
1166
  /* @__PURE__ */ jsx(ContentView, {
1039
1167
  contentType,
1040
1168
  fileTitle,
1041
- rawUrl: `/api/raw?path=${encodeURIComponent(currentPath)}`,
1169
+ filePath: currentPath,
1042
1170
  htmlContent: html
1043
1171
  })
1044
1172
  ]
1045
1173
  }));
1046
1174
  }
1047
- async function renderFileContent(fullPath, contentType) {
1175
+ async function renderFileContent(dirPath, relativePath, contentType) {
1176
+ const realPath = await realPathWithinBase(dirPath, relativePath);
1177
+ if (!realPath.ok) return {
1178
+ ok: false,
1179
+ ...realPathErrorResponse(realPath.error)
1180
+ };
1048
1181
  if (contentType === "html") {
1049
1182
  try {
1050
- await access(fullPath, constants.R_OK);
1183
+ await access(realPath.value, constants.R_OK);
1051
1184
  } catch (e) {
1052
- if (isNodeError(e) && e.code === "ENOENT") return {
1185
+ if (isNotFoundError(e)) return {
1053
1186
  ok: false,
1054
1187
  status: 404,
1055
1188
  message: "File not found"
@@ -1066,7 +1199,7 @@ async function renderFileContent(fullPath, contentType) {
1066
1199
  html: ""
1067
1200
  };
1068
1201
  }
1069
- const result = await readTextFile(fullPath);
1202
+ const result = await readTextFile(realPath.value);
1070
1203
  if (!result.ok) {
1071
1204
  if (result.error.type === "file-not-found") return {
1072
1205
  ok: false,
@@ -1082,7 +1215,7 @@ async function renderFileContent(fullPath, contentType) {
1082
1215
  }
1083
1216
  return {
1084
1217
  ok: true,
1085
- html: await renderMarkdown(result.value)
1218
+ html: await renderMarkdown(result.value, relativePath)
1086
1219
  };
1087
1220
  }
1088
1221
  function createDirectoryRoutes(dirPath, styles, treeCache) {
@@ -1101,7 +1234,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1101
1234
  logger.error("Unexpected unsupported file in tree:", firstFile.path);
1102
1235
  return c.text("Internal server error", 500);
1103
1236
  }
1104
- const rendered = await renderFileContent(resolve(dirPath, normalize(firstFile.path)), contentType);
1237
+ const rendered = await renderFileContent(dirPath, firstFile.path, contentType);
1105
1238
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1106
1239
  const dirTitle = basename(dirPath) || dirPath;
1107
1240
  return c.html(renderDirectoryView({
@@ -1118,11 +1251,10 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1118
1251
  app.get("/view", async (c) => {
1119
1252
  const relativePath = c.req.query("path");
1120
1253
  if (!relativePath) return c.redirect("/");
1121
- const fullPath = resolve(dirPath, normalize(relativePath));
1122
- if (!isWithinBase(dirPath, fullPath)) return c.text("Forbidden", 403);
1254
+ if (!isRelativePathWithinBase(dirPath, relativePath)) return c.text("Forbidden", 403);
1123
1255
  const contentType = getContentType(relativePath);
1124
1256
  if (!contentType) return c.text("Not found", 404);
1125
- const rendered = await renderFileContent(fullPath, contentType);
1257
+ const rendered = await renderFileContent(dirPath, relativePath, contentType);
1126
1258
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1127
1259
  const treeResult = await treeCache.get();
1128
1260
  if (!treeResult.ok) {
@@ -1143,19 +1275,13 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1143
1275
  });
1144
1276
  app.get("/:path{.+}", async (c) => {
1145
1277
  const relativePath = c.req.param("path");
1146
- const fullPath = resolve(dirPath, normalize(relativePath));
1147
- if (!isWithinBase(dirPath, fullPath)) return c.text("Forbidden", 403);
1278
+ if (!isRelativePathWithinBase(dirPath, relativePath)) return c.text("Forbidden", 403);
1148
1279
  const contentType = getContentType(relativePath);
1149
1280
  if (!contentType) return c.text("Not found", 404);
1150
- if (contentType === "html") {
1151
- const rendered = await renderFileContent(fullPath, contentType);
1152
- if (!rendered.ok) return c.text(rendered.message, rendered.status);
1153
- const fileTitle = basename(relativePath);
1154
- return c.html(renderHtmlDocument(fileTitle, `/api/raw?path=${encodeURIComponent(relativePath)}`));
1155
- }
1156
- const rendered = await renderFileContent(fullPath, contentType);
1281
+ const rendered = await renderFileContent(dirPath, relativePath, contentType);
1157
1282
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1158
1283
  const fileTitle = basename(relativePath);
1284
+ if (contentType === "html") return c.html(renderHtmlDocument(fileTitle, rawFileUrl(relativePath)));
1159
1285
  return c.html(renderDocument(/* @__PURE__ */ jsx(Document, {
1160
1286
  title: fileTitle,
1161
1287
  styles,
@@ -1166,7 +1292,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1166
1292
  children: /* @__PURE__ */ jsx(ContentView, {
1167
1293
  contentType,
1168
1294
  fileTitle,
1169
- rawUrl: `/api/raw?path=${encodeURIComponent(relativePath)}`,
1295
+ filePath: relativePath,
1170
1296
  htmlContent: rendered.html,
1171
1297
  markdownClass: "px-2 sm:px-5 py-5 sm:py-15"
1172
1298
  })
@@ -1184,8 +1310,8 @@ function createFileRoutes(filePath, styles) {
1184
1310
  logger.error("Failed to read file:", result.error);
1185
1311
  return c.text("Failed to read file", 500);
1186
1312
  }
1187
- const html = await renderMarkdown(result.value);
1188
1313
  const title = basename(filePath);
1314
+ const html = await renderMarkdown(result.value, title);
1189
1315
  return c.html(renderDocument(/* @__PURE__ */ jsx(Document, {
1190
1316
  title,
1191
1317
  styles,
@@ -1210,33 +1336,116 @@ function createHtmlFileRoutes(filePath) {
1210
1336
  const app = new Hono();
1211
1337
  app.get("/", (c) => {
1212
1338
  const title = basename(filePath);
1213
- return c.html(renderHtmlDocument(title, "/api/raw"));
1339
+ return c.html(renderHtmlDocument(title, rawFileUrl(title)));
1214
1340
  });
1215
1341
  return app;
1216
1342
  }
1343
+ /**
1344
+ * Extensions that `/__peek/raw/` may serve, mapped to their `Content-Type`.
1345
+ * Anything absent is refused, which keeps `--host 0.0.0.0` from exposing
1346
+ * arbitrary files under the base directory.
1347
+ */
1348
+ const MIME_TYPE_MAP = new Map([
1349
+ [".png", "image/png"],
1350
+ [".jpg", "image/jpeg"],
1351
+ [".jpeg", "image/jpeg"],
1352
+ [".gif", "image/gif"],
1353
+ [".webp", "image/webp"],
1354
+ [".svg", "image/svg+xml"],
1355
+ [".avif", "image/avif"],
1356
+ [".ico", "image/x-icon"],
1357
+ [".bmp", "image/bmp"],
1358
+ [".css", "text/css; charset=utf-8"],
1359
+ [".js", "text/javascript; charset=utf-8"],
1360
+ [".mjs", "text/javascript; charset=utf-8"],
1361
+ [".woff", "font/woff"],
1362
+ [".woff2", "font/woff2"],
1363
+ [".ttf", "font/ttf"],
1364
+ [".otf", "font/otf"],
1365
+ [".html", "text/html; charset=utf-8"],
1366
+ [".htm", "text/html; charset=utf-8"]
1367
+ ]);
1368
+ function getMimeType(filePath) {
1369
+ return MIME_TYPE_MAP.get(getExtension(filePath)) ?? null;
1370
+ }
1217
1371
  //#endregion
1218
- //#region src/server/routes/sse.ts
1219
- function sleep(ms, signal) {
1220
- return new Promise((resolve, reject) => {
1221
- const timer = setTimeout(resolve, ms);
1222
- signal.addEventListener("abort", () => {
1223
- clearTimeout(timer);
1224
- reject(signal.reason);
1225
- }, { once: true });
1372
+ //#region src/server/routes/raw.ts
1373
+ async function lookupRawFile(baseDir, relativePath) {
1374
+ if (!isRelativePathWithinBase(baseDir, relativePath)) return {
1375
+ type: "path-error",
1376
+ error: { type: "outside-base" }
1377
+ };
1378
+ const realPath = await realPathWithinBase(baseDir, relativePath);
1379
+ if (!realPath.ok) return {
1380
+ type: "path-error",
1381
+ error: realPath.error
1382
+ };
1383
+ const mimeType = getMimeType(realPath.value);
1384
+ if (!mimeType) return { type: "not-allowed" };
1385
+ try {
1386
+ return {
1387
+ type: "found",
1388
+ body: await readFile(realPath.value),
1389
+ mimeType
1390
+ };
1391
+ } catch (e) {
1392
+ return isNotFoundError(e) ? { type: "not-a-file" } : {
1393
+ type: "unreadable",
1394
+ cause: e
1395
+ };
1396
+ }
1397
+ }
1398
+ /**
1399
+ * Serves allowlisted files under `baseDir` at `/__peek/raw/<relative path>`,
1400
+ * so that the browser resolves relative references in a previewed file
1401
+ * (images, CSS, fonts, ...) against that file's own directory.
1402
+ */
1403
+ function createRawRoutes(baseDir) {
1404
+ const app = new Hono();
1405
+ app.get(`${RAW_FILE_PREFIX}:path{.+}`, async (c) => {
1406
+ const file = await lookupRawFile(baseDir, c.req.param("path"));
1407
+ switch (file.type) {
1408
+ case "path-error": {
1409
+ const { status, message } = realPathErrorResponse(file.error);
1410
+ return c.text(message, status);
1411
+ }
1412
+ case "not-allowed":
1413
+ case "not-a-file": return c.text("File not found", 404);
1414
+ case "unreadable":
1415
+ logger.error("Failed to read file:", file.cause);
1416
+ return c.text("Failed to read file", 500);
1417
+ case "found": break;
1418
+ }
1419
+ c.header("Content-Type", file.mimeType);
1420
+ c.header("X-Content-Type-Options", "nosniff");
1421
+ c.header("Cache-Control", "no-cache");
1422
+ if (file.mimeType === "image/svg+xml") c.header("Content-Security-Policy", "sandbox");
1423
+ return c.body(file.body);
1226
1424
  });
1425
+ return app;
1227
1426
  }
1427
+ //#endregion
1428
+ //#region src/server/routes/sse.ts
1228
1429
  const KEEP_ALIVE_INTERVAL_MS = 3e4;
1229
1430
  function createSseManager() {
1230
1431
  const clients = /* @__PURE__ */ new Set();
1432
+ let shuttingDown = false;
1231
1433
  function broadcast(event, data) {
1232
1434
  for (const client of Array.from(clients)) client.send(event, data);
1233
1435
  }
1234
- function closeAll() {
1436
+ /**
1437
+ * Refuses new `/sse` connections and closes every open one. Raising the flag
1438
+ * *before* walking `clients` is what makes this race-free against a request
1439
+ * that is registering itself concurrently (see the handler below).
1440
+ */
1441
+ function shutdown() {
1442
+ shuttingDown = true;
1235
1443
  for (const client of clients) client.close();
1236
1444
  clients.clear();
1237
1445
  }
1238
1446
  const app = new Hono();
1239
1447
  app.get("/sse", (c) => {
1448
+ if (shuttingDown) return c.body(null, 503);
1240
1449
  return streamSSE(c, async (stream) => {
1241
1450
  let closed = false;
1242
1451
  const abortController = new AbortController();
@@ -1256,22 +1465,26 @@ function createSseManager() {
1256
1465
  },
1257
1466
  close: cleanup
1258
1467
  };
1259
- clients.add(client);
1260
1468
  stream.onAbort(cleanup);
1469
+ if (!closed) clients.add(client);
1470
+ if (shuttingDown) {
1471
+ cleanup();
1472
+ return;
1473
+ }
1261
1474
  while (!closed) {
1262
1475
  try {
1263
- await sleep(KEEP_ALIVE_INTERVAL_MS, abortController.signal);
1476
+ await setTimeout$1(KEEP_ALIVE_INTERVAL_MS, void 0, { signal: abortController.signal });
1264
1477
  } catch {
1265
1478
  break;
1266
1479
  }
1267
- if (!closed) await stream.write(": keep-alive\n\n").catch(cleanup);
1480
+ if (!closed) await stream.write(": keep-alive\n\n");
1268
1481
  }
1269
1482
  });
1270
1483
  });
1271
1484
  return {
1272
1485
  app,
1273
1486
  broadcast,
1274
- closeAll,
1487
+ shutdown,
1275
1488
  get clientCount() {
1276
1489
  return clients.size;
1277
1490
  }
@@ -1279,6 +1492,12 @@ function createSseManager() {
1279
1492
  }
1280
1493
  //#endregion
1281
1494
  //#region src/server/index.ts
1495
+ /**
1496
+ * `server.close()` normally resolves a tick after `closeAllConnections()`, so
1497
+ * this is mostly margin for slow environments: long enough not to warn on
1498
+ * healthy shutdowns, short enough to keep Ctrl+C responsive.
1499
+ */
1500
+ const SHUTDOWN_TIMEOUT_MS = 2e3;
1282
1501
  function createApp(ctx, sse) {
1283
1502
  const app = new Hono();
1284
1503
  app.get("/favicon.ico", (c) => {
@@ -1289,6 +1508,7 @@ function createApp(ctx, sse) {
1289
1508
  });
1290
1509
  });
1291
1510
  app.route("/", sse.app);
1511
+ app.route("/", createRawRoutes(ctx.mode === "file" ? dirname(ctx.targetPath) : ctx.targetPath));
1292
1512
  if (ctx.mode === "file") {
1293
1513
  const apiRoutes = createApiRoutes({
1294
1514
  mode: "file",
@@ -1321,20 +1541,22 @@ function setupWatcher(ctx, sse) {
1321
1541
  });
1322
1542
  return watcher;
1323
1543
  }
1324
- async function startServer(config) {
1544
+ async function startServer(config, options) {
1545
+ const shutdownTimeoutMs = options?.shutdownTimeoutMs ?? SHUTDOWN_TIMEOUT_MS;
1546
+ const targetPath = config.mode === "file" ? await realpath(config.targetPath) : config.targetPath;
1325
1547
  const sse = createSseManager();
1326
1548
  const ctx = config.mode === "directory" ? {
1327
1549
  mode: "directory",
1328
- targetPath: config.targetPath,
1550
+ targetPath,
1329
1551
  styles: config.styles,
1330
- treeCache: createFileTreeCache(config.targetPath)
1552
+ treeCache: createFileTreeCache(targetPath)
1331
1553
  } : config.contentType === "html" ? {
1332
1554
  mode: "file",
1333
- targetPath: config.targetPath,
1555
+ targetPath,
1334
1556
  contentType: "html"
1335
1557
  } : {
1336
1558
  mode: "file",
1337
- targetPath: config.targetPath,
1559
+ targetPath,
1338
1560
  contentType: config.contentType,
1339
1561
  styles: config.styles
1340
1562
  };
@@ -1352,33 +1574,35 @@ async function startServer(config) {
1352
1574
  };
1353
1575
  const onError = (err) => {
1354
1576
  server.removeListener("listening", onListening);
1355
- sse.closeAll();
1577
+ sse.shutdown();
1356
1578
  watcher.close();
1357
1579
  reject(err);
1358
1580
  };
1359
1581
  server.once("listening", onListening);
1360
1582
  server.once("error", onError);
1361
1583
  });
1362
- const close = () => new Promise((resolve, reject) => {
1363
- server.close((err) => err ? reject(err) : resolve());
1364
- });
1365
- const sseCloseAll = () => sse.closeAll();
1366
- let shutdownPromise;
1367
- return {
1368
- close,
1369
- watcher,
1370
- sseCloseAll,
1371
- shutdown() {
1372
- if (shutdownPromise) return shutdownPromise;
1373
- shutdownPromise = (async () => {
1374
- sseCloseAll();
1375
- watcher.close();
1376
- if ("closeAllConnections" in server) server.closeAllConnections();
1377
- await close();
1378
- })();
1379
- return shutdownPromise;
1380
- }
1584
+ let closePromise;
1585
+ const close = () => {
1586
+ closePromise ??= new Promise((resolve, reject) => {
1587
+ server.close((err) => err ? reject(err) : resolve());
1588
+ });
1589
+ return closePromise;
1590
+ };
1591
+ const runShutdown = async () => {
1592
+ const closing = close();
1593
+ sse.shutdown();
1594
+ watcher.close();
1595
+ if ("closeAllConnections" in server) server.closeAllConnections();
1596
+ if ((await withTimeout(closing, shutdownTimeoutMs)).status === "timed-out") logger.warn(`HTTP server did not close within ${shutdownTimeoutMs}ms — giving up and leaving the remaining sockets to the caller.`);
1381
1597
  };
1598
+ let shutdownPromise;
1599
+ return { shutdown() {
1600
+ if (shutdownPromise) return shutdownPromise;
1601
+ const { promise, resolve, reject } = Promise.withResolvers();
1602
+ shutdownPromise = promise;
1603
+ runShutdown().then(resolve, reject);
1604
+ return promise;
1605
+ } };
1382
1606
  }
1383
1607
  //#endregion
1384
1608
  //#region src/index.ts
@@ -1490,13 +1714,14 @@ $ peek README.md --css ./custom.css --no-open`,
1490
1714
  if (open) openBrowser(url);
1491
1715
  outro(pc.dim("Press Ctrl+C to stop"));
1492
1716
  let shuttingDown = false;
1493
- const shutdown = async () => {
1717
+ const shutdown = async (signal) => {
1494
1718
  if (shuttingDown) {
1495
1719
  console.error("\nForce exiting...");
1496
1720
  process.exit(1);
1497
1721
  }
1498
1722
  shuttingDown = true;
1499
1723
  console.log();
1724
+ logger.info(`Received ${signal}, shutting down...`);
1500
1725
  intro(pc.bgYellow(pc.black(" Shutting down... ")));
1501
1726
  try {
1502
1727
  await server.shutdown();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makuja/peek",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Markdown and HTML preview CLI with live reload",
5
5
  "type": "module",
6
6
  "bin": {
@@ -48,13 +48,13 @@
48
48
  "engines": {
49
49
  "node": ">=22.0.0"
50
50
  },
51
- "packageManager": "pnpm@10.33.0",
51
+ "packageManager": "pnpm@10.34.5",
52
52
  "dependencies": {
53
53
  "@clack/prompts": "^1.0.1",
54
54
  "@hono/node-server": "^1.19.9",
55
55
  "@mdit/plugin-tasklist": "^0.23.1",
56
56
  "@shikijs/markdown-it": "^4.0.1",
57
- "gunshi": "^0.29.2",
57
+ "gunshi": "^0.37.0",
58
58
  "hono": "^4.12.3",
59
59
  "ignore": "^7.0.5",
60
60
  "markdown-it": "^14.1.1",
@@ -72,9 +72,9 @@
72
72
  "@tsdown/css": "^0.21.2",
73
73
  "@types/markdown-it": "^14.1.2",
74
74
  "@types/node": "^25.3.3",
75
- "@typescript/native-preview": "7.0.0-dev.20260404.1",
75
+ "@typescript/native-preview": "7.0.0-dev.20260707.2",
76
76
  "@vitest/coverage-v8": "^4.1.1",
77
- "esbuild": "^0.27.3",
77
+ "esbuild": "^0.28.0",
78
78
  "postcss": "^8.5.6",
79
79
  "postcss-cli": "^11.0.1",
80
80
  "semantic-release": "^25.0.3",