@makuja/peek 1.9.1 → 1.11.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 +293 -80
  3. package/package.json +2 -2
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";
@@ -48,9 +48,50 @@ const logger = {
48
48
  error: (...args) => console.error(PREFIX, ...args)
49
49
  };
50
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
51
84
  //#region src/lib/markdown.ts
52
85
  let md = null;
53
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
+ }
54
95
  function initMarkdown() {
55
96
  if (!initPromise) initPromise = (async () => {
56
97
  const instance = createMarkdownItAsync();
@@ -62,6 +103,9 @@ function initMarkdown() {
62
103
  },
63
104
  defaultColor: false
64
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);
65
109
  md = instance;
66
110
  })().catch((e) => {
67
111
  initPromise = null;
@@ -69,16 +113,34 @@ function initMarkdown() {
69
113
  });
70
114
  return initPromise;
71
115
  }
72
- 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) {
73
122
  if (!md) throw new Error("Markdown renderer not initialized. Call initMarkdown() first.");
74
123
  if (content === "") return "";
75
- return md.renderAsync(content);
124
+ const env = { markdownPath };
125
+ return md.renderAsync(content, env);
76
126
  }
77
127
  //#endregion
78
128
  //#region src/lib/node-error.ts
79
129
  function isNodeError(e) {
80
130
  return e instanceof Error && "code" in e && typeof e.code === "string" && typeof e.message === "string";
81
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
+ }
82
144
  //#endregion
83
145
  //#region src/core/result.ts
