pagedex 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # pagedex
2
2
 
3
+ > A fast, browsable catalog (**-dex**, like Rolodex/Pokédex) for any local folder of notes and files—served as a web **page** with full-text search, backlinks, Git sync, and MCP.
4
+
3
5
  Local-first Markdown knowledge viewer, WYSIWYG/raw editor, Git bridge, and multi-era MCP server for any folder.
4
6
 
5
7
  ## Requirements
@@ -1 +1 @@
1
- :root{color-scheme:dark;--bg: #111216;--bg-alt: #181a20;--bg-hover: rgba(255, 255, 255, .06);--border: rgba(255, 255, 255, .09);--text: #eceef2;--muted: #9499a6;--accent: #8b5cf6;--accent-hover: #7c3aed;--accent-soft: rgba(139, 92, 246, .16);--green: #4ade80;--amber: #fbbf24;--code-bg: #16181f;--glass: rgba(24, 26, 32, .88);--font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace}[data-theme=light]{color-scheme:light;--bg: #ffffff;--bg-alt: #f7f7f9;--bg-hover: rgba(0, 0, 0, .05);--border: rgba(0, 0, 0, .09);--text: #18181b;--muted: #6b7280;--accent: #6d28d9;--accent-hover: #5b21b6;--accent-soft: rgba(109, 40, 217, .1);--green: #16a34a;--amber: #d97706;--code-bg: #f3f4f6;--glass: rgba(247, 247, 249, .9)}*{box-sizing:border-box}html,body,#root{margin:0;height:100%;background:var(--bg);color:var(--text);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overscroll-behavior-x:none;overflow-x:hidden}.app{display:grid;grid-template-columns:270px 1fr;height:100vh}.sidebar,.rightbar{background:var(--bg-alt);border-right:1px solid var(--border);display:flex;flex-direction:column;min-height:0}.workspace-body{flex:1;display:flex;min-height:0;min-width:0}.workspace-body.outline-right,.workspace-body.outline-hidden{flex-direction:row}.workspace-body.outline-bottom{flex-direction:column}.note-pane{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0}.workspace-body.outline-bottom .note-pane{flex:7 1 0%}.rightbar{border-right:0;border-left:1px solid var(--border);padding:0;width:240px;flex-shrink:0;overflow:hidden}.workspace-body.outline-bottom .rightbar{flex:3 1 0%;width:100%;max-height:none;min-height:0;border-left:0;border-top:1px solid var(--border)}.rightbar-head{height:44px;padding:0 12px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}.rightbar-body{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:18px}.workspace-body.outline-bottom .rightbar-body{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding:10px 20px 14px}.rightbar-sec{min-width:0}.panel-subtitle{display:none}.workspace-body.outline-bottom .panel-subtitle{display:block;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);margin:2px 0 4px}.backlinks-title{margin-top:0}.workspace-body.outline-bottom .backlinks-title{font-size:10.5px;margin:2px 0 4px}.brand{height:44px;padding:0 12px 0 14px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}.brand-title{font-weight:700;font-size:14px;display:flex;align-items:center;gap:8px}.brand-logo{display:block;flex-shrink:0;border-radius:5px}.pill{font-size:11px;padding:2px 7px;border-radius:999px;background:var(--accent-soft);color:var(--green);font-weight:600}.pill.off{color:var(--amber)}.sidebar-tabs{display:grid;grid-template-columns:1fr 1fr;gap:2px;margin:10px 12px 0;padding:3px;border-radius:8px;background:var(--bg);border:1px solid var(--border)}.sidebar-tab{background:transparent;border:0;color:var(--muted);font-size:12px;font-weight:600;padding:5px 8px;border-radius:6px;cursor:pointer;font-family:inherit;display:flex;align-items:center;justify-content:center;gap:6px}.sidebar-tab:hover{color:var(--text)}.sidebar-tab.active{background:var(--bg-alt);color:var(--text);box-shadow:0 1px 2px #00000040}.search-wrap{padding:8px 12px 10px;border-bottom:1px solid var(--border)}.search{width:100%;padding:7px 10px;border-radius:6px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:13px;outline:none}.search:focus{border-color:var(--accent)}.git-badge{font-size:10.5px;font-weight:700;min-width:18px;text-align:center;padding:1px 5px;border-radius:4px;font-family:var(--font-mono);flex-shrink:0}.git-M{color:var(--amber);background:#fbbf2424}.git-U,.git-A{color:var(--green);background:#4ade8024}.git-D{color:#f87171;background:#f8717124}.changes-bar{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px 8px;border-bottom:1px solid var(--border);margin-bottom:6px}.changes-select{background:var(--bg);border:1px solid var(--border);color:var(--text);border-radius:6px;padding:4px 8px;font-size:12px;outline:none}.commit-files{max-height:220px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;background:var(--bg);padding:6px;margin-bottom:12px}.commit-file-row{display:flex;align-items:center;gap:8px;padding:5px 6px;font-size:12.5px;cursor:pointer;border-radius:6px}.commit-file-row:hover{background:var(--bg-hover)}.git-output{background:var(--code-bg);border:1px solid var(--border);border-radius:8px;padding:10px;font-family:var(--font-mono);font-size:11.5px;white-space:pre-wrap;max-height:140px;overflow-y:auto;margin-top:8px}.diff-wrap{margin:0 auto}.diff-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px;flex-wrap:wrap}.diff-hunk{border:1px solid var(--border);border-radius:10px;overflow:hidden;margin-bottom:14px;background:var(--code-bg)}.diff-hunk-bar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 10px;background:var(--bg-alt);border-bottom:1px solid var(--border);font-family:var(--font-mono);font-size:11.5px;color:var(--muted)}.diff-line{display:grid;grid-template-columns:36px 20px 1fr 28px;align-items:start;font-family:var(--font-mono);font-size:12.5px;line-height:1.5;padding:1px 6px}.diff-line.add{background:#4ade801f}.diff-line.del{background:#f8717121}.diff-ln{color:var(--muted);font-size:11px;-webkit-user-select:none;user-select:none;text-align:right;padding-right:8px}.diff-sig{-webkit-user-select:none;user-select:none;font-weight:700}.diff-line.add .diff-sig{color:var(--green)}.diff-line.del .diff-sig{color:#f87171}.diff-txt{white-space:pre-wrap;word-break:break-word}.diff-discard-btn{background:none;border:0;color:var(--muted);cursor:pointer;font-size:13px;padding:0 4px;border-radius:4px;line-height:1.4}.diff-discard-btn:hover{color:#f87171;background:#f8717129}.tree{flex:1;overflow-y:auto;padding:8px;font-size:13px}.tree-dir-btn,.tree-file{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:5px 8px;border-radius:5px;cursor:pointer;display:flex;align-items:center;gap:6px;font-size:13px;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.tree-dir-btn{color:var(--muted);font-weight:600}.tree-dir-btn:hover,.tree-file-row:hover{background:var(--bg-hover)}.tree-file-row{display:flex;align-items:center;border-radius:5px;gap:2px}.tree-file-row.active{background:var(--accent-soft)}.tree-file-row .tree-file,.tree-file-row .tree-dir-btn{flex:1;min-width:0}.tree-file-row .tree-file:hover,.tree-file-row .tree-dir-btn:hover{background:none}.tree-file.active{background:none;color:var(--accent);font-weight:600}.tree-row-more{background:none;border:0;color:var(--muted);cursor:pointer;padding:4px 6px;border-radius:4px;font-size:13px;line-height:1;opacity:0;flex-shrink:0}.tree-file-row:hover .tree-row-more,.tree-file-row.active .tree-row-more{opacity:1}.tree-row-more:hover{color:var(--text);background:var(--bg-hover)}@media(hover:none),(max-width:768px){.tree-row-more{opacity:.75}}.file-ctx-menu{position:fixed;z-index:60;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:10px;padding:5px;min-width:170px;display:flex;flex-direction:column;gap:2px;box-shadow:0 12px 32px #00000080}.tree-children{padding-left:14px}.main{display:flex;flex-direction:column;min-width:0;min-height:0}.topbar{height:44px;padding:0 14px 0 18px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:12px;flex-shrink:0}.topbar-left{display:flex;align-items:center;gap:8px;min-width:0}.crumbs{font-family:var(--font-mono);font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:6px;align-items:center;position:relative}.icon-btn{width:30px;height:30px;padding:0;border-radius:7px;border:0;background:transparent;color:var(--muted);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,color .12s}.icon-btn:hover,.icon-btn:active{background:var(--bg-hover);color:var(--text)}.icon-btn.active{color:var(--accent);background:var(--accent-soft)}@media(max-width:960px){.outline-toggle-btn.active{color:var(--muted);background:transparent}}.more-menu{position:absolute;top:calc(100% + 6px);right:0;z-index:35;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:12px;padding:5px;min-width:155px;display:flex;flex-direction:column;gap:2px;box-shadow:0 12px 32px #00000073}.more-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:8px 10px;border-radius:8px;font-size:13px;cursor:pointer;font-family:inherit;display:flex;align-items:center;justify-content:space-between}.more-item:hover{background:var(--bg-hover)}.more-item.active{color:var(--accent);font-weight:600}.outline-menu-trigger{display:none}.outline-menu-trigger.show-desktop{display:flex}.tiptap-wrap{margin:0 auto}.tiptap-toolbar{display:flex;gap:4px;align-items:center;overflow-x:auto;padding:6px 8px;margin-bottom:16px;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:12px;position:sticky;top:0;z-index:5}.tiptap-toolbar .btn{border-color:transparent;background:transparent;padding:5px 9px;border-radius:7px}.tiptap-toolbar .btn:hover{background:var(--bg-hover)}.tiptap-toolbar .btn.active{background:var(--accent-soft);color:var(--accent)}.tiptap-toolbar .btn.primary{background:var(--accent);color:#fff;padding:5px 12px;border-radius:8px}.tiptap-body .ProseMirror{outline:none;min-height:55vh;overflow-wrap:anywhere;word-break:break-word}.tiptap-body .ProseMirror>:first-child{margin-top:0}.btn{background:var(--bg-alt);border:1px solid var(--border);color:var(--text);border-radius:8px;padding:5px 11px;font-size:12.5px;font-weight:500;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background .12s,border-color .12s}.btn:hover{background:var(--bg-hover)}.btn.active{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}.btn.primary:hover{background:var(--accent-hover);border-color:var(--accent-hover)}.menu-btn{display:none;gap:5px}.backdrop{display:none}.content-scroll{flex:1;overflow-y:auto;overflow-x:hidden;min-width:0;padding:28px 36px 80px}.doc{max-width:780px;width:100%;margin:0 auto;line-height:1.65;font-size:15px;overflow-wrap:anywhere;word-break:break-word}.doc h1,.doc h2,.doc h3,.doc h4{margin-top:1.5em;margin-bottom:.5em;line-height:1.25}.doc h1{font-size:1.85em;border-bottom:1px solid var(--border);padding-bottom:.3em;margin-top:0}.doc h2{font-size:1.35em}.doc h3{font-size:1.12em}.doc p{margin:.8em 0}.doc a,.wikilink{color:var(--accent);text-decoration:none;cursor:pointer}.doc a:hover,.wikilink:hover{text-decoration:underline}.wikilink.broken{color:var(--amber);border-bottom:1px dashed var(--amber)}.doc code{font-family:var(--font-mono);font-size:.88em;background:var(--code-bg);padding:2px 5px;border-radius:4px;overflow-wrap:anywhere}.doc pre{background:var(--code-bg);border:1px solid var(--border);padding:14px 16px;border-radius:8px;max-width:100%;overflow-x:auto;font-size:13px;line-height:1.5}.doc pre code{background:none;padding:0}.doc blockquote{margin:1em 0;padding:8px 14px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 6px 6px 0}.doc blockquote p{margin:.3em 0}.doc ul,.doc ol{padding-left:1.5em}.doc li{margin:.3em 0}.doc hr{border:0;border-top:1px solid var(--border);margin:1.8em 0}.doc table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse;margin:1em 0;font-size:14px}.doc th,.doc td{border:1px solid var(--border);padding:7px 10px;text-align:left}.doc th{background:var(--bg-alt)}.doc img{max-width:100%;height:auto;border-radius:8px;border:1px solid var(--border)}.raw-view{max-width:860px;width:100%;margin:0 auto;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font-family:var(--font-mono);font-size:13px;line-height:1.55;background:var(--code-bg);border:1px solid var(--border);padding:18px;border-radius:8px}.hljs{color:var(--text);background:transparent}.hljs-comment,.hljs-quote{color:#7f849c;font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-subst,.hljs-section{color:#c084fc}.hljs-number,.hljs-literal,.hljs-variable,.hljs-template-variable,.hljs-tag .hljs-attr{color:#f59e0b}.hljs-string,.hljs-doctag,.hljs-regexp{color:#4ade80}.hljs-title,.hljs-title.function_,.hljs-title.class_{color:#60a5fa}.hljs-type,.hljs-built_in,.hljs-class .hljs-title{color:#38bdf8}.hljs-attr,.hljs-attribute,.hljs-symbol,.hljs-bullet,.hljs-link{color:#f472b6}.hljs-addition{color:#4ade80;background:#4ade801f}.hljs-deletion{color:#f87171;background:#f871711f}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}[data-theme=light] .hljs-comment,[data-theme=light] .hljs-quote{color:#6b7280}[data-theme=light] .hljs-keyword,[data-theme=light] .hljs-selector-tag,[data-theme=light] .hljs-subst,[data-theme=light] .hljs-section{color:#7c3aed}[data-theme=light] .hljs-number,[data-theme=light] .hljs-literal,[data-theme=light] .hljs-variable,[data-theme=light] .hljs-template-variable,[data-theme=light] .hljs-tag .hljs-attr{color:#b45309}[data-theme=light] .hljs-string,[data-theme=light] .hljs-doctag,[data-theme=light] .hljs-regexp{color:#15803d}[data-theme=light] .hljs-title,[data-theme=light] .hljs-title.function_,[data-theme=light] .hljs-title.class_{color:#2563eb}[data-theme=light] .hljs-type,[data-theme=light] .hljs-built_in,[data-theme=light] .hljs-class .hljs-title{color:#0369a1}[data-theme=light] .hljs-attr,[data-theme=light] .hljs-attribute,[data-theme=light] .hljs-symbol,[data-theme=light] .hljs-bullet,[data-theme=light] .hljs-link{color:#be185d}.img-wrap{text-align:center}.img-wrap img{max-width:100%;max-height:80vh}.binary-card{max-width:460px;margin:40px auto;padding:28px 24px;border:1px solid var(--border);border-radius:12px;background:var(--bg-alt);text-align:center}.binary-card-name{font-size:16px;font-weight:700;margin-bottom:6px}.binary-card-path{font-size:12.5px;color:var(--muted);font-family:var(--font-mono);margin-bottom:18px}.panel-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:8px 0}.toc-item,.backlink-item{display:block;padding:4px 6px;border-radius:4px;font-size:12.5px;color:var(--text);text-decoration:none;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.toc-item:hover,.backlink-item:hover{background:var(--bg-hover);color:var(--accent)}.toc-h2{padding-left:14px;color:var(--muted)}.toc-h3{padding-left:24px;color:var(--muted);font-size:12px}.empty-note{font-size:12px;color:var(--muted);padding:4px 6px}.fab-wrap{position:fixed;right:18px;bottom:18px;z-index:25;display:flex;flex-direction:column;align-items:flex-end;gap:8px}.fab-btn{width:48px;height:48px;border-radius:999px;border:0;background:var(--accent);color:#fff;font-size:20px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 20px #00000059}.fab-menu{background:var(--bg-alt);border:1px solid var(--border);border-radius:10px;padding:6px;min-width:170px;display:flex;flex-direction:column;gap:2px;box-shadow:0 10px 28px #0006}.fab-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:8px 10px;border-radius:6px;font-size:13px;cursor:pointer;display:flex;align-items:center;gap:8px;font-family:inherit}.fab-item:hover{background:var(--bg-hover);color:var(--accent)}.mobile-bar,.sheet-backdrop,.bottom-sheet{display:none}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000a6;z-index:50;display:flex;align-items:center;justify-content:center;padding:12px}.modal{width:min(96vw,760px);height:min(90vh,660px);background:var(--bg-alt);border:1px solid var(--border);border-radius:14px;box-shadow:0 18px 48px #0000008c;display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--border);flex-shrink:0}.modal-head h2{margin:0;font-size:16px}.settings-tabs{display:flex;gap:6px;padding:10px 16px;border-bottom:1px solid var(--border);overflow-x:auto;flex-shrink:0;background:var(--bg)}.settings-tab{background:none;border:1px solid transparent;color:var(--muted);padding:6px 12px;border-radius:999px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;font-family:inherit}.settings-tab:hover{color:var(--text);background:var(--bg-hover)}.settings-tab.active{color:var(--accent);background:var(--accent-soft);border-color:var(--accent)}.modal-body{flex:1;overflow-y:auto;padding:18px}.field{margin-bottom:16px}.field label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px;font-weight:600}.field-hint{font-size:11.5px;color:var(--muted);margin-top:4px}.field input[type=text],.field select{width:100%;padding:9px 11px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:13px;outline:none}.field input[type=range]{width:100%}.toggle-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-radius:8px;background:var(--bg);border:1px solid var(--border);margin-bottom:12px;font-size:13px;cursor:pointer}.endpoint-box{background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:10px 12px;font-family:var(--font-mono);font-size:12px;margin-bottom:8px;word-break:break-all}.modal-foot{display:flex;justify-content:space-between;gap:8px;padding:12px 18px;border-top:1px solid var(--border);flex-shrink:0}.switcher-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:45;display:flex;align-items:flex-end;justify-content:center;padding:14px}@media(min-width:769px){.switcher-backdrop{align-items:center}}.switcher{width:100%;max-width:520px;max-height:70vh;background:var(--bg-alt);border:1px solid var(--border);border-radius:16px;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 18px 48px #0000008c}.switcher-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-bottom:1px solid var(--border)}.switcher-tabs{display:flex;gap:4px}.switcher-tab{background:none;border:0;color:var(--muted);font-size:12px;font-weight:600;padding:5px 10px;border-radius:7px;cursor:pointer;font-family:inherit}.switcher-tab:hover{color:var(--text);background:var(--bg-hover)}.switcher-tab.active{background:var(--accent-soft);color:var(--accent)}.switcher-cap{font-size:11px;color:var(--muted);font-family:var(--font-mono)}.switcher-group-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:8px 10px 4px}.switcher-row-top{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%}.switcher-time{font-size:11px;color:var(--muted);font-family:var(--font-mono);flex-shrink:0}.switcher-list{flex:1;overflow-y:auto;padding:10px;display:flex;flex-direction:column;gap:2px}.switcher-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:10px 12px;border-radius:10px;cursor:pointer;font-family:inherit;display:flex;flex-direction:column;gap:2px}.switcher-item:hover,.switcher-item.selected{background:var(--accent-soft);color:var(--accent)}.switcher-path{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.switcher-snippet{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.switcher-input-wrap{padding:10px 12px;border-top:1px solid var(--border);display:flex;align-items:center;gap:8px;background:var(--bg-alt)}.switcher-input{flex:1;padding:10px 14px;border-radius:999px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:14px;outline:none}.switcher-input:focus{border-color:var(--accent)}.switcher-clear{width:30px;height:30px;border-radius:999px;border:0;background:var(--bg-hover);color:var(--text);font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}.folder-picker{margin-top:6px;max-height:170px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;background:var(--bg);padding:4px;display:flex;flex-direction:column;gap:2px}.folder-pick-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:6px 8px;border-radius:6px;cursor:pointer;font-size:12.5px;font-family:var(--font-mono)}.folder-pick-item:hover{background:var(--bg-hover)}.folder-pick-item.active{background:var(--accent-soft);color:var(--accent);font-weight:600}.desktop-tabs{display:flex;align-items:center;gap:4px;padding:6px 14px 0;background:var(--bg-alt);border-bottom:1px solid var(--border);overflow-x:auto}.desktop-tab{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px 8px 0 0;border:1px solid transparent;border-bottom:0;background:none;color:var(--muted);font-size:12px;cursor:pointer;font-family:inherit;white-space:nowrap;max-width:180px}.desktop-tab:hover{background:var(--bg-hover);color:var(--text)}.desktop-tab.active{background:var(--bg);color:var(--text);border-color:var(--border);font-weight:600}.desktop-tab-title{overflow:hidden;text-overflow:ellipsis}.desktop-tab-close{border:0;background:none;color:var(--muted);cursor:pointer;padding:0 2px;font-size:13px;line-height:1}.desktop-tab-close:hover{color:var(--text)}.desktop-tab-add{border:0;background:none;color:var(--muted);cursor:pointer;padding:4px 8px;font-size:16px;border-radius:6px}.desktop-tab-add:hover{background:var(--bg-hover);color:var(--text)}.new-tab-view{min-height:60vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px}.new-tab-btn{width:210px;padding:12px 18px;border-radius:999px;border:1px solid var(--border);background:var(--bg-alt);color:var(--text);font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;gap:12px}.new-tab-btn:hover,.new-tab-btn:active{background:var(--bg-hover);border-color:var(--accent);color:var(--accent)}.new-tab-btn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}.tabs-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0a0c12f0;z-index:42;display:flex;flex-direction:column;justify-content:flex-end}.tabs-grid{overflow-y:auto;padding:20px 14px 12px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;max-width:680px;width:100%;margin:0 auto}.tab-card-wrap{display:flex;flex-direction:column;align-items:center;gap:6px}.tab-card{width:100%;height:190px;background:var(--bg-alt);border:1.5px solid var(--border);border-radius:16px;padding:12px;position:relative;cursor:pointer;overflow:hidden;text-align:left;color:var(--text);font-family:inherit;display:flex;flex-direction:column;gap:6px}.tab-card.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.tab-card-close{position:absolute;top:8px;right:8px;width:24px;height:24px;border-radius:999px;border:0;background:var(--bg-hover);color:var(--text);font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center}.tab-card-title{font-size:13px;font-weight:700;color:var(--accent);padding-right:26px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tab-card-preview{font-size:11px;line-height:1.45;color:var(--muted);overflow:hidden;white-space:pre-wrap}.tab-card-label{font-size:12px;font-weight:600;color:var(--text);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tabs-footer{display:flex;align-items:center;justify-content:space-between;padding:12px 18px calc(14px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--border);background:var(--bg-alt)}.tabs-footer-btn{background:none;border:0;color:var(--text);font-size:15px;font-weight:600;cursor:pointer;padding:4px 8px;font-family:inherit}.tabs-count-badge{width:21px;height:21px;border:1.7px solid currentColor;border-radius:5px;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center}@media(max-width:960px){.app{grid-template-columns:230px 1fr}.outline-menu-trigger{display:flex}.backdrop.open{display:block;position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:20}.workspace-body:not(.outline-bottom) .rightbar{position:fixed;inset:0 0 0 auto;width:min(84vw,300px);z-index:30;transform:translate(100%);transition:transform .18s ease}.workspace-body:not(.outline-bottom) .rightbar.mobile-open{transform:translate(0)}}@media(max-width:768px){.app{grid-template-columns:1fr}.workspace-body.outline-bottom .rightbar-body{grid-template-columns:1fr;gap:10px;padding:10px 14px calc(74px + env(safe-area-inset-bottom,0px))}.menu-btn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0}.menu-btn svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}.icon-btn{width:34px;height:34px}.desktop-tabs,.fab-wrap{display:none}.sheet-backdrop,.bottom-sheet{display:block}.sidebar{position:fixed;inset:0 auto 0 0;width:min(84vw,310px);z-index:30;transform:translate(-100%);transition:transform .18s ease}.sidebar.open{transform:translate(0)}.backdrop.open{display:block;position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:20}.brand{height:48px;padding:0 12px 0 14px}.brand-title{font-size:15px;gap:8px}.sidebar-tabs{margin:10px 12px 0;padding:3px;gap:2px}.sidebar-tab{font-size:13px;padding:6px 8px;border-radius:6px}.search-wrap{padding:8px 12px 10px}.search{font-size:16px;padding:8px 11px;border-radius:7px}.tree{padding:8px 10px;font-size:14px}.tree-dir-btn,.tree-file{padding:8px 9px;font-size:14px;border-radius:6px}.tree-row-more{min-width:32px;min-height:32px;padding:4px 6px;font-size:15px;display:inline-flex;align-items:center;justify-content:center}.changes-bar{padding:6px 8px 8px}.changes-select{font-size:13.5px;padding:6px 9px}.topbar{height:48px;padding:0 12px}.rightbar-head{height:44px;padding:0 12px}.crumbs{font-size:13px}.btn{padding:8px 13px;font-size:13.5px;border-radius:8px}.more-menu,.file-ctx-menu{min-width:200px;padding:5px;border-radius:12px}.more-item{padding:10px 12px;font-size:14px;border-radius:8px}.new-tab-view{gap:12px}.new-tab-btn{width:min(84vw,270px);padding:14px 20px;font-size:15.5px}.new-tab-btn svg{width:19px;height:19px}.switcher-tab{font-size:13.5px;padding:7px 12px}.switcher-item{padding:12px 14px}.switcher-path{font-size:15px}.switcher-snippet{font-size:13px}.switcher-input{font-size:16px;padding:11px 16px}.switcher-clear{width:34px;height:34px;font-size:17px}.field label{font-size:13px}.field input[type=text],.field select{font-size:16px;padding:11px 12px;border-radius:9px}.folder-picker{max-height:200px;padding:6px}.folder-pick-item{padding:10px 12px;font-size:14px;border-radius:7px}.toggle-row{padding:12px 14px;font-size:14px}.commit-file-row{padding:8px 10px;font-size:14px}.content-scroll{padding:18px 16px calc(86px + env(safe-area-inset-bottom,0px))}.mobile-bar{position:fixed;left:50%;transform:translate(-50%);bottom:calc(14px + env(safe-area-inset-bottom,0px));z-index:25;display:flex;align-items:center;gap:6px;background:var(--glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--border);border-radius:999px;padding:7px 12px;box-shadow:0 10px 30px #00000073}.mobile-bar-btn{background:none;border:0;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;width:42px;height:40px;border-radius:999px}.mobile-bar-btn svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}.mobile-bar-btn.active,.mobile-bar-btn:active{color:var(--accent);background:var(--accent-soft)}.tabs-count-badge{width:23px;height:23px;font-size:12px}.sheet-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:35}.bottom-sheet{position:fixed;left:0;right:0;bottom:0;z-index:36;background:var(--bg-alt);border-top:1px solid var(--border);border-radius:18px 18px 0 0;padding:10px 14px calc(18px + env(safe-area-inset-bottom,0px));box-shadow:0 -12px 36px #00000080}.sheet-handle{width:38px;height:4px;border-radius:999px;background:var(--border);margin:0 auto 12px}.sheet-list{background:var(--bg);border:1px solid var(--border);border-radius:12px;overflow:hidden}.sheet-item{width:100%;background:none;border:0;border-bottom:1px solid var(--border);color:var(--text);padding:14px 16px;font-size:15px;font-family:inherit;display:flex;align-items:center;gap:12px;cursor:pointer;text-align:left}.sheet-item:last-child{border-bottom:0}.sheet-item:active,.sheet-item:hover{background:var(--bg-hover);color:var(--accent)}.sheet-item svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0;color:var(--muted)}}
1
+ :root{color-scheme:dark;--bg: #111216;--bg-alt: #181a20;--bg-hover: rgba(255, 255, 255, .06);--border: rgba(255, 255, 255, .09);--text: #eceef2;--muted: #9499a6;--accent: #8b5cf6;--accent-hover: #7c3aed;--accent-soft: rgba(139, 92, 246, .16);--green: #4ade80;--amber: #fbbf24;--code-bg: #16181f;--glass: rgba(24, 26, 32, .88);--font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace}[data-theme=light]{color-scheme:light;--bg: #ffffff;--bg-alt: #f7f7f9;--bg-hover: rgba(0, 0, 0, .05);--border: rgba(0, 0, 0, .09);--text: #18181b;--muted: #6b7280;--accent: #6d28d9;--accent-hover: #5b21b6;--accent-soft: rgba(109, 40, 217, .1);--green: #16a34a;--amber: #d97706;--code-bg: #f3f4f6;--glass: rgba(247, 247, 249, .9)}*{box-sizing:border-box}html,body,#root{margin:0;height:100%;background:var(--bg);color:var(--text);font-family:var(--font-sans);-webkit-font-smoothing:antialiased;overscroll-behavior-x:none;overflow-x:hidden}.app{display:grid;grid-template-columns:270px 1fr;height:100vh}.sidebar,.rightbar{background:var(--bg-alt);border-right:1px solid var(--border);display:flex;flex-direction:column;min-height:0}.workspace-body{flex:1;display:flex;min-height:0;min-width:0}.workspace-body.outline-right,.workspace-body.outline-hidden{flex-direction:row}.workspace-body.outline-bottom{flex-direction:column}.note-pane{flex:1;display:flex;flex-direction:column;min-width:0;min-height:0}.workspace-body.outline-bottom .note-pane{flex:7 1 0%}.rightbar{border-right:0;border-left:1px solid var(--border);padding:0;width:240px;flex-shrink:0;overflow:hidden}.workspace-body.outline-bottom .rightbar{flex:3 1 0%;width:100%;max-height:none;min-height:0;border-left:0;border-top:1px solid var(--border)}.rightbar-head{height:44px;padding:0 12px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}.rightbar-body{flex:1;overflow-y:auto;padding:12px;display:flex;flex-direction:column;gap:18px}.workspace-body.outline-bottom .rightbar-body{display:grid;grid-template-columns:1fr 1fr;gap:16px;padding:10px 20px 14px}.rightbar-sec{min-width:0}.panel-subtitle{display:none}.workspace-body.outline-bottom .panel-subtitle{display:block;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);margin:2px 0 4px}.backlinks-title{margin-top:0}.workspace-body.outline-bottom .backlinks-title{font-size:10.5px;margin:2px 0 4px}.brand{height:44px;padding:0 12px 0 14px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:8px;flex-shrink:0}.brand-title{font-weight:700;font-size:14px;display:flex;align-items:center;gap:8px}.brand-logo{display:block;flex-shrink:0;border-radius:5px}.pill{font-size:11px;padding:2px 7px;border-radius:999px;background:var(--accent-soft);color:var(--green);font-weight:600}.pill.off{color:var(--amber)}.sidebar-tabs{display:grid;grid-template-columns:1fr 1fr;gap:2px;margin:10px 12px 0;padding:3px;border-radius:8px;background:var(--bg);border:1px solid var(--border)}.sidebar-tab{background:transparent;border:0;color:var(--muted);font-size:12px;font-weight:600;padding:5px 8px;border-radius:6px;cursor:pointer;font-family:inherit;display:flex;align-items:center;justify-content:center;gap:6px}.sidebar-tab:hover{color:var(--text)}.sidebar-tab.active{background:var(--bg-alt);color:var(--text);box-shadow:0 1px 2px #00000040}.search-wrap{padding:8px 12px 10px;border-bottom:1px solid var(--border)}.search{width:100%;padding:7px 10px;border-radius:6px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:13px;outline:none}.search:focus{border-color:var(--accent)}.git-badge{font-size:10.5px;font-weight:700;min-width:18px;text-align:center;padding:1px 5px;border-radius:4px;font-family:var(--font-mono);flex-shrink:0}.git-M{color:var(--amber);background:#fbbf2424}.git-U,.git-A{color:var(--green);background:#4ade8024}.git-D{color:#f87171;background:#f8717124}.changes-bar{display:flex;align-items:center;justify-content:space-between;gap:6px;padding:6px 8px 8px;border-bottom:1px solid var(--border);margin-bottom:6px}.changes-select{background:var(--bg);border:1px solid var(--border);color:var(--text);border-radius:6px;padding:4px 8px;font-size:12px;outline:none}.commit-files{max-height:220px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;background:var(--bg);padding:6px;margin-bottom:12px}.commit-file-row{display:flex;align-items:center;gap:8px;padding:5px 6px;font-size:12.5px;cursor:pointer;border-radius:6px}.commit-file-row:hover{background:var(--bg-hover)}.git-output{background:var(--code-bg);border:1px solid var(--border);border-radius:8px;padding:10px;font-family:var(--font-mono);font-size:11.5px;white-space:pre-wrap;max-height:140px;overflow-y:auto;margin-top:8px}.diff-wrap{margin:0 auto}.diff-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px;flex-wrap:wrap}.diff-hunk{border:1px solid var(--border);border-radius:10px;overflow:hidden;margin-bottom:14px;background:var(--code-bg)}.diff-hunk-bar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:6px 10px;background:var(--bg-alt);border-bottom:1px solid var(--border);font-family:var(--font-mono);font-size:11.5px;color:var(--muted)}.diff-line{display:grid;grid-template-columns:36px 20px 1fr 28px;align-items:start;font-family:var(--font-mono);font-size:12.5px;line-height:1.5;padding:1px 6px}.diff-line.add{background:#4ade801f}.diff-line.del{background:#f8717121}.diff-ln{color:var(--muted);font-size:11px;-webkit-user-select:none;user-select:none;text-align:right;padding-right:8px}.diff-sig{-webkit-user-select:none;user-select:none;font-weight:700}.diff-line.add .diff-sig{color:var(--green)}.diff-line.del .diff-sig{color:#f87171}.diff-txt{white-space:pre-wrap;word-break:break-word}.diff-discard-btn{background:none;border:0;color:var(--muted);cursor:pointer;font-size:13px;padding:0 4px;border-radius:4px;line-height:1.4}.diff-discard-btn:hover{color:#f87171;background:#f8717129}.tree{flex:1;overflow-y:auto;padding:8px;font-size:13px}.tree-dir-btn,.tree-file{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:5px 8px;border-radius:5px;cursor:pointer;display:flex;align-items:center;gap:6px;font-size:13px;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;-webkit-touch-callout:none;-webkit-user-select:none;user-select:none}.tree-dir-btn{color:var(--muted);font-weight:600}.tree-dir-btn:hover,.tree-file-row:hover{background:var(--bg-hover)}.tree-file-row{display:flex;align-items:center;border-radius:5px;gap:2px}.tree-file-row.active{background:var(--accent-soft)}.tree-file-row .tree-file,.tree-file-row .tree-dir-btn{flex:1;min-width:0}.tree-file-row .tree-file:hover,.tree-file-row .tree-dir-btn:hover{background:none}.tree-file.active{background:none;color:var(--accent);font-weight:600}.tree-row-more{background:none;border:0;color:var(--muted);cursor:pointer;padding:4px 6px;border-radius:4px;font-size:13px;line-height:1;opacity:0;flex-shrink:0}.tree-file-row:hover .tree-row-more,.tree-file-row.active .tree-row-more{opacity:1}.tree-row-more:hover{color:var(--text);background:var(--bg-hover)}@media(hover:none),(max-width:768px){.tree-row-more{opacity:.75}}.file-ctx-menu{position:fixed;z-index:60;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:10px;padding:5px;min-width:170px;display:flex;flex-direction:column;gap:2px;box-shadow:0 12px 32px #00000080}.tree-children{padding-left:14px}.main{display:flex;flex-direction:column;min-width:0;min-height:0}.topbar{height:44px;padding:0 14px 0 18px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;gap:12px;flex-shrink:0}.topbar-left{display:flex;align-items:center;gap:8px;min-width:0}.crumbs{font-family:var(--font-mono);font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:6px;align-items:center;position:relative}.icon-btn{width:30px;height:30px;padding:0;border-radius:7px;border:0;background:transparent;color:var(--muted);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;transition:background .12s,color .12s}.icon-btn:hover,.icon-btn:active{background:var(--bg-hover);color:var(--text)}.icon-btn.active{color:var(--accent);background:var(--accent-soft)}@media(max-width:960px){.outline-toggle-btn.active{color:var(--muted);background:transparent}}.more-menu{position:absolute;top:calc(100% + 6px);right:0;z-index:35;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:12px;padding:5px;min-width:155px;display:flex;flex-direction:column;gap:2px;box-shadow:0 12px 32px #00000073}.more-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:8px 10px;border-radius:8px;font-size:13px;cursor:pointer;font-family:inherit;display:flex;align-items:center;justify-content:space-between}.more-item:hover{background:var(--bg-hover)}.more-item.active{color:var(--accent);font-weight:600}.outline-menu-trigger{display:none}.outline-menu-trigger.show-desktop{display:flex}.tiptap-wrap{margin:0 auto}.tiptap-toolbar{display:flex;gap:4px;align-items:center;overflow-x:auto;padding:6px 8px;margin-bottom:16px;background:var(--glass);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);border:1px solid var(--border);border-radius:12px;position:sticky;top:0;z-index:5}.tiptap-toolbar .btn{border-color:transparent;background:transparent;padding:5px 9px;border-radius:7px}.tiptap-toolbar .btn:hover{background:var(--bg-hover)}.tiptap-toolbar .btn.active{background:var(--accent-soft);color:var(--accent)}.tiptap-toolbar .btn.primary{background:var(--accent);color:#fff;padding:5px 12px;border-radius:8px}.tiptap-body .ProseMirror{outline:none;min-height:55vh;overflow-wrap:anywhere;word-break:break-word}.tiptap-body .ProseMirror>:first-child{margin-top:0}.btn{background:var(--bg-alt);border:1px solid var(--border);color:var(--text);border-radius:8px;padding:5px 11px;font-size:12.5px;font-weight:500;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background .12s,border-color .12s}.btn:hover{background:var(--bg-hover)}.btn.active{border-color:var(--accent);color:var(--accent);background:var(--accent-soft)}.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600}.btn.primary:hover{background:var(--accent-hover);border-color:var(--accent-hover)}.menu-btn{display:none;gap:5px}.backdrop{display:none}.content-scroll{flex:1;overflow-y:auto;overflow-x:hidden;min-width:0;padding:28px 36px 80px}.doc{max-width:780px;width:100%;margin:0 auto;line-height:1.65;font-size:15px;overflow-wrap:anywhere;word-break:break-word}.doc h1,.doc h2,.doc h3,.doc h4{margin-top:1.5em;margin-bottom:.5em;line-height:1.25}.doc h1{font-size:1.85em;border-bottom:1px solid var(--border);padding-bottom:.3em;margin-top:0}.doc h2{font-size:1.35em}.doc h3{font-size:1.12em}.doc p{margin:.8em 0}.doc a,.wikilink{color:var(--accent);text-decoration:none;cursor:pointer}.doc a:hover,.wikilink:hover{text-decoration:underline}.wikilink.broken{color:var(--amber);border-bottom:1px dashed var(--amber)}.doc code{font-family:var(--font-mono);font-size:.88em;background:var(--code-bg);padding:2px 5px;border-radius:4px;overflow-wrap:anywhere}.doc pre{background:var(--code-bg);border:1px solid var(--border);padding:14px 16px;border-radius:8px;max-width:100%;overflow-x:auto;font-size:13px;line-height:1.5}.doc pre code{background:none;padding:0}.doc blockquote{margin:1em 0;padding:8px 14px;border-left:3px solid var(--accent);background:var(--accent-soft);border-radius:0 6px 6px 0}.doc blockquote p{margin:.3em 0}.doc ul,.doc ol{padding-left:1.5em}.doc li{margin:.3em 0}.doc hr{border:0;border-top:1px solid var(--border);margin:1.8em 0}.doc table{display:block;max-width:100%;overflow-x:auto;border-collapse:collapse;margin:1em 0;font-size:14px}.doc th,.doc td{border:1px solid var(--border);padding:7px 10px;text-align:left}.doc th{background:var(--bg-alt)}.doc img{max-width:100%;height:auto;border-radius:8px;border:1px solid var(--border)}.raw-view{max-width:860px;width:100%;margin:0 auto;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word;font-family:var(--font-mono);font-size:13px;line-height:1.55;background:var(--code-bg);border:1px solid var(--border);padding:18px;border-radius:8px}.hljs{color:var(--text);background:transparent}.hljs-comment,.hljs-quote{color:#7f849c;font-style:italic}.hljs-keyword,.hljs-selector-tag,.hljs-subst,.hljs-section{color:#c084fc}.hljs-number,.hljs-literal,.hljs-variable,.hljs-template-variable,.hljs-tag .hljs-attr{color:#f59e0b}.hljs-string,.hljs-doctag,.hljs-regexp{color:#4ade80}.hljs-title,.hljs-title.function_,.hljs-title.class_{color:#60a5fa}.hljs-type,.hljs-built_in,.hljs-class .hljs-title{color:#38bdf8}.hljs-attr,.hljs-attribute,.hljs-symbol,.hljs-bullet,.hljs-link{color:#f472b6}.hljs-addition{color:#4ade80;background:#4ade801f}.hljs-deletion{color:#f87171;background:#f871711f}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}[data-theme=light] .hljs-comment,[data-theme=light] .hljs-quote{color:#6b7280}[data-theme=light] .hljs-keyword,[data-theme=light] .hljs-selector-tag,[data-theme=light] .hljs-subst,[data-theme=light] .hljs-section{color:#7c3aed}[data-theme=light] .hljs-number,[data-theme=light] .hljs-literal,[data-theme=light] .hljs-variable,[data-theme=light] .hljs-template-variable,[data-theme=light] .hljs-tag .hljs-attr{color:#b45309}[data-theme=light] .hljs-string,[data-theme=light] .hljs-doctag,[data-theme=light] .hljs-regexp{color:#15803d}[data-theme=light] .hljs-title,[data-theme=light] .hljs-title.function_,[data-theme=light] .hljs-title.class_{color:#2563eb}[data-theme=light] .hljs-type,[data-theme=light] .hljs-built_in,[data-theme=light] .hljs-class .hljs-title{color:#0369a1}[data-theme=light] .hljs-attr,[data-theme=light] .hljs-attribute,[data-theme=light] .hljs-symbol,[data-theme=light] .hljs-bullet,[data-theme=light] .hljs-link{color:#be185d}.img-wrap{text-align:center}.img-wrap img{max-width:100%;max-height:80vh}.binary-card{max-width:460px;margin:40px auto;padding:28px 24px;border:1px solid var(--border);border-radius:12px;background:var(--bg-alt);text-align:center}.binary-card-name{font-size:16px;font-weight:700;margin-bottom:6px}.binary-card-path{font-size:12.5px;color:var(--muted);font-family:var(--font-mono);margin-bottom:18px}.panel-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--muted);margin:8px 0}.toc-item,.backlink-item{display:block;padding:4px 6px;border-radius:4px;font-size:12.5px;color:var(--text);text-decoration:none;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.toc-item:hover,.backlink-item:hover{background:var(--bg-hover);color:var(--accent)}.toc-h2{padding-left:14px;color:var(--muted)}.toc-h3{padding-left:24px;color:var(--muted);font-size:12px}.empty-note{font-size:12px;color:var(--muted);padding:4px 6px}.fab-wrap{position:fixed;right:18px;bottom:18px;z-index:25;display:flex;flex-direction:column;align-items:flex-end;gap:8px}.fab-btn{width:48px;height:48px;border-radius:999px;border:0;background:var(--accent);color:#fff;font-size:20px;font-weight:700;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 20px #00000059}.fab-menu{background:var(--bg-alt);border:1px solid var(--border);border-radius:10px;padding:6px;min-width:170px;display:flex;flex-direction:column;gap:2px;box-shadow:0 10px 28px #0006}.fab-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:8px 10px;border-radius:6px;font-size:13px;cursor:pointer;display:flex;align-items:center;gap:8px;font-family:inherit}.fab-item:hover{background:var(--bg-hover);color:var(--accent)}.mobile-bar,.sheet-backdrop,.bottom-sheet{display:none}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#000000a6;z-index:50;display:flex;align-items:center;justify-content:center;padding:12px}.modal{width:min(96vw,760px);height:min(90vh,660px);background:var(--bg-alt);border:1px solid var(--border);border-radius:14px;box-shadow:0 18px 48px #0000008c;display:flex;flex-direction:column;overflow:hidden}.modal-head{display:flex;align-items:center;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--border);flex-shrink:0}.modal-head h2{margin:0;font-size:16px}.settings-tabs{display:flex;gap:6px;padding:10px 16px;border-bottom:1px solid var(--border);overflow-x:auto;flex-shrink:0;background:var(--bg)}.settings-tab{background:none;border:1px solid transparent;color:var(--muted);padding:6px 12px;border-radius:999px;font-size:13px;font-weight:600;cursor:pointer;white-space:nowrap;font-family:inherit}.settings-tab:hover{color:var(--text);background:var(--bg-hover)}.settings-tab.active{color:var(--accent);background:var(--accent-soft);border-color:var(--accent)}.modal-body{flex:1;overflow-y:auto;padding:18px}.field{margin-bottom:16px}.field label{display:block;font-size:12px;color:var(--muted);margin-bottom:6px;font-weight:600}.field-hint{font-size:11.5px;color:var(--muted);margin-top:4px}.field input[type=text],.field select{width:100%;padding:9px 11px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:13px;outline:none}.field input[type=range]{width:100%}.toggle-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 12px;border-radius:8px;background:var(--bg);border:1px solid var(--border);margin-bottom:12px;font-size:13px;cursor:pointer}.endpoint-box{background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:10px 12px;font-family:var(--font-mono);font-size:12px;margin-bottom:8px;word-break:break-all}.modal-foot{display:flex;justify-content:space-between;gap:8px;padding:12px 18px;border-top:1px solid var(--border);flex-shrink:0}.switcher-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#0000008c;z-index:45;display:flex;align-items:flex-end;justify-content:center;padding:14px}@media(min-width:769px){.switcher-backdrop{align-items:center}}.switcher{width:100%;max-width:520px;max-height:70vh;background:var(--bg-alt);border:1px solid var(--border);border-radius:16px;display:flex;flex-direction:column;overflow:hidden;box-shadow:0 18px 48px #0000008c}.switcher-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-bottom:1px solid var(--border)}.switcher-tabs{display:flex;gap:4px}.switcher-tab{background:none;border:0;color:var(--muted);font-size:12px;font-weight:600;padding:5px 10px;border-radius:7px;cursor:pointer;font-family:inherit}.switcher-tab:hover{color:var(--text);background:var(--bg-hover)}.switcher-tab.active{background:var(--accent-soft);color:var(--accent)}.switcher-cap{font-size:11px;color:var(--muted);font-family:var(--font-mono)}.switcher-group-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);padding:8px 10px 4px}.switcher-row-top{display:flex;align-items:center;justify-content:space-between;gap:8px;width:100%}.switcher-time{font-size:11px;color:var(--muted);font-family:var(--font-mono);flex-shrink:0}.switcher-list{flex:1;overflow-y:auto;padding:10px;display:flex;flex-direction:column;gap:2px}.switcher-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:10px 12px;border-radius:10px;cursor:pointer;font-family:inherit;display:flex;flex-direction:column;gap:2px}.switcher-item:hover,.switcher-item.selected{background:var(--accent-soft);color:var(--accent)}.switcher-path{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.switcher-snippet{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.switcher-input-wrap{padding:10px 12px;border-top:1px solid var(--border);display:flex;align-items:center;gap:8px;background:var(--bg-alt)}.switcher-input{flex:1;padding:10px 14px;border-radius:999px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:14px;outline:none}.switcher-input:focus{border-color:var(--accent)}.switcher-clear{width:30px;height:30px;border-radius:999px;border:0;background:var(--bg-hover);color:var(--text);font-size:15px;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}.folder-picker{margin-top:6px;max-height:170px;overflow-y:auto;border:1px solid var(--border);border-radius:8px;background:var(--bg);padding:4px;display:flex;flex-direction:column;gap:2px}.folder-pick-item{width:100%;text-align:left;background:none;border:0;color:var(--text);padding:6px 8px;border-radius:6px;cursor:pointer;font-size:12.5px;font-family:var(--font-mono)}.folder-pick-item:hover{background:var(--bg-hover)}.folder-pick-item.active{background:var(--accent-soft);color:var(--accent);font-weight:600}.desktop-tabs{display:flex;align-items:center;gap:4px;padding:6px 14px 0;background:var(--bg-alt);border-bottom:1px solid var(--border);overflow-x:auto}.desktop-tab{display:flex;align-items:center;gap:6px;padding:6px 10px;border-radius:8px 8px 0 0;border:1px solid transparent;border-bottom:0;background:none;color:var(--muted);font-size:12px;cursor:pointer;font-family:inherit;white-space:nowrap;max-width:180px}.desktop-tab:hover{background:var(--bg-hover);color:var(--text)}.desktop-tab.active{background:var(--bg);color:var(--text);border-color:var(--border);font-weight:600}.desktop-tab-title{overflow:hidden;text-overflow:ellipsis}.desktop-tab-close{border:0;background:none;color:var(--muted);cursor:pointer;padding:0 2px;font-size:13px;line-height:1}.desktop-tab-close:hover{color:var(--text)}.desktop-tab-add{border:0;background:none;color:var(--muted);cursor:pointer;padding:4px 8px;font-size:16px;border-radius:6px}.desktop-tab-add:hover{background:var(--bg-hover);color:var(--text)}.new-tab-view{min-height:60vh;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px}.new-tab-btn{width:210px;padding:12px 18px;border-radius:999px;border:1px solid var(--border);background:var(--bg-alt);color:var(--text);font-size:14px;font-family:inherit;cursor:pointer;display:flex;align-items:center;gap:12px}.new-tab-btn:hover,.new-tab-btn:active{background:var(--bg-hover);border-color:var(--accent);color:var(--accent)}.new-tab-btn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}.tabs-overlay{position:fixed;top:0;right:0;bottom:0;left:0;background:#0a0c12f0;z-index:42;display:flex;flex-direction:column;justify-content:flex-end}.tabs-grid{overflow-y:auto;padding:20px 14px 12px;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;max-width:680px;width:100%;margin:0 auto}.tab-card-wrap{display:flex;flex-direction:column;align-items:center;gap:6px}.tab-card{width:100%;height:190px;background:var(--bg-alt);border:1.5px solid var(--border);border-radius:16px;padding:12px;position:relative;cursor:pointer;overflow:hidden;text-align:left;color:var(--text);font-family:inherit;display:flex;flex-direction:column;gap:6px}.tab-card.active{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}.tab-card-close{position:absolute;top:8px;right:8px;width:24px;height:24px;border-radius:999px;border:0;background:var(--bg-hover);color:var(--text);font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center}.tab-card-title{font-size:13px;font-weight:700;color:var(--accent);padding-right:26px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tab-card-preview{font-size:11px;line-height:1.45;color:var(--muted);overflow:hidden;white-space:pre-wrap}.tab-card-label{font-size:12px;font-weight:600;color:var(--text);max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tabs-footer{display:flex;align-items:center;justify-content:space-between;padding:12px 18px calc(14px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--border);background:var(--bg-alt)}.tabs-footer-btn{background:none;border:0;color:var(--text);font-size:15px;font-weight:600;cursor:pointer;padding:4px 8px;font-family:inherit}.tabs-count-badge{width:21px;height:21px;border:1.7px solid currentColor;border-radius:5px;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center}@media(max-width:960px){.app{grid-template-columns:230px 1fr}.outline-menu-trigger{display:flex}.backdrop.open{display:block;position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:20}.workspace-body:not(.outline-bottom) .rightbar{position:fixed;inset:0 0 0 auto;width:min(84vw,300px);z-index:30;transform:translate(100%);transition:transform .18s ease}.workspace-body:not(.outline-bottom) .rightbar.mobile-open{transform:translate(0)}}@media(max-width:768px){.app{grid-template-columns:1fr}.workspace-body.outline-bottom .rightbar-body{grid-template-columns:1fr;gap:10px;padding:10px 14px calc(74px + env(safe-area-inset-bottom,0px))}.menu-btn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0}.menu-btn svg{width:19px;height:19px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}.icon-btn{width:34px;height:34px}.desktop-tabs,.fab-wrap{display:none}.sheet-backdrop,.bottom-sheet{display:block}.sidebar{position:fixed;inset:0 auto 0 0;width:min(84vw,310px);z-index:30;transform:translate(-100%);transition:transform .18s ease}.sidebar.open{transform:translate(0)}.backdrop.open{display:block;position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:20}.brand{height:48px;padding:0 12px 0 14px}.brand-title{font-size:15px;gap:8px}.sidebar-tabs{margin:10px 12px 0;padding:3px;gap:2px}.sidebar-tab{font-size:13px;padding:6px 8px;border-radius:6px}.search-wrap{padding:8px 12px 10px}.search{font-size:16px;padding:8px 11px;border-radius:7px}.tree{padding:8px 10px;font-size:14px}.tree-dir-btn,.tree-file{padding:8px 9px;font-size:14px;border-radius:6px}.tree-row-more{min-width:32px;min-height:32px;padding:4px 6px;font-size:15px;display:inline-flex;align-items:center;justify-content:center}.changes-bar{padding:6px 8px 8px}.changes-select{font-size:13.5px;padding:6px 9px}.topbar{height:48px;padding:0 12px}.rightbar-head{height:44px;padding:0 12px}.crumbs{font-size:13px}.btn{padding:8px 13px;font-size:13.5px;border-radius:8px}.more-menu,.file-ctx-menu{min-width:200px;padding:5px;border-radius:12px}.more-item{padding:10px 12px;font-size:14px;border-radius:8px}.new-tab-view{gap:12px}.new-tab-btn{width:min(84vw,270px);padding:14px 20px;font-size:15.5px}.new-tab-btn svg{width:19px;height:19px}.switcher-tab{font-size:13.5px;padding:7px 12px}.switcher-item{padding:12px 14px}.switcher-path{font-size:15px}.switcher-snippet{font-size:13px}.switcher-input{font-size:16px;padding:11px 16px}.switcher-clear{width:34px;height:34px;font-size:17px}.field label{font-size:13px}.field input[type=text],.field select{font-size:16px;padding:11px 12px;border-radius:9px}.folder-picker{max-height:200px;padding:6px}.folder-pick-item{padding:10px 12px;font-size:14px;border-radius:7px}.toggle-row{padding:12px 14px;font-size:14px}.commit-file-row{padding:8px 10px;font-size:14px}.content-scroll{padding:18px 16px calc(86px + env(safe-area-inset-bottom,0px))}.mobile-bar{position:fixed;left:50%;transform:translate(-50%);bottom:calc(14px + env(safe-area-inset-bottom,0px));z-index:25;display:flex;align-items:center;gap:6px;background:var(--glass);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);border:1px solid var(--border);border-radius:999px;padding:7px 12px;box-shadow:0 10px 30px #00000073}.mobile-bar-btn{background:none;border:0;color:var(--muted);cursor:pointer;display:flex;align-items:center;justify-content:center;width:42px;height:40px;border-radius:999px}.mobile-bar-btn svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round}.mobile-bar-btn.active,.mobile-bar-btn:active{color:var(--accent);background:var(--accent-soft)}.tabs-count-badge{width:23px;height:23px;font-size:12px}.sheet-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;z-index:35}.bottom-sheet{position:fixed;left:0;right:0;bottom:0;z-index:36;background:var(--bg-alt);border-top:1px solid var(--border);border-radius:18px 18px 0 0;padding:10px 14px calc(18px + env(safe-area-inset-bottom,0px));box-shadow:0 -12px 36px #00000080}.sheet-handle{width:38px;height:4px;border-radius:999px;background:var(--border);margin:0 auto 12px}.sheet-list{background:var(--bg);border:1px solid var(--border);border-radius:12px;overflow:hidden}.sheet-item{width:100%;background:none;border:0;border-bottom:1px solid var(--border);color:var(--text);padding:14px 16px;font-size:15px;font-family:inherit;display:flex;align-items:center;gap:12px;cursor:pointer;text-align:left}.sheet-item:last-child{border-bottom:0}.sheet-item:active,.sheet-item:hover{background:var(--bg-hover);color:var(--accent)}.sheet-item svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0;color:var(--muted)}}.media-viewer{display:flex;flex-direction:column;height:100%;min-height:480px}.media-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 16px;border-bottom:1px solid var(--border);background:var(--bg-alt);font-size:13px;color:var(--muted)}.pdf-frame,.html-frame{flex:1;width:100%;height:100%;min-height:600px;border:0;background:#fff}.video-player{width:100%;max-width:960px;max-height:calc(100vh - 180px);margin:24px auto;border-radius:10px;background:#000}.csv-scroll{overflow-x:auto}
@@ -0,0 +1,6 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TiptapEditor-OFHNcjy3.js","assets/vendor-react-E4kvVwMA.js","assets/vendor-tiptap-ChgD7Piv.js","assets/vendor-markdown-C94ubdL7.js"])))=>i.map(i=>d[i]);
2
+ import{a as u,j as e,R as Is,c as Ws}from"./vendor-react-E4kvVwMA.js";import{m as Dt}from"./vendor-markdown-C94ubdL7.js";import{H as De,d as zs}from"./vendor-hljs-B8we2J8a.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const n of document.querySelectorAll('link[rel="modulepreload"]'))c(n);new MutationObserver(n=>{for(const o of n)if(o.type==="childList")for(const d of o.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&c(d)}).observe(document,{childList:!0,subtree:!0});function i(n){const o={};return n.integrity&&(o.integrity=n.integrity),n.referrerPolicy&&(o.referrerPolicy=n.referrerPolicy),n.crossOrigin==="use-credentials"?o.credentials="include":n.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function c(n){if(n.ep)return;n.ep=!0;const o=i(n);fetch(n.href,o)}})();const ne={theme:"dark",fontSize:15,lineHeight:1.65,maxWidth:780,outlinePosition:"right",startupMode:"readme",startupPath:"README.md",autoCollapsed:["apps"],hiddenFolders:[],hideCollapsedInSearch:!0};function _s(){try{const s=localStorage.getItem("vault-settings");if(!s)return ne;const t=JSON.parse(s);return{...ne,...t,theme:t.theme==="light"?"light":"dark",fontSize:Number(t.fontSize)>=12&&Number(t.fontSize)<=22?Number(t.fontSize):15,lineHeight:Number(t.lineHeight)>=1.3&&Number(t.lineHeight)<=2.1?Number(t.lineHeight):1.65,maxWidth:Number(t.maxWidth)>=560&&Number(t.maxWidth)<=1040?Number(t.maxWidth):780,outlinePosition:["right","bottom","hidden"].includes(t.outlinePosition)?t.outlinePosition:"right",autoCollapsed:Array.isArray(t.autoCollapsed)?t.autoCollapsed:["apps"],hiddenFolders:Array.isArray(t.hiddenFolders)?t.hiddenFolders:[]}}catch{return ne}}function Us(s){const t=decodeURIComponent(location.hash.slice(1)||"");return t||(s.startupMode==="newtab"?null:s.startupMode==="last"?localStorage.getItem("vault-last-path")||"README.md":s.startupMode==="custom"&&s.startupPath.trim()||"README.md")}function Ve(s){return s?s.split("/").pop().replace(/\.md$/i,""):"New tab"}function Fe(s){return/\.(md|markdown|mdx)$/i.test(s)}function $e(s){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(s)}function Mt(s){return/\.svg$/i.test(s)}function Oe(s){return/\.pdf$/i.test(s)}function qe(s){return/\.(mp3|wav|m4a|ogg)$/i.test(s)}function Xe(s){return/\.(mp4|webm|mov)$/i.test(s)}function Fs(s){return/\.html?$/i.test(s)}function Os(s){return/\.(csv|tsv)$/i.test(s)}function Ge(s){return/\.(epub|zip|tar|gz|tgz|7z|rar|docx?|xlsx?|pptx?|odt|ods|odp|mkv|avi|dmg|exe|bin|whl|sqlite|db)$/i.test(s)}function _t(s,t){const i=t.split("#")[0],c=s.includes("/")?s.split("/").slice(0,-1).join("/"):"",n=(c?`${c}/`:"")+i,o=[];for(const d of n.split("/"))d==="."||d===""||(d===".."?o.pop():o.push(d));return o.join("/")}function qs(s,t){const i=s.split("|")[0].split("#")[0].trim().replace(/\.md$/i,"").replace(/^\/+/,"").toLowerCase();if(!i)return null;const c=t.filter(d=>d.endsWith(".md")),n=c.find(d=>d.slice(0,-3).toLowerCase()===i);if(n)return n;const o=i.split("/").pop();return c.find(d=>d.slice(0,-3).split("/").pop().toLowerCase()===o)||null}function Ke(s,t){const i=(s||"").trim().replace(/^\/+|\/+$/g,"");if(!i)return"";const c=/\.[a-z0-9]+$/i.test(i)?i:`${i}.md`,n=(t||"").trim().replace(/^\/+|\/+$/g,"");return n?`${n}/${c}`:c}De.registerLanguage("dockerfile",zs);const At={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"typescript",py:"python",pyw:"python",sh:"bash",bash:"bash",zsh:"bash",json:"json",jsonc:"json",yml:"yaml",yaml:"yaml",css:"css",scss:"scss",less:"less",html:"xml",htm:"xml",xml:"xml",svg:"xml",md:"markdown",markdown:"markdown",sql:"sql",rs:"rust",go:"go",java:"java",kt:"kotlin",c:"c",h:"c",cpp:"cpp",hpp:"cpp",cc:"cpp",toml:"ini",ini:"ini",conf:"ini",env:"ini",diff:"diff",patch:"diff",rb:"ruby",php:"php",swift:"swift",makefile:"makefile",dockerfile:"dockerfile"};function Ut(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ft(s,t){const i=String(s??"");try{const c=(t||"").trim().toLowerCase();if(c&&De.getLanguage(c))return De.highlight(i,{language:c,ignoreIllegals:!0}).value;if(i.length<=15e4)return De.highlightAuto(i).value}catch{}return Ut(i)}function Xs(s,t,i){const c=[],o=s.split(/(```[\s\S]*?```)/g).map((l,r)=>r%2===1?l:l.replace(/\[\[([^\]]+)\]\]/g,(x,p)=>{const[m,$]=p.split("|"),R=($||m).trim(),C=qs(p,i);return C?`<a class="wikilink" data-path="${C.replace(/"/g,"&quot;")}">${R}</a>`:`<span class="wikilink broken" title="Note not created yet">${R}</span>`})).join(""),d=new Dt.Renderer;return d.heading=({tokens:l,depth:r})=>{const x=d.parser.parseInline(l),p=x.replace(/<[^>]+>/g,""),m=p.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return c.push({level:r,text:p,id:m}),`<h${r} id="${m}">${x}</h${r}>`},d.image=({href:l,title:r,text:x})=>`<img src="${/^https?:\/\//.test(l)?l:`/api/v1/file?path=${encodeURIComponent(_t(t,l))}`}" alt="${x||""}"${r?` title="${r}"`:""} />`,d.link=({href:l,title:r,tokens:x})=>{const p=d.parser.parseInline(x);return/^https?:\/\//.test(l)?`<a href="${l}" target="_blank" rel="noreferrer"${r?` title="${r}"`:""}>${p}</a>`:`<a class="md-rel-link" data-href="${l.replace(/"/g,"&quot;")}">${p}</a>`},d.code=({text:l,lang:r})=>{const x=Ft(l,r);return`<pre><code class="${r?`hljs language-${Ut(r.trim())}`:"hljs"}">${x}</code></pre>`},{renderedHtml:Dt.parse(o,{renderer:d,gfm:!0,breaks:!1}),headings:c}}function Gs(s,t){if(!s)return"";const i=t.split("/").pop().toLowerCase(),c=i.includes(".")?i.split(".").pop():i,n=At[c]||At[i]||"";return Ft(s,n)}const Vs=120,Ks=.28,Bt=6,Te=.25,Le=.28,Re=18;function Js(s){let t=s;for(;t&&t!==document.body;){const i=t.tagName;if(i==="PRE"||i==="TABLE"||i==="INPUT"||i==="TEXTAREA"||i==="SELECT"||t.isContentEditable)return!0;if(t.scrollWidth>t.clientWidth+2){const c=getComputedStyle(t).overflowX;if(c==="auto"||c==="scroll")return!0}t=t.parentElement}return!1}function Pt(s,t){if(s)for(const i of t)s.style[i]=""}function Ys({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i="right",setDrawerOpen:c,onOpenOutline:n,setOutlineDrawerOpen:o,disabled:d=!1}){const b=u.useRef({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i,setDrawerOpen:c,onOpenOutline:n,setOutlineDrawerOpen:o,disabled:d});b.current={drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i,setDrawerOpen:c,onOpenOutline:n,setOutlineDrawerOpen:o,disabled:d},u.useEffect(()=>{let l=null;const r=C=>{C&&(Pt(C.panelEl,["transform","transition"]),Pt(C.backdropEl,["display","position","inset","zIndex","background","opacity","transition"]))},x=C=>{const h=b.current;if(h.disabled||C.touches.length!==1)return;const v=C.touches[0],S=v.clientX,L=v.clientY,f=document.documentElement.clientWidth||window.innerWidth,y=Math.min(Vs,Math.round(f*Ks));let w=null,E=null;if(h.drawerOpen&&f<=768?(w="left",E="close"):h.outlineDrawerOpen&&f<=960&&h.outlinePosition!=="bottom"?(w="right",E="close"):!h.drawerOpen&&!h.outlineDrawerOpen&&!Js(C.target)&&(S<=y&&f<=768?(w="left",E="open"):S>=f-y&&f<=960&&h.outlinePosition!=="bottom"&&(w="right",E="open")),!w)return;const B=document.querySelector(w==="left"?".sidebar":".rightbar"),W=document.querySelector(".backdrop"),U=(B==null?void 0:B.offsetWidth)||(w==="left"?310:300);l={side:w,action:E,startX:S,startY:L,lastX:S,startTime:performance.now(),lastTime:performance.now(),locked:null,panelEl:B,backdropEl:W,width:U}},p=C=>{if(!l||C.touches.length!==1)return;const h=C.touches[0],v=h.clientX-l.startX,S=h.clientY-l.startY;if(l.lastX=h.clientX,l.lastTime=performance.now(),!l.locked){if(Math.abs(S)>=Bt&&Math.abs(S)>=Math.abs(v)){l.locked="vertical",l=null;return}if(Math.abs(v)>=Bt&&Math.abs(v)>Math.abs(S)){if(!(l.side==="left"&&l.action==="open"&&v>0||l.side==="left"&&l.action==="close"&&v<0||l.side==="right"&&l.action==="open"&&v<0||l.side==="right"&&l.action==="close"&&v>0)){l=null;return}l.locked="horizontal",l.panelEl&&(l.panelEl.style.transition="none"),l.backdropEl&&(l.backdropEl.style.display="block",l.backdropEl.style.position="fixed",l.backdropEl.style.inset="0",l.backdropEl.style.zIndex="20",l.backdropEl.style.background="rgba(0, 0, 0, 0.5)",l.backdropEl.style.transition="none")}else return}l.locked==="horizontal"&&C.cancelable&&C.preventDefault();const L=l.width;let f;if(l.side==="left"?f=l.action==="open"?v/L:1+v/L:f=l.action==="open"?-v/L:1-v/L,f=Math.max(0,Math.min(1,f)),l.panelEl){const y=l.side==="left"?(f-1)*100:(1-f)*100;l.panelEl.style.transform=`translateX(${y}%)`}l.backdropEl&&(l.backdropEl.style.opacity=String(f))},m=C=>{if(!l)return;const h=l;if(l=null,h.locked!=="horizontal"){r(h);return}const v=h.lastX-h.startX,S=Math.max(1,h.lastTime-h.startTime),L=v/S;let f=!1;if(C||(h.side==="left"&&h.action==="open"?f=v>=h.width*Te||v>=Re&&L>=Le:h.side==="left"&&h.action==="close"||h.side==="right"&&h.action==="open"?f=-v>=h.width*Te||-v>=Re&&-L>=Le:h.side==="right"&&h.action==="close"&&(f=v>=h.width*Te||v>=Re&&L>=Le)),r(h),!f)return;const y=b.current;h.side==="left"?h.action==="open"?(y.setOutlineDrawerOpen(!1),y.setDrawerOpen(!0)):y.setDrawerOpen(!1):h.action==="open"?y.onOpenOutline():y.setOutlineDrawerOpen(!1)},$=()=>m(!1),R=()=>m(!0);return window.addEventListener("touchstart",x,{passive:!0}),window.addEventListener("touchmove",p,{passive:!1}),window.addEventListener("touchend",$,{passive:!0}),window.addEventListener("touchcancel",R,{passive:!0}),()=>{window.removeEventListener("touchstart",x),window.removeEventListener("touchmove",p),window.removeEventListener("touchend",$),window.removeEventListener("touchcancel",R)}},[])}const Qs=450,Ht=8;function It(s){const t=u.useRef(null),i=u.useRef(null),c=u.useRef(!1),n=()=>{t.current&&(clearTimeout(t.current),t.current=null)};return{onTouchStart:o=>{if(o.touches.length!==1)return;const d=o.touches[0],b=o.currentTarget.closest(".tree-file-row")||o.currentTarget;i.current={x:d.clientX,y:d.clientY},c.current=!1,n(),t.current=setTimeout(()=>{var l;t.current=null,c.current=!0,(l=navigator.vibrate)==null||l.call(navigator,10),s(b.getBoundingClientRect())},Qs)},onTouchMove:o=>{if(!t.current||!i.current||o.touches.length!==1)return;const d=o.touches[0];(Math.abs(d.clientX-i.current.x)>Ht||Math.abs(d.clientY-i.current.y)>Ht)&&n()},onTouchEnd:()=>n(),onTouchCancel:()=>n(),onContextMenu:o=>{o.preventDefault();const d=o.currentTarget.closest(".tree-file-row")||o.currentTarget;s(d.getBoundingClientRect())},consumeClick:o=>c.current?(c.current=!1,o.preventDefault(),o.stopPropagation(),!0):!1}}function Ot({node:s,activePath:t,filter:i,collapsed:c,hiddenSet:n,onToggleDir:o,onSelectFile:d,onOpenMenu:b}){const l=It(x=>b(s.path,x,"dir")),r=It(x=>b(s.path,x,"file"));if(s.type==="dir"){if(n.has(s.path.toLowerCase())||n.has(s.name.toLowerCase()))return null;const x=m=>m.type==="file"?m.path.toLowerCase().includes(i):m.children.some(x);if(i&&!x(s))return null;const p=!i&&c.has(s.path);return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-file-row",children:[e.jsxs("button",{className:"tree-dir-btn",title:s.path,onTouchStart:l.onTouchStart,onTouchMove:l.onTouchMove,onTouchEnd:l.onTouchEnd,onTouchCancel:l.onTouchCancel,onContextMenu:l.onContextMenu,onClick:m=>{l.consumeClick(m)||o(s.path)},children:[p?"▸ ":"▾ ",s.name]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for folder ${s.name}`,onClick:m=>{m.stopPropagation(),b(s.path,m.currentTarget.getBoundingClientRect(),"dir")},children:"⋯"})]}),!p&&e.jsx("div",{className:"tree-children",children:s.children.map(m=>e.jsx(Ot,{node:m,activePath:t,filter:i,collapsed:c,hiddenSet:n,onToggleDir:o,onSelectFile:d,onOpenMenu:b},m.path))})]})}return i&&!s.path.toLowerCase().includes(i)?null:e.jsxs("div",{className:`tree-file-row${s.path===t?" active":""}`,children:[e.jsx("button",{className:`tree-file${s.path===t?" active":""}`,title:s.path,onTouchStart:r.onTouchStart,onTouchMove:r.onTouchMove,onTouchEnd:r.onTouchEnd,onTouchCancel:r.onTouchCancel,onContextMenu:r.onContextMenu,onClick:x=>{r.consumeClick(x)||d(s.path)},children:s.name}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${s.name}`,onClick:x=>{x.stopPropagation(),b(s.path,x.currentTarget.getBoundingClientRect())},children:"⋯"})]})}function Zs({drawerOpen:s,live:t,settings:i,setSettings:c,sidebarTab:n,setSidebarTab:o,gitChanges:d,searchRef:b,filter:l,setFilter:r,tree:x,activePath:p,collapsed:m,hiddenSet:$,toggleDir:R,setViewMode:C,openFile:h,openRowMenu:v,changesSort:S,setChangesSort:L,openCommitDialog:f,sortedChanges:y,loadDiff:w}){return e.jsxs("aside",{className:`sidebar${s?" open":""}`,children:[e.jsxs("div",{className:"brand",children:[e.jsxs("div",{className:"brand-title",children:[e.jsx("img",{src:"/vault-logo.svg",alt:"",width:"20",height:"20",className:"brand-logo"}),e.jsx("span",{children:"Vault"}),e.jsx("span",{className:`pill${t?"":" off"}`,children:t?"Live":"Reconnecting"})]}),e.jsx("button",{className:"icon-btn","aria-label":i.theme==="dark"?"Switch to light theme":"Switch to dark theme",title:i.theme==="dark"?"Switch to light theme":"Switch to dark theme",onClick:()=>c(E=>({...E,theme:E.theme==="dark"?"light":"dark"})),children:i.theme==="dark"?e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}):e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})})]}),e.jsxs("div",{className:"sidebar-tabs",children:[e.jsx("button",{className:`sidebar-tab${n==="files"?" active":""}`,onClick:()=>o("files"),children:"Files"}),e.jsxs("button",{className:`sidebar-tab${n==="changes"?" active":""}`,onClick:()=>o("changes"),children:[e.jsx("span",{children:"Changes"}),d.length>0&&e.jsx("span",{className:"pill",children:d.length})]})]}),e.jsx("div",{className:"search-wrap",children:e.jsx("input",{ref:b,className:"search",type:"search",placeholder:n==="files"?"Filter files... (/)":"Filter changes...",value:l,onChange:E=>r(E.target.value.trim().toLowerCase())})}),e.jsx("div",{className:"tree",children:n==="files"?x.map(E=>e.jsx(Ot,{node:E,activePath:p,filter:l,collapsed:m,hiddenSet:$,onToggleDir:R,onSelectFile:B=>{C("preview"),h(B)},onOpenMenu:v},E.path)):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"changes-bar",children:[e.jsxs("select",{className:"changes-select","aria-label":"Sort changes",value:S,onChange:E=>L(E.target.value),children:[e.jsx("option",{value:"path",children:"Sort: Path"}),e.jsx("option",{value:"recent",children:"Sort: Recent"}),e.jsx("option",{value:"status",children:"Sort: Status"})]}),d.length>0&&e.jsx("button",{className:"btn primary",onClick:f,children:"Commit"})]}),y.length===0?e.jsx("div",{className:"empty-note",style:{padding:"10px 8px"},children:"Working tree clean"}):y.map(E=>e.jsxs("div",{className:`tree-file-row${E.path===p?" active":""}`,children:[e.jsxs("button",{className:`tree-file${E.path===p?" active":""}`,title:E.path,onClick:()=>{E.status!=="D"&&(C("diff"),h(E.path),w(E.path))},children:[e.jsx("span",{className:`git-badge git-${E.status}`,children:E.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:E.path})]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${E.path}`,onClick:B=>{B.stopPropagation(),v(E.path,B.currentTarget.getBoundingClientRect())},children:"⋯"})]},E.path))]})})]})}function en({tabs:s,activeTabId:t,switchTab:i,closeTab:c,createNewTab:n}){return e.jsxs("div",{className:"desktop-tabs",children:[s.map(o=>e.jsxs("div",{className:`desktop-tab${o.id===t?" active":""}`,onClick:()=>i(o),children:[e.jsx("span",{className:"desktop-tab-title",children:o.title}),e.jsx("button",{className:"desktop-tab-close",onClick:d=>c(o.id,d),children:"×"})]},o.id)),e.jsx("button",{className:"desktop-tab-add",title:"New tab",onClick:n,children:"+"})]})}function tn({setDrawerOpen:s,activePath:t,moreMenuOpen:i,setMoreMenuOpen:c,viewMode:n,setViewMode:o,loadDiff:d,setDeleteError:b,setDeleteTarget:l,outlinePosition:r,outlineDrawerOpen:x,onToggleOutline:p,onOpenOutline:m}){const $=x||r!=="hidden";return e.jsxs("div",{className:"topbar",children:[e.jsxs("div",{className:"topbar-left",children:[e.jsx("button",{className:"icon-btn menu-btn","aria-label":"Toggle files",onClick:()=>s(R=>!R),children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("div",{className:"crumbs",children:t||"New tab"})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:`icon-btn outline-toggle-btn${$?" active":""}`,"aria-label":"Toggle outline",title:"Toggle outline & backlinks",onClick:p,children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M15 3v18"})]})}),e.jsx("button",{className:"icon-btn","aria-label":"Note options",title:"Note options",onClick:()=>c(R=>!R),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}),i&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>c(!1),children:[t&&e.jsx("a",{className:"more-item",href:`/api/v1/file?path=${encodeURIComponent(t)}&download=1`,download:t.split("/").pop(),style:{textDecoration:"none",borderBottom:"1px solid var(--border)",marginBottom:3,paddingBottom:9},onClick:()=>c(!1),children:e.jsx("span",{children:"Download"})}),e.jsxs("button",{className:`more-item${n==="preview"?" active":""}`,onClick:()=>{o("preview"),c(!1)},children:[e.jsx("span",{children:"Preview"}),n==="preview"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${n==="edit"?" active":""}`,onClick:()=>{o("edit"),c(!1)},children:[e.jsx("span",{children:"Edit"}),n==="edit"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${n==="diff"?" active":""}`,onClick:()=>{o("diff"),c(!1),d(t)},children:[e.jsx("span",{children:"Diff"}),n==="diff"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${n==="raw"?" active":""}`,onClick:()=>{o("raw"),c(!1)},children:[e.jsx("span",{children:"Raw"}),n==="raw"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:`more-item outline-menu-trigger${r==="hidden"?" show-desktop":""}`,style:{borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{c(!1),m()},children:e.jsx("span",{children:"Outline"})}),t&&e.jsx("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{c(!1),b(""),l(t)},children:e.jsx("span",{children:"Delete"})})]})]})]})}const sn="modulepreload",nn=function(s){return"/"+s},Wt={},an=function(t,i,c){let n=Promise.resolve();if(i&&i.length>0){let d=function(r){return Promise.all(r.map(x=>Promise.resolve(x).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const b=document.querySelector("meta[property=csp-nonce]"),l=(b==null?void 0:b.nonce)||(b==null?void 0:b.getAttribute("nonce"));n=d(i.map(r=>{if(r=nn(r),r in Wt)return;Wt[r]=!0;const x=r.endsWith(".css"),p=x?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${r}"]${p}`))return;const m=document.createElement("link");if(m.rel=x?"stylesheet":sn,x||(m.as="script"),m.crossOrigin="",m.href=r,l&&m.setAttribute("nonce",l),document.head.appendChild(m),x)return new Promise(($,R)=>{m.addEventListener("load",$),m.addEventListener("error",()=>R(new Error(`Unable to preload CSS for ${r}`)))})}))}function o(d){const b=new Event("vite:preloadError",{cancelable:!0});if(b.payload=d,window.dispatchEvent(b),!b.defaultPrevented)throw d}return n.then(d=>{for(const b of d||[])b.status==="rejected"&&o(b.reason);return t().catch(o)})};function ln(s,t=","){const i=[];let c=[],n="",o=!1;for(let d=0;d<s.length;d+=1){const b=s[d];if(o){b==='"'?s[d+1]==='"'?(n+='"',d+=1):o=!1:n+=b;continue}b==='"'?o=!0:b===t?(c.push(n),n=""):b==="\r"?(s[d+1]===`
3
+ `&&(d+=1),c.push(n),i.push(c),c=[],n=""):b===`
4
+ `?(c.push(n),i.push(c),c=[],n=""):n+=b}return(n.length>0||c.length>0)&&(c.push(n),i.push(c)),i}const on=u.lazy(()=>an(()=>import("./TiptapEditor-OFHNcjy3.js"),__vite__mapDeps([0,1,2,3])));function rn({scrollRef:s,activePath:t,openNewNoteDialog:i,openFile:c,openSwitcher:n,setDrawerOpen:o,setSettingsOpen:d,isImg:b,isSvg:l,isMarkdown:r,isPdf:x,isAudio:p,isVideo:m,isHtml:$,isCsv:R,reloadTick:C,isBinaryDownload:h,viewMode:v,settings:S,diffData:L,requestDiscard:f,content:y,saving:w,dirty:E,setDraftContent:B,setDirty:W,saveActiveNote:U,highlightedRawHtml:Me,handleDocClick:pe,renderedHtml:G}){var ee,fe;const V=u.useMemo(()=>{if(!R||v!=="preview"||!y)return[];const I=t.toLowerCase().endsWith(".tsv")?" ":",";return ln(y,I)},[R,v,y,t]),ae=t?`/api/v1/file?path=${encodeURIComponent(t)}&t=${C}`:"",Q=t?`/api/v1/file?path=${encodeURIComponent(t)}&download=1`:"",Z=t?`/raw/${t.split("/").map(encodeURIComponent).join("/")}?t=${C}`:"";return e.jsx("div",{ref:s,className:"content-scroll",children:t?b&&!(l&&v==="raw")?e.jsx("div",{className:"doc img-wrap",children:e.jsx("img",{src:ae,alt:t})}):x?e.jsxs("div",{className:"media-viewer pdf-viewer",children:[e.jsxs("div",{className:"media-bar",children:[e.jsx("span",{children:t.split("/").pop()}),e.jsx("a",{className:"btn",href:Q,download:t.split("/").pop(),children:"Download PDF"})]}),e.jsx("iframe",{className:"pdf-frame",src:ae,title:t})]}):p?e.jsxs("div",{className:"doc binary-card audio-viewer",children:[e.jsx("div",{className:"binary-card-name",children:t.split("/").pop()}),e.jsx("div",{className:"binary-card-path",children:t}),e.jsx("audio",{controls:!0,src:ae,style:{width:"100%",maxWidth:460}}),e.jsx("a",{className:"btn",href:Q,download:t.split("/").pop(),style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6,marginTop:12},children:"Download audio"})]}):m?e.jsxs("div",{className:"media-viewer video-viewer",children:[e.jsxs("div",{className:"media-bar",children:[e.jsx("span",{children:t.split("/").pop()}),e.jsx("a",{className:"btn",href:Q,download:t.split("/").pop(),children:"Download video"})]}),e.jsx("video",{controls:!0,src:ae,className:"video-player"})]}):h?e.jsxs("div",{className:"doc binary-card",children:[e.jsx("div",{className:"binary-card-name",children:t.split("/").pop()}),e.jsx("div",{className:"binary-card-path",children:t}),e.jsx("a",{className:"btn primary",href:`/api/v1/file?path=${encodeURIComponent(t)}&download=1`,download:t.split("/").pop(),style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6},children:"Download file"})]}):v==="diff"?e.jsxs("div",{className:"diff-wrap",style:{maxWidth:`${S.maxWidth+80}px`},children:[e.jsxs("div",{className:"diff-head",children:[e.jsx("span",{style:{fontSize:13,color:"var(--muted)"},children:L!=null&&L.untracked?"Untracked file":`${((ee=L==null?void 0:L.hunks)==null?void 0:ee.length)||0} hunk(s)`}),((fe=L==null?void 0:L.hunks)==null?void 0:fe.length)>0&&e.jsx("button",{className:"btn",style:{color:"#f87171"},onClick:()=>f(),children:"Discard file"})]}),!L||L.hunks.length===0?e.jsx("div",{className:"empty-note",children:"No uncommitted changes for this file."}):L.hunks.map((I,O)=>e.jsxs("div",{className:"diff-hunk",children:[e.jsxs("div",{className:"diff-hunk-bar",children:[e.jsx("span",{children:I.header}),!L.untracked&&e.jsx("button",{className:"btn",onClick:()=>f({hunkIndex:O}),children:"Discard hunk"})]}),I.lines.map((z,H)=>e.jsxs("div",{className:`diff-line ${z.type}`,children:[e.jsx("span",{className:"diff-ln",children:z.newLine??z.oldLine??""}),e.jsx("span",{className:"diff-sig",children:z.type==="add"?"+":z.type==="del"?"-":" "}),e.jsx("span",{className:"diff-txt",children:z.text||" "}),!L.untracked&&z.type!=="context"?e.jsx("button",{className:"diff-discard-btn",title:"Discard line",onClick:()=>f({hunkIndex:O,lineIndex:H,previewText:`${z.type==="add"?"+":"-"} ${z.text}`}),children:"↺"}):e.jsx("span",{})]},H))]},O))]}):v==="edit"&&r?e.jsx(u.Suspense,{fallback:e.jsx("div",{className:"empty-note",style:{padding:"24px"},children:"Loading editor..."}),children:e.jsx(on,{fileKey:t,content:y,fontSize:S.fontSize,lineHeight:S.lineHeight,maxWidth:S.maxWidth,saving:w,dirty:E,onChange:I=>{B(I),W(I!==y)},onSave:U})}):$&&v==="preview"?e.jsx("div",{className:"media-viewer html-viewer",children:e.jsx("iframe",{className:"html-frame",src:Z,sandbox:"allow-scripts",title:t})}):R&&v==="preview"?e.jsx("div",{className:"doc csv-wrap",style:{fontSize:`${Math.max(12,S.fontSize-1)}px`,maxWidth:`${S.maxWidth+160}px`},children:V.length===0?e.jsx("div",{className:"empty-note",children:"Empty table."}):e.jsx("div",{className:"csv-scroll",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsx("tr",{children:V[0].map((I,O)=>e.jsx("th",{children:I},O))})}),e.jsx("tbody",{children:V.slice(1).map((I,O)=>e.jsx("tr",{children:V[0].map((z,H)=>e.jsx("td",{children:I[H]??""},H))},O))})]})})}):v==="raw"||!r?e.jsx("pre",{className:"raw-view",style:{fontSize:`${Math.max(12,S.fontSize-2)}px`,maxWidth:`${S.maxWidth+80}px`},children:e.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:Me}})}):e.jsx("div",{className:"doc",style:{fontSize:`${S.fontSize}px`,lineHeight:S.lineHeight,maxWidth:`${S.maxWidth}px`},onClick:pe,dangerouslySetInnerHTML:{__html:G}}):e.jsxs("div",{className:"new-tab-view",children:[e.jsxs("button",{className:"new-tab-btn",onClick:()=>i(""),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{children:"Create new note"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>c("README.md"),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"})}),e.jsx("span",{children:"Go to README"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:n,children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]}),e.jsx("span",{children:"Go to file"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>o(!0),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})}),e.jsx("span",{children:"Browse files"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>d(!0),children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:"Settings"})]})]})})}function cn({headings:s,isImg:t,isBinaryDownload:i,viewMode:c,currentBacklinks:n,openFile:o,position:d="right",onChangePosition:b,mobileOpen:l=!1,onCloseMobile:r}){const[x,p]=u.useState(!1);if(d==="hidden"&&!l&&window.innerWidth>960)return null;const m=t?"Image preview":i?"Binary file":c==="raw"?"Raw view":c==="edit"?"Edit mode":c==="diff"?"Diff mode":"No headings";return e.jsxs("aside",{className:`rightbar${l?" mobile-open":""}`,children:[e.jsxs("div",{className:"rightbar-head",children:[e.jsx("div",{className:"panel-title",style:{margin:0},children:d==="bottom"?"Outline & Backlinks":"Outline"}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:"icon-btn","aria-label":"Outline panel options",title:"Outline panel options",onClick:()=>p($=>!$),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}),x&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>p(!1),children:[e.jsxs("button",{className:`more-item${d==="right"?" active":""}`,onClick:()=>{b("right"),p(!1)},children:[e.jsx("span",{children:"Position: Right"}),d==="right"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${d==="bottom"?" active":""}`,onClick:()=>{b("bottom"),r==null||r(),p(!1)},children:[e.jsx("span",{children:"Position: Bottom"}),d==="bottom"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:"more-item",style:{borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{window.innerWidth<=960&&l?r==null||r():b("hidden"),p(!1)},children:e.jsx("span",{children:"Hide panel"})})]})]})]}),e.jsxs("div",{className:"rightbar-body",children:[e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-subtitle",children:"Outline"}),s.length===0?e.jsx("div",{className:"empty-note",children:m}):s.map(($,R)=>e.jsx("a",{className:`toc-item toc-h${$.level}`,onClick:()=>{var C;(C=document.getElementById($.id))==null||C.scrollIntoView({behavior:"smooth"}),r==null||r()},children:$.text},`${$.id}-${R}`))]}),e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-title backlinks-title",children:"Backlinks"}),n.length===0?e.jsx("div",{className:"empty-note",children:"No backlinks yet"}):n.map($=>e.jsx("a",{className:"backlink-item",onClick:()=>{o($),r==null||r()},children:$},$))]})]})]})}function dn({fabOpen:s,setFabOpen:t,openSwitcher:i,drawerOpen:c,setDrawerOpen:n,openFile:o,viewMode:d,setViewMode:b,settings:l,setSettings:r,setSettingsOpen:x,scrollRef:p,loadDiff:m,activePath:$,createNewTab:R,tabsOpen:C,setTabsOpen:h,tabs:v,activeTabId:S,switchTab:L,closeTab:f,onToggleOutline:y}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fab-wrap",children:[s&&e.jsxs("div",{className:"fab-menu",children:[e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),i()},children:"🔍 Quick switcher"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),n(w=>!w)},children:"📁 Toggle files"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),y==null||y()},children:"📑 Toggle outline"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),o("README.md")},children:"🏠 Home (README)"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),b(w=>w==="raw"?"preview":"raw")},children:d==="raw"?"📄 Preview mode":"🧾 Raw view"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),r(w=>({...w,theme:w.theme==="dark"?"light":"dark"}))},children:l.theme==="dark"?"☀️ Light theme":"🌙 Dark theme"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),x(!0)},children:"⚙️ Settings"}),e.jsx("button",{className:"fab-item",onClick:()=>{var w;t(!1),(w=p.current)==null||w.scrollTo({top:0,behavior:"smooth"})},children:"⬆️ Scroll to top"})]}),e.jsx("button",{className:"fab-btn","aria-label":"Quick actions",onClick:()=>t(w=>!w),children:s?"×":"+"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sheet-backdrop",onClick:()=>t(!1)}),e.jsxs("div",{className:"bottom-sheet",role:"dialog","aria-label":"Quick actions",children:[e.jsx("div",{className:"sheet-handle"}),e.jsxs("div",{className:"sheet-list",children:[e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),i()},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]}),e.jsx("span",{children:"Open quick switcher"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),n(w=>!w)},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]}),e.jsx("span",{children:"Toggle files sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),y==null||y()},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M15 3v18"})]}),e.jsx("span",{children:"Toggle outline sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),o("README.md")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"})}),e.jsx("span",{children:"Go to Home (README)"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b(w=>w==="edit"?"preview":"edit")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z"})}),e.jsx("span",{children:d==="edit"?"Switch to Preview mode":"Switch to Edit mode"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b("diff"),m($)},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 3v18M3 12h18"})}),e.jsx("span",{children:"View Git Diff"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),b(w=>w==="raw"?"preview":"raw")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"})}),e.jsx("span",{children:d==="raw"?"Switch to Preview mode":"Switch to Raw view"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{var w;t(!1),(w=p.current)==null||w.scrollTo({top:0,behavior:"smooth"})},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})}),e.jsx("span",{children:"Scroll to top"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),r(w=>({...w,theme:w.theme==="dark"?"light":"dark"}))},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}),e.jsx("span",{children:l.theme==="dark"?"Switch to Light theme":"Switch to Dark theme"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),x(!0)},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:"Settings"})]})]})]})]}),e.jsxs("nav",{className:"mobile-bar","aria-label":"Mobile quick actions",children:[e.jsx("button",{className:`mobile-bar-btn${c?" active":""}`,"aria-label":"Files",onClick:()=>{t(!1),n(w=>!w)},children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Back",onClick:()=>window.history.back(),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Forward",onClick:()=>window.history.forward(),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Search",onClick:()=>{t(!1),i()},children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"New tab",onClick:R,children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),e.jsx("button",{className:`mobile-bar-btn${C?" active":""}`,"aria-label":"Open tabs",onClick:()=>{t(!1),h(!0)},children:e.jsx("span",{className:"tabs-count-badge",children:v.length})}),e.jsx("button",{className:`mobile-bar-btn${s?" active":""}`,"aria-label":"Menu",onClick:()=>t(w=>!w),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})})})]}),C&&e.jsxs("div",{className:"tabs-overlay",onClick:()=>h(!1),children:[e.jsx("div",{className:"tabs-grid",onClick:w=>w.stopPropagation(),children:v.map(w=>e.jsxs("div",{className:"tab-card-wrap",children:[e.jsxs("div",{className:`tab-card${w.id===S?" active":""}`,onClick:()=>L(w),children:[e.jsx("button",{className:"tab-card-close","aria-label":"Close tab",onClick:E=>f(w.id,E),children:"×"}),e.jsx("div",{className:"tab-card-title",children:w.title}),e.jsx("div",{className:"tab-card-preview",children:w.preview||(w.path?w.path:"Empty tab")})]}),e.jsx("div",{className:"tab-card-label",children:w.title})]},w.id))}),e.jsxs("div",{className:"tabs-footer",onClick:w=>w.stopPropagation(),children:[e.jsx("button",{className:"tabs-footer-btn","aria-label":"New tab",onClick:R,children:"+"}),e.jsxs("span",{style:{fontSize:14,fontWeight:600},children:[v.length," ",v.length===1?"tab":"tabs"]}),e.jsx("button",{className:"tabs-footer-btn",onClick:()=>h(!1),children:"Done"})]})]})]})}function hn({switcherOpen:s,setSwitcherOpen:t,switcherTab:i,setSwitcherTab:c,switcherIdx:n,setSwitcherIdx:o,switcherInputRef:d,totalFiles:b,fileStats:l,switcherItems:r,switcherData:x,openFile:p,isLargeVault:m,pagedFiles:$,loadMorePagedFiles:R,switcherQuery:C,setSwitcherQuery:h}){return s?e.jsx("div",{className:"switcher-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"switcher",onClick:v=>v.stopPropagation(),children:[e.jsxs("div",{className:"switcher-head",children:[e.jsxs("div",{className:"switcher-tabs",children:[e.jsx("button",{className:`switcher-tab${i==="recent"?" active":""}`,onClick:()=>{var v;c("recent"),o(0),(v=d.current)==null||v.focus()},children:"Recent"}),e.jsx("button",{className:`switcher-tab${i==="alpha"?" active":""}`,onClick:()=>{var v;c("alpha"),o(0),(v=d.current)==null||v.focus()},children:"A–Z"})]}),b>l.length&&e.jsxs("span",{className:"switcher-cap",children:[l.length.toLocaleString()," / ",b.toLocaleString()," indexed"]})]}),e.jsxs("div",{className:"switcher-list",children:[r.length===0?e.jsx("div",{className:"empty-note",style:{padding:"12px"},children:"No matching notes"}):(()=>{let v=0;const S=Date.now(),L=f=>{if(!f)return"";const y=Math.max(0,S-f);return y<6e4?"now":y<36e5?`${Math.floor(y/6e4)}m`:y<864e5?`${Math.floor(y/36e5)}h`:y<7*864e5?`${Math.floor(y/864e5)}d`:new Date(f).toLocaleDateString(void 0,{month:"short",day:"numeric"})};return x.groups.map(f=>e.jsxs(Is.Fragment,{children:[f.label&&e.jsx("div",{className:"switcher-group-title",children:f.label}),f.items.map(y=>{const w=v++;return e.jsxs("button",{className:`switcher-item${w===n?" selected":""}`,onClick:()=>{t(!1),p(y.path)},children:[e.jsxs("div",{className:"switcher-row-top",children:[e.jsx("span",{className:"switcher-path",children:y.path}),y.mtimeMs>0&&e.jsx("span",{className:"switcher-time",children:L(y.mtimeMs)})]}),y.snippet&&e.jsx("span",{className:"switcher-snippet",children:y.snippet})]},y.path)})]},f.label||"all"))})(),m&&$.hasMore&&e.jsx("button",{className:"btn",style:{margin:"8px auto",display:"block"},onClick:R,children:"Load more"})]}),e.jsxs("div",{className:"switcher-input-wrap",children:[e.jsx("input",{ref:d,className:"switcher-input",type:"text",placeholder:"Find a note...",value:C,onChange:v=>{h(v.target.value),o(0)},onKeyDown:v=>{v.key==="ArrowDown"?(v.preventDefault(),o(S=>Math.min(S+1,Math.max(0,r.length-1)))):v.key==="ArrowUp"?(v.preventDefault(),o(S=>Math.max(S-1,0))):v.key==="Enter"&&r[n]&&(v.preventDefault(),t(!1),p(r[n].path))}}),e.jsx("button",{className:"switcher-clear","aria-label":"Clear or close",onClick:()=>C?h(""):t(!1),children:"×"})]})]})}):null}function mn({fileMenu:s,setFileMenu:t,openNewNoteDialog:i,uploadDirRef:c,uploadInputRef:n,setRenameError:o,setRenameTarget:d,setTabs:b,setActiveTabId:l,setViewMode:r,openFile:x,gitChanges:p,loadDiff:m,requestDiscard:$,setDeleteError:R,setDeleteTarget:C}){return s?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:59},onClick:()=>t(null),children:e.jsx("div",{className:"file-ctx-menu",style:{left:s.x,top:s.y},onClick:h=>h.stopPropagation(),children:s.type==="dir"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const h=s.path;t(null),i(h)},children:e.jsx("span",{children:"New note here"})}),e.jsx("button",{className:"more-item",onClick:()=>{var h;c.current=s.path,t(null),(h=n.current)==null||h.click()},children:e.jsx("span",{children:"Upload file..."})}),e.jsx("button",{className:"more-item",onClick:()=>{const h=s.path;t(null),o(""),d({type:"dir",oldPath:h,newPath:h})},children:e.jsx("span",{children:"Rename / Move"})}),e.jsx("button",{className:"more-item",onClick:()=>{var h;(h=navigator.clipboard)==null||h.writeText(s.path),t(null)},children:e.jsx("span",{children:"Copy path"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const h=s.path,v=`tab-${Date.now()}`;t(null),b(S=>[...S,{id:v,path:h,title:Ve(h),preview:""}]),l(v),r("preview"),x(h,!1,v)},children:e.jsx("span",{children:"Open in new tab"})}),e.jsx("button",{className:"more-item",onClick:()=>{const h=s.path;t(null),o(""),d({type:"file",oldPath:h,newPath:h})},children:e.jsx("span",{children:"Rename / Move"})}),e.jsx("button",{className:"more-item",onClick:()=>{var h;(h=navigator.clipboard)==null||h.writeText(s.path),t(null)},children:e.jsx("span",{children:"Copy path"})}),s.path.endsWith(".md")&&e.jsx("button",{className:"more-item",onClick:()=>{var h;(h=navigator.clipboard)==null||h.writeText(`[[${s.path.replace(/\.md$/i,"")}]]`),t(null)},children:e.jsx("span",{children:"Copy [[wikilink]]"})}),p.some(h=>h.path===s.path)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const h=s.path;t(null),r("diff"),x(h),m(h)},children:e.jsx("span",{children:"View Diff"})}),e.jsx("button",{className:"more-item",style:{color:"var(--amber)"},onClick:()=>{const h=s.path;t(null),$({path:h})},children:e.jsx("span",{children:"Discard changes"})})]}),e.jsx("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{const h=s.path;t(null),R(""),C(h)},children:e.jsx("span",{children:"Delete"})})]})})}):null}function un({newNoteOpen:s,setNewNoteOpen:t,newNoteTitle:i,setNewNoteTitle:c,newNoteFolder:n,setNewNoteFolder:o,allFolders:d,newNoteError:b,confirmNewNote:l}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:460},onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"New note"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:"My note title",value:i,onChange:r=>c(r.target.value),onKeyDown:r=>r.key==="Enter"&&l()})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Folder"}),e.jsx("input",{type:"text",placeholder:"(vault root) or type/select folder",value:n,onChange:r=>o(r.target.value),onKeyDown:r=>r.key==="Enter"&&l()}),e.jsx("div",{className:"folder-picker",children:d.map(r=>{const x=n.trim().replace(/^\/+|\/+$/g,"")===r;return e.jsx("button",{type:"button",className:`folder-pick-item${x?" active":""}`,onClick:()=>o(r),children:r||"/ (vault root)"},r||"__root__")})})]}),Ke(i,n)&&e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["Path: ",Ke(i,n)]}),b&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:b})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:l,children:"Create note"})]})]})}):null}function pn({renameTarget:s,setRenameTarget:t,renameError:i,confirmRenameFile:c}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Rename / Move"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"New path"}),e.jsx("input",{type:"text",value:s.newPath,onChange:n=>t(o=>({...o,newPath:n.target.value})),onKeyDown:n=>n.key==="Enter"&&c()})]}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:c,children:"Rename"})]})]})}):null}function fn({deleteTarget:s,setDeleteTarget:t,deleteError:i,confirmDeleteFile:c}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:420},onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Delete file?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{style:{fontSize:13,color:"var(--muted)"},children:["This will permanently remove ",e.jsx("strong",{style:{color:"var(--text)"},children:s})," from disk."]}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:c,children:"Delete"})]})]})}):null}function xn({discardTarget:s,setDiscardTarget:t,discardError:i,confirmDiscard:c}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:n=>n.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:s.hunkIndex===void 0?"Discard file changes?":s.lineIndex===void 0?"Discard hunk?":"Discard line?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("div",{style:{fontSize:13,color:"var(--muted)",marginBottom:10},children:s.path}),s.previewText&&e.jsx("div",{className:"git-output",style:{marginTop:0},children:s.previewText}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:c,children:"Discard"})]})]})}):null}function jn({commitOpen:s,setCommitOpen:t,commitSelected:i,setCommitSelected:c,gitChanges:n,commitMessage:o,setCommitMessage:d,commitPush:b,setCommitPush:l,commitStatus:r,commitBusy:x,handleCommitSubmit:p}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Commit & Push"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Files (",i.size," selected)"]}),e.jsx("div",{className:"commit-files",children:n.map(m=>e.jsxs("label",{className:"commit-file-row",children:[e.jsx("input",{type:"checkbox",checked:i.has(m.path),onChange:$=>{c(R=>{const C=new Set(R);return $.target.checked?C.add(m.path):C.delete(m.path),C})}}),e.jsx("span",{className:`git-badge git-${m.status}`,children:m.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.path})]},m.path))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Commit message"}),e.jsx("input",{type:"text",placeholder:"docs: update vault notes",value:o,onChange:m=>d(m.target.value)})]}),e.jsxs("label",{className:"toggle-row",children:[e.jsx("span",{children:"Push to remote after commit"}),e.jsx("input",{type:"checkbox",checked:b,onChange:m=>l(m.target.checked)})]}),r&&e.jsx("div",{className:"git-output",style:{color:r.ok?"var(--green)":"#f87171"},children:r.text})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",disabled:x||!o.trim()||i.size===0,onClick:p,children:x?"Running...":b?"Commit & Push":"Commit"})]})]})}):null}function zt(s){return s.split(",").map(t=>t.trim().replace(/^\/+|\/+$/g,"")).filter(Boolean)}function vn({settingsOpen:s,setSettingsOpen:t,settingsTab:i,setSettingsTab:c,settings:n,setSettings:o,setCollapsed:d}){const[b,l]=u.useState(()=>n.autoCollapsed.join(", ")),[r,x]=u.useState(()=>n.hiddenFolders.join(", "));return u.useEffect(()=>{s&&(l(n.autoCollapsed.join(", ")),x(n.hiddenFolders.join(", ")))},[s]),s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Settings"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsx("div",{className:"settings-tabs",children:[["general","General"],["appearance","Appearance"],["files","Files & Search"],["endpoints","API & MCP"]].map(([p,m])=>e.jsx("button",{className:`settings-tab${i===p?" active":""}`,onClick:()=>c(p),children:m},p))}),e.jsxs("div",{className:"modal-body",children:[i==="general"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"On startup / first open"}),e.jsxs("select",{value:n.startupMode,onChange:p=>o(m=>({...m,startupMode:p.target.value})),children:[e.jsx("option",{value:"readme",children:"README.md"}),e.jsx("option",{value:"last",children:"Last opened note"}),e.jsx("option",{value:"newtab",children:"New tab launcher"}),e.jsx("option",{value:"custom",children:"Custom note path"})]}),e.jsx("div",{className:"field-hint",children:"Used when opening the vault without a specific #note in the URL."})]}),n.startupMode==="custom"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Custom startup note path"}),e.jsx("input",{type:"text",placeholder:"core/README.md",value:n.startupPath,onChange:p=>o(m=>({...m,startupPath:p.target.value}))})]})]}),i==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Theme"}),e.jsxs("select",{value:n.theme,onChange:p=>o(m=>({...m,theme:p.target.value})),children:[e.jsx("option",{value:"dark",children:"Dark"}),e.jsx("option",{value:"light",children:"Light"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Outline & Backlinks panel"}),e.jsxs("select",{value:n.outlinePosition,onChange:p=>o(m=>({...m,outlinePosition:p.target.value})),children:[e.jsx("option",{value:"right",children:"Right sidebar"}),e.jsx("option",{value:"bottom",children:"Bottom panel"}),e.jsx("option",{value:"hidden",children:"Hidden"})]})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Reader font size: ",n.fontSize,"px"]}),e.jsx("input",{type:"range",min:"13",max:"20",value:n.fontSize,onChange:p=>o(m=>({...m,fontSize:Number(p.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Line height: ",n.lineHeight]}),e.jsx("input",{type:"range",min:"1.35",max:"2.0",step:"0.05",value:n.lineHeight,onChange:p=>o(m=>({...m,lineHeight:Number(p.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Max reading width: ",n.maxWidth,"px"]}),e.jsx("input",{type:"range",min:"580",max:"980",step:"20",value:n.maxWidth,onChange:p=>o(m=>({...m,maxWidth:Number(p.target.value)}))})]})]}),i==="files"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Auto-collapsed folders (comma-separated)"}),e.jsx("input",{type:"text",placeholder:"apps, templates",value:b,onChange:p=>{const m=p.target.value;l(m);const $=zt(m);o(R=>({...R,autoCollapsed:$})),d(new Set($))},onBlur:()=>l(n.autoCollapsed.join(", "))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Hidden folders (hide from sidebar & search)"}),e.jsx("input",{type:"text",placeholder:"ideas, templates",value:r,onChange:p=>{const m=p.target.value;x(m);const $=zt(m);o(R=>({...R,hiddenFolders:$}))},onBlur:()=>x(n.hiddenFolders.join(", "))})]}),e.jsxs("label",{className:"toggle-row",children:[e.jsx("span",{children:"Hide auto-collapsed folders from Quick Switcher"}),e.jsx("input",{type:"checkbox",checked:n.hideCollapsedInSearch,onChange:p=>o(m=>({...m,hideCollapsedInSearch:p.target.checked}))})]})]}),i==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"REST API (v1)"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/health"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/tree"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/file?path=README.md"}),e.jsxs("div",{className:"endpoint-box",children:["PUT / POST / PATCH /api/v1/file — ","{ path, content, append? } or { path, target, replacement, replaceAll? }"]}),e.jsx("div",{className:"endpoint-box",children:"DELETE /api/v1/file?path=..."}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/search?q=python"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/events (SSE)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"MCP Endpoint (Streamable HTTP)"}),e.jsx("div",{className:"endpoint-box",children:"POST /mcp — tools: list_vault, read_note, search_vault, write_note, delete_note"})]})]})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>{o(ne),d(new Set(ne.autoCollapsed)),l(ne.autoCollapsed.join(", ")),x(ne.hiddenFolders.join(", "))},children:"Reset defaults"}),e.jsx("button",{className:"btn primary",onClick:()=>t(!1),children:"Done"})]})]})}):null}function gn(){const[s,t]=u.useState([]),[i,c]=u.useState([]),[n,o]=u.useState([]),[d,b]=u.useState(0),[l,r]=u.useState({}),[x,p]=u.useState(_s),[m,$]=u.useState("general"),R=Us(x),[C,h]=u.useState(()=>[{id:"tab-1",path:R,title:Ve(R),preview:""}]),[v,S]=u.useState("tab-1"),L=C.find(a=>a.id===v)||C[0],f=(L==null?void 0:L.path)||"",[y,w]=u.useState(!1),[E,B]=u.useState(""),[W,U]=u.useState("preview"),[Me,pe]=u.useState(null),[G,V]=u.useState(null),[ae,Q]=u.useState(""),[Z,ee]=u.useState(null),[fe,I]=u.useState(""),[O,z]=u.useState(null),[H,Ae]=u.useState(null),[qt,Be]=u.useState(""),[Je,Pe]=u.useState(!1),[He,Ye]=u.useState(""),[Qe,Ze]=u.useState(""),[Xt,he]=u.useState(""),et=u.useRef(null),tt=u.useRef(""),[Gt,Vt]=u.useState(!1),[bn,xe]=u.useState(""),[Kt,je]=u.useState(!1),[Jt,st]=u.useState(!1),[Yt,Qt]=u.useState("files"),[ie,nt]=u.useState([]),[ve,Zt]=u.useState("path"),[at,it]=u.useState(!1),[Ie,lt]=u.useState(""),[ot,es]=u.useState(!1),[rt,ct]=u.useState(()=>new Set),[ts,dt]=u.useState(!1),[ss,me]=u.useState(null),[ge,ns]=u.useState(""),[as,ht]=u.useState(()=>new Set(x.autoCollapsed)),[is,mt]=u.useState(!0),[be,q]=u.useState(!1),[we,le]=u.useState(!1),[ut,pt]=u.useState(!1),[ft,We]=u.useState(!1),[K,ze]=u.useState(!1),[oe,ls]=u.useState("recent"),[J,xt]=u.useState(""),[os,jt]=u.useState(0),[vt,Ne]=u.useState([]),[ke,ye]=u.useState({items:[],hasMore:!1}),[rs,cs]=u.useState(0),ds=u.useRef(null),gt=u.useRef(null),te=u.useRef(null);u.useEffect(()=>{document.documentElement.setAttribute("data-theme",x.theme),localStorage.setItem("vault-settings",JSON.stringify(x))},[x]),u.useEffect(()=>{const a=j=>{var g;if((j.metaKey||j.ctrlKey)&&j.key.toLowerCase()==="k"){j.preventDefault(),Ce();return}j.key==="/"&&((g=document.activeElement)==null?void 0:g.tagName)!=="INPUT"&&(j.preventDefault(),Ce()),j.key==="Escape"&&K&&ze(!1)};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[K]);function Ce(){xt(""),jt(0),Ne([]),ze(!0),setTimeout(()=>{var a;return(a=gt.current)==null?void 0:a.focus()},40)}u.useEffect(()=>{if(!K)return;const a=J.trim();if(!a){Ne([]);return}const j=setTimeout(async()=>{try{const k=await(await fetch(`/api/v1/search?q=${encodeURIComponent(a)}`)).json();Ne(k.results||[])}catch{Ne([])}},150);return()=>clearTimeout(j)},[J,K]);const Se=u.useMemo(()=>new Set(x.hiddenFolders.map(a=>a.toLowerCase())),[x.hiddenFolders]),hs=u.useMemo(()=>{const a=[""],j=g=>{for(const k of g)if(k.type==="dir"){if(Se.has(k.path.toLowerCase())||Se.has(k.name.toLowerCase()))continue;a.push(k.path),j(k.children||[])}};return j(s),a},[s,Se]),re=d>n.length;u.useEffect(()=>{if(!K||!re){ye({items:[],hasMore:!1});return}const a=oe==="alpha"?"name":"mtime",j=J.trim(),g=setTimeout(async()=>{try{const N=await(await fetch(`/api/v1/files?sort=${a}&offset=0&limit=100&q=${encodeURIComponent(j)}`)).json();ye({items:N.items||[],hasMore:!!N.hasMore})}catch{ye({items:[],hasMore:!1})}},100);return()=>clearTimeout(g)},[K,re,oe,J]);async function ms(){const a=oe==="alpha"?"name":"mtime",j=J.trim(),g=ke.items.length,N=await(await fetch(`/api/v1/files?sort=${a}&offset=${g}&limit=100&q=${encodeURIComponent(j)}`)).json();ye(T=>({items:[...T.items,...N.items||[]],hasMore:!!N.hasMore}))}const bt=u.useMemo(()=>{const a=J.trim().toLowerCase(),j=D=>{const P=D.toLowerCase();return x.hiddenFolders.some(M=>P.startsWith(M.toLowerCase()+"/"))?!0:x.hideCollapsedInSearch?x.autoCollapsed.some(M=>{const Ue=M.toLowerCase()+"/";return P.startsWith(Ue)&&!a.includes(M.toLowerCase())}):!1},g=re?ke.items:n.length>0?n:i.map(D=>({path:D,mtimeMs:0})),k=new Map(g.map(D=>[D.path,D.mtimeMs||0]));let N;if(!a)N=g.filter(D=>!j(D.path)).map(D=>({path:D.path,mtimeMs:D.mtimeMs||0,snippet:""}));else{const D=g.filter(M=>!j(M.path)&&M.path.toLowerCase().includes(a)).map(M=>({path:M.path,mtimeMs:M.mtimeMs||0,snippet:""})),P=new Set(D.map(M=>M.path));for(const M of vt)!j(M.path)&&!P.has(M.path)&&(P.add(M.path),D.push({path:M.path,mtimeMs:M.mtimeMs??k.get(M.path)??0,snippet:M.snippet||""}));N=D}const T=re?N.length:100;if(oe==="alpha"){const D=[...N].sort((P,M)=>{const Ue=P.path.split("/").pop().toLowerCase(),Hs=M.path.split("/").pop().toLowerCase();return Ue.localeCompare(Hs)||P.path.localeCompare(M.path)}).slice(0,T);return{groups:[{label:null,items:D}],items:D}}const X=[...N].sort((D,P)=>(P.mtimeMs||0)-(D.mtimeMs||0)).slice(0,T),_=Date.now(),F=new Date(_);F.setHours(0,0,0,0);const Ee=F.getTime(),_e=864e5,de=new Map([["Today",[]],["Yesterday",[]],["Last 7 days",[]],["Last 30 days",[]],["Older",[]]]);for(const D of X){const P=D.mtimeMs||0;P>=Ee?de.get("Today").push(D):P>=Ee-_e?de.get("Yesterday").push(D):P>=Ee-7*_e?de.get("Last 7 days").push(D):P>=Ee-30*_e?de.get("Last 30 days").push(D):de.get("Older").push(D)}const Lt=[],Rt=[];for(const[D,P]of de)P.length>0&&(Lt.push({label:D,items:P}),Rt.push(...P));return{groups:Lt,items:Rt}},[J,oe,re,ke.items,n,i,vt,x.autoCollapsed,x.hiddenFolders,x.hideCollapsedInSearch]),us=bt.items;async function Y(){var k;const[a,j]=await Promise.all([fetch("/api/v1/tree?limit=10000"),fetch("/api/v1/changes")]),g=await a.json();if(t(g.tree),c(g.flatFiles),o(g.fileStats||[]),b(g.totalFiles??((k=g.flatFiles)==null?void 0:k.length)??0),r(g.backlinks),j.ok){const N=await j.json();nt(N.changes||[])}}function wt(){const a=`tab-${Date.now()}`;h(j=>[...j,{id:a,path:null,title:"New tab",preview:""}]),S(a),B(""),w(!1),q(!1),pt(!1)}function Nt(a,j){j==null||j.stopPropagation(),h(g=>{const k=g.filter(N=>N.id!==a);if(k.length===0){const N={id:`tab-${Date.now()}`,path:null,title:"New tab",preview:""};return S(N.id),B(""),[N]}if(a===v){const N=k[k.length-1];S(N.id),N.path?A(N.path,!1,N.id):B("")}return k})}function kt(a){S(a.id),w(!1),a.path?A(a.path,!1,a.id):(B(""),location.hash="")}async function A(a,j=!1,g=v){var X;if(!a){B("");return}const k=((X=te.current)==null?void 0:X.scrollTop)??0;let N="";if($e(a)&&!Mt(a)||Oe(a)||qe(a)||Xe(a)||Ge(a)){if(!(await fetch(`/api/v1/file?path=${encodeURIComponent(a)}`,{method:"HEAD"})).ok)return a!=="README.md"?A("README.md",!1,g):void 0;B(""),xe(""),je(!1),$e(a)?N="[Image preview]":Oe(a)?N="[PDF document]":qe(a)?N="[Audio]":Xe(a)?N="[Video]":N="[Binary file — download]"}else{const _=await fetch(`/api/v1/file?path=${encodeURIComponent(a)}`);if(!_.ok)return a!=="README.md"?A("README.md",!1,g):void 0;const F=await _.text();B(F),xe(F),je(!1),N=F.replace(/^#+\s*/gm,"").slice(0,260)}location.hash=encodeURIComponent(a),localStorage.setItem("vault-last-path",a),h(_=>_.map(F=>F.id===g?{...F,path:a,title:Ve(a),preview:N}:F)),j?requestAnimationFrame(()=>{te.current&&(te.current.scrollTop=k)}):(q(!1),requestAnimationFrame(()=>{te.current&&(te.current.scrollTop=0)})),W==="diff"&&ce(a)}async function ce(a=f){if(!a)return;const j=await fetch(`/api/v1/git/diff?path=${encodeURIComponent(a)}`);j.ok?pe(await j.json()):pe(null)}function yt({path:a=f,hunkIndex:j,lineIndex:g,previewText:k}={}){a&&(Q(""),V({path:a,hunkIndex:j,lineIndex:g,previewText:k}))}async function ps(){if(!(G!=null&&G.path))return;const{path:a,hunkIndex:j,lineIndex:g}=G,k=await fetch("/api/v1/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,hunkIndex:j,lineIndex:g})}),N=await k.json().catch(()=>({}));k.ok?(V(null),Q(""),await Y(),a===f&&(await A(f,!0),await ce(f))):Q(N.error||"Failed to discard")}async function fs(){if(!Z)return;I("");const a=await fetch(`/api/v1/file?path=${encodeURIComponent(Z)}`,{method:"DELETE"}),j=await a.json().catch(()=>({}));if(a.ok){const g=Z;ee(null),localStorage.getItem("vault-last-path")===g&&localStorage.removeItem("vault-last-path");const k=N=>N.filter(T=>!(T.type==="file"&&T.path===g)).map(T=>T.type==="dir"?{...T,children:k(T.children||[])}:T);if(t(N=>k(N)),c(N=>N.filter(T=>T!==g)),o(N=>N.filter(T=>T.path!==g)),nt(N=>N.filter(T=>T.path!==g)),g===f){U("preview");const N=C.filter(T=>T.path!==g);if(N.length>0){const T=N[N.length-1];h(N),S(T.id),T.path?await A(T.path,!1,T.id):(B(""),location.hash="")}else await A("README.md",!1,v)}else h(N=>N.filter(T=>T.path!==g));await Y()}else I(j.error||"Failed to delete file")}async function xs(a){var X;const j=Array.from(a||[]);if(!j.length)return;const g=tt.current||"",k=new FormData;k.append("dir",g);for(const _ of j)k.append("files",_);const N=await fetch("/api/v1/file/upload",{method:"POST",body:k}),T=await N.json().catch(()=>({}));if(N.ok&&(await Y(),((X=T.uploaded)==null?void 0:X.length)===1)){const _=T.uploaded[0].path;/\.(md|markdown|txt|png|jpe?g|gif|webp|svg|ico)$/i.test(_)&&A(_)}}async function js(){if(!(H!=null&&H.oldPath)||!(H!=null&&H.newPath.trim()))return;Be("");const a=H.type==="dir",j=a?"/api/v1/dir/rename":"/api/v1/file/rename",g=H.newPath.trim().replace(/^\/+|\/+$/g,""),k=await fetch(j,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:H.oldPath,newPath:g})}),N=await k.json().catch(()=>({}));if(k.ok){const{oldPath:T}=H;Ae(null),await Y(),a?f.startsWith(`${T}/`)&&A(`${g}${f.slice(T.length)}`):T===f&&A(g)}else Be(N.error||"Failed to rename")}function vs(a,j,g="file"){const k=window.innerWidth<=768?215:175,N=window.innerWidth<=768?310:250,T=Math.min(j.right-k,window.innerWidth-(k+12)),X=Math.min(j.bottom+4,window.innerHeight-N);z({type:g,path:a,x:Math.max(8,T),y:Math.max(8,X)})}function Ct(a=""){Ye(""),Ze(a.replace(/^\/+|\/+$/g,"")),he(""),Pe(!0)}async function gs(){const a=Ke(He,Qe);if(!a){he("Please enter a note title");return}if(i.includes(a)){he(`Already exists: ${a}`);return}he("");const j=He.trim().replace(/\.md$/i,""),g=await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a,content:`# ${j}
5
+
6
+ `})}),k=await g.json().catch(()=>({}));if(!g.ok||k.error){he(k.error||"Failed to create note");return}Pe(!1),await Y(),U("edit"),A(a)}u.useEffect(()=>{Y(),A(f)},[]),u.useEffect(()=>{const a=()=>{const j=decodeURIComponent(location.hash.slice(1)||"");j&&j!==f&&A(j)};return window.addEventListener("hashchange",a),()=>window.removeEventListener("hashchange",a)},[f]),u.useEffect(()=>{const a=new EventSource("/api/v1/events");return a.onopen=()=>mt(!0),a.onmessage=async j=>{JSON.parse(j.data).type==="reload"&&(await Y(),cs(k=>k+1),await A(f,!0))},a.onerror=()=>mt(!1),()=>a.close()},[f]);async function bs(a){if(f){st(!0);try{(await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:f,content:a})})).ok&&(B(a),xe(a),je(!1))}finally{st(!1)}}}const{renderedHtml:ws,headings:Ns}=u.useMemo(()=>!Fe(f)||W!=="preview"||$e(f)||Ge(f)?{renderedHtml:"",headings:[]}:Xs(E,f,i),[E,f,W,i]),ks=u.useMemo(()=>!E||W!=="raw"&&Fe(f)?"":Gs(E,f),[E,f,W]);function ys(a){const j=a.target.closest("a.wikilink");if(j){a.preventDefault(),A(j.dataset.path);return}const g=a.target.closest("a.md-rel-link");if(g){a.preventDefault();const k=_t(f,g.dataset.href);i.includes(k)&&A(k)}}function Cs(a){ht(j=>{const g=new Set(j);return g.has(a)?g.delete(a):g.add(a),g})}const Ss=u.useMemo(()=>{const j=[...ie.filter(g=>!ge||g.path.toLowerCase().includes(ge))];return ve==="recent"?j.sort((g,k)=>(k.mtimeMs||0)-(g.mtimeMs||0)||g.path.localeCompare(k.path)):ve==="status"?j.sort((g,k)=>g.status.localeCompare(k.status)||g.path.localeCompare(k.path)):j.sort((g,k)=>g.path.localeCompare(k.path)),j},[ie,ge,ve]);function Es(){ct(new Set(ie.map(a=>a.path))),lt(""),me(null),it(!0)}async function $s(){if(Ie.trim()){dt(!0),me(null);try{const a=await fetch("/api/v1/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:Ie.trim(),files:Array.from(rt),push:ot})}),j=await a.json();!a.ok||j.error?me({ok:!1,text:j.error||"Commit failed"}):(me({ok:!0,text:j.output||"Committed successfully"}),await Y())}catch(a){me({ok:!1,text:a.message})}finally{dt(!1)}}}const Ts=l[f]||[],St=$e(f),Ls=Mt(f),Rs=Fe(f),Ds=Oe(f),Ms=qe(f),As=Xe(f),Bs=Fs(f),Ps=Os(f),Et=Ge(f),se=x.outlinePosition||"right",ue=a=>p(j=>({...j,outlinePosition:a})),$t=()=>{ue("right"),window.innerWidth<=960&&(q(!1),le(!0))},Tt=()=>{window.innerWidth<=960?se==="bottom"?(ue("hidden"),le(!1)):(se==="hidden"&&ue("right"),q(!1),le(a=>!a)):ue(se==="hidden"?"right":"hidden")};return Ys({drawerOpen:be,outlineDrawerOpen:we,outlinePosition:se,setDrawerOpen:q,onOpenOutline:$t,setOutlineDrawerOpen:le,disabled:!!(K||ft||y||at||ut||Je||H||Z||G)}),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`backdrop${be||we?" open":""}`,onClick:()=>{q(!1),le(!1)}}),e.jsxs("div",{className:"app",children:[e.jsx(Zs,{drawerOpen:be,live:is,settings:x,setSettings:p,sidebarTab:Yt,setSidebarTab:Qt,gitChanges:ie,searchRef:ds,filter:ge,setFilter:ns,tree:s,activePath:f,collapsed:as,hiddenSet:Se,toggleDir:Cs,setViewMode:U,openFile:A,openRowMenu:vs,changesSort:ve,setChangesSort:Zt,openCommitDialog:Es,sortedChanges:Ss,loadDiff:ce}),e.jsxs("main",{className:"main",children:[e.jsx(en,{tabs:C,activeTabId:v,switchTab:kt,closeTab:Nt,createNewTab:wt}),e.jsxs("div",{className:`workspace-body outline-${se}`,children:[e.jsxs("div",{className:"note-pane",children:[e.jsx(tn,{setDrawerOpen:q,activePath:f,moreMenuOpen:Gt,setMoreMenuOpen:Vt,viewMode:W,setViewMode:U,loadDiff:ce,setDeleteError:I,setDeleteTarget:ee,outlinePosition:se,outlineDrawerOpen:we,onToggleOutline:Tt,onOpenOutline:$t}),e.jsx(rn,{scrollRef:te,activePath:f,openNewNoteDialog:Ct,openFile:A,openSwitcher:Ce,setDrawerOpen:q,setSettingsOpen:We,isImg:St,isSvg:Ls,isMarkdown:Rs,isPdf:Ds,isAudio:Ms,isVideo:As,isHtml:Bs,isCsv:Ps,reloadTick:rs,isBinaryDownload:Et,viewMode:W,settings:x,diffData:Me,requestDiscard:yt,content:E,saving:Jt,dirty:Kt,setDraftContent:xe,setDirty:je,saveActiveNote:bs,highlightedRawHtml:ks,handleDocClick:ys,renderedHtml:ws})]}),e.jsx(cn,{headings:Ns,isImg:St,isBinaryDownload:Et,viewMode:W,currentBacklinks:Ts,openFile:A,position:se,onChangePosition:ue,mobileOpen:we,onCloseMobile:()=>le(!1)})]})]})]}),e.jsx(dn,{fabOpen:ut,setFabOpen:pt,openSwitcher:Ce,drawerOpen:be,setDrawerOpen:q,onToggleOutline:Tt,openFile:A,viewMode:W,setViewMode:U,settings:x,setSettings:p,setSettingsOpen:We,scrollRef:te,loadDiff:ce,activePath:f,createNewTab:wt,tabsOpen:y,setTabsOpen:w,tabs:C,activeTabId:v,switchTab:kt,closeTab:Nt}),e.jsx(hn,{switcherOpen:K,setSwitcherOpen:ze,switcherTab:oe,setSwitcherTab:ls,switcherIdx:os,setSwitcherIdx:jt,switcherInputRef:gt,totalFiles:d,fileStats:n,switcherItems:us,switcherData:bt,openFile:A,isLargeVault:re,pagedFiles:ke,loadMorePagedFiles:ms,switcherQuery:J,setSwitcherQuery:xt}),e.jsx("input",{ref:et,type:"file",multiple:!0,style:{display:"none"},onChange:a=>{xs(a.target.files),a.target.value=""}}),e.jsx(mn,{fileMenu:O,setFileMenu:z,openNewNoteDialog:Ct,uploadDirRef:tt,uploadInputRef:et,setRenameError:Be,setRenameTarget:Ae,setTabs:h,setActiveTabId:S,setViewMode:U,openFile:A,gitChanges:ie,loadDiff:ce,requestDiscard:yt,setDeleteError:I,setDeleteTarget:ee}),e.jsx(un,{newNoteOpen:Je,setNewNoteOpen:Pe,newNoteTitle:He,setNewNoteTitle:Ye,newNoteFolder:Qe,setNewNoteFolder:Ze,allFolders:hs,newNoteError:Xt,confirmNewNote:gs}),e.jsx(pn,{renameTarget:H,setRenameTarget:Ae,renameError:qt,confirmRenameFile:js}),e.jsx(fn,{deleteTarget:Z,setDeleteTarget:ee,deleteError:fe,confirmDeleteFile:fs}),e.jsx(xn,{discardTarget:G,setDiscardTarget:V,discardError:ae,confirmDiscard:ps}),e.jsx(jn,{commitOpen:at,setCommitOpen:it,commitSelected:rt,setCommitSelected:ct,gitChanges:ie,commitMessage:Ie,setCommitMessage:lt,commitPush:ot,setCommitPush:es,commitStatus:ss,commitBusy:ts,handleCommitSubmit:$s}),e.jsx(vn,{settingsOpen:ft,setSettingsOpen:We,settingsTab:m,setSettingsTab:$,settings:x,setSettings:p,setCollapsed:ht})]})}Ws.createRoot(document.getElementById("root")).render(e.jsx(gn,{}));
package/dist/index.html CHANGED
@@ -10,11 +10,11 @@
10
10
  <link rel="icon" href="/favicon.ico" sizes="any" />
11
11
  <link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
12
12
  <title>Vault</title>
13
- <script type="module" crossorigin src="/assets/index-B9GrzXPf.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-ZVjt99Mq.js"></script>
14
14
  <link rel="modulepreload" crossorigin href="/assets/vendor-react-E4kvVwMA.js">
15
15
  <link rel="modulepreload" crossorigin href="/assets/vendor-markdown-C94ubdL7.js">
16
16
  <link rel="modulepreload" crossorigin href="/assets/vendor-hljs-B8we2J8a.js">
17
- <link rel="stylesheet" crossorigin href="/assets/index-D21lvsqQ.css">
17
+ <link rel="stylesheet" crossorigin href="/assets/index-BXGU3AiE.css">
18
18
  </head>
19
19
  <body>
20
20
  <div id="root"></div>
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "pagedex",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Local-first Markdown knowledge viewer, editor, Git bridge, and MCP v2 server for any directory.",
5
5
  "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/quanhua92/pagedex.git"
9
+ },
6
10
  "type": "module",
7
11
  "engines": {
8
12
  "node": ">=22.5.0"
@@ -24,6 +24,16 @@ startVaultWatcher();
24
24
 
25
25
  const app = new Hono();
26
26
 
27
+ app.use('/api/v1/*', async (c, next) => {
28
+ const method = c.req.method.toUpperCase();
29
+ if (method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS') {
30
+ if (c.req.header('origin') === 'null') {
31
+ return c.json({ error: 'Forbidden origin' }, 403);
32
+ }
33
+ }
34
+ await next();
35
+ });
36
+
27
37
  registerFileRoutes(app);
28
38
  registerGitRoutes(app);
29
39
  registerEventRoutes(app);
@@ -34,6 +34,37 @@ export const IMAGE_MIME = {
34
34
  '.ico': 'image/x-icon'
35
35
  };
36
36
 
37
+ export const MIME_TYPES = {
38
+ ...IMAGE_MIME,
39
+ '.html': 'text/html; charset=utf-8',
40
+ '.htm': 'text/html; charset=utf-8',
41
+ '.css': 'text/css; charset=utf-8',
42
+ '.js': 'application/javascript; charset=utf-8',
43
+ '.mjs': 'application/javascript; charset=utf-8',
44
+ '.json': 'application/json; charset=utf-8',
45
+ '.csv': 'text/csv; charset=utf-8',
46
+ '.tsv': 'text/tab-separated-values; charset=utf-8',
47
+ '.txt': 'text/plain; charset=utf-8',
48
+ '.md': 'text/markdown; charset=utf-8',
49
+ '.markdown': 'text/markdown; charset=utf-8',
50
+ '.mdx': 'text/markdown; charset=utf-8',
51
+ '.xml': 'application/xml; charset=utf-8',
52
+ '.yaml': 'text/yaml; charset=utf-8',
53
+ '.yml': 'text/yaml; charset=utf-8',
54
+ '.wasm': 'application/wasm',
55
+ '.woff': 'font/woff',
56
+ '.woff2': 'font/woff2',
57
+ '.ttf': 'font/ttf',
58
+ '.pdf': 'application/pdf',
59
+ '.mp3': 'audio/mpeg',
60
+ '.wav': 'audio/wav',
61
+ '.m4a': 'audio/mp4',
62
+ '.ogg': 'audio/ogg',
63
+ '.mp4': 'video/mp4',
64
+ '.webm': 'video/webm',
65
+ '.mov': 'video/quicktime'
66
+ };
67
+
37
68
  export function isImagePath(p) {
38
69
  return /\.(png|jpe?g|gif|webp|svg|ico)$/i.test(p);
39
70
  }
@@ -1,11 +1,12 @@
1
1
  import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import {
4
- IMAGE_MIME,
5
- VAULT_ROOT,
4
+ MIME_TYPES,
5
+ VAULT_ROOT,
6
6
  deleteNote,
7
7
  editNote,
8
8
  getCachedVault,
9
+ isProtectedPath,
9
10
  renameDir,
10
11
  renameNote,
11
12
  resolveSafe,
@@ -58,6 +59,72 @@ export function registerFileRoutes(app) {
58
59
  return c.json({ query: q, results: searchFts(q, limit) });
59
60
  });
60
61
 
62
+ function buildRequestOrigins(c) {
63
+ const url = new URL(c.req.url);
64
+ const proto = (c.req.header('x-forwarded-proto') || url.protocol.replace(':', '')).split(',')[0].trim();
65
+ const host = (c.req.header('x-forwarded-host') || c.req.header('host') || url.host).split(',')[0].trim();
66
+ const origins = new Set([`${proto}://${host}`]);
67
+ const referer = c.req.header('referer');
68
+ if (referer) {
69
+ try {
70
+ origins.add(new URL(referer).origin);
71
+ } catch {
72
+ // ignore invalid referer
73
+ }
74
+ }
75
+ return Array.from(origins).join(' ');
76
+ }
77
+
78
+ function serveFileResponse(c, full, contentType, { isDownload = false, extraHeaders = {} } = {}) {
79
+ const stat = fs.statSync(full);
80
+ const size = stat.size;
81
+ const headers = {
82
+ 'Content-Type': contentType,
83
+ 'Accept-Ranges': 'bytes',
84
+ ...extraHeaders
85
+ };
86
+ if (isDownload) {
87
+ const fileName = path.basename(full).replace(/"/g, '');
88
+ headers['Content-Disposition'] = `attachment; filename="${fileName}"`;
89
+ }
90
+
91
+ const rangeHeader = !isDownload ? c.req.header('range') : null;
92
+ if (rangeHeader && rangeHeader.startsWith('bytes=')) {
93
+ const [rawStart, rawEnd] = rangeHeader.slice(6).split('-');
94
+ let start = rawStart === '' ? 0 : Number(rawStart);
95
+ let end = rawEnd === '' ? size - 1 : Number(rawEnd);
96
+ if (rawStart === '' && rawEnd !== '') {
97
+ start = Math.max(0, size - Number(rawEnd));
98
+ end = size - 1;
99
+ }
100
+ if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end >= size || start > end) {
101
+ return new Response(null, {
102
+ status: 416,
103
+ headers: { 'Content-Range': `bytes */${size}` }
104
+ });
105
+ }
106
+ const chunkLen = end - start + 1;
107
+ const fd = fs.openSync(full, 'r');
108
+ const slice = Buffer.alloc(chunkLen);
109
+ try {
110
+ fs.readSync(fd, slice, 0, chunkLen, start);
111
+ } finally {
112
+ fs.closeSync(fd);
113
+ }
114
+ return new Response(slice, {
115
+ status: 206,
116
+ headers: {
117
+ ...headers,
118
+ 'Content-Range': `bytes ${start}-${end}/${size}`,
119
+ 'Content-Length': String(chunkLen)
120
+ }
121
+ });
122
+ }
123
+
124
+ const buf = fs.readFileSync(full);
125
+ return new Response(buf, { status: 200, headers });
126
+ }
127
+
61
128
  app.get('/api/v1/file', (c) => {
62
129
  const rel = c.req.query('path') || '';
63
130
  const full = resolveSafe(rel);
@@ -66,14 +133,35 @@ export function registerFileRoutes(app) {
66
133
  }
67
134
  const ext = path.extname(full).toLowerCase();
68
135
  const isDownload = c.req.query('download') === '1';
69
- const contentType = IMAGE_MIME[ext] || (isDownload ? 'application/octet-stream' : 'text/plain; charset=utf-8');
70
- const buf = fs.readFileSync(full);
71
- const headers = { 'Content-Type': contentType };
72
- if (isDownload) {
73
- const fileName = path.basename(full).replace(/"/g, '');
74
- headers['Content-Disposition'] = `attachment; filename="${fileName}"`;
75
- }
76
- return new Response(buf, { status: 200, headers });
136
+ const contentType = MIME_TYPES[ext] || (isDownload ? 'application/octet-stream' : 'text/plain; charset=utf-8');
137
+ return serveFileResponse(c, full, contentType, { isDownload });
138
+ });
139
+
140
+ app.get('/raw/*', (c) => {
141
+ let rel = '';
142
+ try {
143
+ rel = decodeURIComponent(c.req.path.replace(/^\/raw\/?/, ''));
144
+ } catch {
145
+ return c.text('Bad path', 400);
146
+ }
147
+ if (!rel || isProtectedPath(rel) || path.basename(rel).startsWith('.env')) {
148
+ return c.text('Not found', 404);
149
+ }
150
+ const full = resolveSafe(rel);
151
+ if (!full || !fs.existsSync(full) || !fs.statSync(full).isFile()) {
152
+ return c.text('Not found', 404);
153
+ }
154
+ const ext = path.extname(full).toLowerCase();
155
+ const contentType = MIME_TYPES[ext] || 'application/octet-stream';
156
+ const extraHeaders = {
157
+ 'Access-Control-Allow-Origin': '*'
158
+ };
159
+ if (ext === '.html' || ext === '.htm') {
160
+ const origins = buildRequestOrigins(c);
161
+ extraHeaders['Content-Security-Policy'] =
162
+ `default-src ${origins} 'unsafe-inline' 'unsafe-eval' data: blob:`;
163
+ }
164
+ return serveFileResponse(c, full, contentType, { extraHeaders });
77
165
  });
78
166
 
79
167
  async function handleWriteOrEdit(c) {
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TiptapEditor-OFHNcjy3.js","assets/vendor-react-E4kvVwMA.js","assets/vendor-tiptap-ChgD7Piv.js","assets/vendor-markdown-C94ubdL7.js"])))=>i.map(i=>d[i]);
2
- import{a as m,j as e,R as Ss,c as Es}from"./vendor-react-E4kvVwMA.js";import{m as yt}from"./vendor-markdown-C94ubdL7.js";import{H as Se,d as Ts}from"./vendor-hljs-B8we2J8a.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))f(a);new MutationObserver(a=>{for(const o of a)if(o.type==="childList")for(const u of o.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&f(u)}).observe(document,{childList:!0,subtree:!0});function i(a){const o={};return a.integrity&&(o.integrity=a.integrity),a.referrerPolicy&&(o.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?o.credentials="include":a.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function f(a){if(a.ep)return;a.ep=!0;const o=i(a);fetch(a.href,o)}})();const V={theme:"dark",fontSize:15,lineHeight:1.65,maxWidth:780,outlinePosition:"right",startupMode:"readme",startupPath:"README.md",autoCollapsed:["apps"],hiddenFolders:[],hideCollapsedInSearch:!0};function $s(){try{const s=localStorage.getItem("vault-settings");if(!s)return V;const t=JSON.parse(s);return{...V,...t,theme:t.theme==="light"?"light":"dark",fontSize:Number(t.fontSize)>=12&&Number(t.fontSize)<=22?Number(t.fontSize):15,lineHeight:Number(t.lineHeight)>=1.3&&Number(t.lineHeight)<=2.1?Number(t.lineHeight):1.65,maxWidth:Number(t.maxWidth)>=560&&Number(t.maxWidth)<=1040?Number(t.maxWidth):780,outlinePosition:["right","bottom","hidden"].includes(t.outlinePosition)?t.outlinePosition:"right",autoCollapsed:Array.isArray(t.autoCollapsed)?t.autoCollapsed:["apps"],hiddenFolders:Array.isArray(t.hiddenFolders)?t.hiddenFolders:[]}}catch{return V}}function Ls(s){const t=decodeURIComponent(location.hash.slice(1)||"");return t||(s.startupMode==="newtab"?null:s.startupMode==="last"?localStorage.getItem("vault-last-path")||"README.md":s.startupMode==="custom"&&s.startupPath.trim()||"README.md")}function We(s){return s?s.split("/").pop().replace(/\.md$/i,""):"New tab"}function ke(s){return/\.(png|jpe?g|gif|webp|svg|ico)$/i.test(s)}function Ie(s){return/\.(epub|pdf|zip|tar|gz|tgz|7z|rar|docx?|xlsx?|pptx?|odt|ods|odp|mp3|wav|m4a|mp4|mov|webm|mkv|avi|dmg|exe|bin|whl|sqlite|db)$/i.test(s)}function Dt(s,t){const i=t.split("#")[0],f=s.includes("/")?s.split("/").slice(0,-1).join("/"):"",a=(f?`${f}/`:"")+i,o=[];for(const u of a.split("/"))u==="."||u===""||(u===".."?o.pop():o.push(u));return o.join("/")}function Ms(s,t){const i=s.split("|")[0].split("#")[0].trim().replace(/\.md$/i,"").replace(/^\/+/,"").toLowerCase();if(!i)return null;const f=t.filter(u=>u.endsWith(".md")),a=f.find(u=>u.slice(0,-3).toLowerCase()===i);if(a)return a;const o=i.split("/").pop();return f.find(u=>u.slice(0,-3).split("/").pop().toLowerCase()===o)||null}function ze(s,t){const i=(s||"").trim().replace(/^\/+|\/+$/g,"");if(!i)return"";const f=/\.[a-z0-9]+$/i.test(i)?i:`${i}.md`,a=(t||"").trim().replace(/^\/+|\/+$/g,"");return a?`${a}/${f}`:f}Se.registerLanguage("dockerfile",Ts);const St={js:"javascript",jsx:"javascript",mjs:"javascript",cjs:"javascript",ts:"typescript",tsx:"typescript",py:"python",pyw:"python",sh:"bash",bash:"bash",zsh:"bash",json:"json",jsonc:"json",yml:"yaml",yaml:"yaml",css:"css",scss:"scss",less:"less",html:"xml",htm:"xml",xml:"xml",svg:"xml",md:"markdown",markdown:"markdown",sql:"sql",rs:"rust",go:"go",java:"java",kt:"kotlin",c:"c",h:"c",cpp:"cpp",hpp:"cpp",cc:"cpp",toml:"ini",ini:"ini",conf:"ini",env:"ini",diff:"diff",patch:"diff",rb:"ruby",php:"php",swift:"swift",makefile:"makefile",dockerfile:"dockerfile"};function Pt(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function At(s,t){const i=String(s??"");try{const f=(t||"").trim().toLowerCase();if(f&&Se.getLanguage(f))return Se.highlight(i,{language:f,ignoreIllegals:!0}).value;if(i.length<=15e4)return Se.highlightAuto(i).value}catch{}return Pt(i)}function Rs(s,t,i){const f=[],o=s.split(/(```[\s\S]*?```)/g).map((l,c)=>c%2===1?l:l.replace(/\[\[([^\]]+)\]\]/g,(p,h)=>{const[r,S]=h.split("|"),$=(S||r).trim(),C=Ms(h,i);return C?`<a class="wikilink" data-path="${C.replace(/"/g,"&quot;")}">${$}</a>`:`<span class="wikilink broken" title="Note not created yet">${$}</span>`})).join(""),u=new yt.Renderer;return u.heading=({tokens:l,depth:c})=>{const p=u.parser.parseInline(l),h=p.replace(/<[^>]+>/g,""),r=h.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");return f.push({level:c,text:h,id:r}),`<h${c} id="${r}">${p}</h${c}>`},u.image=({href:l,title:c,text:p})=>`<img src="${/^https?:\/\//.test(l)?l:`/api/v1/file?path=${encodeURIComponent(Dt(t,l))}`}" alt="${p||""}"${c?` title="${c}"`:""} />`,u.link=({href:l,title:c,tokens:p})=>{const h=u.parser.parseInline(p);return/^https?:\/\//.test(l)?`<a href="${l}" target="_blank" rel="noreferrer"${c?` title="${c}"`:""}>${h}</a>`:`<a class="md-rel-link" data-href="${l.replace(/"/g,"&quot;")}">${h}</a>`},u.code=({text:l,lang:c})=>{const p=At(l,c);return`<pre><code class="${c?`hljs language-${Pt(c.trim())}`:"hljs"}">${p}</code></pre>`},{renderedHtml:yt.parse(o,{renderer:u,gfm:!0,breaks:!1}),headings:f}}function Ds(s,t){if(!s)return"";const i=t.split("/").pop().toLowerCase(),f=i.includes(".")?i.split(".").pop():i,a=St[f]||St[i]||"";return At(s,a)}const Ps=120,As=.28,Et=6,Ne=.25,Ce=.28,ye=18;function Bs(s){let t=s;for(;t&&t!==document.body;){const i=t.tagName;if(i==="PRE"||i==="TABLE"||i==="INPUT"||i==="TEXTAREA"||i==="SELECT"||t.isContentEditable)return!0;if(t.scrollWidth>t.clientWidth+2){const f=getComputedStyle(t).overflowX;if(f==="auto"||f==="scroll")return!0}t=t.parentElement}return!1}function Tt(s,t){if(s)for(const i of t)s.style[i]=""}function Hs({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i="right",setDrawerOpen:f,onOpenOutline:a,setOutlineDrawerOpen:o,disabled:u=!1}){const w=m.useRef({drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i,setDrawerOpen:f,onOpenOutline:a,setOutlineDrawerOpen:o,disabled:u});w.current={drawerOpen:s,outlineDrawerOpen:t,outlinePosition:i,setDrawerOpen:f,onOpenOutline:a,setOutlineDrawerOpen:o,disabled:u},m.useEffect(()=>{let l=null;const c=C=>{C&&(Tt(C.panelEl,["transform","transition"]),Tt(C.backdropEl,["display","position","inset","zIndex","background","opacity","transition"]))},p=C=>{const d=w.current;if(d.disabled||C.touches.length!==1)return;const g=C.touches[0],L=g.clientX,R=g.clientY,v=document.documentElement.clientWidth||window.innerWidth,y=Math.min(Ps,Math.round(v*As));let b=null,E=null;if(d.drawerOpen&&v<=768?(b="left",E="close"):d.outlineDrawerOpen&&v<=960&&d.outlinePosition!=="bottom"?(b="right",E="close"):!d.drawerOpen&&!d.outlineDrawerOpen&&!Bs(C.target)&&(L<=y&&v<=768?(b="left",E="open"):L>=v-y&&v<=960&&d.outlinePosition!=="bottom"&&(b="right",E="open")),!b)return;const P=document.querySelector(b==="left"?".sidebar":".rightbar"),H=document.querySelector(".backdrop"),W=(P==null?void 0:P.offsetWidth)||(b==="left"?310:300);l={side:b,action:E,startX:L,startY:R,lastX:L,startTime:performance.now(),lastTime:performance.now(),locked:null,panelEl:P,backdropEl:H,width:W}},h=C=>{if(!l||C.touches.length!==1)return;const d=C.touches[0],g=d.clientX-l.startX,L=d.clientY-l.startY;if(l.lastX=d.clientX,l.lastTime=performance.now(),!l.locked){if(Math.abs(L)>=Et&&Math.abs(L)>=Math.abs(g)){l.locked="vertical",l=null;return}if(Math.abs(g)>=Et&&Math.abs(g)>Math.abs(L)){if(!(l.side==="left"&&l.action==="open"&&g>0||l.side==="left"&&l.action==="close"&&g<0||l.side==="right"&&l.action==="open"&&g<0||l.side==="right"&&l.action==="close"&&g>0)){l=null;return}l.locked="horizontal",l.panelEl&&(l.panelEl.style.transition="none"),l.backdropEl&&(l.backdropEl.style.display="block",l.backdropEl.style.position="fixed",l.backdropEl.style.inset="0",l.backdropEl.style.zIndex="20",l.backdropEl.style.background="rgba(0, 0, 0, 0.5)",l.backdropEl.style.transition="none")}else return}l.locked==="horizontal"&&C.cancelable&&C.preventDefault();const R=l.width;let v;if(l.side==="left"?v=l.action==="open"?g/R:1+g/R:v=l.action==="open"?-g/R:1-g/R,v=Math.max(0,Math.min(1,v)),l.panelEl){const y=l.side==="left"?(v-1)*100:(1-v)*100;l.panelEl.style.transform=`translateX(${y}%)`}l.backdropEl&&(l.backdropEl.style.opacity=String(v))},r=C=>{if(!l)return;const d=l;if(l=null,d.locked!=="horizontal"){c(d);return}const g=d.lastX-d.startX,L=Math.max(1,d.lastTime-d.startTime),R=g/L;let v=!1;if(C||(d.side==="left"&&d.action==="open"?v=g>=d.width*Ne||g>=ye&&R>=Ce:d.side==="left"&&d.action==="close"||d.side==="right"&&d.action==="open"?v=-g>=d.width*Ne||-g>=ye&&-R>=Ce:d.side==="right"&&d.action==="close"&&(v=g>=d.width*Ne||g>=ye&&R>=Ce)),c(d),!v)return;const y=w.current;d.side==="left"?d.action==="open"?(y.setOutlineDrawerOpen(!1),y.setDrawerOpen(!0)):y.setDrawerOpen(!1):d.action==="open"?y.onOpenOutline():y.setOutlineDrawerOpen(!1)},S=()=>r(!1),$=()=>r(!0);return window.addEventListener("touchstart",p,{passive:!0}),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",S,{passive:!0}),window.addEventListener("touchcancel",$,{passive:!0}),()=>{window.removeEventListener("touchstart",p),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",S),window.removeEventListener("touchcancel",$)}},[])}const Is=450,$t=8;function Lt(s){const t=m.useRef(null),i=m.useRef(null),f=m.useRef(!1),a=()=>{t.current&&(clearTimeout(t.current),t.current=null)};return{onTouchStart:o=>{if(o.touches.length!==1)return;const u=o.touches[0],w=o.currentTarget.closest(".tree-file-row")||o.currentTarget;i.current={x:u.clientX,y:u.clientY},f.current=!1,a(),t.current=setTimeout(()=>{var l;t.current=null,f.current=!0,(l=navigator.vibrate)==null||l.call(navigator,10),s(w.getBoundingClientRect())},Is)},onTouchMove:o=>{if(!t.current||!i.current||o.touches.length!==1)return;const u=o.touches[0];(Math.abs(u.clientX-i.current.x)>$t||Math.abs(u.clientY-i.current.y)>$t)&&a()},onTouchEnd:()=>a(),onTouchCancel:()=>a(),onContextMenu:o=>{o.preventDefault();const u=o.currentTarget.closest(".tree-file-row")||o.currentTarget;s(u.getBoundingClientRect())},consumeClick:o=>f.current?(f.current=!1,o.preventDefault(),o.stopPropagation(),!0):!1}}function Bt({node:s,activePath:t,filter:i,collapsed:f,hiddenSet:a,onToggleDir:o,onSelectFile:u,onOpenMenu:w}){const l=Lt(p=>w(s.path,p,"dir")),c=Lt(p=>w(s.path,p,"file"));if(s.type==="dir"){if(a.has(s.path.toLowerCase())||a.has(s.name.toLowerCase()))return null;const p=r=>r.type==="file"?r.path.toLowerCase().includes(i):r.children.some(p);if(i&&!p(s))return null;const h=!i&&f.has(s.path);return e.jsxs("div",{children:[e.jsxs("div",{className:"tree-file-row",children:[e.jsxs("button",{className:"tree-dir-btn",title:s.path,onTouchStart:l.onTouchStart,onTouchMove:l.onTouchMove,onTouchEnd:l.onTouchEnd,onTouchCancel:l.onTouchCancel,onContextMenu:l.onContextMenu,onClick:r=>{l.consumeClick(r)||o(s.path)},children:[h?"▸ ":"▾ ",s.name]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for folder ${s.name}`,onClick:r=>{r.stopPropagation(),w(s.path,r.currentTarget.getBoundingClientRect(),"dir")},children:"⋯"})]}),!h&&e.jsx("div",{className:"tree-children",children:s.children.map(r=>e.jsx(Bt,{node:r,activePath:t,filter:i,collapsed:f,hiddenSet:a,onToggleDir:o,onSelectFile:u,onOpenMenu:w},r.path))})]})}return i&&!s.path.toLowerCase().includes(i)?null:e.jsxs("div",{className:`tree-file-row${s.path===t?" active":""}`,children:[e.jsx("button",{className:`tree-file${s.path===t?" active":""}`,title:s.path,onTouchStart:c.onTouchStart,onTouchMove:c.onTouchMove,onTouchEnd:c.onTouchEnd,onTouchCancel:c.onTouchCancel,onContextMenu:c.onContextMenu,onClick:p=>{c.consumeClick(p)||u(s.path)},children:s.name}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${s.name}`,onClick:p=>{p.stopPropagation(),w(s.path,p.currentTarget.getBoundingClientRect())},children:"⋯"})]})}function Ws({drawerOpen:s,live:t,settings:i,setSettings:f,sidebarTab:a,setSidebarTab:o,gitChanges:u,searchRef:w,filter:l,setFilter:c,tree:p,activePath:h,collapsed:r,hiddenSet:S,toggleDir:$,setViewMode:C,openFile:d,openRowMenu:g,changesSort:L,setChangesSort:R,openCommitDialog:v,sortedChanges:y,loadDiff:b}){return e.jsxs("aside",{className:`sidebar${s?" open":""}`,children:[e.jsxs("div",{className:"brand",children:[e.jsxs("div",{className:"brand-title",children:[e.jsx("img",{src:"/vault-logo.svg",alt:"",width:"20",height:"20",className:"brand-logo"}),e.jsx("span",{children:"Vault"}),e.jsx("span",{className:`pill${t?"":" off"}`,children:t?"Live":"Reconnecting"})]}),e.jsx("button",{className:"icon-btn","aria-label":i.theme==="dark"?"Switch to light theme":"Switch to dark theme",title:i.theme==="dark"?"Switch to light theme":"Switch to dark theme",onClick:()=>f(E=>({...E,theme:E.theme==="dark"?"light":"dark"})),children:i.theme==="dark"?e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}):e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.9",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})})]}),e.jsxs("div",{className:"sidebar-tabs",children:[e.jsx("button",{className:`sidebar-tab${a==="files"?" active":""}`,onClick:()=>o("files"),children:"Files"}),e.jsxs("button",{className:`sidebar-tab${a==="changes"?" active":""}`,onClick:()=>o("changes"),children:[e.jsx("span",{children:"Changes"}),u.length>0&&e.jsx("span",{className:"pill",children:u.length})]})]}),e.jsx("div",{className:"search-wrap",children:e.jsx("input",{ref:w,className:"search",type:"search",placeholder:a==="files"?"Filter files... (/)":"Filter changes...",value:l,onChange:E=>c(E.target.value.trim().toLowerCase())})}),e.jsx("div",{className:"tree",children:a==="files"?p.map(E=>e.jsx(Bt,{node:E,activePath:h,filter:l,collapsed:r,hiddenSet:S,onToggleDir:$,onSelectFile:P=>{C("preview"),d(P)},onOpenMenu:g},E.path)):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"changes-bar",children:[e.jsxs("select",{className:"changes-select","aria-label":"Sort changes",value:L,onChange:E=>R(E.target.value),children:[e.jsx("option",{value:"path",children:"Sort: Path"}),e.jsx("option",{value:"recent",children:"Sort: Recent"}),e.jsx("option",{value:"status",children:"Sort: Status"})]}),u.length>0&&e.jsx("button",{className:"btn primary",onClick:v,children:"Commit"})]}),y.length===0?e.jsx("div",{className:"empty-note",style:{padding:"10px 8px"},children:"Working tree clean"}):y.map(E=>e.jsxs("div",{className:`tree-file-row${E.path===h?" active":""}`,children:[e.jsxs("button",{className:`tree-file${E.path===h?" active":""}`,title:E.path,onClick:()=>{E.status!=="D"&&(C("diff"),d(E.path),b(E.path))},children:[e.jsx("span",{className:`git-badge git-${E.status}`,children:E.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:E.path})]}),e.jsx("button",{className:"tree-row-more","aria-label":`Actions for ${E.path}`,onClick:P=>{P.stopPropagation(),g(E.path,P.currentTarget.getBoundingClientRect())},children:"⋯"})]},E.path))]})})]})}function zs({tabs:s,activeTabId:t,switchTab:i,closeTab:f,createNewTab:a}){return e.jsxs("div",{className:"desktop-tabs",children:[s.map(o=>e.jsxs("div",{className:`desktop-tab${o.id===t?" active":""}`,onClick:()=>i(o),children:[e.jsx("span",{className:"desktop-tab-title",children:o.title}),e.jsx("button",{className:"desktop-tab-close",onClick:u=>f(o.id,u),children:"×"})]},o.id)),e.jsx("button",{className:"desktop-tab-add",title:"New tab",onClick:a,children:"+"})]})}function _s({setDrawerOpen:s,activePath:t,moreMenuOpen:i,setMoreMenuOpen:f,viewMode:a,setViewMode:o,loadDiff:u,setDeleteError:w,setDeleteTarget:l,outlinePosition:c,outlineDrawerOpen:p,onToggleOutline:h,onOpenOutline:r}){const S=p||c!=="hidden";return e.jsxs("div",{className:"topbar",children:[e.jsxs("div",{className:"topbar-left",children:[e.jsx("button",{className:"icon-btn menu-btn","aria-label":"Toggle files",onClick:()=>s($=>!$),children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("div",{className:"crumbs",children:t||"New tab"})]}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:`icon-btn outline-toggle-btn${S?" active":""}`,"aria-label":"Toggle outline",title:"Toggle outline & backlinks",onClick:h,children:e.jsxs("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M15 3v18"})]})}),e.jsx("button",{className:"icon-btn","aria-label":"Note options",title:"Note options",onClick:()=>f($=>!$),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}),i&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>f(!1),children:[e.jsxs("button",{className:`more-item${a==="preview"?" active":""}`,onClick:()=>{o("preview"),f(!1)},children:[e.jsx("span",{children:"Preview"}),a==="preview"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="edit"?" active":""}`,onClick:()=>{o("edit"),f(!1)},children:[e.jsx("span",{children:"Edit"}),a==="edit"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="diff"?" active":""}`,onClick:()=>{o("diff"),f(!1),u(t)},children:[e.jsx("span",{children:"Diff"}),a==="diff"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${a==="raw"?" active":""}`,onClick:()=>{o("raw"),f(!1)},children:[e.jsx("span",{children:"Raw"}),a==="raw"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:`more-item outline-menu-trigger${c==="hidden"?" show-desktop":""}`,style:{borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{f(!1),r()},children:e.jsx("span",{children:"Outline"})}),t&&e.jsx("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:3,paddingTop:9},onClick:()=>{f(!1),w(""),l(t)},children:e.jsx("span",{children:"Delete"})})]})]})]})}const Fs="modulepreload",Us=function(s){return"/"+s},Mt={},Os=function(t,i,f){let a=Promise.resolve();if(i&&i.length>0){let u=function(c){return Promise.all(c.map(p=>Promise.resolve(p).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const w=document.querySelector("meta[property=csp-nonce]"),l=(w==null?void 0:w.nonce)||(w==null?void 0:w.getAttribute("nonce"));a=u(i.map(c=>{if(c=Us(c),c in Mt)return;Mt[c]=!0;const p=c.endsWith(".css"),h=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const r=document.createElement("link");if(r.rel=p?"stylesheet":Fs,p||(r.as="script"),r.crossOrigin="",r.href=c,l&&r.setAttribute("nonce",l),document.head.appendChild(r),p)return new Promise((S,$)=>{r.addEventListener("load",S),r.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(u){const w=new Event("vite:preloadError",{cancelable:!0});if(w.payload=u,window.dispatchEvent(w),!w.defaultPrevented)throw u}return a.then(u=>{for(const w of u||[])w.status==="rejected"&&o(w.reason);return t().catch(o)})},qs=m.lazy(()=>Os(()=>import("./TiptapEditor-OFHNcjy3.js"),__vite__mapDeps([0,1,2,3])));function Xs({scrollRef:s,activePath:t,openNewNoteDialog:i,openFile:f,openSwitcher:a,setDrawerOpen:o,setSettingsOpen:u,isImg:w,reloadTick:l,isBinaryDownload:c,viewMode:p,settings:h,diffData:r,requestDiscard:S,content:$,saving:C,dirty:d,setDraftContent:g,setDirty:L,saveActiveNote:R,highlightedRawHtml:v,handleDocClick:y,renderedHtml:b}){var E,P;return e.jsx("div",{ref:s,className:"content-scroll",children:t?w?e.jsx("div",{className:"doc img-wrap",children:e.jsx("img",{src:`/api/v1/file?path=${encodeURIComponent(t)}&t=${l}`,alt:t})}):c?e.jsxs("div",{className:"doc binary-card",children:[e.jsx("div",{className:"binary-card-name",children:t.split("/").pop()}),e.jsx("div",{className:"binary-card-path",children:t}),e.jsx("a",{className:"btn primary",href:`/api/v1/file?path=${encodeURIComponent(t)}&download=1`,download:t.split("/").pop(),style:{textDecoration:"none",display:"inline-flex",alignItems:"center",gap:6},children:"Download file"})]}):p==="diff"?e.jsxs("div",{className:"diff-wrap",style:{maxWidth:`${h.maxWidth+80}px`},children:[e.jsxs("div",{className:"diff-head",children:[e.jsx("span",{style:{fontSize:13,color:"var(--muted)"},children:r!=null&&r.untracked?"Untracked file":`${((E=r==null?void 0:r.hunks)==null?void 0:E.length)||0} hunk(s)`}),((P=r==null?void 0:r.hunks)==null?void 0:P.length)>0&&e.jsx("button",{className:"btn",style:{color:"#f87171"},onClick:()=>S(),children:"Discard file"})]}),!r||r.hunks.length===0?e.jsx("div",{className:"empty-note",children:"No uncommitted changes for this file."}):r.hunks.map((H,W)=>e.jsxs("div",{className:"diff-hunk",children:[e.jsxs("div",{className:"diff-hunk-bar",children:[e.jsx("span",{children:H.header}),!r.untracked&&e.jsx("button",{className:"btn",onClick:()=>S({hunkIndex:W}),children:"Discard hunk"})]}),H.lines.map((F,ae)=>e.jsxs("div",{className:`diff-line ${F.type}`,children:[e.jsx("span",{className:"diff-ln",children:F.newLine??F.oldLine??""}),e.jsx("span",{className:"diff-sig",children:F.type==="add"?"+":F.type==="del"?"-":" "}),e.jsx("span",{className:"diff-txt",children:F.text||" "}),!r.untracked&&F.type!=="context"?e.jsx("button",{className:"diff-discard-btn",title:"Discard line",onClick:()=>S({hunkIndex:W,lineIndex:ae,previewText:`${F.type==="add"?"+":"-"} ${F.text}`}),children:"↺"}):e.jsx("span",{})]},ae))]},W))]}):p==="edit"&&t.endsWith(".md")?e.jsx(m.Suspense,{fallback:e.jsx("div",{className:"empty-note",style:{padding:"24px"},children:"Loading editor..."}),children:e.jsx(qs,{fileKey:t,content:$,fontSize:h.fontSize,lineHeight:h.lineHeight,maxWidth:h.maxWidth,saving:C,dirty:d,onChange:H=>{g(H),L(H!==$)},onSave:R})}):p==="raw"||!t.endsWith(".md")?e.jsx("pre",{className:"raw-view",style:{fontSize:`${Math.max(12,h.fontSize-2)}px`,maxWidth:`${h.maxWidth+80}px`},children:e.jsx("code",{className:"hljs",dangerouslySetInnerHTML:{__html:v}})}):e.jsx("div",{className:"doc",style:{fontSize:`${h.fontSize}px`,lineHeight:h.lineHeight,maxWidth:`${h.maxWidth}px`},onClick:y,dangerouslySetInnerHTML:{__html:b}}):e.jsxs("div",{className:"new-tab-view",children:[e.jsxs("button",{className:"new-tab-btn",onClick:()=>i(""),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})}),e.jsx("span",{children:"Create new note"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>f("README.md"),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"})}),e.jsx("span",{children:"Go to README"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:a,children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]}),e.jsx("span",{children:"Go to file"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>o(!0),children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"})}),e.jsx("span",{children:"Browse files"})]}),e.jsxs("button",{className:"new-tab-btn",onClick:()=>u(!0),children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:"Settings"})]})]})})}function Gs({headings:s,isImg:t,isBinaryDownload:i,viewMode:f,currentBacklinks:a,openFile:o,position:u="right",onChangePosition:w,mobileOpen:l=!1,onCloseMobile:c}){const[p,h]=m.useState(!1);if(u==="hidden"&&!l&&window.innerWidth>960)return null;const r=t?"Image preview":i?"Binary file":f==="raw"?"Raw view":f==="edit"?"Edit mode":f==="diff"?"Diff mode":"No headings";return e.jsxs("aside",{className:`rightbar${l?" mobile-open":""}`,children:[e.jsxs("div",{className:"rightbar-head",children:[e.jsx("div",{className:"panel-title",style:{margin:0},children:u==="bottom"?"Outline & Backlinks":"Outline"}),e.jsxs("div",{className:"actions",children:[e.jsx("button",{className:"icon-btn","aria-label":"Outline panel options",title:"Outline panel options",onClick:()=>h(S=>!S),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.8"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.8"})]})}),p&&e.jsxs("div",{className:"more-menu",onMouseLeave:()=>h(!1),children:[e.jsxs("button",{className:`more-item${u==="right"?" active":""}`,onClick:()=>{w("right"),h(!1)},children:[e.jsx("span",{children:"Position: Right"}),u==="right"&&e.jsx("span",{children:"✓"})]}),e.jsxs("button",{className:`more-item${u==="bottom"?" active":""}`,onClick:()=>{w("bottom"),c==null||c(),h(!1)},children:[e.jsx("span",{children:"Position: Bottom"}),u==="bottom"&&e.jsx("span",{children:"✓"})]}),e.jsx("button",{className:"more-item",style:{borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{window.innerWidth<=960&&l?c==null||c():w("hidden"),h(!1)},children:e.jsx("span",{children:"Hide panel"})})]})]})]}),e.jsxs("div",{className:"rightbar-body",children:[e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-subtitle",children:"Outline"}),s.length===0?e.jsx("div",{className:"empty-note",children:r}):s.map((S,$)=>e.jsx("a",{className:`toc-item toc-h${S.level}`,onClick:()=>{var C;(C=document.getElementById(S.id))==null||C.scrollIntoView({behavior:"smooth"}),c==null||c()},children:S.text},`${S.id}-${$}`))]}),e.jsxs("div",{className:"rightbar-sec",children:[e.jsx("div",{className:"panel-title backlinks-title",children:"Backlinks"}),a.length===0?e.jsx("div",{className:"empty-note",children:"No backlinks yet"}):a.map(S=>e.jsx("a",{className:"backlink-item",onClick:()=>{o(S),c==null||c()},children:S},S))]})]})]})}function Ks({fabOpen:s,setFabOpen:t,openSwitcher:i,drawerOpen:f,setDrawerOpen:a,openFile:o,viewMode:u,setViewMode:w,settings:l,setSettings:c,setSettingsOpen:p,scrollRef:h,loadDiff:r,activePath:S,createNewTab:$,tabsOpen:C,setTabsOpen:d,tabs:g,activeTabId:L,switchTab:R,closeTab:v,onToggleOutline:y}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fab-wrap",children:[s&&e.jsxs("div",{className:"fab-menu",children:[e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),i()},children:"🔍 Quick switcher"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),a(b=>!b)},children:"📁 Toggle files"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),y==null||y()},children:"📑 Toggle outline"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),o("README.md")},children:"🏠 Home (README)"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),w(b=>b==="raw"?"preview":"raw")},children:u==="raw"?"📄 Preview mode":"🧾 Raw view"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),c(b=>({...b,theme:b.theme==="dark"?"light":"dark"}))},children:l.theme==="dark"?"☀️ Light theme":"🌙 Dark theme"}),e.jsx("button",{className:"fab-item",onClick:()=>{t(!1),p(!0)},children:"⚙️ Settings"}),e.jsx("button",{className:"fab-item",onClick:()=>{var b;t(!1),(b=h.current)==null||b.scrollTo({top:0,behavior:"smooth"})},children:"⬆️ Scroll to top"})]}),e.jsx("button",{className:"fab-btn","aria-label":"Quick actions",onClick:()=>t(b=>!b),children:s?"×":"+"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sheet-backdrop",onClick:()=>t(!1)}),e.jsxs("div",{className:"bottom-sheet",role:"dialog","aria-label":"Quick actions",children:[e.jsx("div",{className:"sheet-handle"}),e.jsxs("div",{className:"sheet-list",children:[e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),i()},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]}),e.jsx("span",{children:"Open quick switcher"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),a(b=>!b)},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]}),e.jsx("span",{children:"Toggle files sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),y==null||y()},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M15 3v18"})]}),e.jsx("span",{children:"Toggle outline sidebar"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),o("README.md")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z"})}),e.jsx("span",{children:"Go to Home (README)"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),w(b=>b==="edit"?"preview":"edit")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 20h9M16.5 3.5a2.12 2.12 0 1 1 3 3L7 19l-4 1 1-4Z"})}),e.jsx("span",{children:u==="edit"?"Switch to Preview mode":"Switch to Edit mode"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),w("diff"),r(S)},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 3v18M3 12h18"})}),e.jsx("span",{children:"View Git Diff"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),w(b=>b==="raw"?"preview":"raw")},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"})}),e.jsx("span",{children:u==="raw"?"Switch to Preview mode":"Switch to Raw view"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{var b;t(!1),(b=h.current)==null||b.scrollTo({top:0,behavior:"smooth"})},children:[e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 19V5M5 12l7-7 7 7"})}),e.jsx("span",{children:"Scroll to top"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),c(b=>({...b,theme:b.theme==="dark"?"light":"dark"}))},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"4"}),e.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41"})]}),e.jsx("span",{children:l.theme==="dark"?"Switch to Light theme":"Switch to Dark theme"})]}),e.jsxs("button",{className:"sheet-item",onClick:()=>{t(!1),p(!0)},children:[e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("span",{children:"Settings"})]})]})]})]}),e.jsxs("nav",{className:"mobile-bar","aria-label":"Mobile quick actions",children:[e.jsx("button",{className:`mobile-bar-btn${f?" active":""}`,"aria-label":"Files",onClick:()=>{t(!1),a(b=>!b)},children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),e.jsx("path",{d:"M9 3v18"})]})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Back",onClick:()=>window.history.back(),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"m15 18-6-6 6-6"})})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Forward",onClick:()=>window.history.forward(),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"m9 18 6-6-6-6"})})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"Search",onClick:()=>{t(!1),i()},children:e.jsxs("svg",{viewBox:"0 0 24 24",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"m20 20-3.5-3.5"})]})}),e.jsx("button",{className:"mobile-bar-btn","aria-label":"New tab",onClick:$,children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 5v14M5 12h14"})})}),e.jsx("button",{className:`mobile-bar-btn${C?" active":""}`,"aria-label":"Open tabs",onClick:()=>{t(!1),d(!0)},children:e.jsx("span",{className:"tabs-count-badge",children:g.length})}),e.jsx("button",{className:`mobile-bar-btn${s?" active":""}`,"aria-label":"Menu",onClick:()=>t(b=>!b),children:e.jsx("svg",{viewBox:"0 0 24 24",children:e.jsx("path",{d:"M4 6h16M4 12h16M4 18h16"})})})]}),C&&e.jsxs("div",{className:"tabs-overlay",onClick:()=>d(!1),children:[e.jsx("div",{className:"tabs-grid",onClick:b=>b.stopPropagation(),children:g.map(b=>e.jsxs("div",{className:"tab-card-wrap",children:[e.jsxs("div",{className:`tab-card${b.id===L?" active":""}`,onClick:()=>R(b),children:[e.jsx("button",{className:"tab-card-close","aria-label":"Close tab",onClick:E=>v(b.id,E),children:"×"}),e.jsx("div",{className:"tab-card-title",children:b.title}),e.jsx("div",{className:"tab-card-preview",children:b.preview||(b.path?b.path:"Empty tab")})]}),e.jsx("div",{className:"tab-card-label",children:b.title})]},b.id))}),e.jsxs("div",{className:"tabs-footer",onClick:b=>b.stopPropagation(),children:[e.jsx("button",{className:"tabs-footer-btn","aria-label":"New tab",onClick:$,children:"+"}),e.jsxs("span",{style:{fontSize:14,fontWeight:600},children:[g.length," ",g.length===1?"tab":"tabs"]}),e.jsx("button",{className:"tabs-footer-btn",onClick:()=>d(!1),children:"Done"})]})]})]})}function Vs({switcherOpen:s,setSwitcherOpen:t,switcherTab:i,setSwitcherTab:f,switcherIdx:a,setSwitcherIdx:o,switcherInputRef:u,totalFiles:w,fileStats:l,switcherItems:c,switcherData:p,openFile:h,isLargeVault:r,pagedFiles:S,loadMorePagedFiles:$,switcherQuery:C,setSwitcherQuery:d}){return s?e.jsx("div",{className:"switcher-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"switcher",onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"switcher-head",children:[e.jsxs("div",{className:"switcher-tabs",children:[e.jsx("button",{className:`switcher-tab${i==="recent"?" active":""}`,onClick:()=>{var g;f("recent"),o(0),(g=u.current)==null||g.focus()},children:"Recent"}),e.jsx("button",{className:`switcher-tab${i==="alpha"?" active":""}`,onClick:()=>{var g;f("alpha"),o(0),(g=u.current)==null||g.focus()},children:"A–Z"})]}),w>l.length&&e.jsxs("span",{className:"switcher-cap",children:[l.length.toLocaleString()," / ",w.toLocaleString()," indexed"]})]}),e.jsxs("div",{className:"switcher-list",children:[c.length===0?e.jsx("div",{className:"empty-note",style:{padding:"12px"},children:"No matching notes"}):(()=>{let g=0;const L=Date.now(),R=v=>{if(!v)return"";const y=Math.max(0,L-v);return y<6e4?"now":y<36e5?`${Math.floor(y/6e4)}m`:y<864e5?`${Math.floor(y/36e5)}h`:y<7*864e5?`${Math.floor(y/864e5)}d`:new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric"})};return p.groups.map(v=>e.jsxs(Ss.Fragment,{children:[v.label&&e.jsx("div",{className:"switcher-group-title",children:v.label}),v.items.map(y=>{const b=g++;return e.jsxs("button",{className:`switcher-item${b===a?" selected":""}`,onClick:()=>{t(!1),h(y.path)},children:[e.jsxs("div",{className:"switcher-row-top",children:[e.jsx("span",{className:"switcher-path",children:y.path}),y.mtimeMs>0&&e.jsx("span",{className:"switcher-time",children:R(y.mtimeMs)})]}),y.snippet&&e.jsx("span",{className:"switcher-snippet",children:y.snippet})]},y.path)})]},v.label||"all"))})(),r&&S.hasMore&&e.jsx("button",{className:"btn",style:{margin:"8px auto",display:"block"},onClick:$,children:"Load more"})]}),e.jsxs("div",{className:"switcher-input-wrap",children:[e.jsx("input",{ref:u,className:"switcher-input",type:"text",placeholder:"Find a note...",value:C,onChange:g=>{d(g.target.value),o(0)},onKeyDown:g=>{g.key==="ArrowDown"?(g.preventDefault(),o(L=>Math.min(L+1,Math.max(0,c.length-1)))):g.key==="ArrowUp"?(g.preventDefault(),o(L=>Math.max(L-1,0))):g.key==="Enter"&&c[a]&&(g.preventDefault(),t(!1),h(c[a].path))}}),e.jsx("button",{className:"switcher-clear","aria-label":"Clear or close",onClick:()=>C?d(""):t(!1),children:"×"})]})]})}):null}function Js({fileMenu:s,setFileMenu:t,openNewNoteDialog:i,uploadDirRef:f,uploadInputRef:a,setRenameError:o,setRenameTarget:u,setTabs:w,setActiveTabId:l,setViewMode:c,openFile:p,gitChanges:h,loadDiff:r,requestDiscard:S,setDeleteError:$,setDeleteTarget:C}){return s?e.jsx("div",{style:{position:"fixed",inset:0,zIndex:59},onClick:()=>t(null),children:e.jsx("div",{className:"file-ctx-menu",style:{left:s.x,top:s.y},onClick:d=>d.stopPropagation(),children:s.type==="dir"?e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const d=s.path;t(null),i(d)},children:e.jsx("span",{children:"New note here"})}),e.jsx("button",{className:"more-item",onClick:()=>{var d;f.current=s.path,t(null),(d=a.current)==null||d.click()},children:e.jsx("span",{children:"Upload file..."})}),e.jsx("button",{className:"more-item",onClick:()=>{const d=s.path;t(null),o(""),u({type:"dir",oldPath:d,newPath:d})},children:e.jsx("span",{children:"Rename / Move"})}),e.jsx("button",{className:"more-item",onClick:()=>{var d;(d=navigator.clipboard)==null||d.writeText(s.path),t(null)},children:e.jsx("span",{children:"Copy path"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const d=s.path,g=`tab-${Date.now()}`;t(null),w(L=>[...L,{id:g,path:d,title:We(d),preview:""}]),l(g),c("preview"),p(d,!1,g)},children:e.jsx("span",{children:"Open in new tab"})}),e.jsx("button",{className:"more-item",onClick:()=>{const d=s.path;t(null),o(""),u({type:"file",oldPath:d,newPath:d})},children:e.jsx("span",{children:"Rename / Move"})}),e.jsx("button",{className:"more-item",onClick:()=>{var d;(d=navigator.clipboard)==null||d.writeText(s.path),t(null)},children:e.jsx("span",{children:"Copy path"})}),s.path.endsWith(".md")&&e.jsx("button",{className:"more-item",onClick:()=>{var d;(d=navigator.clipboard)==null||d.writeText(`[[${s.path.replace(/\.md$/i,"")}]]`),t(null)},children:e.jsx("span",{children:"Copy [[wikilink]]"})}),h.some(d=>d.path===s.path)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"more-item",onClick:()=>{const d=s.path;t(null),c("diff"),p(d),r(d)},children:e.jsx("span",{children:"View Diff"})}),e.jsx("button",{className:"more-item",style:{color:"var(--amber)"},onClick:()=>{const d=s.path;t(null),S({path:d})},children:e.jsx("span",{children:"Discard changes"})})]}),e.jsx("button",{className:"more-item",style:{color:"#f87171",borderTop:"1px solid var(--border)",marginTop:2,paddingTop:8},onClick:()=>{const d=s.path;t(null),$(""),C(d)},children:e.jsx("span",{children:"Delete"})})]})})}):null}function Ys({newNoteOpen:s,setNewNoteOpen:t,newNoteTitle:i,setNewNoteTitle:f,newNoteFolder:a,setNewNoteFolder:o,allFolders:u,newNoteError:w,confirmNewNote:l}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:460},onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"New note"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Title"}),e.jsx("input",{type:"text",autoFocus:!0,placeholder:"My note title",value:i,onChange:c=>f(c.target.value),onKeyDown:c=>c.key==="Enter"&&l()})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Folder"}),e.jsx("input",{type:"text",placeholder:"(vault root) or type/select folder",value:a,onChange:c=>o(c.target.value),onKeyDown:c=>c.key==="Enter"&&l()}),e.jsx("div",{className:"folder-picker",children:u.map(c=>{const p=a.trim().replace(/^\/+|\/+$/g,"")===c;return e.jsx("button",{type:"button",className:`folder-pick-item${p?" active":""}`,onClick:()=>o(c),children:c||"/ (vault root)"},c||"__root__")})})]}),ze(i,a)&&e.jsxs("div",{style:{fontSize:12,color:"var(--muted)",fontFamily:"var(--font-mono)"},children:["Path: ",ze(i,a)]}),w&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:w})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:l,children:"Create note"})]})]})}):null}function Qs({renameTarget:s,setRenameTarget:t,renameError:i,confirmRenameFile:f}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Rename / Move"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"New path"}),e.jsx("input",{type:"text",value:s.newPath,onChange:a=>t(o=>({...o,newPath:a.target.value})),onKeyDown:a=>a.key==="Enter"&&f()})]}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn primary",onClick:f,children:"Rename"})]})]})}):null}function Zs({deleteTarget:s,setDeleteTarget:t,deleteError:i,confirmDeleteFile:f}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:420},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Delete file?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{style:{fontSize:13,color:"var(--muted)"},children:["This will permanently remove ",e.jsx("strong",{style:{color:"var(--text)"},children:s})," from disk."]}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:f,children:"Delete"})]})]})}):null}function ea({discardTarget:s,setDiscardTarget:t,discardError:i,confirmDiscard:f}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(null),children:e.jsxs("div",{className:"modal",style:{height:"auto",maxWidth:440},onClick:a=>a.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:s.hunkIndex===void 0?"Discard file changes?":s.lineIndex===void 0?"Discard hunk?":"Discard line?"}),e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsx("div",{style:{fontSize:13,color:"var(--muted)",marginBottom:10},children:s.path}),s.previewText&&e.jsx("div",{className:"git-output",style:{marginTop:0},children:s.previewText}),i&&e.jsx("div",{className:"git-output",style:{color:"#f87171"},children:i})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(null),children:"Cancel"}),e.jsx("button",{className:"btn",style:{background:"#ef4444",borderColor:"#ef4444",color:"#ffffff",fontWeight:600},onClick:f,children:"Discard"})]})]})}):null}function ta({commitOpen:s,setCommitOpen:t,commitSelected:i,setCommitSelected:f,gitChanges:a,commitMessage:o,setCommitMessage:u,commitPush:w,setCommitPush:l,commitStatus:c,commitBusy:p,handleCommitSubmit:h}){return s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:r=>r.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Commit & Push"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsxs("div",{className:"modal-body",children:[e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Files (",i.size," selected)"]}),e.jsx("div",{className:"commit-files",children:a.map(r=>e.jsxs("label",{className:"commit-file-row",children:[e.jsx("input",{type:"checkbox",checked:i.has(r.path),onChange:S=>{f($=>{const C=new Set($);return S.target.checked?C.add(r.path):C.delete(r.path),C})}}),e.jsx("span",{className:`git-badge git-${r.status}`,children:r.status}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.path})]},r.path))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Commit message"}),e.jsx("input",{type:"text",placeholder:"docs: update vault notes",value:o,onChange:r=>u(r.target.value)})]}),e.jsxs("label",{className:"toggle-row",children:[e.jsx("span",{children:"Push to remote after commit"}),e.jsx("input",{type:"checkbox",checked:w,onChange:r=>l(r.target.checked)})]}),c&&e.jsx("div",{className:"git-output",style:{color:c.ok?"var(--green)":"#f87171"},children:c.text})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Cancel"}),e.jsx("button",{className:"btn primary",disabled:p||!o.trim()||i.size===0,onClick:h,children:p?"Running...":w?"Commit & Push":"Commit"})]})]})}):null}function Rt(s){return s.split(",").map(t=>t.trim().replace(/^\/+|\/+$/g,"")).filter(Boolean)}function sa({settingsOpen:s,setSettingsOpen:t,settingsTab:i,setSettingsTab:f,settings:a,setSettings:o,setCollapsed:u}){const[w,l]=m.useState(()=>a.autoCollapsed.join(", ")),[c,p]=m.useState(()=>a.hiddenFolders.join(", "));return m.useEffect(()=>{s&&(l(a.autoCollapsed.join(", ")),p(a.hiddenFolders.join(", ")))},[s]),s?e.jsx("div",{className:"modal-backdrop",onClick:()=>t(!1),children:e.jsxs("div",{className:"modal",onClick:h=>h.stopPropagation(),children:[e.jsxs("div",{className:"modal-head",children:[e.jsx("h2",{children:"Settings"}),e.jsx("button",{className:"btn",onClick:()=>t(!1),children:"Close"})]}),e.jsx("div",{className:"settings-tabs",children:[["general","General"],["appearance","Appearance"],["files","Files & Search"],["endpoints","API & MCP"]].map(([h,r])=>e.jsx("button",{className:`settings-tab${i===h?" active":""}`,onClick:()=>f(h),children:r},h))}),e.jsxs("div",{className:"modal-body",children:[i==="general"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"On startup / first open"}),e.jsxs("select",{value:a.startupMode,onChange:h=>o(r=>({...r,startupMode:h.target.value})),children:[e.jsx("option",{value:"readme",children:"README.md"}),e.jsx("option",{value:"last",children:"Last opened note"}),e.jsx("option",{value:"newtab",children:"New tab launcher"}),e.jsx("option",{value:"custom",children:"Custom note path"})]}),e.jsx("div",{className:"field-hint",children:"Used when opening the vault without a specific #note in the URL."})]}),a.startupMode==="custom"&&e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Custom startup note path"}),e.jsx("input",{type:"text",placeholder:"core/README.md",value:a.startupPath,onChange:h=>o(r=>({...r,startupPath:h.target.value}))})]})]}),i==="appearance"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Theme"}),e.jsxs("select",{value:a.theme,onChange:h=>o(r=>({...r,theme:h.target.value})),children:[e.jsx("option",{value:"dark",children:"Dark"}),e.jsx("option",{value:"light",children:"Light"})]})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Outline & Backlinks panel"}),e.jsxs("select",{value:a.outlinePosition,onChange:h=>o(r=>({...r,outlinePosition:h.target.value})),children:[e.jsx("option",{value:"right",children:"Right sidebar"}),e.jsx("option",{value:"bottom",children:"Bottom panel"}),e.jsx("option",{value:"hidden",children:"Hidden"})]})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Reader font size: ",a.fontSize,"px"]}),e.jsx("input",{type:"range",min:"13",max:"20",value:a.fontSize,onChange:h=>o(r=>({...r,fontSize:Number(h.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Line height: ",a.lineHeight]}),e.jsx("input",{type:"range",min:"1.35",max:"2.0",step:"0.05",value:a.lineHeight,onChange:h=>o(r=>({...r,lineHeight:Number(h.target.value)}))})]}),e.jsxs("div",{className:"field",children:[e.jsxs("label",{children:["Max reading width: ",a.maxWidth,"px"]}),e.jsx("input",{type:"range",min:"580",max:"980",step:"20",value:a.maxWidth,onChange:h=>o(r=>({...r,maxWidth:Number(h.target.value)}))})]})]}),i==="files"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Auto-collapsed folders (comma-separated)"}),e.jsx("input",{type:"text",placeholder:"apps, templates",value:w,onChange:h=>{const r=h.target.value;l(r);const S=Rt(r);o($=>({...$,autoCollapsed:S})),u(new Set(S))},onBlur:()=>l(a.autoCollapsed.join(", "))})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"Hidden folders (hide from sidebar & search)"}),e.jsx("input",{type:"text",placeholder:"ideas, templates",value:c,onChange:h=>{const r=h.target.value;p(r);const S=Rt(r);o($=>({...$,hiddenFolders:S}))},onBlur:()=>p(a.hiddenFolders.join(", "))})]}),e.jsxs("label",{className:"toggle-row",children:[e.jsx("span",{children:"Hide auto-collapsed folders from Quick Switcher"}),e.jsx("input",{type:"checkbox",checked:a.hideCollapsedInSearch,onChange:h=>o(r=>({...r,hideCollapsedInSearch:h.target.checked}))})]})]}),i==="endpoints"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"REST API (v1)"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/health"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/tree"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/file?path=README.md"}),e.jsxs("div",{className:"endpoint-box",children:["PUT / POST / PATCH /api/v1/file — ","{ path, content, append? } or { path, target, replacement, replaceAll? }"]}),e.jsx("div",{className:"endpoint-box",children:"DELETE /api/v1/file?path=..."}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/search?q=python"}),e.jsx("div",{className:"endpoint-box",children:"GET /api/v1/events (SSE)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("label",{children:"MCP Endpoint (Streamable HTTP)"}),e.jsx("div",{className:"endpoint-box",children:"POST /mcp — tools: list_vault, read_note, search_vault, write_note, delete_note"})]})]})]}),e.jsxs("div",{className:"modal-foot",children:[e.jsx("button",{className:"btn",onClick:()=>{o(V),u(new Set(V.autoCollapsed)),l(V.autoCollapsed.join(", ")),p(V.hiddenFolders.join(", "))},children:"Reset defaults"}),e.jsx("button",{className:"btn primary",onClick:()=>t(!1),children:"Done"})]})]})}):null}function aa(){const[s,t]=m.useState([]),[i,f]=m.useState([]),[a,o]=m.useState([]),[u,w]=m.useState(0),[l,c]=m.useState({}),[p,h]=m.useState($s),[r,S]=m.useState("general"),$=Ls(p),[C,d]=m.useState(()=>[{id:"tab-1",path:$,title:We($),preview:""}]),[g,L]=m.useState("tab-1"),R=C.find(n=>n.id===g)||C[0],v=(R==null?void 0:R.path)||"",[y,b]=m.useState(!1),[E,P]=m.useState(""),[H,W]=m.useState("preview"),[F,ae]=m.useState(null),[J,Ee]=m.useState(null),[Ht,Te]=m.useState(""),[ne,re]=m.useState(null),[It,ce]=m.useState(""),[Wt,_e]=m.useState(null),[z,$e]=m.useState(null),[zt,Le]=m.useState(""),[Fe,Me]=m.useState(!1),[Re,Ue]=m.useState(""),[Oe,qe]=m.useState(""),[_t,ie]=m.useState(""),Xe=m.useRef(null),Ge=m.useRef(""),[Ft,Ut]=m.useState(!1),[na,de]=m.useState(""),[Ot,he]=m.useState(!1),[qt,Ke]=m.useState(!1),[Xt,Gt]=m.useState("files"),[Y,Ve]=m.useState([]),[ue,Kt]=m.useState("path"),[Je,Ye]=m.useState(!1),[De,Qe]=m.useState(""),[Ze,Vt]=m.useState(!1),[et,tt]=m.useState(()=>new Set),[Jt,st]=m.useState(!1),[Yt,le]=m.useState(null),[me,Qt]=m.useState(""),[Zt,at]=m.useState(()=>new Set(p.autoCollapsed)),[es,nt]=m.useState(!0),[pe,U]=m.useState(!1),[fe,Q]=m.useState(!1),[it,lt]=m.useState(!1),[ot,Pe]=m.useState(!1),[O,Ae]=m.useState(!1),[Z,ts]=m.useState("recent"),[q,rt]=m.useState(""),[ss,ct]=m.useState(0),[dt,xe]=m.useState([]),[je,ve]=m.useState({items:[],hasMore:!1}),[as,ns]=m.useState(0),is=m.useRef(null),ht=m.useRef(null),G=m.useRef(null);m.useEffect(()=>{document.documentElement.setAttribute("data-theme",p.theme),localStorage.setItem("vault-settings",JSON.stringify(p))},[p]),m.useEffect(()=>{const n=x=>{var j;if((x.metaKey||x.ctrlKey)&&x.key.toLowerCase()==="k"){x.preventDefault(),ge();return}x.key==="/"&&((j=document.activeElement)==null?void 0:j.tagName)!=="INPUT"&&(x.preventDefault(),ge()),x.key==="Escape"&&O&&Ae(!1)};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[O]);function ge(){rt(""),ct(0),xe([]),Ae(!0),setTimeout(()=>{var n;return(n=ht.current)==null?void 0:n.focus()},40)}m.useEffect(()=>{if(!O)return;const n=q.trim();if(!n){xe([]);return}const x=setTimeout(async()=>{try{const k=await(await fetch(`/api/v1/search?q=${encodeURIComponent(n)}`)).json();xe(k.results||[])}catch{xe([])}},150);return()=>clearTimeout(x)},[q,O]);const be=m.useMemo(()=>new Set(p.hiddenFolders.map(n=>n.toLowerCase())),[p.hiddenFolders]),ls=m.useMemo(()=>{const n=[""],x=j=>{for(const k of j)if(k.type==="dir"){if(be.has(k.path.toLowerCase())||be.has(k.name.toLowerCase()))continue;n.push(k.path),x(k.children||[])}};return x(s),n},[s,be]),ee=u>a.length;m.useEffect(()=>{if(!O||!ee){ve({items:[],hasMore:!1});return}const n=Z==="alpha"?"name":"mtime",x=q.trim(),j=setTimeout(async()=>{try{const N=await(await fetch(`/api/v1/files?sort=${n}&offset=0&limit=100&q=${encodeURIComponent(x)}`)).json();ve({items:N.items||[],hasMore:!!N.hasMore})}catch{ve({items:[],hasMore:!1})}},100);return()=>clearTimeout(j)},[O,ee,Z,q]);async function os(){const n=Z==="alpha"?"name":"mtime",x=q.trim(),j=je.items.length,N=await(await fetch(`/api/v1/files?sort=${n}&offset=${j}&limit=100&q=${encodeURIComponent(x)}`)).json();ve(T=>({items:[...T.items,...N.items||[]],hasMore:!!N.hasMore}))}const ut=m.useMemo(()=>{const n=q.trim().toLowerCase(),x=M=>{const B=M.toLowerCase();return p.hiddenFolders.some(D=>B.startsWith(D.toLowerCase()+"/"))?!0:p.hideCollapsedInSearch?p.autoCollapsed.some(D=>{const He=D.toLowerCase()+"/";return B.startsWith(He)&&!n.includes(D.toLowerCase())}):!1},j=ee?je.items:a.length>0?a:i.map(M=>({path:M,mtimeMs:0})),k=new Map(j.map(M=>[M.path,M.mtimeMs||0]));let N;if(!n)N=j.filter(M=>!x(M.path)).map(M=>({path:M.path,mtimeMs:M.mtimeMs||0,snippet:""}));else{const M=j.filter(D=>!x(D.path)&&D.path.toLowerCase().includes(n)).map(D=>({path:D.path,mtimeMs:D.mtimeMs||0,snippet:""})),B=new Set(M.map(D=>D.path));for(const D of dt)!x(D.path)&&!B.has(D.path)&&(B.add(D.path),M.push({path:D.path,mtimeMs:D.mtimeMs??k.get(D.path)??0,snippet:D.snippet||""}));N=M}const T=ee?N.length:100;if(Z==="alpha"){const M=[...N].sort((B,D)=>{const He=B.path.split("/").pop().toLowerCase(),ys=D.path.split("/").pop().toLowerCase();return He.localeCompare(ys)||B.path.localeCompare(D.path)}).slice(0,T);return{groups:[{label:null,items:M}],items:M}}const _=[...N].sort((M,B)=>(B.mtimeMs||0)-(M.mtimeMs||0)).slice(0,T),I=Date.now(),kt=new Date(I);kt.setHours(0,0,0,0);const we=kt.getTime(),Be=864e5,se=new Map([["Today",[]],["Yesterday",[]],["Last 7 days",[]],["Last 30 days",[]],["Older",[]]]);for(const M of _){const B=M.mtimeMs||0;B>=we?se.get("Today").push(M):B>=we-Be?se.get("Yesterday").push(M):B>=we-7*Be?se.get("Last 7 days").push(M):B>=we-30*Be?se.get("Last 30 days").push(M):se.get("Older").push(M)}const Nt=[],Ct=[];for(const[M,B]of se)B.length>0&&(Nt.push({label:M,items:B}),Ct.push(...B));return{groups:Nt,items:Ct}},[q,Z,ee,je.items,a,i,dt,p.autoCollapsed,p.hiddenFolders,p.hideCollapsedInSearch]),rs=ut.items;async function X(){var k;const[n,x]=await Promise.all([fetch("/api/v1/tree?limit=10000"),fetch("/api/v1/changes")]),j=await n.json();if(t(j.tree),f(j.flatFiles),o(j.fileStats||[]),w(j.totalFiles??((k=j.flatFiles)==null?void 0:k.length)??0),c(j.backlinks),x.ok){const N=await x.json();Ve(N.changes||[])}}function mt(){const n=`tab-${Date.now()}`;d(x=>[...x,{id:n,path:null,title:"New tab",preview:""}]),L(n),P(""),b(!1),U(!1),lt(!1)}function pt(n,x){x==null||x.stopPropagation(),d(j=>{const k=j.filter(N=>N.id!==n);if(k.length===0){const N={id:`tab-${Date.now()}`,path:null,title:"New tab",preview:""};return L(N.id),P(""),[N]}if(n===g){const N=k[k.length-1];L(N.id),N.path?A(N.path,!1,N.id):P("")}return k})}function ft(n){L(n.id),b(!1),n.path?A(n.path,!1,n.id):(P(""),location.hash="")}async function A(n,x=!1,j=g){var T;if(!n){P("");return}const k=((T=G.current)==null?void 0:T.scrollTop)??0;let N="";if(ke(n)||Ie(n)){if(!(await fetch(`/api/v1/file?path=${encodeURIComponent(n)}`,{method:"HEAD"})).ok)return n!=="README.md"?A("README.md",!1,j):void 0;P(""),de(""),he(!1),N=ke(n)?"[Image preview]":"[Binary file — download]"}else{const _=await fetch(`/api/v1/file?path=${encodeURIComponent(n)}`);if(!_.ok)return n!=="README.md"?A("README.md",!1,j):void 0;const I=await _.text();P(I),de(I),he(!1),N=I.replace(/^#+\s*/gm,"").slice(0,260)}location.hash=encodeURIComponent(n),localStorage.setItem("vault-last-path",n),d(_=>_.map(I=>I.id===j?{...I,path:n,title:We(n),preview:N}:I)),x?requestAnimationFrame(()=>{G.current&&(G.current.scrollTop=k)}):(U(!1),requestAnimationFrame(()=>{G.current&&(G.current.scrollTop=0)})),H==="diff"&&te(n)}async function te(n=v){if(!n)return;const x=await fetch(`/api/v1/git/diff?path=${encodeURIComponent(n)}`);x.ok?ae(await x.json()):ae(null)}function xt({path:n=v,hunkIndex:x,lineIndex:j,previewText:k}={}){n&&(Te(""),Ee({path:n,hunkIndex:x,lineIndex:j,previewText:k}))}async function cs(){if(!(J!=null&&J.path))return;const{path:n,hunkIndex:x,lineIndex:j}=J,k=await fetch("/api/v1/git/discard",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,hunkIndex:x,lineIndex:j})}),N=await k.json().catch(()=>({}));k.ok?(Ee(null),Te(""),await X(),n===v&&(await A(v,!0),await te(v))):Te(N.error||"Failed to discard")}async function ds(){if(!ne)return;ce("");const n=await fetch(`/api/v1/file?path=${encodeURIComponent(ne)}`,{method:"DELETE"}),x=await n.json().catch(()=>({}));if(n.ok){const j=ne;re(null),localStorage.getItem("vault-last-path")===j&&localStorage.removeItem("vault-last-path");const k=N=>N.filter(T=>!(T.type==="file"&&T.path===j)).map(T=>T.type==="dir"?{...T,children:k(T.children||[])}:T);if(t(N=>k(N)),f(N=>N.filter(T=>T!==j)),o(N=>N.filter(T=>T.path!==j)),Ve(N=>N.filter(T=>T.path!==j)),j===v){W("preview");const N=C.filter(T=>T.path!==j);if(N.length>0){const T=N[N.length-1];d(N),L(T.id),T.path?await A(T.path,!1,T.id):(P(""),location.hash="")}else await A("README.md",!1,g)}else d(N=>N.filter(T=>T.path!==j));await X()}else ce(x.error||"Failed to delete file")}async function hs(n){var _;const x=Array.from(n||[]);if(!x.length)return;const j=Ge.current||"",k=new FormData;k.append("dir",j);for(const I of x)k.append("files",I);const N=await fetch("/api/v1/file/upload",{method:"POST",body:k}),T=await N.json().catch(()=>({}));if(N.ok&&(await X(),((_=T.uploaded)==null?void 0:_.length)===1)){const I=T.uploaded[0].path;/\.(md|markdown|txt|png|jpe?g|gif|webp|svg|ico)$/i.test(I)&&A(I)}}async function us(){if(!(z!=null&&z.oldPath)||!(z!=null&&z.newPath.trim()))return;Le("");const n=z.type==="dir",x=n?"/api/v1/dir/rename":"/api/v1/file/rename",j=z.newPath.trim().replace(/^\/+|\/+$/g,""),k=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:z.oldPath,newPath:j})}),N=await k.json().catch(()=>({}));if(k.ok){const{oldPath:T}=z;$e(null),await X(),n?v.startsWith(`${T}/`)&&A(`${j}${v.slice(T.length)}`):T===v&&A(j)}else Le(N.error||"Failed to rename")}function ms(n,x,j="file"){const k=window.innerWidth<=768?215:175,N=window.innerWidth<=768?310:250,T=Math.min(x.right-k,window.innerWidth-(k+12)),_=Math.min(x.bottom+4,window.innerHeight-N);_e({type:j,path:n,x:Math.max(8,T),y:Math.max(8,_)})}function jt(n=""){Ue(""),qe(n.replace(/^\/+|\/+$/g,"")),ie(""),Me(!0)}async function ps(){const n=ze(Re,Oe);if(!n){ie("Please enter a note title");return}if(i.includes(n)){ie(`Already exists: ${n}`);return}ie("");const x=Re.trim().replace(/\.md$/i,""),j=await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:`# ${x}
3
-
4
- `})}),k=await j.json().catch(()=>({}));if(!j.ok||k.error){ie(k.error||"Failed to create note");return}Me(!1),await X(),W("edit"),A(n)}m.useEffect(()=>{X(),A(v)},[]),m.useEffect(()=>{const n=()=>{const x=decodeURIComponent(location.hash.slice(1)||"");x&&x!==v&&A(x)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[v]),m.useEffect(()=>{const n=new EventSource("/api/v1/events");return n.onopen=()=>nt(!0),n.onmessage=async x=>{JSON.parse(x.data).type==="reload"&&(await X(),ns(k=>k+1),await A(v,!0))},n.onerror=()=>nt(!1),()=>n.close()},[v]);async function fs(n){if(v){Ke(!0);try{(await fetch("/api/v1/file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:v,content:n})})).ok&&(P(n),de(n),he(!1))}finally{Ke(!1)}}}const{renderedHtml:xs,headings:js}=m.useMemo(()=>!v.endsWith(".md")||H!=="preview"||ke(v)||Ie(v)?{renderedHtml:"",headings:[]}:Rs(E,v,i),[E,v,H,i]),vs=m.useMemo(()=>!E||H!=="raw"&&v.endsWith(".md")?"":Ds(E,v),[E,v,H]);function gs(n){const x=n.target.closest("a.wikilink");if(x){n.preventDefault(),A(x.dataset.path);return}const j=n.target.closest("a.md-rel-link");if(j){n.preventDefault();const k=Dt(v,j.dataset.href);i.includes(k)&&A(k)}}function bs(n){at(x=>{const j=new Set(x);return j.has(n)?j.delete(n):j.add(n),j})}const ws=m.useMemo(()=>{const x=[...Y.filter(j=>!me||j.path.toLowerCase().includes(me))];return ue==="recent"?x.sort((j,k)=>(k.mtimeMs||0)-(j.mtimeMs||0)||j.path.localeCompare(k.path)):ue==="status"?x.sort((j,k)=>j.status.localeCompare(k.status)||j.path.localeCompare(k.path)):x.sort((j,k)=>j.path.localeCompare(k.path)),x},[Y,me,ue]);function ks(){tt(new Set(Y.map(n=>n.path))),Qe(""),le(null),Ye(!0)}async function Ns(){if(De.trim()){st(!0),le(null);try{const n=await fetch("/api/v1/git/commit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:De.trim(),files:Array.from(et),push:Ze})}),x=await n.json();!n.ok||x.error?le({ok:!1,text:x.error||"Commit failed"}):(le({ok:!0,text:x.output||"Committed successfully"}),await X())}catch(n){le({ok:!1,text:n.message})}finally{st(!1)}}}const Cs=l[v]||[],vt=ke(v),gt=Ie(v),K=p.outlinePosition||"right",oe=n=>h(x=>({...x,outlinePosition:n})),bt=()=>{oe("right"),window.innerWidth<=960&&(U(!1),Q(!0))},wt=()=>{window.innerWidth<=960?K==="bottom"?(oe("hidden"),Q(!1)):(K==="hidden"&&oe("right"),U(!1),Q(n=>!n)):oe(K==="hidden"?"right":"hidden")};return Hs({drawerOpen:pe,outlineDrawerOpen:fe,outlinePosition:K,setDrawerOpen:U,onOpenOutline:bt,setOutlineDrawerOpen:Q,disabled:!!(O||ot||y||Je||it||Fe||z||ne||J)}),e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`backdrop${pe||fe?" open":""}`,onClick:()=>{U(!1),Q(!1)}}),e.jsxs("div",{className:"app",children:[e.jsx(Ws,{drawerOpen:pe,live:es,settings:p,setSettings:h,sidebarTab:Xt,setSidebarTab:Gt,gitChanges:Y,searchRef:is,filter:me,setFilter:Qt,tree:s,activePath:v,collapsed:Zt,hiddenSet:be,toggleDir:bs,setViewMode:W,openFile:A,openRowMenu:ms,changesSort:ue,setChangesSort:Kt,openCommitDialog:ks,sortedChanges:ws,loadDiff:te}),e.jsxs("main",{className:"main",children:[e.jsx(zs,{tabs:C,activeTabId:g,switchTab:ft,closeTab:pt,createNewTab:mt}),e.jsxs("div",{className:`workspace-body outline-${K}`,children:[e.jsxs("div",{className:"note-pane",children:[e.jsx(_s,{setDrawerOpen:U,activePath:v,moreMenuOpen:Ft,setMoreMenuOpen:Ut,viewMode:H,setViewMode:W,loadDiff:te,setDeleteError:ce,setDeleteTarget:re,outlinePosition:K,outlineDrawerOpen:fe,onToggleOutline:wt,onOpenOutline:bt}),e.jsx(Xs,{scrollRef:G,activePath:v,openNewNoteDialog:jt,openFile:A,openSwitcher:ge,setDrawerOpen:U,setSettingsOpen:Pe,isImg:vt,reloadTick:as,isBinaryDownload:gt,viewMode:H,settings:p,diffData:F,requestDiscard:xt,content:E,saving:qt,dirty:Ot,setDraftContent:de,setDirty:he,saveActiveNote:fs,highlightedRawHtml:vs,handleDocClick:gs,renderedHtml:xs})]}),e.jsx(Gs,{headings:js,isImg:vt,isBinaryDownload:gt,viewMode:H,currentBacklinks:Cs,openFile:A,position:K,onChangePosition:oe,mobileOpen:fe,onCloseMobile:()=>Q(!1)})]})]})]}),e.jsx(Ks,{fabOpen:it,setFabOpen:lt,openSwitcher:ge,drawerOpen:pe,setDrawerOpen:U,onToggleOutline:wt,openFile:A,viewMode:H,setViewMode:W,settings:p,setSettings:h,setSettingsOpen:Pe,scrollRef:G,loadDiff:te,activePath:v,createNewTab:mt,tabsOpen:y,setTabsOpen:b,tabs:C,activeTabId:g,switchTab:ft,closeTab:pt}),e.jsx(Vs,{switcherOpen:O,setSwitcherOpen:Ae,switcherTab:Z,setSwitcherTab:ts,switcherIdx:ss,setSwitcherIdx:ct,switcherInputRef:ht,totalFiles:u,fileStats:a,switcherItems:rs,switcherData:ut,openFile:A,isLargeVault:ee,pagedFiles:je,loadMorePagedFiles:os,switcherQuery:q,setSwitcherQuery:rt}),e.jsx("input",{ref:Xe,type:"file",multiple:!0,style:{display:"none"},onChange:n=>{hs(n.target.files),n.target.value=""}}),e.jsx(Js,{fileMenu:Wt,setFileMenu:_e,openNewNoteDialog:jt,uploadDirRef:Ge,uploadInputRef:Xe,setRenameError:Le,setRenameTarget:$e,setTabs:d,setActiveTabId:L,setViewMode:W,openFile:A,gitChanges:Y,loadDiff:te,requestDiscard:xt,setDeleteError:ce,setDeleteTarget:re}),e.jsx(Ys,{newNoteOpen:Fe,setNewNoteOpen:Me,newNoteTitle:Re,setNewNoteTitle:Ue,newNoteFolder:Oe,setNewNoteFolder:qe,allFolders:ls,newNoteError:_t,confirmNewNote:ps}),e.jsx(Qs,{renameTarget:z,setRenameTarget:$e,renameError:zt,confirmRenameFile:us}),e.jsx(Zs,{deleteTarget:ne,setDeleteTarget:re,deleteError:It,confirmDeleteFile:ds}),e.jsx(ea,{discardTarget:J,setDiscardTarget:Ee,discardError:Ht,confirmDiscard:cs}),e.jsx(ta,{commitOpen:Je,setCommitOpen:Ye,commitSelected:et,setCommitSelected:tt,gitChanges:Y,commitMessage:De,setCommitMessage:Qe,commitPush:Ze,setCommitPush:Vt,commitStatus:Yt,commitBusy:Jt,handleCommitSubmit:Ns}),e.jsx(sa,{settingsOpen:ot,setSettingsOpen:Pe,settingsTab:r,setSettingsTab:S,settings:p,setSettings:h,setCollapsed:at})]})}Es.createRoot(document.getElementById("root")).render(e.jsx(aa,{}));