84
146
  function ok(value) {
@@ -140,6 +202,29 @@ async function resolveStyles(cssOption) {
140
202
  return ok({ contentCss: content_default });
141
203
  }
142
204
  //#endregion
205
+ //#region src/core/path.ts
206
+ function isWithinBase(base, target) {
207
+ const resolvedBase = resolve(base);
208
+ const resolvedTarget = resolve(target);
209
+ const prefix = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
210
+ return resolvedTarget === resolvedBase || resolvedTarget.startsWith(prefix);
211
+ }
212
+ /**
213
+ * Whether `relativePath`, resolved against `base` without touching the file
214
+ * system, stays inside `base`.
215
+ */
216
+ function isRelativePathWithinBase(base, relativePath) {
217
+ return isWithinBase(base, resolve(base, normalize(relativePath)));
218
+ }
219
+ /**
220
+ * Rewrites a relative path taken from the OS (`path.relative`, `fs.watch`, a
221
+ * URL typed on Windows) into a `SlashPath`. On POSIX `\` is an ordinary file
222
+ * name character and is kept.
223
+ */
224
+ function toSlashPath(osPath) {
225
+ return osPath.split(sep).join("/");
226
+ }
227
+ //#endregion
143
228
  //#region src/lib/file-tree.ts
144
229
  const DEFAULT_IGNORE_PATTERNS = [".git/"];
145
230
  async function readGitignore(path) {
@@ -232,11 +317,12 @@ async function processEntries(entries, dir, rootDir, rules, visited) {
232
317
  for (const entry of entries) {
233
318
  const fullPath = join(dir, entry.name);
234
319
  const relPath = relative(rootDir, fullPath);
320
+ const path = toSlashPath(relPath);
235
321
  if (entry.isDirectory()) {
236
322
  if (isPathIgnored(relPath, true, rules)) continue;
237
323
  dirPromises.push(scanDirectory(fullPath, rootDir, rules, visited).then((children) => children.length > 0 ? {
238
324
  name: entry.name,
239
- path: relPath,
325
+ path,
240
326
  type: "directory",
241
327
  children
242
328
  } : null));
@@ -244,7 +330,7 @@ async function processEntries(entries, dir, rootDir, rules, visited) {
244
330
  if (isPathIgnored(relPath, false, rules)) continue;
245
331
  fileNodes.push({
246
332
  name: entry.name,
247
- path: relPath,
333
+ path,
248
334
  type: "file"
249
335
  });
250
336
  }
@@ -390,12 +476,43 @@ const FULLSCREEN_IFRAME_STYLE = {
390
476
  left: "0"
391
477
  };
392
478
  //#endregion
393
- //#region src/core/path.ts
394
- function isWithinBase(base, target) {
395
- const resolvedBase = resolve(base);
396
- const resolvedTarget = resolve(target);
397
- const prefix = resolvedBase.endsWith(sep) ? resolvedBase : resolvedBase + sep;
398
- return resolvedTarget === resolvedBase || resolvedTarget.startsWith(prefix);
479
+ //#region src/lib/real-path.ts
480
+ /**
481
+ * Resolves `relativePath` against `base`, following symlinks, and checks that
482
+ * the real path is still inside the real `base`, so that neither `..` nor a
483
+ * symlink can lead outside of it.
484
+ */
485
+ async function realPathWithinBase(base, relativePath) {
486
+ try {
487
+ const [realBase, realTarget] = await Promise.all([realpath(base), realpath(resolve(base, relativePath))]);
488
+ return isWithinBase(realBase, realTarget) ? ok(realTarget) : err({ type: "outside-base" });
489
+ } catch (e) {
490
+ return err(isNotFoundError(e) ? { type: "not-found" } : {
491
+ type: "io-error",
492
+ cause: e
493
+ });
494
+ }
495
+ }
496
+ //#endregion
497
+ //#region src/server/routes/real-path-error.ts
498
+ /** Maps a failed path lookup to the HTTP response every route returns for it. */
499
+ function realPathErrorResponse(error) {
500
+ switch (error.type) {
501
+ case "outside-base": return {
502
+ status: 403,
503
+ message: "Forbidden"
504
+ };
505
+ case "not-found": return {
506
+ status: 404,
507
+ message: "File not found"
508
+ };
509
+ case "io-error":
510
+ logger.error("Failed to read file:", error.cause);
511
+ return {
512
+ status: 500,
513
+ message: "Failed to read file"
514
+ };
515
+ }
399
516
  }
400
517
  //#endregion
401
518
  //#region src/server/routes/api.tsx
@@ -412,8 +529,7 @@ function resolveAndValidatePath(basePath, query) {
412
529
  status: 400,
413
530
  message: "Missing path parameter"
414
531
  };
415
- const fullPath = resolve(basePath, normalize(query));
416
- if (!isWithinBase(basePath, fullPath)) return {
532
+ if (!isRelativePathWithinBase(basePath, query)) return {
417
533
  ok: false,
418
534
  status: 403,
419
535
  message: "Forbidden"
@@ -428,7 +544,6 @@ function resolveAndValidatePath(basePath, query) {
428
544
  ok: true,
429
545
  value: {
430
546
  relativePath: query,
431
- fullPath,
432
547
  contentType
433
548
  }
434
549
  };
@@ -438,50 +553,31 @@ function createApiRoutes(config) {
438
553
  const fileContentType = config.mode === "file" ? getContentType(config.targetPath) : null;
439
554
  app.get("/api/content", async (c) => {
440
555
  if (config.mode === "file") {
441
- if (fileContentType === "html") return c.html(renderRawHtmlIframe("/api/raw", basename(config.targetPath)));
556
+ if (fileContentType === "html") return c.html(renderRawHtmlIframe(rawFileUrl(basename(config.targetPath)), basename(config.targetPath)));
442
557
  const result = await readTextFile(config.targetPath);
443
558
  if (!result.ok) {
444
559
  if (result.error.type === "file-not-found") return c.text("File not found", 404);
445
560
  logger.error("Failed to read file:", result.error);
446
561
  return c.text("Failed to read file", 500);
447
562
  }
448
- return c.html(await renderMarkdown(result.value));
563
+ return c.html(await renderMarkdown(result.value, basename(config.targetPath)));
449
564
  }
450
565
  const resolved = resolveAndValidatePath(config.targetPath, c.req.query("path"));
451
566
  if (!resolved.ok) return c.text(resolved.message, resolved.status);
452
- const { relativePath, fullPath, contentType } = resolved.value;
453
- if (contentType === "html") return c.html(renderRawHtmlIframe(`/api/raw?path=${encodeURIComponent(relativePath)}`, basename(relativePath)));
454
- const result = await readTextFile(fullPath);
455
- if (!result.ok) {
456
- if (result.error.type === "file-not-found") return c.text("File not found", 404);
457
- logger.error("Failed to read file:", result.error);
458
- return c.text("Failed to read file", 500);
459
- }
460
- return c.html(await renderMarkdown(result.value));
461
- });
462
- app.get("/api/raw", async (c) => {
463
- if (config.mode === "file") {
464
- if (fileContentType !== "html") return c.text("Not found", 404);
465
- const result = await readTextFile(config.targetPath);
466
- if (!result.ok) {
467
- if (result.error.type === "file-not-found") return c.text("File not found", 404);
468
- logger.error("Failed to read file:", result.error);
469
- return c.text("Failed to read file", 500);
470
- }
471
- c.header("X-Content-Type-Options", "nosniff");
472
- return c.html(result.value);
567
+ const { relativePath, contentType } = resolved.value;
568
+ if (contentType === "html") return c.html(renderRawHtmlIframe(rawFileUrl(relativePath), basename(relativePath)));
569
+ const realPath = await realPathWithinBase(config.targetPath, relativePath);
570
+ if (!realPath.ok) {
571
+ const { status, message } = realPathErrorResponse(realPath.error);
572
+ return c.text(message, status);
473
573
  }
474
- const resolved = resolveAndValidatePath(config.targetPath, c.req.query("path"));
475
- if (!resolved.ok) return c.text(resolved.message, resolved.status);
476
- if (resolved.value.contentType !== "html") return c.text("Not found", 404);
477
- const result = await readTextFile(resolved.value.fullPath);
574
+ const result = await readTextFile(realPath.value);
478
575
  if (!result.ok) {
479
576
  if (result.error.type === "file-not-found") return c.text("File not found", 404);
480
577
  logger.error("Failed to read file:", result.error);
481
578
  return c.text("Failed to read file", 500);
482
579
  }
483
- c.header("X-Content-Type-Options", "nosniff");
484
- return c.html(result.value);
580
+ return c.html(await renderMarkdown(result.value, relativePath));
485
581
  });
486
582
  app.get("/api/tree", async (c) => {
487
583
  if (config.mode === "file") return c.json([]);
@@ -514,12 +610,12 @@ function MarkdownContent({ htmlContent }) {
514
610
  }
515
611
  //#endregion
516
612
  //#region src/components/content-view.tsx
517
- function ContentView({ contentType, fileTitle, rawUrl, htmlContent, htmlReloadKey, markdownClass = "px-5 sm:px-10 py-5 sm:py-10" }) {
613
+ function ContentView({ contentType, fileTitle, filePath, htmlContent, htmlReloadKey, markdownClass = "px-5 sm:px-10 py-5 sm:py-10" }) {
518
614
  if (contentType === "html") return /* @__PURE__ */ jsx(MainContent, {
519
615
  class: "relative flex-1 overflow-hidden",
520
616
  children: /* @__PURE__ */ jsx("iframe", {
521
617
  title: fileTitle,
522
- src: rawUrl,
618
+ src: rawFileUrl(filePath),
523
619
  style: FULLSCREEN_IFRAME_STYLE
524
620
  }, htmlReloadKey)
525
621
  });
@@ -783,7 +879,7 @@ function PageHeader({ id, breadcrumbs, showSidebarToggle, onToggleSidebar, exter
783
879
  //#region src/components/navigation/file-tree-items.tsx
784
880
  const MAX_DEPTH = 20;
785
881
  function DirectoryItem({ node, currentPath, depth, isOpen, onToggle }) {
786
- const open = isOpen ? isOpen(node.path) : true;
882
+ const open = isOpen(node.path);
787
883
  return /* @__PURE__ */ jsxs("li", {
788
884
  class: depth === 0 ? "px-2 lg:px-5" : "",
789
885
  children: [/* @__PURE__ */ jsxs("button", {
@@ -797,7 +893,7 @@ function DirectoryItem({ node, currentPath, depth, isOpen, onToggle }) {
797
893
  class: "min-w-0 truncate",
798
894
  children: node.name
799
895
  }),
800
- /* @__PURE__ */ jsx(ChevronDownIcon, { class: `${open ? "" : "-rotate-180 "}shrink-0 size-3.5 ms-auto transition-transform` })
896
+ /* @__PURE__ */ jsx(ChevronDownIcon, { class: `${open ? "" : "-rotate-90 "}shrink-0 size-3.5 ms-auto transition-transform` })
801
897
  ]
802
898
  }), open && /* @__PURE__ */ jsx("ul", {
803
899
  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",
@@ -912,6 +1008,36 @@ function Sidebar({ title, tree, currentPath, onClose, isOpen, onToggle, searchQu
912
1008
  })] });
913
1009
  }
914
1010
  //#endregion
1011
+ //#region src/core/file-tree.ts
1012
+ /**
1013
+ * Paths of the directories in the tree that contain `targetPath`, outermost
1014
+ * first. `targetPath` itself need not be in the tree: a file excluded by
1015
+ * `.gitignore` can still be displayed, and its directories are found.
1016
+ */
1017
+ function findAncestorPaths(nodes, targetPath) {
1018
+ for (const node of nodes) {
1019
+ if (node.type !== "directory") continue;
1020
+ if (targetPath.startsWith(`${node.path}/`)) return [node.path, ...findAncestorPaths(node.children ?? [], targetPath)];
1021
+ }
1022
+ return [];
1023
+ }
1024
+ //#endregion
1025
+ //#region src/core/file-tree-open-state.ts
1026
+ /**
1027
+ * State before any persisted state is known: only the ancestors of the
1028
+ * displayed file are open. Shared by SSR and the first client render so that
1029
+ * hydration sees identical markup.
1030
+ */
1031
+ function initialOpenState(tree, currentPath) {
1032
+ return {
1033
+ expanded: /* @__PURE__ */ new Set(),
1034
+ revealed: new Set(findAncestorPaths(tree, currentPath))
1035
+ };
1036
+ }
1037
+ function isDirectoryOpen(state, path) {
1038
+ return state.expanded.has(path) || state.revealed.has(path);
1039
+ }
1040
+ //#endregion
915
1041
  //#region src/lib/project-id.ts
916
1042
  /**
917
1043
  * Create a stable, short project identifier from an absolute path.
@@ -928,10 +1054,10 @@ function createProjectId(absolutePath) {
928
1054
  }
929
1055
  //#endregion
930
1056
  //#region src/server/renderer/client-bundle.js
931
- const clientBundle = "\"use strict\";(()=>{var G,h,Je,Wt,N,Ye,Ze,Ge,_e,Y,z,et,me,pe,fe,Kt,Q={},J=[],Vt=/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 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?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 X(e,l,r,s,null)}function X(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??++Je,__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 Xt(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),ye(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,it(r,o,s),t.__e=t.__=null,o.__e!=n&&tt(o)}}function tt(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}),tt(e)}function Xe(e){(!e.__d&&(e.__d=!0)&&N.push(e)&&!Z.__r++||Ye!=h.debounceRendering)&&((Ye=h.debounceRendering)||Ze)(Z)}function Z(){try{for(var e,t=1;N.length;)N.length>t&&N.sort(Ge),e=N.shift(),t=N.length,Xt(e)}finally{N.length=Z.__r=0}}function nt(e,t,n,r,s,o,l,u,d,c,_){var f,a,p,y,w,x,g,m=r&&r.__k||J,T=t.length;for(d=qt(n,t,m,d,T),f=0;f<T;f++)(p=n.__k[f])!=null&&(a=p.__i!=-1&&m[p.__i]||Q,p.__i=f,x=ye(e,p,a,s,o,l,u,d,c,_),y=p.__e,p.ref&&a.ref!=p.ref&&(a.ref&&ge(a.ref,null,p),_.push(p.ref,p.__c||y,p)),w==null&&y!=null&&(w=y),(g=!!(4&p.__u))||a.__k===p.__k?(d=rt(p,d,e,g),g&&a.__e&&(a.__e=null)):typeof p.type==\"function\"&&x!==void 0?d=x:y&&(d=y.nextSibling),p.__u&=-7);return n.__e=w,d}function qt(e,t,n,r,s){var o,l,u,d,c,_=n.length,f=_,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]=X(null,l,null,null,null):ee(l)?l=e.__k[o]=X(k,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=X(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=Qt(l,n,d,f))!=-1&&(f--,(u=n[c])&&(u.__u|=2)),u==null||u.__v==null?(c==-1&&(s>_?a--:s<_&&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<_;o++)(u=n[o])!=null&&(2&u.__u)==0&&(u.__e==r&&(r=U(u)),lt(u,u));return r}function rt(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=rt(s[o],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=U(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 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(et,\"$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:pe,o)):e.removeEventListener(t,o?fe:pe,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 Qe(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[Y]==null)t[Y]=me++;else if(t[Y]<n[z])return;return n(h.event?h.event(t):t)}}}function ye(e,t,n,r,s,o,l,u,d,c){var _,f,a,p,y,w,x,g,m,T,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]),(_=h.__b)&&_(t);e:if(typeof C==\"function\"){f=l.length;try{if(m=t.props,T=C.prototype&&C.prototype.render,R=(_=C.contextType)&&r[_.__c],I=_?R?R.props.value:_.__:r,n.__c?g=(a=t.__c=n.__c).__=a.__E:(T?t.__c=a=new C(m,I):(t.__c=a=new q(m,I),a.constructor=C,a.render=Zt),R&&R.sub(a),a.state||(a.state={}),a.__n=r,p=a.__d=!0,a.__h=[],a._sb=[]),T&&a.__s==null&&(a.__s=a.state),T&&C.getDerivedStateFromProps!=null&&(a.__s==a.state&&(a.__s=M({},a.__s)),M(a.__s,C.getDerivedStateFromProps(m,a.__s))),y=a.props,w=a.state,a.__v=t,p)T&&C.getDerivedStateFromProps==null&&a.componentWillMount!=null&&a.componentWillMount(),T&&a.componentDidMount!=null&&a.__h.push(a.componentDidMount);else{if(T&&C.getDerivedStateFromProps==null&&m!==y&&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);break e}a.componentWillUpdate!=null&&a.componentWillUpdate(m,a.__s,I),T&&a.componentDidUpdate!=null&&a.__h.push(function(){a.componentDidUpdate(y,w,x)})}if(a.context=I,a.props=m,a.__P=e,a.__e=!1,B=h.__r,$=0,T)a.state=a.__s,a.__d=!1,B&&B(t),_=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),_=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())),T&&!p&&a.getSnapshotBeforeUpdate!=null&&(x=a.getSnapshotBeforeUpdate(y,w)),D=_!=null&&_.type===k&&_.key==null?st(_.props.children):_,u=nt(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),g&&(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||ot(t),h.__e(A,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(_=h.diffed)&&_(t),128&t.__u?void 0:u}function ot(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(ot))}function it(e,t,n){for(var r=0;r<n.length;r++)ge(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 st(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ee(e)?e.map(st):e.constructor!==void 0?null:M({},e)}function Jt(e,t,n,r,s,o,l,u,d){var c,_,f,a,p,y,w,x=n.props||Q,g=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(g);e=document.createElementNS(s,m,g.is&&g),u&&(h.__m&&h.__m(t,o),u=!1),o=null}if(m==null)x===g||u&&e.data==g||(e.data=g);else{if(o=m==\"textarea\"&&g.defaultValue!=null?null:o&&G.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\"?f=p:c==\"children\"||c in g||c==\"value\"&&\"defaultValue\"in g||c==\"checked\"&&\"defaultChecked\"in g||V(e,c,null,p,s);for(c in g)p=g[c],c==\"children\"?a=p:c==\"dangerouslySetInnerHTML\"?_=p:c==\"value\"?y=p:c==\"checked\"?w=p:u&&typeof p!=\"function\"||x[c]===p||V(e,c,p,x[c],s);if(_)u||f&&(_.__html==f.__html||_.__html==e.innerHTML)||(e.innerHTML=_.__html),t.__k=[];else if(f&&(e.innerHTML=\"\"),nt(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\"&&y==null?e.removeAttribute(\"value\"):y!=null&&(y!==e[c]||m==\"progress\"&&!y||m==\"option\"&&y!=x[c])&&V(e,c,y,x[c],s),c=\"checked\",w!=null&&w!=e[c]&&V(e,c,w,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){h.__e(s,n)}}function lt(e,t,n){var r,s;if(h.unmount&&h.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){h.__e(o,t)}r.base=r.__P=r.__n=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),h.__&&h.__(e,t),s=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],l=[],ye(t,e=(!r&&n||t).__k=Yt(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),it(o,e,l),e.props.children=null}function te(e,t){Gt(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}},Je=0,Wt=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),Xe(this))},q.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Xe(this))},q.prototype.render=k,N=[],Ze=typeof Promise==\"function\"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ge=function(e,t){return e.__v.__b-t.__v.__b},Z.__r=0,_e=Math.random().toString(8),Y=\"__d\"+_e,z=\"__a\"+_e,et=/(PointerCapture)$|Capture$/i,me=0,pe=Qe(!1),fe=Qe(!0),Kt=0;var O,v,ve,at,j=0,ht=[],b=h,ct=b.__b,ut=b.__r,dt=b.diffed,_t=b.__c,pt=b.unmount,ft=b.__;function re(e,t){b.__h&&b.__h(v,e,j||t),j=0;var n=v.__H||(v.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function E(e){return j=1,en(yt,e)}function en(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=v,!v.__f)){var s=function(u,d,c){if(!r.__c.__H)return!0;var _=!1,f=r.__c.props!==u;if(r.__c.__H.__.some(function(p){if(p.__N){_=!0;var y=p.__[0];p.__=p.__N,p.__N=void 0,y!==p.__[0]&&(f=!0)}}),o){var a=o.call(this,u,d,c);return _?a||f:a}return!_||f};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 H(e,t){var n=re(O++,3);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,v.__H.__h.push(n))}function oe(e,t){var n=re(O++,4);!b.__s&&Se(n.__H,t)&&(n.__=e,n.u=t,v.__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 tn(){for(var e;e=ht.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){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),O=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(ne),t.__h.some(be),t.__h=[],O=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(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){pt&&pt(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 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 ne(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 h.vnode&&h.vnode(c),c}function xe({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 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(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 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(k,{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(k,{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(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(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=P(!0),s=P(t);s.current=t;function o(){try{return Ft(localStorage.getItem(Ne))}catch{return{}}}function l(c){try{localStorage.setItem(Ne,Mt(c))}catch{}}oe(()=>{if(!r.current)return;r.current=!1;let c=Date.now(),_=At(o(),c,2592e6),f=Be(_,e,He(_,e),c);l(f),n(He(f,e))},[e]);let u=L(c=>{let _=new Set(s.current);_.has(c)?_.delete(c):_.add(c),s.current=_,n(_);let f=Be(o(),e,_,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 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 K(e){return e&&e.replace(/\\\\/g,\"/\")}function le(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function Nt(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 _=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){H(()=>{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 ae=\"sidebar-open\",Bt=\"sidebar-width\",De=200,Ue=480,pn=1024;function ce(){return window.innerWidth>=pn}function Dt(){let[e,t]=E(!1),n=P(!0);oe(()=>{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(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 _(a){let p=Math.min(Math.max(a.clientX,De),Ue);document.documentElement.style.setProperty(\"--sidebar-width\",`${p}px`)}function f(a){if(l.releasePointerCapture(a.pointerId),l.removeEventListener(\"pointermove\",_),l.removeEventListener(\"pointerup\",f),l.removeEventListener(\"pointercancel\",f),document.body.style.removeProperty(\"user-select\"),c?.style.removeProperty(\"transition\"),a.type===\"pointerup\"){let p=Math.min(Math.max(a.clientX,De),Ue);localStorage.setItem(Bt,String(p))}}l.addEventListener(\"pointermove\",_),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 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?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){$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 ue(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:s,onTreeUpdate:o}=e;H(()=>{let l=null,u=null,d=Ut({onFileChanged:c=>{if(n){if(c===null)return;let _=n();if(K(c)!==K(_))return;if(r?.()===\"html\"){s?.();return}l?.abort(),l=new AbortController,W(_,{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(_=>{_!==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),[_,f]=E(s),[a,p]=E(o),[y,w]=E(\"\"),[x,g]=E(0),m=P(l);m.current=l;let T=Dt(),R=Lt(e),I=y.trim()!==\"\",B=ie(()=>It(a,y),[a,y]);Ht(T.open),Nt((F,C)=>{let A=Et(F);if(!A){console.error(`Unexpected unsupported file type: ${F}`);return}m.current=F,u(F),c(A),f(C),g(0)});let $=P(d);$.current=d,ue({getCurrentPath:()=>m.current,getCurrentContentType:()=>$.current,onContentUpdate:f,onHtmlReload:()=>g(F=>F+1),onTreeUpdate:p});let D=le(l);return i(k,{children:[i(kt,{title:t,tree:B,currentPath:l,onClose:T.close,isOpen:I?()=>!0:R.isOpen,onToggle:I?void 0:R.toggle,searchQuery:y,onSearchChange:w,isSearching:I}),i(Tt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:D}],showSidebarToggle:!0,onToggleSidebar:T.toggle,externalLinkHref:`/${l.split(\"/\").map(encodeURIComponent).join(\"/\")}`}),i(vt,{contentType:d,fileTitle:D,rawUrl:`/api/raw?path=${encodeURIComponent(l)}`,htmlContent:_,htmlReloadKey:x})]})}function $t({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 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 de=window.__INITIAL_STATE__,Ve=document.getElementById(\"app\");Ve&&de?de.mode===\"directory\"?te(i(Ot,{...de}),Ve):te(i($t,{...de}),Ve):console.error(\"[peek] hydration failed: missing #app or initial state\");jt();})();\n";
1057
+ const clientBundle = "\"use strict\";(()=>{var G,y,Ze,Jt,N,Ye,Ge,et,pe,X,$,tt,he,_e,fe,Zt,Q={},J=[],Gt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ee=Array.isArray;function R(e,t){for(var n in t)e[n]=t[n];return e}function me(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function en(e,t,n){var r,a,o,s={};for(o in t)o==\"key\"?r=t[o]:o==\"ref\"?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?G.call(arguments,2):n),typeof e==\"function\"&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return Y(e,s,r,a,null)}function Y(e,t,n,r,a){var o={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:a??++Ze,__i:-1,__u:0};return a==null&&y.vnode!=null&&y.vnode(o),o}function P(e){return e.children}function q(e,t){this.props=e,this.context=t}function O(e,t){if(t==null)return e.__?O(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\"?O(e):null}function tn(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],a=[],o=R({},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??O(t),!!(32&t.__u),a),o.__v=t.__v,o.__.__k[o.__i]=o,at(r,o,a),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!=y.debounceRendering)&&((Ye=y.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,tn(e)}finally{N.length=Z.__r=0}}function rt(e,t,n,r,a,o,s,c,u,d,p){var h,l,_,f,x,g,S=r&&r.__k||J,m=t.length;for(u=nn(n,t,S,u,m),h=0;h<m;h++)(_=n.__k[h])!=null&&(l=_.__i!=-1&&S[_.__i]||Q,_.__i=h,g=ye(e,_,l,a,o,s,c,u,d,p),f=_.__e,_.ref&&l.ref!=_.ref&&(l.ref&&ge(l.ref,null,_),p.push(_.ref,_.__c||f,_)),x==null&&f!=null&&(x=f),4&_.__u?(u=ot(_,u,e),l.__e&&(l.__e=null)):typeof _.type==\"function\"&&g!==void 0?u=g:f&&(u=f.nextSibling),_.__u&=-7);return n.__e=x,u}function nn(e,t,n,r,a){var o,s,c,u,d,p=n.length,h=p,l=0;for(e.__k=new Array(a),o=0;o<a;o++)(s=t[o])!=null&&typeof s!=\"boolean\"&&typeof s!=\"function\"?(typeof s==\"string\"||typeof s==\"number\"||typeof s==\"bigint\"||s.constructor==String?s=e.__k[o]=Y(null,s,null,null,null):ee(s)?s=e.__k[o]=Y(P,{children:s},null,null,null):s.constructor===void 0&&s.__b>0?s=e.__k[o]=Y(s.type,s.props,s.key,s.ref?s.ref:null,s.__v):e.__k[o]=s,u=o+l,s.__=e,s.__b=e.__b+1,c=null,(d=s.__i=rn(s,n,u,h))!=-1&&(h--,(c=n[d])&&(c.__u|=2)),c==null||c.__v==null?(d==-1&&(a>p?l--:a<p&&l++),typeof s.type!=\"function\"&&(s.__u|=4)):d!=u&&(d==u-1?l--:d==u+1?l++:(d>u?l--:l++,s.__u|=4))):e.__k[o]=null;if(h)for(o=0;o<p;o++)(c=n[o])!=null&&(2&c.__u)==0&&(c.__e==r&&(r=O(c)),lt(c,c));return r}function ot(e,t,n){var r,a;if(typeof e.type==\"function\"){for(r=e.__k,a=0;r&&a<r.length;a++)r[a]&&(r[a].__=e,t=ot(r[a],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=O(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function rn(e,t,n,r){var a,o,s,c=e.key,u=e.type,d=t[n],p=d!=null&&(2&d.__u)==0;if(d===null&&c==null||p&&c==d.key&&u==d.type)return n;if(r>(p?1:0)){for(a=n-1,o=n+1;a>=0||o<t.length;)if((d=t[s=a>=0?a--:o++])!=null&&(2&d.__u)==0&&c==d.key&&u==d.type)return s}return-1}function Qe(e,t,n){t[0]==\"-\"?e.setProperty(t,n??\"\"):e[t]=n==null?\"\":typeof n!=\"number\"||Gt.test(t)?n:n+\"px\"}function V(e,t,n,r,a){var o,s;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\")),s=t.toLowerCase(),t=s in e||t==\"onFocusOut\"||t==\"onFocusIn\"?s.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+o]=n,n?r?n[$]=r[$]:(n[$]=he,e.addEventListener(t,o?fe:_e,o)):e.removeEventListener(t,o?fe:_e,o);else{if(a==\"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]=he++;else if(t[X]<n[$])return;return n(y.event?y.event(t):t)}}}function ye(e,t,n,r,a,o,s,c,u,d){var p,h,l,_,f,x,g,S,m,w,M,I,H,j,B,F,E=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(u=!!(32&n.__u),o=[c=t.__e=n.__e]),(p=y.__b)&&p(t);e:if(typeof E==\"function\"){h=s.length;try{if(m=t.props,w=E.prototype&&E.prototype.render,M=(p=E.contextType)&&r[p.__c],I=p?M?M.props.value:p.__:r,n.__c?S=(l=t.__c=n.__c).__=l.__E:(w?t.__c=l=new E(m,I):(t.__c=l=new q(m,I),l.constructor=E,l.render=an),M&&M.sub(l),l.state||(l.state={}),l.__n=r,_=l.__d=!0,l.__h=[],l._sb=[]),w&&l.__s==null&&(l.__s=l.state),w&&E.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=R({},l.__s)),R(l.__s,E.getDerivedStateFromProps(m,l.__s))),f=l.props,x=l.state,l.__v=t,_)w&&E.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),w&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(w&&E.getDerivedStateFromProps==null&&m!==f&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(m,I),t.__v==n.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(m,l.__s,I)===!1){t.__v!=n.__v&&(l.props=m,l.state=l.__s,l.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(L){L&&(L.__=t)}),J.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&s.push(l),c=O(n);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(m,l.__s,I),w&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(f,x,g)})}if(l.context=I,l.props=m,l.__P=e,l.__e=!1,H=y.__r,j=0,w)l.state=l.__s,l.__d=!1,H&&H(t),p=l.render(l.props,l.state,l.context),J.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,H&&H(t),p=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++j<25);l.state=l.__s,l.getChildContext!=null&&(r=R(R({},r),l.getChildContext())),w&&!_&&l.getSnapshotBeforeUpdate!=null&&(g=l.getSnapshotBeforeUpdate(f,x)),B=p!=null&&p.type===P&&p.key==null?st(p.props.children):p,c=rt(e,ee(B)?B:[B],t,n,r,a,o,s,c,u,d),l.base=t.__e,t.__u&=-161,l.__h.length&&s.push(l),S&&(l.__E=l.__=null)}catch(L){if(s.length=h,t.__v=null,u||o!=null){if(L.then){for(t.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o!=null&&(o[o.indexOf(c)]=null),t.__e=c}else if(o!=null)for(F=o.length;F--;)me(o[F])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),L.then||it(t),y.__e(L,t,n)}}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=on(n.__e,t,n,r,a,o,s,u,d);return(p=y.diffed)&&p(t),128&t.__u?void 0:c}function it(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(it))}function at(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(a){try{e=a.__h,a.__h=[],e.some(function(o){o.call(a)})}catch(o){y.__e(o,a.__v)}})}function st(e){return typeof e!=\"object\"||e==null||e.__b>0?e:ee(e)?e.map(st):e.constructor!==void 0?null:R({},e)}function on(e,t,n,r,a,o,s,c,u){var d,p,h,l,_,f,x,g=n.props||Q,S=t.props,m=t.type;if(m==\"svg\"?a=\"http://www.w3.org/2000/svg\":m==\"math\"?a=\"http://www.w3.org/1998/Math/MathML\":a||(a=\"http://www.w3.org/1999/xhtml\"),o!=null){for(d=0;d<o.length;d++)if((_=o[d])&&\"setAttribute\"in _==!!m&&(m?_.localName==m:_.nodeType==3)){e=_,o[d]=null;break}}if(e==null){if(m==null)return document.createTextNode(S);e=document.createElementNS(a,m,S.is&&S),c&&(y.__m&&y.__m(t,o),c=!1),o=null}if(m==null)g===S||c&&e.data==S||(e.data=S);else{if(o=m==\"textarea\"&&S.defaultValue!=null?null:o&&G.call(e.childNodes),!c&&o!=null)for(g={},d=0;d<e.attributes.length;d++)g[(_=e.attributes[d]).name]=_.value;for(d in g)_=g[d],d==\"dangerouslySetInnerHTML\"?h=_:d==\"children\"||d in S||d==\"value\"&&\"defaultValue\"in S||d==\"checked\"&&\"defaultChecked\"in S||V(e,d,null,_,a);for(d in S)_=S[d],d==\"children\"?l=_:d==\"dangerouslySetInnerHTML\"?p=_:d==\"value\"?f=_:d==\"checked\"?x=_:c&&typeof _!=\"function\"||g[d]===_||V(e,d,_,g[d],a);if(p)c||h&&(p.__html==h.__html||p.__html==e.innerHTML)||(e.innerHTML=p.__html),t.__k=[];else if(h&&(e.innerHTML=\"\"),rt(t.type==\"template\"?e.content:e,ee(l)?l:[l],t,n,r,m==\"foreignObject\"?\"http://www.w3.org/1999/xhtml\":a,o,s,o?o[0]:n.__k&&O(n,0),c,u),o!=null)for(d=o.length;d--;)me(o[d]);c&&m!=\"textarea\"||(d=\"value\",m==\"progress\"&&f==null?e.removeAttribute(\"value\"):f!=null&&(f!==e[d]||m==\"progress\"&&!f||m==\"option\"&&f!=g[d])&&V(e,d,f,g[d],a),d=\"checked\",x!=null&&x!=e[d]&&V(e,d,x,g[d],a))}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(a){y.__e(a,n)}}function lt(e,t,n){var r,a;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=r.__n=null}if(r=e.__k)for(a=0;a<r.length;a++)r[a]&&lt(r[a],t,n||typeof e.type!=\"function\");n||me(e.__e),e.__c=e.__=e.__e=void 0}function an(e,t,n){return this.constructor(e,n)}function sn(e,t,n){var r,a,o,s;t==document&&(t=document.documentElement),y.__&&y.__(e,t),a=(r=typeof n==\"function\")?null:n&&n.__k||t.__k,o=[],s=[],ye(t,e=(!r&&n||t).__k=en(P,null,[e]),a||Q,Q,t.namespaceURI,!r&&n?[n]:a?null:t.firstChild?G.call(t.childNodes):null,o,!r&&n?n:a?a.__e:t.firstChild,r,s),at(o,e,s),e.props.children=null}function te(e,t){sn(e,t,te)}G=J.slice,y={__e:function(e,t,n,r){for(var a,o,s;t=t.__;)if((a=t.__c)&&!a.__)try{if((o=a.constructor)&&o.getDerivedStateFromError!=null&&(a.setState(o.getDerivedStateFromError(e)),s=a.__d),a.componentDidCatch!=null&&(a.componentDidCatch(e,r||{}),s=a.__d),s)return a.__E=a}catch(c){e=c}throw e}},Ze=0,Jt=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=R({},this.state),typeof e==\"function\"&&(e=e(R({},n),this.props)),e&&R(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=P,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,$=\"__a\"+pe,tt=/(PointerCapture)$|Capture$/i,he=0,_e=Je(!1),fe=Je(!0),Zt=0;var U,v,ve,ct,W=0,yt=[],b=y,dt=b.__b,ut=b.__r,pt=b.diffed,_t=b.__c,ft=b.unmount,ht=b.__;function re(e,t){b.__h&&b.__h(v,e,W||t),W=0;var n=v.__H||(v.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function k(e){return W=1,ln(gt,e)}function ln(e,t,n){var r=re(U++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):gt(void 0,t),function(c){var u=r.__N?r.__N[0]:r.__[0],d=r.t(u,c);u!==d&&(r.__N=[d,r.__[1]],r.__c.setState({}))}],r.__c=v,!v.__f)){var a=function(c,u,d){if(!r.__c.__H)return!0;var p=!1,h=r.__c.props!==c;if(r.__c.__H.__.some(function(_){if(_.__N){p=!0;var f=_.__[0];_.__=_.__N,_.__N=void 0,f!==_.__[0]&&(h=!0)}}),o){var l=o.call(this,c,u,d);return p?l||h:l}return!p||h};v.__f=!0;var o=v.shouldComponentUpdate,s=v.componentWillUpdate;v.componentWillUpdate=function(c,u,d){if(this.__e){var p=o;o=void 0,a(c,u,d),o=p}s&&s.call(this,c,u,d)},v.shouldComponentUpdate=a}return r.__N||r.__}function D(e,t){var n=re(U++,3);!b.__s&&be(n.__H,t)&&(n.__=e,n.u=t,v.__H.__h.push(n))}function oe(e,t){var n=re(U++,4);!b.__s&&be(n.__H,t)&&(n.__=e,n.u=t,v.__h.push(n))}function C(e){return W=5,ie(function(){return{current:e}},[])}function ie(e,t){var n=re(U++,7);return be(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function A(e,t){return W=8,ie(function(){return e},t)}function cn(){for(var e;e=yt.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(ne),t.__h.some(Se),t.__h=[]}catch(n){t.__h=[],b.__e(n,e.__v)}}}b.__b=function(e){v=null,dt&&dt(e)},b.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),ht&&ht(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(ne),t.__h.some(Se),t.__h=[],U=0)),ve=v},b.diffed=function(e){pt&&pt(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(yt.push(t)!==1&&ct===b.requestAnimationFrame||((ct=b.requestAnimationFrame)||dn)(cn)),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(ne),n.__h=n.__h.filter(function(r){return!r.__||Se(r)})}catch(r){t.some(function(a){a.__h&&(a.__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(a){t=a}}),n.__H=void 0,t&&b.__e(t,n.__v))};var mt=typeof requestAnimationFrame==\"function\";function dn(e){var t,n=function(){clearTimeout(r),mt&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);mt&&(t=requestAnimationFrame(n))}function ne(e){var t=v,n=e.__c;typeof n==\"function\"&&(e.__c=void 0,n()),v=t}function Se(e){var t=v;e.__c=e.__(),v=t}function be(e,t){return!e||e.length!==t.length||t.some(function(n,r){return n!==e[r]})}function gt(e,t){return typeof t==\"function\"?t(e):t}var vt={border:\"none\",width:\"100%\",height:\"100%\",position:\"absolute\",top:\"0\",left:\"0\"};var un=\"/__peek/raw/\";function xe(e){return e.split(\"/\").map(encodeURIComponent).join(\"/\")}function St(e){return`${un}${xe(e)}`}var pn=0;function i(e,t,n,r,a,o){t||(t={});var s,c,u=t;if(\"ref\"in u)for(c in u={},t)c==\"ref\"?s=t[c]:u[c]=t[c];var d={type:e,props:u,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--pn,__i:-1,__u:0,__source:a,__self:o};if(typeof e==\"function\"&&(s=e.defaultProps))for(c in s)u[c]===void 0&&(u[c]=s[c]);return y.vnode&&y.vnode(d),d}function Te({class:e,children:t}){return i(\"main\",{id:\"main-content\",class:e??\"\",children:t})}function ae({htmlContent:e}){return i(\"div\",{id:\"markdown-content\",class:\"markdown-body\",dangerouslySetInnerHTML:{__html:e}})}function bt({contentType:e,fileTitle:t,filePath:n,htmlContent:r,htmlReloadKey:a,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:St(n),style:vt},a)}):i(Te,{class:o,children:i(\"div\",{class:\"max-w-4xl mx-auto\",children:i(ae,{htmlContent:r})})})}function T({class:e,children:t,width:n=\"24\",height:r=\"24\",viewBox:a=\"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:a,fill:\"none\",stroke:\"currentColor\",\"stroke-width\":\"2\",\"stroke-linecap\":\"round\",\"stroke-linejoin\":\"round\",children:t})}function we(e){return i(T,{...e,children:i(\"path\",{d:\"m6 9 6 6 6-6\"})})}function Pe({class:e}){return i(T,{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(T,{...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(T,{...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(T,{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(T,{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(T,{class:e,...t,children:i(\"path\",{d:\"M17 8L21 12L17 16M3 12H13M3 6H13M3 18H13\"})})}function Ae(e){return i(T,{...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(T,{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(T,{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\"},_n=\"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(P,{children:[i(\"a\",{class:Re.dirLink,href:t.href??\"#\",children:t.label}),i(Ae,{class:_n})]})},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(Pe,{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(Ce,{class:\"hidden size-4\",id:\"icon-theme-dark\"}),i(Le,{class:\"hidden size-4\",id:\"icon-theme-system\"})]})}function Pt({id:e,breadcrumbs:t,showSidebarToggle:n,onToggleSidebar:r,externalLinkHref:a}){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(Ie,{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,{}),a!==void 0&&i(Tt,{href:a})]})]})})}var fn=20;function hn({node:e,currentPath:t,depth:n,isOpen:r,onToggle:a}){let o=r(e.path);return i(\"li\",{class:n===0?\"px-2 lg:px-5\":\"\",children:[i(\"button\",{type:\"button\",\"aria-expanded\":o,onClick:()=>a?.(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(we,{class:`${o?\"\":\"-rotate-90 \"}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<fn?i(Ne,{nodes:e.children,currentPath:t,depth:n+1,isOpen:r,onToggle:a}):null})]})}function Ne({nodes:e,currentPath:t,depth:n=0,isOpen:r,onToggle:a}){return i(P,{children:e.map(o=>{if(o.type===\"directory\")return i(hn,{node:o,currentPath:t,depth:n,isOpen:r,onToggle:a},o.path);let s=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 ${s?\"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 kt({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 Et({title:e,tree:t,currentPath:n,onClose:r,isOpen:a,onToggle:o,searchQuery:s,onSearchChange:c,isSearching:u}){return i(P,{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:s??\"\",onInput:d=>c?.(d.target.value),onKeyDown:d=>{d.key===\"Escape\"&&!d.isComposing&&(c?.(\"\"),d.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:u&&t.length===0?i(\"p\",{class:\"px-5 py-3 text-sm text-sidebar-foreground/60\",children:\"No matches found\"}):i(kt,{nodes:t,currentPath:n,isOpen:a,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 mn=new Map([[\".md\",\"markdown\"],[\".html\",\"html\"],[\".htm\",\"html\"]]);function yn(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 Ct(e){return mn.get(yn(e))??null}function It(e,t){return e.name.toLowerCase().includes(t)}function z(e,t){for(let n of e)if(n.type===\"directory\"&&t.startsWith(`${n.path}/`))return[n.path,...z(n.children??[],t)];return[]}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(It(r,t)){n.push(r);continue}let a=r.children?At(r.children,t):[];a.length>0&&n.push({...r,children:a});continue}It(r,t)&&n.push(r)}return n}function Lt(e,t){return{expanded:new Set,revealed:new Set(z(e,t))}}function De(e,t){return e.expanded.has(t)||e.revealed.has(t)}function Rt(e,t,n){return De(e,n)?{expanded:Mt(e.expanded,n),revealed:Mt(e.revealed,n)}:{expanded:new Set([...e.expanded,...z(t,n),n]),revealed:e.revealed}}function Nt(e,t,n){return{expanded:e.expanded,revealed:new Set([...e.revealed,...z(t,n)])}}function Mt(e,t){let n=new Set(e);return n.delete(t),n}var He=\"file-tree-state\";function Dt(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!=\"object\"||Array.isArray(t))return{};let n={};for(let[r,a]of Object.entries(t)){if(!a||typeof a!=\"object\"||Array.isArray(a))continue;let{expanded:o,lastAccess:s}=a;typeof s!=\"number\"||!Array.isArray(o)||(n[r]={expanded:o.filter(c=>typeof c==\"string\"),lastAccess:s})}return n}catch{return{}}}function Ht(e,t,n){let r={};for(let[a,o]of Object.entries(e))t-o.lastAccess<=n&&(r[a]=o);return r}function Bt(e,t){return new Set(e[t]?.expanded??[])}function Be(e,t,n,r){return{...e,[t]:{expanded:Array.from(n),lastAccess:r}}}function Ot(e){return JSON.stringify(e)}function Ut(e,t,n){let[r,a]=k(()=>Lt(t,n)),o=C(!0),s=C(t);s.current=t;let c=C(r);c.current=r;function u(f){c.current=f,a(f)}function d(){try{return Dt(localStorage.getItem(He))}catch{return{}}}function p(f){try{localStorage.setItem(He,Ot(f))}catch{}}oe(()=>{if(!o.current)return;o.current=!1;let f=Date.now(),x=Ht(d(),f,2592e6),g=Bt(x,e);p(Be(x,e,g,f)),u({...c.current,expanded:g})},[e]);let h=A(f=>{let x=Rt(c.current,s.current,f);u(x),p(Be(d(),e,x.expanded,Date.now()))},[e]),l=A(f=>{u(Nt(c.current,s.current,f))},[]);return{isOpen:A(f=>De(r,f),[r]),toggle:h,reveal:l}}async function K(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 jt(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 se(e){let n=e.replace(/\\/+$/,\"\").split(\"/\");return n[n.length-1]||e}function $t(e){let t=C(null),n=C(e);n.current=e;let r=A(async(a,o)=>{t.current&&t.current.abort();let s=new AbortController;t.current=s;try{let c=await K(a,{signal:s.signal});if(c===null)return;n.current(a,c),document.title=`${se(a)} - peek`;let u=`/view?path=${encodeURIComponent(a)}`;o&&history.pushState({path:a},\"\",u)}catch(c){if(c instanceof DOMException&&c.name===\"AbortError\")return;console.error(\"[peek] Failed to navigate:\",c)}},[]);return D(()=>{let a=new URLSearchParams(window.location.search).get(\"path\");a&&history.replaceState({path:a},\"\");function o(c){if(c.ctrlKey||c.metaKey||c.shiftKey||c.altKey)return;let u=c.target.closest(\"a[href]\");if(!u)return;let d;try{d=new URL(u.href,window.location.origin)}catch{return}if(d.origin!==window.location.origin||d.pathname!==\"/view\")return;let p=d.searchParams.get(\"path\");p&&(c.preventDefault(),r(p,!0))}function s(c){let d=c.state?.path??new URLSearchParams(window.location.search).get(\"path\");d?r(d,!1):window.location.reload()}return document.addEventListener(\"click\",o),window.addEventListener(\"popstate\",s),()=>{document.removeEventListener(\"click\",o),window.removeEventListener(\"popstate\",s)}},[r]),r}var vn=\"sidebar-search\";function Sn(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===\"INPUT\"||t===\"TEXTAREA\"||t===\"SELECT\"||e.isContentEditable}function Wt(e){D(()=>{function t(n){n.key===\"/\"&&(n.isComposing||Sn(n.target)||(n.preventDefault(),e?.(),document.getElementById(vn)?.focus()))}return window.addEventListener(\"keydown\",t),()=>window.removeEventListener(\"keydown\",t)},[e])}var le=\"sidebar-open\",zt=\"sidebar-width\",Oe=200,Ue=480,bn=1024;function ce(){return window.innerWidth>=bn}function Kt(){let[e,t]=k(!1),n=C(!0);oe(()=>{if(n.current){n.current=!1;let s=localStorage.getItem(zt);if(s){let c=Number(s);c>=Oe&&c<=Ue&&document.documentElement.style.setProperty(\"--sidebar-width\",`${c}px`)}if(ce()&&localStorage.getItem(le)!==\"false\"){let c=[document.getElementById(\"sidebar\"),document.getElementById(\"header-bar\"),document.getElementById(\"main-content\")];for(let u of c)u&&(u.style.transition=\"none\");document.body.setAttribute(\"data-sidebar-open\",\"\"),document.body.offsetHeight,requestAnimationFrame(()=>{for(let u of c)u&&u.style.removeProperty(\"transition\")}),t(!0)}return}e?document.body.setAttribute(\"data-sidebar-open\",\"\"):document.body.removeAttribute(\"data-sidebar-open\")},[e]),D(()=>{let s=document.getElementById(\"sidebar-resize\");if(!s)return;let c=u=>{u.preventDefault(),s.setPointerCapture(u.pointerId);let d=document.getElementById(\"sidebar\");document.body.style.setProperty(\"user-select\",\"none\"),d?.style.setProperty(\"transition\",\"none\");function p(l){let _=Math.min(Math.max(l.clientX,Oe),Ue);document.documentElement.style.setProperty(\"--sidebar-width\",`${_}px`)}let h=l=>{if(s.releasePointerCapture(l.pointerId),s.removeEventListener(\"pointermove\",p),s.removeEventListener(\"pointerup\",h),s.removeEventListener(\"pointercancel\",h),document.body.style.removeProperty(\"user-select\"),d?.style.removeProperty(\"transition\"),l.type===\"pointerup\"){let _=Math.min(Math.max(l.clientX,Oe),Ue);localStorage.setItem(zt,String(_))}};s.addEventListener(\"pointermove\",p),s.addEventListener(\"pointerup\",h),s.addEventListener(\"pointercancel\",h)};return s.addEventListener(\"pointerdown\",c),()=>s.removeEventListener(\"pointerdown\",c)},[]);let r=A(()=>{t(s=>{let c=!s;return ce()&&localStorage.setItem(le,String(c)),c})},[]),a=A(()=>{t(!1),ce()&&localStorage.setItem(le,\"false\")},[]),o=A(()=>{t(!0),ce()&&localStorage.setItem(le,\"true\")},[]);return{toggle:r,close:a,open:o}}var je=\"[peek]\",$e={info:(...e)=>console.log(je,...e),warn:(...e)=>console.warn(je,...e),error:(...e)=>console.error(je,...e)};function Pn(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 Vt(e){let t=0,n=null,r=null,a=null;function o(){r&&(clearTimeout(r),r=null);let s=new EventSource(\"/sse\");if(a=s,s.addEventListener(\"file-changed\",c=>{let u=Pn(c.data);e.onFileChanged(u?u.path:null)}),e.onTreeChanged){let c=e.onTreeChanged;s.addEventListener(\"tree-changed\",()=>{c()})}s.onerror=()=>{if(s.close(),a=null,r&&(clearTimeout(r),r=null),t++,t>10){$e.warn(`SSE connection lost after ${10} retries, giving up.`);return}let c=Math.min(1e3*2**(t-1),3e4);$e.info(`SSE reconnecting in ${c}ms (${t}/${10})...`),n=setTimeout(o,c)},r=setTimeout(()=>{t=0,r=null},5e3)}return o(),()=>{n&&clearTimeout(n),r&&clearTimeout(r),a&&a.close()}}function de(e){let{onContentUpdate:t,getCurrentPath:n,getCurrentContentType:r,onHtmlReload:a,onTreeUpdate:o}=e;D(()=>{let s=null,c=null,u=Vt({onFileChanged:d=>{if(n){if(d===null)return;let p=n();if(d!==p)return;if(r?.()===\"html\"){a?.();return}s?.abort(),s=new AbortController,K(p,{signal:s.signal}).then(h=>{h!==null&&t(h)}).catch(h=>{h instanceof DOMException&&h.name===\"AbortError\"||console.error(\"[peek] Failed to refresh content:\",h)})}else s?.abort(),s=new AbortController,K(void 0,{signal:s.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?()=>{c?.abort(),c=new AbortController,jt({signal:c.signal}).then(d=>{d&&o(d)}).catch(d=>{d instanceof DOMException&&d.name===\"AbortError\"||console.error(\"[peek] Failed to refresh tree:\",d)})}:void 0});return()=>{s?.abort(),c?.abort(),u()}},[])}function Xt({projectId:e,dirTitle:t,currentPath:n,contentType:r,content:a,tree:o}){let[s,c]=k(n),[u,d]=k(r),[p,h]=k(a),[l,_]=k(o),[f,x]=k(\"\"),[g,S]=k(0),m=C(s);m.current=s;let w=Kt(),M=Ut(e,l,n),I=f.trim()!==\"\",H=ie(()=>Ft(l,f),[l,f]);Wt(w.open),$t((F,E)=>{let L=Ct(F);if(!L){console.error(`Unexpected unsupported file type: ${F}`);return}m.current=F,c(F),d(L),h(E),S(0),M.reveal(F)});let j=C(u);j.current=u,de({getCurrentPath:()=>m.current,getCurrentContentType:()=>j.current,onContentUpdate:h,onHtmlReload:()=>S(F=>F+1),onTreeUpdate:_});let B=se(s);return i(P,{children:[i(Et,{title:t,tree:H,currentPath:s,onClose:w.close,isOpen:I?()=>!0:M.isOpen,onToggle:I?void 0:M.toggle,searchQuery:f,onSearchChange:x,isSearching:I}),i(Pt,{id:\"header-bar\",breadcrumbs:[{label:t,href:\"/\"},{label:B}],showSidebarToggle:!0,onToggleSidebar:w.toggle,externalLinkHref:`/${xe(s)}`}),i(bt,{contentType:u,fileTitle:B,filePath:s,htmlContent:p,htmlReloadKey:g})]})}function Yt({content:e}){let[t,n]=k(e);return de({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(ae,{htmlContent:t})})})}var Ve=\"theme\";function ze(){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 qt(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 kn(e){return e===\"light\"?\"dark\":e===\"dark\"?\"system\":\"light\"}function Qt(){let e=ze();Ke(e),qt(e);let t=document.getElementById(\"theme-toggle\");t&&t.addEventListener(\"click\",()=>{let n=kn(ze());n===\"system\"?localStorage.removeItem(Ve):localStorage.setItem(Ve,n),Ke(n),qt(n)}),window.matchMedia(\"(prefers-color-scheme: dark)\").addEventListener(\"change\",()=>{ze()===\"system\"&&Ke(\"system\")})}var ue=window.__INITIAL_STATE__,Xe=document.getElementById(\"app\");Xe&&ue?ue.mode===\"directory\"?te(i(Xt,{...ue}),Xe):te(i(Yt,{...ue}),Xe):console.error(\"[peek] hydration failed: missing #app or initial state\");Qt();})();\n";
932
1058
  //#endregion
933
1059
  //#region src/server/renderer/global.css?inline
934
- 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 {\n inset-inline-end: var(--spacing);\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";
1060
+ 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-90 {\n rotate: -90deg;\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";
935
1061
  //#endregion
936
1062
  //#region src/server/renderer/document.tsx
937
1063
  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")})()`;
@@ -1049,6 +1175,7 @@ function findFirstFile(nodes) {
1049
1175
  }
1050
1176
  function renderDirectoryView(params) {
1051
1177
  const { projectId, dirTitle, fileTitle, currentPath, contentType, html, tree, styles } = params;
1178
+ const openState = initialOpenState(tree, currentPath);
1052
1179
  return renderDocument(/* @__PURE__ */ jsxs(Document, {
1053
1180
  title: fileTitle,
1054
1181
  styles,
@@ -1065,7 +1192,8 @@ function renderDirectoryView(params) {
1065
1192
  /* @__PURE__ */ jsx(Sidebar, {
1066
1193
  title: dirTitle,
1067
1194
  tree,
1068
- currentPath
1195
+ currentPath,
1196
+ isOpen: (path) => isDirectoryOpen(openState, path)
1069
1197
  }),
1070
1198
  /* @__PURE__ */ jsx(PageHeader, {
1071
1199
  id: "header-bar",
@@ -1074,23 +1202,28 @@ function renderDirectoryView(params) {
1074
1202
  href: "/"
1075
1203
  }, { label: fileTitle }],
1076
1204
  showSidebarToggle: true,
1077
- externalLinkHref: `/${currentPath.split("/").map(encodeURIComponent).join("/")}`
1205
+ externalLinkHref: `/${encodeUrlPath(currentPath)}`
1078
1206
  }),
1079
1207
  /* @__PURE__ */ jsx(ContentView, {
1080
1208
  contentType,
1081
1209
  fileTitle,
1082
- rawUrl: `/api/raw?path=${encodeURIComponent(currentPath)}`,
1210
+ filePath: currentPath,
1083
1211
  htmlContent: html
1084
1212
  })
1085
1213
  ]
1086
1214
  }));
1087
1215
  }
1088
- async function renderFileContent(fullPath, contentType) {
1216
+ async function renderFileContent(dirPath, relativePath, contentType) {
1217
+ const realPath = await realPathWithinBase(dirPath, relativePath);
1218
+ if (!realPath.ok) return {
1219
+ ok: false,
1220
+ ...realPathErrorResponse(realPath.error)
1221
+ };
1089
1222
  if (contentType === "html") {
1090
1223
  try {
1091
- await access(fullPath, constants.R_OK);
1224
+ await access(realPath.value, constants.R_OK);
1092
1225
  } catch (e) {
1093
- if (isNodeError(e) && e.code === "ENOENT") return {
1226
+ if (isNotFoundError(e)) return {
1094
1227
  ok: false,
1095
1228
  status: 404,
1096
1229
  message: "File not found"
@@ -1107,7 +1240,7 @@ async function renderFileContent(fullPath, contentType) {
1107
1240
  html: ""
1108
1241
  };
1109
1242
  }
1110
- const result = await readTextFile(fullPath);
1243
+ const result = await readTextFile(realPath.value);
1111
1244
  if (!result.ok) {
1112
1245
  if (result.error.type === "file-not-found") return {
1113
1246
  ok: false,
@@ -1123,7 +1256,7 @@ async function renderFileContent(fullPath, contentType) {
1123
1256
  }
1124
1257
  return {
1125
1258
  ok: true,
1126
- html: await renderMarkdown(result.value)
1259
+ html: await renderMarkdown(result.value, relativePath)
1127
1260
  };
1128
1261
  }
1129
1262
  function createDirectoryRoutes(dirPath, styles, treeCache) {
@@ -1142,7 +1275,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1142
1275
  logger.error("Unexpected unsupported file in tree:", firstFile.path);
1143
1276
  return c.text("Internal server error", 500);
1144
1277
  }
1145
- const rendered = await renderFileContent(resolve(dirPath, normalize(firstFile.path)), contentType);
1278
+ const rendered = await renderFileContent(dirPath, firstFile.path, contentType);
1146
1279
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1147
1280
  const dirTitle = basename(dirPath) || dirPath;
1148
1281
  return c.html(renderDirectoryView({
@@ -1159,11 +1292,12 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1159
1292
  app.get("/view", async (c) => {
1160
1293
  const relativePath = c.req.query("path");
1161
1294
  if (!relativePath) return c.redirect("/");
1162
- const fullPath = resolve(dirPath, normalize(relativePath));
1163
- if (!isWithinBase(dirPath, fullPath)) return c.text("Forbidden", 403);
1295
+ const slashPath = toSlashPath(relativePath);
1296
+ if (slashPath !== relativePath) return c.redirect(`/view?path=${encodeURIComponent(slashPath)}`);
1297
+ if (!isRelativePathWithinBase(dirPath, relativePath)) return c.text("Forbidden", 403);
1164
1298
  const contentType = getContentType(relativePath);
1165
1299
  if (!contentType) return c.text("Not found", 404);
1166
- const rendered = await renderFileContent(fullPath, contentType);
1300
+ const rendered = await renderFileContent(dirPath, relativePath, contentType);
1167
1301
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1168
1302
  const treeResult = await treeCache.get();
1169
1303
  if (!treeResult.ok) {
@@ -1175,7 +1309,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1175
1309
  projectId,
1176
1310
  dirTitle,
1177
1311
  fileTitle: basename(relativePath),
1178
- currentPath: relativePath,
1312
+ currentPath: slashPath,
1179
1313
  contentType,
1180
1314
  html: rendered.html,
1181
1315
  tree: treeResult.value,
@@ -1184,19 +1318,13 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1184
1318
  });
1185
1319
  app.get("/:path{.+}", async (c) => {
1186
1320
  const relativePath = c.req.param("path");
1187
- const fullPath = resolve(dirPath, normalize(relativePath));
1188
- if (!isWithinBase(dirPath, fullPath)) return c.text("Forbidden", 403);
1321
+ if (!isRelativePathWithinBase(dirPath, relativePath)) return c.text("Forbidden", 403);
1189
1322
  const contentType = getContentType(relativePath);
1190
1323
  if (!contentType) return c.text("Not found", 404);
1191
- if (contentType === "html") {
1192
- const rendered = await renderFileContent(fullPath, contentType);
1193
- if (!rendered.ok) return c.text(rendered.message, rendered.status);
1194
- const fileTitle = basename(relativePath);
1195
- return c.html(renderHtmlDocument(fileTitle, `/api/raw?path=${encodeURIComponent(relativePath)}`));
1196
- }
1197
- const rendered = await renderFileContent(fullPath, contentType);
1324
+ const rendered = await renderFileContent(dirPath, relativePath, contentType);
1198
1325
  if (!rendered.ok) return c.text(rendered.message, rendered.status);
1199
1326
  const fileTitle = basename(relativePath);
1327
+ if (contentType === "html") return c.html(renderHtmlDocument(fileTitle, rawFileUrl(relativePath)));
1200
1328
  return c.html(renderDocument(/* @__PURE__ */ jsx(Document, {
1201
1329
  title: fileTitle,
1202
1330
  styles,
@@ -1207,7 +1335,7 @@ function createDirectoryRoutes(dirPath, styles, treeCache) {
1207
1335
  children: /* @__PURE__ */ jsx(ContentView, {
1208
1336
  contentType,
1209
1337
  fileTitle,
1210
- rawUrl: `/api/raw?path=${encodeURIComponent(relativePath)}`,
1338
+ filePath: relativePath,
1211
1339
  htmlContent: rendered.html,
1212
1340
  markdownClass: "px-2 sm:px-5 py-5 sm:py-15"
1213
1341
  })
@@ -1225,8 +1353,8 @@ function createFileRoutes(filePath, styles) {
1225
1353
  logger.error("Failed to read file:", result.error);
1226
1354
  return c.text("Failed to read file", 500);
1227
1355
  }
1228
- const html = await renderMarkdown(result.value);
1229
1356
  const title = basename(filePath);
1357
+ const html = await renderMarkdown(result.value, title);
1230
1358
  return c.html(renderDocument(/* @__PURE__ */ jsx(Document, {
1231
1359
  title,
1232
1360
  styles,
@@ -1251,7 +1379,91 @@ function createHtmlFileRoutes(filePath) {
1251
1379
  const app = new Hono();
1252
1380
  app.get("/", (c) => {
1253
1381
  const title = basename(filePath);
1254
- return c.html(renderHtmlDocument(title, "/api/raw"));
1382
+ return c.html(renderHtmlDocument(title, rawFileUrl(title)));
1383
+ });
1384
+ return app;
1385
+ }
1386
+ /**
1387
+ * Extensions that `/__peek/raw/` may serve, mapped to their `Content-Type`.
1388
+ * Anything absent is refused, which keeps `--host 0.0.0.0` from exposing
1389
+ * arbitrary files under the base directory.
1390
+ */
1391
+ const MIME_TYPE_MAP = new Map([
1392
+ [".png", "image/png"],
1393
+ [".jpg", "image/jpeg"],
1394
+ [".jpeg", "image/jpeg"],
1395
+ [".gif", "image/gif"],
1396
+ [".webp", "image/webp"],
1397
+ [".svg", "image/svg+xml"],
1398
+ [".avif", "image/avif"],
1399
+ [".ico", "image/x-icon"],
1400
+ [".bmp", "image/bmp"],
1401
+ [".css", "text/css; charset=utf-8"],
1402
+ [".js", "text/javascript; charset=utf-8"],
1403
+ [".mjs", "text/javascript; charset=utf-8"],
1404
+ [".woff", "font/woff"],
1405
+ [".woff2", "font/woff2"],
1406
+ [".ttf", "font/ttf"],
1407
+ [".otf", "font/otf"],
1408
+ [".html", "text/html; charset=utf-8"],
1409
+ [".htm", "text/html; charset=utf-8"]
1410
+ ]);
1411
+ function getMimeType(filePath) {
1412
+ return MIME_TYPE_MAP.get(getExtension(filePath)) ?? null;
1413
+ }
1414
+ //#endregion
1415
+ //#region src/server/routes/raw.ts
1416
+ async function lookupRawFile(baseDir, relativePath) {
1417
+ if (!isRelativePathWithinBase(baseDir, relativePath)) return {
1418
+ type: "path-error",
1419
+ error: { type: "outside-base" }
1420
+ };
1421
+ const realPath = await realPathWithinBase(baseDir, relativePath);
1422
+ if (!realPath.ok) return {
1423
+ type: "path-error",
1424
+ error: realPath.error
1425
+ };
1426
+ const mimeType = getMimeType(realPath.value);
1427
+ if (!mimeType) return { type: "not-allowed" };
1428
+ try {
1429
+ return {
1430
+ type: "found",
1431
+ body: await readFile(realPath.value),
1432
+ mimeType
1433
+ };
1434
+ } catch (e) {
1435
+ return isNotFoundError(e) ? { type: "not-a-file" } : {
1436
+ type: "unreadable",
1437
+ cause: e
1438
+ };
1439
+ }
1440
+ }
1441
+ /**
1442
+ * Serves allowlisted files under `baseDir` at `/__peek/raw/<relative path>`,
1443
+ * so that the browser resolves relative references in a previewed file
1444
+ * (images, CSS, fonts, ...) against that file's own directory.
1445
+ */
1446
+ function createRawRoutes(baseDir) {
1447
+ const app = new Hono();
1448
+ app.get(`${RAW_FILE_PREFIX}:path{.+}`, async (c) => {
1449
+ const file = await lookupRawFile(baseDir, c.req.param("path"));
1450
+ switch (file.type) {
1451
+ case "path-error": {
1452
+ const { status, message } = realPathErrorResponse(file.error);
1453
+ return c.text(message, status);
1454
+ }
1455
+ case "not-allowed":
1456
+ case "not-a-file": return c.text("File not found", 404);
1457
+ case "unreadable":
1458
+ logger.error("Failed to read file:", file.cause);
1459
+ return c.text("Failed to read file", 500);
1460
+ case "found": break;
1461
+ }
1462
+ c.header("Content-Type", file.mimeType);
1463
+ c.header("X-Content-Type-Options", "nosniff");
1464
+ c.header("Cache-Control", "no-cache");
1465
+ if (file.mimeType === "image/svg+xml") c.header("Content-Security-Policy", "sandbox");
1466
+ return c.body(file.body);
1255
1467
  });
1256
1468
  return app;
1257
1469
  }
@@ -1339,6 +1551,7 @@ function createApp(ctx, sse) {
1339
1551
  });
1340
1552
  });
1341
1553
  app.route("/", sse.app);
1554
+ app.route("/", createRawRoutes(ctx.mode === "file" ? dirname(ctx.targetPath) : ctx.targetPath));
1342
1555
  if (ctx.mode === "file") {
1343
1556
  const apiRoutes = createApiRoutes({
1344
1557
  mode: "file",
@@ -1364,28 +1577,28 @@ function setupWatcher(ctx, sse) {
1364
1577
  sse.broadcast("file-changed", JSON.stringify({}));
1365
1578
  });
1366
1579
  else watcher.watchDirectory(ctx.targetPath, (filePath) => {
1367
- const normalizedPath = filePath.replace(/\\/g, "/");
1368
1580
  ctx.treeCache.invalidate();
1369
- sse.broadcast("file-changed", JSON.stringify({ path: normalizedPath }));
1581
+ sse.broadcast("file-changed", JSON.stringify({ path: toSlashPath(filePath) }));
1370
1582
  sse.broadcast("tree-changed", JSON.stringify({}));
1371
1583
  });
1372
1584
  return watcher;
1373
1585
  }
1374
1586
  async function startServer(config, options) {
1375
1587
  const shutdownTimeoutMs = options?.shutdownTimeoutMs ?? SHUTDOWN_TIMEOUT_MS;
1588
+ const targetPath = config.mode === "file" ? await realpath(config.targetPath) : config.targetPath;
1376
1589
  const sse = createSseManager();
1377
1590
  const ctx = config.mode === "directory" ? {
1378
1591
  mode: "directory",
1379
- targetPath: config.targetPath,
1592
+ targetPath,
1380
1593
  styles: config.styles,
1381
- treeCache: createFileTreeCache(config.targetPath)
1594
+ treeCache: createFileTreeCache(targetPath)
1382
1595
  } : config.contentType === "html" ? {
1383
1596
  mode: "file",
1384
- targetPath: config.targetPath,
1597
+ targetPath,
1385
1598
  contentType: "html"
1386
1599
  } : {
1387
1600
  mode: "file",
1388
- targetPath: config.targetPath,
1601
+ targetPath,
1389
1602
  contentType: config.contentType,
1390
1603
  styles: config.styles
1391
1604
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makuja/peek",
3
- "version": "1.9.1",
3
+ "version": "1.11.0",
4
4
  "description": "Markdown and HTML preview CLI with live reload",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "lint:fix": "biome check --write",
24
24
  "format": "biome format --write",
25
25
  "format:check": "biome format",
26
- "typecheck": "tsgo",
26
+ "typecheck": "tsgo && tsgo -p tsconfig.client.json",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
29
29
  "test:coverage": "vitest run --coverage",