From d9f77381309cd21d52a35c1cf0c6d277e94b048d Mon Sep 17 00:00:00 2001 From: whackur Date: Wed, 18 Nov 2026 16:08:05 +0900 Subject: [PATCH 1/2] fix(tui): align wrapped preview lines with the body --- Cargo.toml | 2 +- docs/architecture/git-views.md | 2 +- src/ui/diff_viewer/gutter.rs | 54 ++++++++++++++++----------- src/ui/diff_viewer/mod.rs | 30 ++++++++------- src/ui/diff_viewer/tests/file_view.rs | 21 +++++++++++ src/ui/diff_viewer/tests/wrap.rs | 26 +++++++++---- 6 files changed, 89 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8ad84f27..0d593e8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ exclude = [ ] [dependencies] -ratatui = { version = "0.30", features = ["crossterm"] } +ratatui = { version = "0.30", features = ["crossterm", "unstable-rendered-line-info"] } crossterm = "0.29" git2 = { version = "0.21", features = ["vendored-openssl", "vendored-libgit2"] } syntect = "5.3" diff --git a/docs/architecture/git-views.md b/docs/architecture/git-views.md index bc369715..54b6715f 100644 --- a/docs/architecture/git-views.md +++ b/docs/architecture/git-views.md @@ -18,7 +18,7 @@ Paths used only as commit objects or Git pathspecs go through `validate_commit_p `DiffLine` preserves the old/new line numbers supplied by libgit2. Unified mode uses two gutter columns, split mode one old and one new column, and file view displays file line numbers. The gutter and body render as separate `Paragraph`s so horizontal scrolling affects only the body; gutter width is computed from the maximum number in the whole hunk and a minimum width. -Wrap mode cannot be combined with horizontal scrolling and resets `scroll_x` to zero when enabled. In wrap mode the gutter is included in the body; split mode ignores wrap to preserve old/new row alignment. Vertical scroll and search indexes use logical lines. `DiffPaneView` cycles through `Diff → Split → File`, skipping File when the selected file cannot be opened. +Wrap mode cannot be combined with horizontal scrolling and resets `scroll_x` to zero when enabled. Wrapped TUI lines reserve the gutter across all continuation rows and display line numbers and diff markers on the first row. Split mode keeps old/new rows aligned by clipping to one screen row per side. The browser uses horizontal scrolling for long diff and file lines and its virtualized previews use fixed-height rows. Vertical scroll and search indexes use logical lines. `DiffPaneView` cycles through `Diff → Split → File`, skipping File when the selected file cannot be opened. Syntax highlighting runs synchronously on the UI thread, so both the diff pane and the file overlay highlight only the leading `HIGHLIGHT_LINE_CAP` body lines of the current generation. A hunk past the cap has no cached entry and a hunk that straddles it keeps only its in-budget prefix; the renderers emit plain text for the rest while keeping the add/remove background derived from the line kind. Each generation reuses the unchanged leading hunks, or the leading lines of a grown hunk, from the previous cache and resumes syntect from saved parser/highlighter state, so an appended diff or file overlay highlights only its new tail. A changed line, hunk shape, or syntax stops reuse at that point and the remainder is recomputed exactly as a full pass; a hunk header change alone does not invalidate the cache because headers do not feed the segments. The file overlay applies the same rule to line-boundary appends and falls back when its last cached line was unterminated. Search and the split layout still cover every line because they read the full hunk and search indexes, not the highlight cache, and the file overlay keeps per-line byte offsets so its unhighlighted tail can be rendered without rescanning the content. The lowercased search cache is also built on demand by `ensure_lower_cache`: a load without an active query skips the lowercase pass, and a search pays it once per generation. diff --git a/src/ui/diff_viewer/gutter.rs b/src/ui/diff_viewer/gutter.rs index 9101e504..7d5eb908 100644 --- a/src/ui/diff_viewer/gutter.rs +++ b/src/ui/diff_viewer/gutter.rs @@ -60,9 +60,6 @@ fn lineno_text(no: Option) -> String { /// separate `Paragraph`s because `Paragraph::scroll` shifts the whole line, so /// a gutter span in the body's paragraph would slide off the left edge; /// vertical scroll is instead expressed by *which* lines the caller collected. -/// With `wrap` set that split is abandoned: a wrapped body line occupies -/// several screen rows while its gutter line still occupies one, so the number -/// is folded into the body line instead, where wrapping carries it along. pub(crate) fn render_gutter_and_body( frame: &mut Frame, inner: Rect, @@ -73,12 +70,7 @@ pub(crate) fn render_gutter_and_body( wrap: bool, ) { if wrap { - frame.render_widget( - // `trim: false` keeps a continuation row's leading whitespace, which - // in source code is the indentation. - Paragraph::new(merge_gutter_into_body(gutter, body)).wrap(Wrap { trim: false }), - inner, - ); + render_wrapped_rows(frame, inner, gutter_width, gutter, body); return; } let cols = Layout::default() @@ -89,18 +81,36 @@ pub(crate) fn render_gutter_and_body( frame.render_widget(Paragraph::new(body).scroll((0, scroll_x)), cols[1]); } -/// Prepend each gutter line's spans to the body line it belongs to; the two -/// vectors are built in lockstep by the callers, so index `i` pairs row `i`. -fn merge_gutter_into_body<'a>(gutter: Vec>, body: Vec>) -> Vec> { +fn render_wrapped_rows( + frame: &mut Frame, + inner: Rect, + gutter_width: u16, + gutter: Vec>, + body: Vec>, +) { let mut gutter = gutter.into_iter(); - body.into_iter() - .map(|line| match gutter.next() { - Some(g) => { - let mut spans = g.spans; - spans.extend(line.spans); - Line::from(spans) - } - None => line, - }) - .collect() + let mut y = inner.top(); + for line in body { + let remaining_height = inner.bottom().saturating_sub(y); + if remaining_height == 0 { + break; + } + + // Headers and placeholders have no gutter contents and use the full width. + let number = gutter.next().filter(|line| line.width() > 0); + let reserved = if let Some(number) = number { + let width = gutter_width.min(inner.width); + frame.render_widget(number, Rect::new(inner.x, y, width, 1)); + width + } else { + 0 + }; + let width = inner.width - reserved; + let paragraph = Paragraph::new(line).wrap(Wrap { trim: false }); + let height = paragraph + .line_count(width) + .clamp(1, usize::from(remaining_height)) as u16; + frame.render_widget(paragraph, Rect::new(inner.x + reserved, y, width, height)); + y += height; + } } diff --git a/src/ui/diff_viewer/mod.rs b/src/ui/diff_viewer/mod.rs index 206ea644..69b9be99 100644 --- a/src/ui/diff_viewer/mod.rs +++ b/src/ui/diff_viewer/mod.rs @@ -94,10 +94,11 @@ pub fn render( // loaded the pane holds only a placeholder message, which has no line to // number. let digits = digits_for(app.diff_pane().max_line_number() as usize); + let wrap = app.diff_pane().wrap; let gutter_width = if total_lines == 0 { 0 } else { - unified_gutter_width(digits) + unified_gutter_width(digits) + u16::from(wrap) }; let mut lines: Vec = Vec::with_capacity(visible_height); @@ -121,8 +122,6 @@ pub fn render( hunk.header.as_str(), Style::default().fg(Color::Cyan), ))); - // Blank, but full width: a header row with no gutter cell would - // start its `@@` one column left of the body's left edge. gutter_lines.push(Line::from("")); } @@ -158,10 +157,19 @@ pub fn render( LineKind::Context => " ", }; - let mut spans = vec![Span::styled( - prefix, - Style::default().fg(Color::DarkGray).bg(bg), - )]; + let gutter_style = Style::default().fg(Color::DarkGray).bg(bg); + let number = Span::styled( + unified_gutter_text(diff_line.old_lineno, diff_line.new_lineno, digits), + gutter_style, + ); + let marker = Span::styled(prefix, gutter_style); + let mut spans = Vec::new(); + if wrap { + gutter_lines.push(Line::from(vec![number, marker])); + } else { + gutter_lines.push(Line::from(number)); + spans.push(marker); + } // Read from the prebuilt highlight cache; the shape is guaranteed // to match `hunks` after `ensure_highlight_cache`, so a mismatch @@ -186,12 +194,6 @@ pub fn render( } lines.push(Line::from(spans)); - // Same background as the row so the number reads as part of it - // rather than as a column floating beside the highlight. - gutter_lines.push(Line::from(Span::styled( - unified_gutter_text(diff_line.old_lineno, diff_line.new_lineno, digits), - Style::default().fg(Color::DarkGray).bg(bg), - ))); } } @@ -239,7 +241,7 @@ pub fn render( gutter_lines, lines, app.diff_pane().scroll_x.min(u16::MAX as usize) as u16, - app.diff_pane().wrap, + wrap, ); if let Some(sa) = search_area { diff --git a/src/ui/diff_viewer/tests/file_view.rs b/src/ui/diff_viewer/tests/file_view.rs index 0323e214..f1e7923d 100644 --- a/src/ui/diff_viewer/tests/file_view.rs +++ b/src/ui/diff_viewer/tests/file_view.rs @@ -41,6 +41,27 @@ fn file_view_line_numbers_stay_put_when_the_body_scrolls_sideways() { ); } +#[test] +fn file_view_wraps_wide_text_under_the_body_column() { + let mut app = app_with_files(vec!["src/lib.rs"]); + app.git.view.mode = ViewMode::Status; + app.git.view.diff.view = DiffPaneView::File; + app.git.view.diff.wrap = true; + app.git.view.diff.file_view.key = + Some(crate::app::FileViewKey::Status("src/lib.rs".to_string())); + app.git + .view + .diff + .file_view + .set_content("start 가나다라마바\nnext row\n".to_string()); + + let screen = drawn_file_view(&mut app, 20, 8, 0); + let first = screen.iter().find(|row| row.contains("start")).unwrap(); + let continuation = screen.iter().find(|row| row.contains('가')).unwrap(); + assert_eq!(col_of(first, "start"), col_of(continuation, "가")); + assert!(screen.iter().any(|row| row.contains("2 next row"))); +} + /// The file view reads its own horizontal offset, not `diff.scroll_x`. fn drawn_file_view(app: &mut App, width: u16, height: u16, scroll_x: usize) -> Vec { app.git.view.diff.file_view.scroll_x = scroll_x; diff --git a/src/ui/diff_viewer/tests/wrap.rs b/src/ui/diff_viewer/tests/wrap.rs index dd4868b1..a9edf68e 100644 --- a/src/ui/diff_viewer/tests/wrap.rs +++ b/src/ui/diff_viewer/tests/wrap.rs @@ -50,11 +50,18 @@ fn wrapping_folds_a_long_line_onto_several_rows() { ); } -/// With wrapping on the gutter is folded into the body line, because a separate -/// gutter paragraph would desynchronise the moment a line spans two rows. #[test] -fn wrapping_keeps_the_line_number_on_the_row_the_line_starts_on() { - let mut app = app_showing(long_line_hunk(), DiffPaneView::Diff); +fn wrapping_aligns_continuations_and_keeps_numbers_with_their_lines() { + let mut hunk = long_line_hunk(); + hunk.lines[0].kind = LineKind::Added; + hunk.lines[0].old_lineno = None; + hunk.lines.push(DiffLine { + kind: LineKind::Added, + content: "next row".to_string(), + old_lineno: None, + new_lineno: Some(8), + }); + let mut app = app_showing(hunk, DiffPaneView::Diff); app.git.view.diff.wrap = true; let screen = drawn(&mut app, 40, 10, 0); @@ -64,17 +71,20 @@ fn wrapping_keeps_the_line_number_on_the_row_the_line_starts_on() { .expect("the row the line starts on"); assert!( - first.contains('7'), + first.contains("7 +alpha"), "the number travels with its own line: {first:?}" ); let continuation = screen .iter() .find(|l| l.contains("juliett") && !l.contains("alpha")) .expect("a continuation row"); - assert!( - !continuation.contains('7'), - "a continuation row must not be numbered again: {continuation:?}" + let body_column = col_of(first, "alpha"); + assert_eq!( + left_columns(continuation, body_column), + format!("│{}", " ".repeat(body_column - 1)), + "the continuation must leave the gutter and marker columns blank" ); + assert!(screen.iter().any(|row| row.contains("8 +next row"))); } #[test] From 54c98755b940ba9537b4eeaa1e7dfd283b97b6d6 Mon Sep 17 00:00:00 2001 From: whackur Date: Wed, 18 Nov 2026 16:08:07 +0900 Subject: [PATCH 2/2] chore: prepare release v0.1.29 --- Cargo.lock | 6 +++--- Cargo.toml | 2 +- .../dist/assets/{index-B8i5sjJU.js => index-DQWkMvEh.js} | 2 +- viewer-ui/dist/index.html | 2 +- viewer-ui/package-lock.json | 4 ++-- viewer-ui/package.json | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) rename viewer-ui/dist/assets/{index-B8i5sjJU.js => index-DQWkMvEh.js} (99%) diff --git a/Cargo.lock b/Cargo.lock index 3e4378b5..72e0bca7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1505,7 +1505,7 @@ dependencies = [ [[package]] name = "nightcrow" -version = "0.1.28" +version = "0.1.29" dependencies = [ "aes-gcm", "alacritty_terminal", @@ -1546,7 +1546,7 @@ dependencies = [ [[package]] name = "nightcrow-memory" -version = "0.1.28" +version = "0.1.29" dependencies = [ "anyhow", "rusqlite", @@ -1557,7 +1557,7 @@ dependencies = [ [[package]] name = "nightcrow-recovery" -version = "0.1.28" +version = "0.1.29" dependencies = [ "anyhow", "serde", diff --git a/Cargo.toml b/Cargo.toml index 0d593e8e..e4a39254 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [".", "plugins/nightcrow-recovery", "plugins/nightcrow-memory"] # was never built at — a class of drift the release check could only report # after the fact. [workspace.package] -version = "0.1.28" +version = "0.1.29" [package] name = "nightcrow" diff --git a/viewer-ui/dist/assets/index-B8i5sjJU.js b/viewer-ui/dist/assets/index-DQWkMvEh.js similarity index 99% rename from viewer-ui/dist/assets/index-B8i5sjJU.js rename to viewer-ui/dist/assets/index-DQWkMvEh.js index 78ee9da9..4fb25f95 100644 --- a/viewer-ui/dist/assets/index-B8i5sjJU.js +++ b/viewer-ui/dist/assets/index-DQWkMvEh.js @@ -8,4 +8,4 @@ import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_w Error generating stack: `+e.message+` `+e.stack}}var Ve=Object.prototype.hasOwnProperty,He=t.unstable_scheduleCallback,Ue=t.unstable_cancelCallback,We=t.unstable_shouldYield,Ge=t.unstable_requestPaint,Ke=t.unstable_now,qe=t.unstable_getCurrentPriorityLevel,Je=t.unstable_ImmediatePriority,Ye=t.unstable_UserBlockingPriority,Xe=t.unstable_NormalPriority,Ze=t.unstable_LowPriority,Qe=t.unstable_IdlePriority,$e=t.log,et=t.unstable_setDisableYieldValue,tt=null,nt=null;function rt(e){if(typeof $e==`function`&&et(e),nt&&typeof nt.setStrictMode==`function`)try{nt.setStrictMode(tt,e)}catch{}}var it=Math.clz32?Math.clz32:st,at=Math.log,ot=Math.LN2;function st(e){return e>>>=0,e===0?32:31-(at(e)/ot|0)|0}var ct=256,lt=262144,ut=4194304;function dt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ft(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=dt(n))):i=dt(o):i=dt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=dt(n))):i=dt(o)):i=dt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function pt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function vt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function yt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=_r),br=` `,xr=!1;function Sr(e,t){switch(e){case`keyup`:return hr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Cr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var wr=!1;function Tr(e,t){switch(e){case`compositionend`:return Cr(t);case`keypress`:return t.which===32?(xr=!0,br):null;case`textInput`:return e=t.data,e===br&&xr?null:e;default:return null}}function Er(e,t){if(wr)return e===`compositionend`||!gr&&Sr(e,t)?(e=zn(),Rn=Ln=In=null,wr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Yr(n)}}function Zr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Jr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Jr(e.document)}return t}function $r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var ei=Nn&&`documentMode`in document&&11>=document.documentMode,ti=null,ni=null,ri=null,ii=!1;function ai(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ii||ti==null||ti!==Jr(r)||(r=ti,`selectionStart`in r&&$r(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ri&&qr(ri,r)||(ri=r,r=Jf(ni,`onSelect`),0>=o,i-=o,ta=1<<32-it(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),I&&ra(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),I&&ra(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return I&&ra(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),I&&ra(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ne&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case ee:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ne){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),fo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&io(l)===r.type){n(e,r.sibling),c=i(r,o.props),fo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ne?(c=Hi(o.props.children,e.mode,c,o.key),fo(c,o),c.return=e,e=c):(c=Vi(o.type,o.key,o.props,null,e.mode,c),fo(c,o),c.return=e,e=c)}return s(e);case te:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Gi(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=io(o),_(e,r,o,c)}if(xe(o))return h(e,r,o,c);if(ve(o)){if(l=ve(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,uo(o),c);if(o.$$typeof===oe)return _(e,r,Aa(e,o),c);po(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Ui(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{lo=0;var i=_(e,t,n,r);return co=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ho=mo(!0),go=mo(!1),_o=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Pi(e),Ni(e,null,n),t}return Ai(e,r,t,n),Pi(e)}function So(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}function Co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var wo=!1;function To(){if(wo){var e=Ua;if(e!==null)throw e}}function Eo(e,t,n,r){wo=!1;var i=e.updateQueue;_o=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Ha&&(wo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=T({},d,f);break a;case 2:_o=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function Do(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function Oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=D.T,s={};s.types=o===null?null:o.types,D.T=s,pc(e,!1,t,n);try{var c=i(),l=D.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Ka(c,r),jd(e)):fc(e,t,r,jd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{O.p=a,o!==null&&s.types!==null&&(o.types=s.types),D.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=ic(e).queue;tc(e,i,t,Se,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Se,baseState:Se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:Se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},jd())}function oc(){return ka(sh)}function sc(){return ls().memoizedState}function cc(){return ls().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=bo(n);var r=xo(t,e,n);r!==null&&(Pd(r,t,n),So(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=ji(e,t,n,r),n!==null&&(Pd(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,jd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Kr(s,o))return Ai(e,t,i,0),G===null&&ki(),!1}catch{}if(n=ji(e,t,i,r),n!==null)return Pd(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(a(479))}else t=ji(e,n,r,2),t!==null&&Pd(t,e,2)}function mc(e){var t=e.alternate;return e===R||t!==null&&t===R}function hc(e,t){Jo=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}var _c={readContext:ka,use:fs,useCallback:B,useContext:B,useEffect:B,useImperativeHandle:B,useLayoutEffect:B,useInsertionEffect:B,useMemo:B,useReducer:B,useRef:B,useState:B,useDebugValue:B,useDeferredValue:B,useTransition:B,useSyncExternalStore:B,useId:B,useHostTransitionStatus:B,useFormState:B,useActionState:B,useOptimistic:B,useMemoCache:B,useCacheRefresh:B,useEffectEvent:B},vc={readContext:ka,use:fs,useCallback:function(e,t){return cs().memoizedState=[e,t===void 0?null:t],e},useContext:ka,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=cs();t=t===void 0?null:t;var r=e();if(Yo){rt(!0);try{e()}finally{rt(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=cs();if(n!==void 0){var i=n(t);if(Yo){rt(!0);try{n(t)}finally{rt(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,R,e),[r.memoizedState,e]},useRef:function(e){var t=cs();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,R,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(cs(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,R,e.queue,!0,!1),cs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=R,i=cs();if(I){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),G===null)throw Error(a(349));q&127||ys(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Hs(xs.bind(null,r,o,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,o,n,t),null),n},useId:function(){var e=cs(),t=G.identifierPrefix;if(I){var n=na,r=ta;n=(r&~(1<<32-it(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Xo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[Ot]=t,o[kt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return V(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=Ae.current,ha(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ca,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Ot]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||fa(t,!0)}else e=lp(e).createTextNode(r),e[Ot]=t,t.stateNode=e}return V(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ha(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),e=!1}else n=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Bo(t),t):(Bo(t),null);if(t.flags&128)throw Error(a(558))}return V(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ha(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),i=!1}else i=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Bo(t),t):(Bo(t),null)}return Bo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),V(t),null);case 4:return Ne(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,V(t),null;case 10:return Ca(t.type),V(t),null;case 19:if(Uo(t),r=t.memoizedState,r===null)return V(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)bl(r,!1);else{if(Y!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Bi(n,e),n=n.sibling;return Ho(t,Vo.current&1|2),I&&ra(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ke()>_d&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Wo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!I)return V(t),null}else 2*Ke()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ke(),e.sibling=null,o=Vo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||I?Ho(t,o):(n=o,k(Po,t),k(Vo,n),Fo===null&&(Fo=t)),I&&ra(t,r.treeForkCount),e}return V(t),null;case 22:case 23:return Bo(t),No(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&De(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(L),V(t),null;case 25:return null;case 30:return t.flags|=33554432,V(t),null}throw Error(a(156,t.tag))}function Sl(e,t){switch(oa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ca(L),Ne(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Pe(t),null;case 31:if(t.memoizedState!==null){if(Bo(t),t.alternate===null)throw Error(a(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Uo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Ne(),null;case 10:return Ca(t.type),null;case 22:case 23:return Bo(t),No(),e!==null&&De(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ca(L),null;case 25:return null;default:return null}}function Cl(e,t){switch(oa(t),t.tag){case 3:Ca(L),Ne();break;case 26:case 27:case 5:Pe(t);break;case 4:Ne();break;case 31:t.memoizedState!==null&&Bo(t);break;case 13:Bo(t);break;case 19:Uo(t);break;case 10:Ca(t.type);break;case 22:case 23:Bo(t),No(),e!==null&&De(Ja);break;case 24:Ca(L)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Oo(t,n)}catch(t){Z(e,e.return,t)}}}function Dl(e,t,n){n.props=Tc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=Si(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);p(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[Ot]=e,Ht(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Xr(s,h),v=Xr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,D.T=null,n=wd,wd=null;var o=bd,s=Sd;if(X=0,xd=bd=null,Sd=0,W&6)throw Error(a(331));var c=W;if(W|=4,Zu(o.current),Uu(o,o.current,s,n),W=c,Df(0,!1),nt&&typeof nt.onPostCommitFiberRoot==`function`)try{nt.onPostCommitFiberRoot(tt,o)}catch{}return!0}finally{O.p=i,D.T=r,uf(e,t)}}function pf(e,t,n){t=qi(n,t),t=jc(e.stateNode,t,2),e=xo(e,t,2),e!==null&&(vt(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=qi(n,e),n=Mc(2),r=xo(t,n,2),r!==null&&(Nc(n,r,t,e),vt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new td;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ad=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Y===4||Y===3&&(q&62914560)===q&&300>Ke()-hd?W&2?ld|=n:Vd(e,0):ld|=n,dd===q&&(dd=0)),Ef(e)}function gf(e,t){t===0&&(t=gt()),e=Mi(e,t),e!==null&&(vt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return He(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-it(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=q,a=ft(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||pt(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Ke(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}X!==0&&X!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=ln(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Ht(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+ln(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+ln(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+ln(n.imageSizes)+`"]`)):i+=`[href="`+ln(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=T({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[It]=!0,o.onload=o.onerror=function(){Ut(o)}),Ht(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+ln(r)+`"][href="`+ln(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=T({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Ht(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Vt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=T({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Ht(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Vt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ht(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Vt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ht(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=Ae.current)?bm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Vt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Vt(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Vt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Pm(e){return`href="`+ln(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return T({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[It]){r.loading=1;return}}else t=e.createElement(`link`),t[It]=!0,t.onload=t.onerror=Ut.bind(null,t),np(t,`link`,n),Ht(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+ln(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+ln(n.href)+`"]`);if(r)return t.instance=r,Ht(r),r;var i=T({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ht(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var o=e.querySelector(Fm(i));if(o)return t.state.loading|=4,t.instance=o,Ht(o),o;r=Im(n),(i=vm.get(i))&&Hm(r,i),o=(e.ownerDocument||e).createElement(`link`),Ht(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(i=e.querySelector(zm(o)))?(t.instance=i,Ht(i),i):(r=n,(i=vm.get(o))&&(r=T({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Ht(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ht(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Ht(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ie()}))(),j=n(),M=t();function Re({onClose:e,onOpened:t,canClone:n,cloning:r,onClone:i}){let[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(0);(0,j.useEffect)(()=>{let e=!1;return A.browse(a??void 0).then(t=>{e||(c(t),u(null))}).catch(t=>{e||u(t instanceof Error?t.message:`could not browse`)}),()=>{e=!0}},[a,y]);let x=e=>o(`${s.path.replace(/\/$/,``)}/${e}`),S=async()=>{if(s){f(!0);try{t(await A.open(s.path))}catch(e){T.error(e instanceof Error?e.message:`could not open`),f(!1)}}},C=async()=>{if(!s)return;let e=p.trim();if(e){g(!0);try{await A.mkdir(s.path,e),m(``),b(e=>e+1)}catch(e){T.error(e instanceof Error?e.message:`could not create folder`)}finally{g(!1)}}};return(0,M.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 md:pt-[8vh]`,onClick:e,children:(0,M.jsxs)(`div`,{className:`nc-rise-in flex max-h-[min(80vh,calc(var(--nc-visual-viewport-height,100vh)-8vh-1rem))] w-[34rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`span`,{className:`font-medium text-ink-50`,children:`Open a project`}),(0,M.jsx)(`button`,{onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,M.jsx)(pe,{})})]}),(0,M.jsx)(`div`,{className:`shrink-0 truncate border-b border-ink-700 px-3 py-1.5 text-ink-400`,children:s?.path??`…`}),(0,M.jsxs)(`ul`,{className:`h-72 min-h-0 overflow-y-auto`,children:[s?.parent&&(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{onClick:()=>o(s.parent),className:`w-full px-3 py-1 text-left text-ink-400 hover:bg-ink-850`,children:`../`})}),s?.entries.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{onClick:()=>x(e.name),className:`flex w-full items-center gap-2 px-3 py-1 text-left hover:bg-ink-850`,children:[(0,M.jsxs)(`span`,{className:`truncate text-accent`,children:[e.name,`/`]}),e.is_repo&&(0,M.jsx)(`span`,{className:`rounded-sm bg-ink-700 px-1 text-2xs text-ink-200`,children:`git`})]})},e.name)),s&&s.entries.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-1 text-ink-400`,children:`No sub-folders.`})]}),l&&(0,M.jsx)(`p`,{className:`shrink-0 px-3 py-1 text-removed`,children:l}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C()},placeholder:`New folder name`,"aria-label":`new folder name`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,M.jsx)(`button`,{onClick:C,disabled:!s||!p.trim()||h,"aria-busy":h,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,M.jsx)(k,{busy:h,children:`Create`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s&&i(s.path,_)},disabled:!n,placeholder:n?`Clone a git URL here`:`git is not installed on the server`,"aria-label":`git URL to clone`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none disabled:opacity-50`}),(0,M.jsx)(`button`,{onClick:()=>s&&i(s.path,_),disabled:!n||!s||!_.trim()||r,"aria-busy":r,title:n?void 0:`the server has no git on its PATH`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,M.jsx)(k,{busy:r,children:`Clone`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-ink-400`,children:s?s.path:``}),(0,M.jsx)(`button`,{onClick:S,disabled:!s||d,"aria-busy":d,className:`ml-auto shrink-0 rounded-sm bg-ink-50 px-3 py-1 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,M.jsx)(k,{busy:d,children:`Open`})})]})]})})}var ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='12%2057%201150%201150'%20role='img'%20aria-label='Black%20crow'%3e%3ctitle%3eBlack%20crow%3c/title%3e%3cdesc%3eMonochrome%20black%20crow%20silhouette%20on%20a%20transparent%20background,%20framed%20so%20the%20bird%20sits%20centred%20for%20use%20as%20an%20inline%20mark%20on%20a%20square%20tile.%3c/desc%3e%3cg%20fill-rule='evenodd'%20clip-rule='evenodd'%3e%3cpath%20fill='%23000000'%20d='M%20882%20147%20L%20859%20136%20L%20844%20131%20L%20831%20129%20L%20830%20128%20L%20815%20127%20L%20814%20126%20L%20796%20126%20L%20795%20127%20L%20786%20127%20L%20785%20128%20L%20775%20129%20L%20752%20136%20L%20732%20146%20L%20713%20160%20L%20701%20172%20L%20684%20172%20L%20683%20173%20L%20673%20173%20L%20672%20174%20L%20650%20176%20L%20649%20177%20L%20627%20181%20L%20602%20190%20L%20589%20197%20L%20579%20204%20L%20562%20221%20L%20562%20223%20L%20565%20223%20L%20578%20228%20L%20581%20228%20L%20612%20238%20L%20672%20252%20L%20684%20258%20L%20698%20271%20L%20702%20278%20L%20705%20288%20L%20705%20294%20L%20703%20301%20L%20699%20308%20L%20688%20318%20L%20630%20347%20L%20593%20372%20L%20561%20399%20L%20544%20416%20L%20522%20441%20L%20492%20481%20L%20461%20531%20L%20438%20576%20L%20431%20594%20L%20425%20602%20L%20405%20635%20L%20387%20668%20L%20385%20676%20L%20390%20679%20L%20368%20705%20L%20330%20755%20L%20306%20790%20L%20296%20808%20L%20289%20818%20L%20280%20838%20L%20280%20843%20L%20283%20845%20L%20292%20843%20L%20297%20840%20L%20299%20840%20L%20321%20828%20L%20322%20830%20L%20311%20844%20L%20288%20878%20L%20287%20881%20L%20259%20924%20L%20235%20965%20L%20205%201023%20L%20205%201025%20L%20197%201042%20L%20191%201061%20L%20191%201071%20L%20192%201072%20L%20198%201071%20L%20220%201056%20L%20242%201038%20L%20300%20986%20L%20302%20987%20L%20265%201040%20L%20264%201043%20L%20246%201070%20L%20235%201090%20L%20227%201112%20L%20227%201123%20L%20229%201128%20L%20234%201133%20L%20239%201135%20L%20255%201135%20L%20274%201129%20L%20279%201134%20L%20286%201137%20L%20290%201137%20L%20291%201138%20L%20310%201138%20L%20311%201137%20L%20317%201137%20L%20318%201136%20L%20326%201135%20L%20344%201129%20L%20369%201116%20L%20395%201097%20L%20420%201073%20L%20445%201042%20L%20457%201024%20L%20461%201016%20L%20464%201013%20L%20468%201011%20L%20489%20994%20L%20595%20901%20L%20601%20906%20L%20606%20913%20L%20614%20921%20L%20637%20949%20L%20639%20953%20L%20639%20956%20L%20636%20960%20L%20634%20961%20L%20619%20962%20L%20613%20965%20L%20605%20974%20L%20602%20982%20L%20602%20994%20L%20605%201001%20L%20608%201004%20L%20609%201004%20L%20609%20999%20L%20612%20992%20L%20616%20988%20L%20620%20986%20L%20627%20986%20L%20635%20983%20L%20645%20983%20L%20646%20982%20L%20655%20982%20L%20668%20986%20L%20676%20990%20L%20682%20996%20L%20685%201003%20L%20688%201006%20L%20696%201009%20L%20697%201012%20L%20697%201024%20L%20693%201033%20L%20693%201035%20L%20695%201035%20L%20700%201032%20L%20707%201025%20L%20710%201020%20L%20713%201010%20L%20713%201003%20L%20711%20998%20L%20711%20994%20L%20712%20993%20L%20719%201003%20L%20723%201005%20L%20727%201005%20L%20730%201011%20L%20730%201022%20L%20727%201031%20L%20728%201033%20L%20740%201021%20L%20743%201014%20L%20744%201003%20L%20747%20999%20L%20749%20992%20L%20748%20977%20L%20744%20968%20L%20740%20963%20L%20741%20962%20L%20755%20961%20L%20768%20964%20L%20777%20969%20L%20783%20975%20L%20786%20981%20L%20789%20984%20L%20795%20987%20L%20799%20987%20L%20801%20991%20L%20801%20997%20L%20802%20998%20L%20799%201013%20L%20802%201012%20L%20808%201007%20L%20813%201000%20L%20816%20991%20L%20816%20981%20L%20814%20976%20L%20814%20968%20L%20815%20967%20L%20819%20970%20L%20823%20970%20L%20826%20973%20L%20829%20980%20L%20830%20993%20L%20834%20990%20L%20838%20979%20L%20838%20968%20L%20832%20951%20L%20822%20940%20L%20815%20936%20L%20803%20933%20L%20776%20935%20L%20763%20931%20L%20753%20922%20L%20731%20898%20L%20703%20865%20L%20703%20863%20L%20710%20853%20L%20711%20855%20L%20707%20862%20L%20709%20862%20L%20718%20857%20L%20754%20832%20L%20793%20799%20L%20818%20774%20L%20849%20737%20L%20850%20741%20L%20845%20755%20L%20847%20755%20L%20861%20743%20L%20881%20721%20L%20906%20686%20L%20918%20665%20L%20933%20635%20L%20951%20590%20L%20971%20525%20L%20971%20521%20L%20974%20512%20L%20974%20508%20L%20978%20493%20L%20979%20482%20L%20980%20481%20L%20981%20466%20L%20982%20465%20L%20983%20441%20L%20982%20440%20L%20982%20428%20L%20981%20427%20L%20980%20414%20L%20978%20409%20L%20976%20397%20L%20970%20381%20L%20971%20379%20L%20974%20383%20L%20976%20381%20L%20977%20334%20L%20976%20333%20L%20976%20322%20L%20975%20321%20L%20974%20307%20L%20973%20306%20L%20973%20301%20L%20972%20300%20L%20969%20280%20L%20958%20243%20L%20949%20224%20L%20949%20222%20L%20939%20204%20L%20922%20181%20L%20903%20162%20Z%20M%20625%20888%20L%20656%20874%20L%20658%20874%20L%20665%20870%20L%20725%20930%20L%20728%20934%20L%20728%20940%20L%20723%20943%20L%20714%20944%20L%20707%20950%20L%20683%20951%20L%20673%20947%20L%20659%20932%20Z%20M%20787%20182%20L%20792%20182%20L%20796%20187%20L%20795%20192%20L%20791%20195%20L%20788%20195%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20895%20156%20L%20863%20138%20L%20838%20130%20L%20819%20127%20L%20789%20127%20L%20777%20129%20L%20753%20136%20L%20736%20144%20L%20717%20157%20L%20702%20172%20L%20652%20176%20L%20628%20181%20L%20607%20188%20L%20585%20200%20L%20562%20222%20L%20613%20238%20L%20670%20251%20L%20683%20257%20L%20697%20269%20L%20705%20286%20L%20705%20296%20L%20703%20302%20L%20698%20310%20L%20687%20319%20L%20631%20347%20L%20591%20374%20L%20568%20393%20L%20538%20423%20L%20520%20444%20L%20481%20498%20L%20457%20539%20L%20437%20579%20L%20432%20593%20L%20413%20622%20L%20386%20671%20L%20386%20677%20L%20390%20677%20L%20391%20679%20L%20374%20698%20L%20334%20750%20L%20307%20789%20L%20290%20817%20L%20280%20839%20L%20281%20844%20L%20291%20843%20L%20323%20826%20L%20325%20827%20L%20289%20877%20L%20237%20962%20L%20209%201015%20L%20198%201040%20L%20191%201063%20L%20191%201070%20L%20194%201072%20L%20213%201061%20L%20259%201023%20L%20302%20984%20L%20303%20985%20L%20262%201045%20L%20245%201072%20L%20233%201095%20L%20227%201114%20L%20228%201126%20L%20233%201132%20L%20242%201135%20L%20252%201135%20L%20274%201128%20L%20278%201133%20L%20288%201137%20L%20313%201137%20L%20343%201129%20L%20373%201113%20L%20398%201094%20L%20424%201068%20L%20441%201047%20L%20465%201012%20L%20520%20967%20L%20595%20900%20L%20611%20917%20L%20639%20952%20L%20639%20957%20L%20637%20960%20L%20632%20962%20L%20618%20963%20L%20611%20967%20L%20606%20973%20L%20602%20983%20L%20602%20992%20L%20608%201004%20L%20611%20993%20L%20619%20986%20L%20626%20986%20L%20643%20982%20L%20656%20982%20L%20675%20989%20L%20683%20997%20L%20688%201006%20L%20696%201009%20L%20697%201025%20L%20693%201034%20L%20694%201035%20L%20701%201031%20L%20710%201019%20L%20712%201013%20L%20712%20993%20L%20720%201003%20L%20727%201005%20L%20730%201009%20L%20730%201025%20L%20727%201032%20L%20732%201030%20L%20739%201022%20L%20743%201013%20L%20743%201004%20L%20749%20991%20L%20748%20978%20L%20740%20964%20L%20743%20961%20L%20757%20961%20L%20769%20964%20L%20781%20972%20L%20791%20985%20L%20798%20986%20L%20802%20994%20L%20802%201003%20L%20799%201013%20L%20810%201004%20L%20815%20994%20L%20816%20983%20L%20814%20977%20L%20814%20965%20L%20818%20969%20L%20825%20971%20L%20830%20983%20L%20830%20993%20L%20833%20991%20L%20837%20982%20L%20838%20969%20L%20834%20956%20L%20825%20943%20L%20820%20939%20L%20807%20934%20L%20774%20935%20L%20762%20931%20L%20736%20904%20L%20702%20864%20L%20715%20845%20L%20716%20847%20L%20707%20862%20L%20719%20856%20L%20744%20839%20L%20786%20805%20L%20824%20767%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20853%20750%20L%20883%20718%20L%20906%20685%20L%20927%20647%20L%20951%20589%20L%20968%20535%20L%20976%20502%20L%20982%20461%20L%20981%20422%20L%20976%20398%20L%20968%20378%20L%20969%20376%20L%20975%20383%20L%20977%20341%20L%20970%20286%20L%20958%20244%20L%20945%20215%20L%20925%20185%20L%20906%20165%20Z%20M%20625%20888%20L%20665%20870%20L%20728%20933%20L%20729%20940%20L%20726%20943%20L%20715%20944%20L%20708%20950%20L%20692%20952%20L%20678%20950%20L%20672%20947%20L%20662%20936%20Z%20M%20785%20183%20L%20792%20182%20L%20796%20186%20L%20796%20191%20L%20791%20195%20L%20785%20194%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20896%20157%20L%20869%20141%20L%20837%20130%20L%20817%20127%20L%20792%20127%20L%20778%20129%20L%20751%20137%20L%20733%20146%20L%20715%20159%20L%20702%20172%20L%20653%20176%20L%20610%20187%20L%20581%20203%20L%20562%20222%20L%20625%20241%20L%20671%20251%20L%20683%20257%20L%20698%20270%20L%20705%20285%20L%20704%20300%20L%20699%20309%20L%20689%20318%20L%20628%20349%20L%20581%20382%20L%20540%20421%20L%20517%20448%20L%20478%20503%20L%20456%20541%20L%20439%20575%20L%20432%20593%20L%20412%20624%20L%20388%20667%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20363%20712%20L%20332%20753%20L%20289%20819%20L%20281%20836%20L%20281%20844%20L%20293%20842%20L%20323%20826%20L%20325%20827%20L%20284%20885%20L%20236%20964%20L%20205%201024%20L%20197%201043%20L%20191%201064%20L%20191%201070%20L%20197%201071%20L%20210%201063%20L%20253%201028%20L%20303%20983%20L%20304%20984%20L%20259%201050%20L%20235%201091%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20238%201134%20L%20249%201135%20L%20261%201133%20L%20274%201128%20L%20278%201133%20L%20289%201137%20L%20312%201137%20L%20342%201129%20L%20368%201116%20L%20399%201093%20L%20423%201069%20L%20443%201044%20L%20463%201013%20L%20493%20990%20L%20595%20900%20L%20612%20918%20L%20639%20952%20L%20639%20957%20L%20636%20961%20L%20616%20964%20L%20606%20973%20L%20602%20984%20L%20602%20991%20L%20608%201004%20L%20611%20993%20L%20621%20985%20L%20625%20986%20L%20639%20982%20L%20657%20982%20L%20677%20990%20L%20685%201002%20L%20690%201007%20L%20697%201010%20L%20698%201021%20L%20693%201034%20L%20694%201035%20L%20705%201027%20L%20710%201018%20L%20712%201011%20L%20712%201001%20L%20710%20994%20L%20712%20993%20L%20720%201003%20L%20729%201006%20L%20731%201020%20L%20728%201032%20L%20738%201023%20L%20743%201012%20L%20743%201003%20L%20748%20994%20L%20747%20976%20L%20740%20964%20L%20743%20961%20L%20759%20961%20L%20767%20963%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201004%20L%20799%201012%20L%20803%201011%20L%20810%201004%20L%20815%20994%20L%20814%20965%20L%20818%20969%20L%20823%20969%20L%20830%20982%20L%20830%20992%20L%20832%20992%20L%20837%20982%20L%20837%20965%20L%20831%20950%20L%20821%20940%20L%20806%20934%20L%20772%20935%20L%20762%20931%20L%20733%20901%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20707%20862%20L%20738%20843%20L%20780%20810%20L%20822%20769%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20855%20748%20L%20882%20719%20L%20904%20688%20L%20930%20640%20L%20950%20591%20L%20967%20538%20L%20978%20490%20L%20982%20459%20L%20982%20434%20L%20976%20399%20L%20967%20376%20L%20969%20375%20L%20975%20383%20L%20976%20329%20L%20971%20293%20L%20960%20250%20L%20942%20210%20L%20923%20183%20Z%20M%20625%20888%20L%20665%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20708%20950%20L%20695%20952%20L%20677%20950%20L%20666%20941%20Z%20M%20786%20182%20L%20790%20181%20L%20794%20183%20L%20797%20188%20L%20792%20195%20L%20787%20195%20L%20782%20190%20L%20782%20187%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20873%20143%20L%20841%20131%20L%20816%20127%20L%20794%20127%20L%20779%20129%20L%20754%20136%20L%20735%20145%20L%20715%20159%20L%20702%20172%20L%20648%20177%20L%20629%20181%20L%20608%20188%20L%20584%20201%20L%20562%20222%20L%20614%20238%20L%20671%20251%20L%20685%20258%20L%20698%20270%20L%20704%20281%20L%20706%20292%20L%20703%20303%20L%20699%20309%20L%20686%20320%20L%20628%20349%20L%20590%20375%20L%20565%20396%20L%20543%20418%20L%20518%20447%20L%20490%20485%20L%20460%20534%20L%20441%20571%20L%20431%20595%20L%20405%20636%20L%20386%20672%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20371%20702%20L%20335%20749%20L%20291%20816%20L%20280%20840%20L%20282%20844%20L%20298%20840%20L%20324%20825%20L%20326%20826%20L%20294%20870%20L%20235%20966%20L%20206%201022%20L%20198%201041%20L%20191%201065%20L%20191%201070%20L%20196%201071%20L%20214%201060%20L%20254%201027%20L%20303%20983%20L%20304%20984%20L%20256%201055%20L%20232%201098%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20239%201134%20L%20248%201135%20L%20264%201132%20L%20274%201128%20L%20280%201134%20L%20289%201137%20L%20311%201137%20L%20339%201130%20L%20371%201114%20L%20401%201091%20L%20422%201070%20L%20440%201048%20L%20463%201013%20L%20487%20995%20L%20595%20900%20L%20613%20919%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20605%20975%20L%20602%20991%20L%20604%20998%20L%20608%201003%20L%20611%20993%20L%20620%20985%20L%20624%20986%20L%20632%20983%20L%20647%20981%20L%20658%20982%20L%20677%20990%20L%20689%201006%20L%20697%201009%20L%20698%201021%20L%20694%201035%20L%20703%201029%20L%20710%201018%20L%20712%201010%20L%20712%201002%20L%20710%20997%20L%20711%20992%20L%20720%201003%20L%20728%201005%20L%20730%201008%20L%20731%201021%20L%20728%201032%20L%20738%201023%20L%20742%201014%20L%20743%201003%20L%20748%20994%20L%20748%20980%20L%20742%20966%20L%20739%20963%20L%20741%20961%20L%20753%20960%20L%20770%20964%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20804%201010%20L%20809%201005%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20823%20969%20L%20826%20972%20L%20830%20982%20L%20831%20992%20L%20834%20989%20L%20838%20975%20L%20837%20966%20L%20831%20950%20L%20821%20940%20L%20804%20934%20L%20779%20936%20L%20763%20932%20L%20731%20899%20L%20702%20865%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20708%20862%20L%20749%20835%20L%20781%20809%20L%20820%20771%20L%20851%20733%20L%20852%20736%20L%20846%20755%20L%20857%20746%20L%20881%20720%20L%20907%20683%20L%20928%20644%20L%20945%20604%20L%20967%20537%20L%20978%20489%20L%20982%20455%20L%20982%20437%20L%20979%20413%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20332%20L%20972%20299%20L%20962%20257%20L%20954%20235%20L%20943%20212%20L%20923%20183%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20706%20951%20L%20684%20952%20L%20677%20950%20L%20665%20940%20Z%20M%20701%20220%20L%20710%20219%20L%20717%20221%20L%20704%20223%20L%20704%20221%20Z%20M%20666%20217%20L%20679%20216%20L%20689%20218%20L%20685%20220%20L%20675%20220%20Z%20M%20658%20210%20L%20661%20208%20L%20686%20205%20L%20706%20206%20L%20725%20209%20L%20733%20217%20L%20741%20220%20L%20738%20221%20L%20696%20214%20L%20661%20212%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20188%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20864%20139%20L%20836%20130%20L%20813%20127%20L%20796%20127%20L%20774%20130%20L%20749%20138%20L%20735%20145%20L%20720%20155%20L%20702%20172%20L%20687%20173%20L%20700%20174%20L%20694%20181%20L%20674%20184%20L%20670%20180%20L%20665%20183%20L%20657%20184%20L%20639%20196%20L%20641%20198%20L%20647%20198%20L%20648%20194%20L%20654%20193%20L%20686%20204%20L%20724%20208%20L%20740%20213%20L%20751%20222%20L%20750%20223%20L%20693%20214%20L%20671%20212%20L%20639%20212%20L%20636%20211%20L%20634%20207%20L%20629%20207%20L%20626%20210%20L%20617%20210%20L%20614%20208%20L%20604%20207%20L%20594%20213%20L%20582%20216%20L%20580%20214%20L%20581%20210%20L%20576%20208%20L%20586%20200%20L%20565%20218%20L%20563%20222%20L%20618%20239%20L%20671%20251%20L%20682%20256%20L%20689%20261%20L%20702%20276%20L%20706%20288%20L%20704%20301%20L%20700%20308%20L%20683%20322%20L%20630%20348%20L%20585%20379%20L%20563%20398%20L%20523%20441%20L%20497%20475%20L%20459%20536%20L%20443%20567%20L%20431%20595%20L%20411%20626%20L%20387%20670%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20368%20706%20L%20333%20752%20L%20290%20818%20L%20281%20837%20L%20282%20844%20L%20300%20839%20L%20324%20825%20L%20326%20826%20L%20285%20884%20L%20242%20954%20L%20207%201020%20L%20192%201060%20L%20192%201071%20L%20196%201071%20L%20211%201062%20L%20240%201039%20L%20303%20983%20L%20305%20984%20L%20277%201023%20L%20242%201078%20L%20228%201110%20L%20227%201119%20L%20231%201130%20L%20239%201134%20L%20255%201134%20L%20274%201128%20L%20280%201134%20L%20285%201136%20L%20310%201137%20L%20339%201130%20L%20374%201112%20L%20394%201097%20L%20421%201071%20L%20445%201041%20L%20463%201013%20L%20488%20994%20L%20595%20900%20L%20614%20920%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20607%20972%20L%20603%20980%20L%20602%20989%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20620%20985%20L%20623%20986%20L%20631%20983%20L%20647%20981%20L%20665%20984%20L%20676%20989%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201023%20L%20694%201035%20L%20699%201032%20L%20709%201020%20L%20712%201010%20L%20710%20997%20L%20711%20992%20L%20719%201002%20L%20725%201005%20L%20727%201004%20L%20730%201008%20L%20731%201022%20L%20728%201032%20L%20739%201021%20L%20743%201010%20L%20743%201003%20L%20748%20993%20L%20748%20981%20L%20746%20974%20L%20739%20963%20L%20741%20961%20L%20755%20960%20L%20770%20964%20L%20779%20970%20L%20789%20983%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20808%201006%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20825%20970%20L%20829%20978%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20832%20952%20L%20822%20941%20L%20813%20936%20L%20803%20934%20L%20776%20936%20L%20763%20932%20L%20723%20890%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20708%20862%20L%20742%20840%20L%20782%20808%20L%20818%20773%20L%20851%20733%20L%20852%20736%20L%20846%20754%20L%20850%20752%20L%20881%20720%20L%20905%20686%20L%20932%20635%20L%20950%20590%20L%20969%20529%20L%20977%20494%20L%20982%20454%20L%20980%20419%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20334%20L%20969%20284%20L%20959%20248%20L%20941%20209%20L%20921%20181%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20941%20L%20724%20944%20L%20716%20944%20L%20707%20951%20L%20683%20952%20L%20673%20948%20L%20659%20933%20Z%20M%20563%20618%20L%20569%20614%20L%20579%20621%20L%20576%20626%20L%20572%20627%20L%20568%20623%20L%20565%20623%20Z%20M%20575%20603%20L%20578%20603%20L%20588%20613%20L%20588%20619%20L%20585%20621%20L%20582%20620%20L%20575%20613%20L%20576%20612%20L%20573%20605%20Z%20M%20748%20398%20L%20752%20412%20L%20752%20432%20L%20748%20444%20L%20732%20470%20L%20716%20484%20L%20698%20493%20L%20685%20494%20L%20682%20491%20L%20707%20445%20L%20685%20473%20L%20667%20492%20L%20647%20508%20L%20632%20517%20L%20619%20519%20L%20615%20517%20L%20615%20513%20L%20643%20470%20L%20603%20514%20L%20589%20526%20L%20569%20538%20L%20558%20540%20L%20554%20539%20L%20552%20535%20L%20577%20498%20L%20549%20528%20L%20526%20546%20L%20508%20554%20L%20498%20555%20L%20495%20552%20L%20501%20541%20L%20482%20555%20L%20471%20558%20L%20464%20558%20L%20461%20560%20L%20460%20559%20L%20461%20555%20L%20469%20547%20L%20473%20537%20L%20491%20512%20L%20511%20497%20L%20582%20434%20L%20617%20408%20L%20632%20399%20L%20659%20386%20L%20677%20380%20L%20695%20377%20L%20712%20377%20L%20725%20380%20L%20739%20388%20Z%20M%20625%20216%20L%20683%20216%20L%20737%20222%20L%20742%20224%20L%20733%20226%20L%20721%20225%20L%20713%20230%20L%20711%20228%20L%20706%20228%20L%20694%20237%20L%20690%20233%20L%20690%20225%20L%20679%20228%20L%20674%20232%20L%20668%20232%20L%20659%20229%20L%20649%20222%20L%20632%20219%20L%20632%20217%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20795%20193%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20607%20972%20L%20603%20981%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20616%20987%20L%20620%20985%20L%20627%20985%20L%20635%20982%20L%20655%20981%20L%20676%20989%20L%20683%20996%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201024%20L%20694%201034%20L%20699%201032%20L%20706%201025%20L%20712%201010%20L%20710%20994%20L%20709%20997%20L%20706%20994%20L%20700%20994%20L%20694%20997%20L%20672%20976%20L%20658%20974%20L%20647%20967%20L%20642%20974%20L%20638%20974%20L%20636%20972%20L%20636%20961%20L%20629%20963%20L%20631%20972%20L%20625%20977%20L%20620%20977%20L%20613%20967%20L%20614%20966%20Z%20M%20686%20966%20L%20704%20980%20L%20719%201002%20L%20727%201004%20L%20730%201007%20L%20731%201023%20L%20728%201032%20L%20731%201030%20L%20741%201017%20L%20743%201003%20L%20748%20992%20L%20748%20981%20L%20742%20967%20L%20740%20965%20L%20742%20968%20L%20735%20972%20L%20726%20965%20L%20705%20960%20L%20724%20968%20L%20740%20983%20L%20742%20987%20L%20740%20991%20L%20732%20991%20L%20728%20996%20L%20726%20996%20L%20721%20992%20L%20713%20979%20Z%20M%20784%20943%20L%20784%20946%20L%20798%20950%20L%20819%20969%20L%20825%20970%20L%20830%20981%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20829%20948%20L%20825%20944%20L%20830%20950%20L%20821%20957%20L%20813%20951%20L%20794%20942%20Z%20M%20659%20933%20L%20662%20937%20L%20658%20942%20L%20658%20945%20L%20663%20947%20L%20666%20945%20L%20667%20946%20L%20668%20944%20L%20670%20946%20Z%20M%20643%20913%20L%20647%20918%20L%20644%20921%20L%20642%20928%20L%20629%20938%20L%20627%20936%20L%20636%20947%20L%20634%20945%20L%20641%20933%20L%20651%20923%20L%20657%20930%20Z%20M%20936%20310%20L%20934%20309%20L%20945%20338%20L%20949%20368%20L%20949%20381%20L%20947%20383%20L%20935%20367%20L%20914%20348%20L%20929%20377%20L%20934%20397%20L%20936%20414%20L%20935%20440%20L%20933%20442%20L%20930%20440%20L%20924%20419%20L%20912%20395%20L%20909%20393%20L%20910%20410%20L%20907%20433%20L%20899%20458%20L%20895%20462%20L%20893%20460%20L%20892%20445%20L%20888%20427%20L%20873%20390%20L%20873%20416%20L%20871%20430%20L%20866%20448%20L%20862%20454%20L%20859%20452%20L%20853%20433%20L%20842%20410%20L%20823%20382%20L%20807%20365%20L%20805%20366%20L%20811%20394%20L%20812%20416%20L%20810%20425%20L%20806%20428%20L%20801%20423%20L%20790%20403%20L%20772%20383%20L%20759%20372%20L%20733%20357%20L%20724%20355%20L%20705%20346%20L%20693%20344%20L%20669%20344%20L%20646%20349%20L%20636%20353%20L%20662%20349%20L%20677%20349%20L%20699%20353%20L%20708%20356%20L%20725%20366%20L%20736%20376%20L%20745%20389%20L%20753%20415%20L%20752%20442%20L%20743%20476%20L%20723%20520%20L%20693%20569%20L%20646%20631%20L%20605%20676%20L%20568%20709%20L%20565%20710%20L%20562%20706%20L%20562%20692%20L%20567%20665%20L%20578%20636%20L%20602%20619%20L%20622%20602%20L%20645%20578%20L%20670%20546%20L%20630%20588%20L%20603%20610%20L%20574%20628%20L%20560%20633%20L%20556%20633%20L%20555%20631%20L%20563%20617%20L%20596%20572%20L%20647%20509%20L%20636%20515%20L%20562%20609%20L%20541%20630%20L%20520%20645%20L%20502%20653%20L%20490%20653%20L%20536%20590%20L%20513%20617%20L%20478%20651%20L%20454%20665%20L%20440%20669%20L%20436%20667%20L%20488%20596%20L%20459%20630%20L%20436%20653%20L%20411%20671%20L%20392%20678%20L%20372%20701%20L%20319%20772%20L%20289%20820%20L%20281%20838%20L%20282%20844%20L%20295%20841%20L%20324%20825%20L%20326%20826%20L%20289%20878%20L%20242%20954%20L%20209%201016%20L%20193%201056%20L%20191%201069%20L%20192%201071%20L%20196%201071%20L%20219%201056%20L%20303%20983%20L%20305%20984%20L%20255%201057%20L%20234%201094%20L%20228%201111%20L%20228%201124%20L%20234%201132%20L%20240%201134%20L%20254%201134%20L%20275%201128%20L%20279%201133%20L%20291%201137%20L%20316%201136%20L%20344%201128%20L%20364%201118%20L%20389%201101%20L%20403%201089%20L%20427%201064%20L%20447%201038%20L%20463%201013%20L%20489%20993%20L%20594%20901%20L%20595%20899%20L%20593%20894%20L%20588%20891%20L%20567%20868%20L%20569%20865%20L%20576%20867%20L%20586%20873%20L%20589%20867%20L%20607%20867%20L%20619%20880%20L%20622%20887%20L%20626%20891%20L%20624%20889%20L%20626%20886%20L%20666%20870%20L%20705%20909%20L%20710%20905%20L%20713%20905%20L%20716%20908%20L%20716%20911%20L%20712%20916%20L%20728%20932%20L%20730%20939%20L%20727%20943%20L%20717%20944%20L%20710%20949%20L%20712%20948%20L%20725%20951%20L%20739%20963%20L%20740%20961%20L%20756%20960%20L%20774%20966%20L%20784%20975%20L%20789%20983%20L%20800%20987%20L%20802%20991%20L%20802%201005%20L%20799%201012%20L%20806%201008%20L%20811%201002%20L%20815%20993%20L%20813%20968%20L%20812%20973%20L%20807%20971%20L%20796%20976%20L%20791%20973%20L%20788%20967%20L%20779%20958%20L%20767%20952%20L%20762%20941%20L%20756%20940%20L%20751%20932%20L%20749%20931%20L%20743%20936%20L%20738%20936%20L%20736%20933%20L%20741%20925%20L%20739%20915%20L%20742%20912%20L%20745%20914%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20709%20861%20L%20746%20837%20L%20783%20807%20L%20826%20764%20L%20851%20732%20L%20853%20734%20L%20846%20754%20L%20851%20751%20L%20874%20728%20L%20890%20708%20L%20908%20681%20L%20938%20621%20L%20960%20560%20L%20971%20521%20L%20979%20481%20L%20982%20444%20L%20977%20405%20L%20970%20382%20L%20966%20375%20L%20968%20374%20L%20974%20381%20L%20975%20368%20L%20974%20372%20L%20968%20364%20L%20966%20354%20L%20957%20337%20Z%20M%20247%201077%20L%20251%201085%20L%20246%201088%20L%20245%201091%20L%20240%201092%20L%20239%201085%20L%20241%201081%20Z%20M%20370%20935%20L%20371%20937%20L%20326%20997%20L%20301%201034%20L%20289%201044%20L%20286%201042%20L%20283%201045%20L%20277%201045%20L%20273%201043%20L%20264%201052%20L%20261%201049%20L%20270%201037%20L%20271%201038%20L%20281%201027%20L%20293%201010%20L%20326%20971%20Z%20M%20726%20921%20L%20728%20921%20L%20731%20926%20L%20729%20933%20L%20722%20926%20Z%20M%20729%20897%20L%20734%20902%20L%20732%20906%20L%20726%20902%20L%20726%20899%20Z%20M%20715%20882%20L%20720%20886%20L%20718%20890%20L%20711%20887%20Z%20M%20605%20762%20L%20608%20761%20L%20607%20760%20L%20609%20757%20L%20610%20759%20L%20617%20761%20L%20620%20764%20L%20611%20770%20L%20607%20770%20L%20606%20765%20L%20608%20765%20Z%20M%20611%20754%20L%20617%20750%20L%20620%20751%20L%20621%20749%20L%20625%20749%20L%20628%20752%20L%20628%20756%20L%20623%20761%20Z%20M%20549%20710%20L%20551%20713%20L%20551%20722%20L%20506%20774%20L%20403%20878%20L%20309%20963%20L%20307%20961%20L%20313%20953%20L%20322%20945%20L%20340%20922%20L%20375%20885%20Z%20M%20695%20704%20L%20696%20708%20L%20698%20709%20L%20695%20710%20L%20695%20713%20L%20692%20715%20L%20688%20710%20Z%20M%20704%20694%20L%20706%20695%20L%20706%20698%20L%20710%20698%20L%20713%20703%20L%20708%20708%20L%20707%20714%20L%20705%20716%20L%20701%20716%20L%20697%20708%20L%20699%20706%20L%20697%20705%20L%20701%20701%20L%20704%20705%20L%20706%20704%20L%20706%20700%20L%20702%20697%20Z%20M%20552%20678%20L%20554%20681%20L%20552%20701%20L%20465%20787%20L%20361%20883%20L%20316%20927%20L%20253%20993%20L%20211%201042%20L%20211%201036%20L%20222%201011%20L%20261%20942%20L%20292%20898%20L%20338%20843%20L%20374%20807%20L%20387%20807%20L%20403%20801%20L%20419%20792%20L%20456%20766%20L%20500%20728%20Z%20M%20704%20654%20L%20706%20658%20L%20711%20658%20L%20714%20661%20L%20715%20673%20L%20713%20676%20L%20705%20676%20L%20702%20674%20L%20704%20677%20L%20704%20681%20L%20702%20682%20L%20704%20685%20L%20700%20686%20L%20694%20678%20L%20691%20678%20L%20688%20674%20L%20692%20670%20L%20692%20664%20L%20694%20661%20Z%20M%20565%20642%20L%20558%20663%20L%20545%20677%20L%20494%20726%20L%20443%20767%20L%20401%20792%20L%20392%20795%20L%20387%20794%20L%20405%20766%20L%20455%20707%20L%20388%20767%20L%20355%20794%20L%20304%20827%20L%20299%20826%20L%20302%20817%20L%20316%20795%20L%20360%20739%20L%20398%20700%20L%20425%20677%20L%20428%20679%20L%20443%20679%20L%20461%20673%20L%20476%20664%20L%20493%20666%20L%20517%20657%20L%20542%20641%20L%20546%20643%20Z%20M%20563%20221%20L%20572%20225%20L%20571%20223%20L%20574%20220%20L%20585%20217%20L%20596%20218%20L%20607%20215%20L%20653%20214%20L%20706%20218%20L%20749%20224%20L%20749%20226%20L%20735%20233%20L%20732%20238%20L%20732%20249%20L%20693%20242%20L%20620%20239%20L%20672%20251%20L%20688%20260%20L%20701%20274%20L%20706%20287%20L%20704%20301%20L%20707%20297%20L%20711%20300%20L%20713%20309%20L%20720%20324%20L%20723%20327%20L%20724%20308%20L%20726%20304%20L%20735%20318%20L%20757%20341%20L%20753%20319%20L%20754%20313%20L%20760%20317%20L%20786%20345%20L%20784%20324%20L%20775%20300%20L%20779%20300%20L%20800%20317%20L%20800%20312%20L%20787%20283%20L%20772%20264%20L%20778%20263%20L%20800%20271%20L%20803%20270%20L%20770%20236%20L%20772%20234%20L%20797%20234%20L%20807%20230%20L%20801%20230%20L%20800%20228%20L%20811%20218%20L%20818%20203%20L%20818%20193%20L%20812%20179%20L%20798%20168%20L%20784%20166%20L%20760%20173%20L%20747%20173%20L%20712%20163%20L%20718%20157%20L%20703%20171%20L%20711%20173%20L%20720%20178%20L%20723%20182%20L%20720%20186%20L%20695%20190%20L%20680%20190%20L%20670%20193%20L%20656%20193%20L%20687%20204%20L%20729%20209%20L%20742%20214%20L%20753%20223%20L%20752%20224%20L%20729%20219%20L%20669%20212%20L%20610%20213%20L%20576%20218%20L%20565%20221%20L%20565%20219%20Z%20M%20771%20189%20L%20772%20201%20L%20775%20207%20L%20780%20212%20L%20787%20215%20L%20796%20216%20L%20796%20218%20L%20784%20219%20L%20776%20215%20L%20771%20210%20L%20768%20204%20L%20768%20194%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20796%20192%20L%20790%20196%20L%20786%20195%20L%20782%20191%20L%20782%20186%20Z'/%3e%3c/g%3e%3c/svg%3e`;function Be({className:e}){return(0,M.jsx)(`span`,{className:`block overflow-hidden rounded-[20.7%] bg-accent ${e??``}`,children:(0,M.jsx)(`img`,{src:ze,alt:``,"aria-hidden":`true`,className:`h-full w-full`})})}function Ve(){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(Be,{className:`h-[22px] w-[22px] shrink-0`}),(0,M.jsx)(`span`,{className:`hidden text-[16px] font-medium tracking-[0.04em] text-ink-50 md:inline`,children:`nightcrow`})]})}function He({open:e}){return(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5 shrink-0 transition-transform ${e?`rotate-90`:``}`,children:(0,M.jsx)(`path`,{d:`m9 18 6-6-6-6`})})}function Ue({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`M3 6h.01`}),(0,M.jsx)(`path`,{d:`M3 12h.01`}),(0,M.jsx)(`path`,{d:`M3 18h.01`}),(0,M.jsx)(`path`,{d:`M8 6h13`}),(0,M.jsx)(`path`,{d:`M8 12h13`}),(0,M.jsx)(`path`,{d:`M8 18h13`})]})}function We({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,M.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`}),(0,M.jsx)(`path`,{d:`M10 9H8`}),(0,M.jsx)(`path`,{d:`M16 13H8`}),(0,M.jsx)(`path`,{d:`M16 17H8`})]})}function Ge({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`m4 17 6-6-6-6`}),(0,M.jsx)(`path`,{d:`M12 19h8`})]})}function Ke({repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i,className:a=``}){let[o,s]=(0,j.useState)(!1),c=f(),l=(0,j.useRef)(null),u=e.find(e=>e.id===t);return(0,j.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),(0,M.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${a}`,children:[(0,M.jsxs)(`button`,{ref:l,onClick:()=>s(e=>!e),"aria-haspopup":`menu`,"aria-expanded":o,title:u?.display_path??`Select a project`,className:`flex min-w-0 max-w-full items-center gap-1 rounded-sm bg-ink-700 py-0.5 pl-2 pr-1 text-ink-50`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:u?.name??`No project`}),(0,M.jsx)(He,{open:o})]}),o&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,M.jsxs)(`div`,{role:`menu`,className:`nc-pop-in origin-top-left absolute left-0 z-50 mt-1 max-h-[70vh] w-56 max-w-[80vw] overflow-y-auto rounded-md border border-ink-700 bg-ink-900 py-1 shadow-lg`,children:[e.length===0&&(0,M.jsx)(`p`,{className:`px-3 py-1.5 text-ink-400`,children:`No projects open.`}),e.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center ${e.id===t?`bg-ink-700 text-ink-50`:`text-ink-200`}`,children:[(0,M.jsx)(`button`,{role:`menuitem`,onClick:()=>{n(e.id),s(!1)},title:e.display_path,className:`min-w-0 flex-1 truncate py-1.5 pl-3 pr-1 text-left hover:text-accent`,children:e.name}),(0,M.jsx)(`button`,{onClick:()=>r(e.id),"aria-label":`close ${e.name}`,...e.id===t?c(`project.close`,`Close project`):{title:`Close project`},className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,M.jsx)(pe,{className:`h-3.5 w-3.5`})})]},e.id)),(0,M.jsx)(`div`,{className:`my-1 border-t border-ink-800`}),(0,M.jsxs)(`button`,{role:`menuitem`,onClick:()=>{i(),s(!1)},...c(`project.openDialog`,`Open a project`),className:`flex w-full items-center gap-1 px-3 py-1.5 text-left text-ink-400 hover:text-ink-200`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),`open`]})]})]})]})}function qe({side:e,repos:t,repo:n,onSelectRepo:r,onCloseRepo:i,onOpenPicker:a,draggingRepo:o,dragOverRepo:s,onRepoDragStart:u,onRepoDragMove:p,onRepoDragEnd:m}){let h=f(),g=c(),_=t.length>1?[`project.previous`,`project.next`]:[],v=e=>e!==null,b=_.map(e=>ge(e,g)).filter(v),x=_.map(e=>d(e,g)).filter(v),S=e===`left`;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`nav`,{"aria-keyshortcuts":b.length>0?b.join(` `):void 0,title:x.length>0?`Previous or next project (${x.join(`, `)})`:void 0,className:S?`hidden min-h-0 flex-1 flex-col overflow-y-auto md:flex`:`hidden items-stretch self-stretch overflow-x-auto pl-1 md:flex`,children:t.map(e=>(0,M.jsxs)(`div`,{"data-repo-id":e.id,onPointerDown:t=>u(t,e.id),onPointerMove:p,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,"data-active":e.id===n,className:`nc-title-target flex items-center whitespace-nowrap ${S?`min-w-0 border-b border-ink-700`:`border-r border-ink-700`} ${t.length>1?`touch-none`:``} ${o===e.id?`opacity-60`:``} ${s===e.id?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${e.id===n?S?`bg-ink-900 text-ink-50 shadow-[inset_1px_0_0_0_var(--color-accent)]`:`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,title:e.display_path,children:[(0,M.jsx)(`button`,{onClick:()=>{r(e.id)},"aria-label":e.name,className:`self-stretch pl-3 pr-1 text-left ${S?`min-w-0 flex-1 py-2`:``}`,children:(0,M.jsx)(l,{title:e.name,className:S?``:y})}),(0,M.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id)},"data-tab-close":!0,...e.id===n?h(`project.close`,`Close project`):{title:`Close project`},"aria-label":`close ${e.name}`,className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,M.jsx)(pe,{})})]},e.id))}),(0,M.jsxs)(`button`,{onClick:a,...h(`project.openDialog`,`Open a project`),className:`hidden shrink-0 items-center gap-1 rounded-sm px-2 py-0.5 text-ink-400 hover:text-accent md:inline-flex ${S?`mx-1 my-2 justify-center`:``}`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),`open`]})]})}var Je={key:()=>Me(`/api/push/key`).then(e=>e.public_key),subscribe:e=>ke(`/api/push/subscribe`,e),unsubscribe:e=>ke(`/api/push/unsubscribe`,{endpoint:e}),status:e=>ke(`/api/push/status`,{endpoint:e}).then(e=>e.subscribed),test:e=>ke(`/api/push/test`,{endpoint:e})};function Ye(){let e=navigator;return{secure:window.isSecureContext,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0,hasPushManager:`PushManager`in window,permission:()=>typeof Notification>`u`?void 0:Notification.permission,requestPermission:()=>Notification.requestPermission(),isIos:/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&navigator.maxTouchPoints>1,standalone:e.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`).matches===!0}}function Xe(e){return e.secure?e.isIos&&!e.standalone?`needs-install`:!e.serviceWorker||!e.hasPushManager||e.permission()===void 0?`unsupported`:e.permission()===`denied`?`denied`:null:`insecure`}function Ze(e){e.secure&&e.serviceWorker&&e.serviceWorker.register(`./sw.js`).catch(()=>{})}async function Qe(e){return(await e.serviceWorker.ready).pushManager.getSubscription()}async function $e(e){let t=Xe(e);if(t)return t;let n=await Qe(e);return n?await Je.status(n.endpoint)?`on`:(await n.unsubscribe().catch(()=>!1),`off`):`off`}async function et(e){let t=Xe(e);if(t)return t;let n=await e.requestPermission();if(n===`denied`)return`denied`;if(n!==`granted`)return`off`;let r;try{r=await Je.key()}catch{return`unavailable`}let i=await e.serviceWorker.ready;await(await i.pushManager.getSubscription())?.unsubscribe();let a=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:rt(r)});return await Je.subscribe(a.toJSON()),`on`}async function tt(e){let t=await Qe(e);return t&&(await Je.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>!1)),Xe(e)??`off`}async function nt(e){let t=await Qe(e);if(!t)throw Error(`notifications are off in this browser`);await Je.test(t.endpoint)}function rt(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e{let e=!1;return $e(a).then(t=>!e&&n(t)).catch(()=>!e&&n(`off`)),()=>{e=!0}},[a]);let o=(0,j.useCallback)(async(e,t)=>{i(!0);try{let t=await e();return t&&n(t),!0}catch(e){return T.error(e instanceof Error?`${t}: ${e.message}`:t),!1}finally{i(!1)}},[]);return{state:t,busy:r,enable:()=>o(()=>et(a),`could not turn notifications on`),disable:()=>o(()=>tt(a),`could not turn notifications off`),test:async()=>{await o(()=>nt(a),`could not send a test`)&&T.info(`Test notification sent`)}}}var at={unsupported:`This browser does not support notifications.`,insecure:`Notifications need HTTPS or localhost. See the notifications guide for tailscale serve.`,"needs-install":`On iPhone and iPad, add nightcrow to the Home Screen and open it from there first.`,denied:`Notifications are blocked for this site. Allow them in the browser's site settings.`,unavailable:`The server could not load its notification key. Check the daemon log.`},ot=`rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`;function st(){let{state:e,busy:t,enable:n,disable:r,test:i}=it(),a=e?at[e]:void 0;return(0,M.jsxs)(`section`,{"aria-labelledby":`nc-notifications-title`,className:`border-t border-ink-800 px-3 py-2`,children:[(0,M.jsx)(`h3`,{id:`nc-notifications-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Notifications`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`When a terminal asks for you`}),(e===`off`||e===`on`)&&(0,M.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e===`on`,"aria-busy":t,disabled:t,onClick:e===`on`?r:n,className:ot,children:e===`on`?`On`:`Off`}),e===null&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:`…`})]}),a&&(0,M.jsx)(`p`,{className:`mt-1 text-xs text-ink-400`,children:a}),e===`on`&&(0,M.jsx)(`button`,{type:`button`,disabled:t,onClick:i,className:`mt-1 ${ot}`,children:`Send a test notification`})]})}var ct=`nc-settings-title`,lt=`nc-settings-dialog`,ut=`nc-screen-scale`;function dt({accent:e,next:t,cycle:n,onReloadConfig:r,reloading:i,onShowShortcuts:a}){let[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(null),{scale:p,setScale:m}=ue(),h=f();(0,j.useLayoutEffect)(()=>{if(!c)return;let e=d.current;if(!e)return;e.querySelector(`[data-initial-focus]`)?.focus();let t=()=>[...e.querySelectorAll(`a[href], button:not(:disabled), select:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])`)],n=n=>{if(n.key===`Escape`){n.preventDefault(),l(!1),u.current?.focus();return}if(n.key!==`Tab`)return;let r=t(),i=r[0],a=r.at(-1);!i||!a?(n.preventDefault(),e.focus()):n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus())},r=t=>{let n=t.target;n instanceof Node&&!e.contains(n)&&!u.current?.contains(n)&&l(!1)};return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}},[c]);let g=()=>{l(!1),u.current?.focus(),a()};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{ref:u,type:`button`,onClick:()=>l(e=>!e),"aria-label":`Settings`,"aria-haspopup":`dialog`,"aria-expanded":c,"aria-controls":lt,title:`Settings`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,M.jsx)(he,{})}),c&&(0,M.jsxs)(`div`,{ref:d,id:lt,role:`dialog`,"aria-labelledby":ct,tabIndex:-1,className:`nc-pop-in origin-top-right fixed right-2 top-[calc(var(--nc-header-h)+8px)] z-50 flex max-h-[calc(100vh-3.75rem)] w-72 max-w-[calc(100vw-1rem)] flex-col overflow-y-auto rounded-md border border-ink-700 bg-ink-900 shadow-xl focus:outline-none`,style:{maxHeight:`calc(100dvh - 3.75rem)`},children:[(0,M.jsx)(`div`,{className:`border-b border-ink-700 px-3 py-2`,children:(0,M.jsx)(`h2`,{id:ct,className:`font-medium text-ink-50`,children:`Settings`})}),(0,M.jsxs)(`section`,{"aria-labelledby":`nc-appearance-title`,className:`px-3 py-2`,children:[(0,M.jsx)(`h3`,{id:`nc-appearance-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Appearance`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`Accent colour`}),(0,M.jsxs)(`button`,{type:`button`,"data-initial-focus":!0,onClick:n,...h(`session.cycleAccent`,`Accent: ${e.name} (click for ${t.name})`),"aria-label":`accent colour: ${e.name}, click for ${t.name}`,className:`flex items-center gap-1.5 rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 rounded-full bg-accent ring-1 ring-ink-600`}),e.name]})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,M.jsx)(`label`,{htmlFor:ut,className:`min-w-0 flex-1 text-ink-200`,children:`Screen scale`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`select`,{id:ut,"aria-label":`Screen scale`,value:p,onChange:e=>m(Number(e.currentTarget.value)),className:`appearance-none rounded-sm border border-ink-700 bg-ink-850 py-1 pl-2 pr-7 text-ink-50 focus:border-accent focus:outline-none`,children:o.map(e=>(0,M.jsxs)(`option`,{value:e,children:[e,`%`]},e))}),(0,M.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2 flex items-center text-ink-400`,children:(0,M.jsx)(He,{open:!0})})]})]})]}),(0,M.jsx)(st,{}),(0,M.jsxs)(`div`,{className:`border-t border-ink-800 px-3 py-2`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,"aria-busy":i,...h(`session.reloadConfig`,`Reload config.toml on the server (does not reload this page)`),"aria-label":`reload the server config`,className:`flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`,children:[(0,M.jsx)(ne,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),`Reload config.toml`]}),(0,M.jsxs)(`button`,{type:`button`,onClick:g,...h(`help.shortcuts`,`Keyboard shortcuts`),"aria-label":`keyboard shortcuts`,className:`mt-1 flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700`,children:[(0,M.jsx)(s,{className:`h-3.5 w-3.5`}),`Keyboard shortcuts`]})]})]})]})}function ft(e){return e===`top`||e===`left`?e:null}function pt(e){return e===`top`?`left`:`top`}function mt({repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,cloning:a,accent:o,next:s,cycle:c,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p,onReloadConfig:m,reloading:h,onShowShortcuts:g,tabStrip:_}){return(0,M.jsxs)(`header`,{className:`flex h-(--nc-header-h) items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,M.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,M.jsx)(Ve,{})}),(0,M.jsx)(Ke,{className:`md:hidden`,repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i}),_.side===`top`&&(0,M.jsx)(qe,{side:`top`,repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p}),a&&(0,M.jsxs)(`span`,{role:`status`,title:`A clone is running on the server`,className:`flex shrink-0 items-center gap-1.5 px-2 py-0.5 text-ink-400`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-accent`}),`Cloning…`]}),(0,M.jsx)(dt,{accent:o,next:s,cycle:c,onReloadConfig:m,reloading:h,onShowShortcuts:g}),(0,M.jsx)(`button`,{onClick:_.toggle,title:`Project tabs ${_.side===`top`?`across the top`:`down the left`} (click to move them ${pt(_.side)})`,"aria-label":`project tabs: ${_.side}, click for ${pt(_.side)}`,"aria-pressed":_.side===`left`,className:`ml-1 hidden h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:flex`,children:(0,M.jsx)(De,{side:_.side})}),(0,M.jsx)(`a`,{href:`/logout`,title:`Sign out`,"aria-label":`sign out`,className:`ml-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,M.jsx)(be,{})})]})}var ht=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-3/4`,`w-1/3`,`w-2/3`];function gt({className:e=``}){return(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`nc-skeleton block h-2.5 rounded-xs ${e}`})}function _t({rows:e=6,as:t=`div`,className:n=``}){let r=t;return(0,M.jsx)(M.Fragment,{children:Array.from({length:e},(e,t)=>(0,M.jsxs)(r,{"aria-hidden":`true`,className:`flex items-center gap-2 px-3 py-1.5 ${n}`,children:[(0,M.jsx)(gt,{className:`w-3 shrink-0`}),(0,M.jsx)(gt,{className:ht[t%ht.length]})]},t))})}function vt(){return(0,M.jsxs)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`flex h-full flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex h-(--nc-header-h) shrink-0 items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,M.jsx)(gt,{className:`h-[22px] w-[22px] shrink-0 rounded-sm`}),(0,M.jsx)(gt,{className:`hidden w-24 md:block`}),(0,M.jsx)(gt,{className:`w-28 md:hidden`}),(0,M.jsx)(gt,{className:`ml-auto h-4 w-4 shrink-0`}),(0,M.jsx)(gt,{className:`ml-1 h-4 w-4 shrink-0`})]}),(0,M.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)] md:grid-cols-[18rem_minmax(0,1fr)] md:grid-rows-[minmax(0,3fr)_minmax(0,2fr)]`,children:[(0,M.jsx)(`div`,{className:`overflow-hidden border-chrome-line py-2 md:border-r`,children:(0,M.jsx)(_t,{rows:10})}),(0,M.jsx)(`div`,{className:`hidden overflow-hidden py-2 md:block`,children:(0,M.jsx)(_t,{rows:14})}),(0,M.jsxs)(`div`,{className:`hidden overflow-hidden border-t border-chrome-line md:col-span-2 md:block`,children:[(0,M.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b border-chrome-line px-3`,children:[(0,M.jsx)(gt,{className:`w-30`}),(0,M.jsx)(gt,{className:`w-30`})]}),(0,M.jsx)(`div`,{className:`py-2`,children:(0,M.jsx)(_t,{rows:5})})]})]}),(0,M.jsx)(`div`,{className:`flex shrink-0 border-t border-chrome-line bg-ink-900 md:hidden`,children:[0,1,2].map(e=>(0,M.jsxs)(`div`,{className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-1 py-1`,children:[(0,M.jsx)(gt,{className:`h-5 w-5`}),(0,M.jsx)(gt,{className:`h-2 w-10`})]},e))})]})}function yt({onSuccess:e}){let[t,n]=(0,j.useState)(``),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(!1);return(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,M.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),o(!0),i(null);try{await A.login(t),e()}catch(e){i(e instanceof Error?e.message:`login failed`)}finally{o(!1)}},className:`w-[17rem] max-w-[86vw]`,children:[(0,M.jsx)(Be,{className:`mx-auto mb-3 block h-10 w-10`}),(0,M.jsx)(`h1`,{className:`text-center text-lg font-medium tracking-wide text-ink-50`,children:`nightcrow`}),(0,M.jsx)(`p`,{className:`mt-1 mb-5 text-center text-caption text-ink-400 uppercase`,children:`web viewer`}),r&&(0,M.jsx)(`p`,{className:`mb-2.5 text-center text-removed`,children:r}),(0,M.jsx)(`input`,{type:`password`,autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`password`,className:`mb-2 w-full rounded-sm border border-ink-700 bg-ink-900 px-2.5 py-1.5 outline-none placeholder:text-ink-400 focus:border-accent focus:ring-[3px] focus:ring-accent/15`}),(0,M.jsx)(`button`,{"aria-busy":a,type:`submit`,disabled:a,className:`w-full rounded-sm bg-ink-50 py-1.5 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,M.jsx)(k,{busy:a,children:`Sign in`})})]})})}var bt=`nightcrow.sidebarWidth`,xt=.5;function St(e){return Math.min(Math.max(Math.round(e),280),720)}function Ct(e){let t=720;try{t=Math.min(t,Math.round(window.innerWidth*xt))}catch{}return Math.min(Math.max(Math.round(e),280),Math.max(t,280))}function wt(){let e=Number(m(bt));return Number.isFinite(e)&&e>0?St(e):460}function Tt(e){h(bt,String(e))}function Et(){let[e,t]=(0,j.useState)(wt),n=(0,j.useCallback)(e=>{let n=Ct(e);t(n),Tt(n)},[]);return{width:e,resize:n,commit:n,reset:(0,j.useCallback)(()=>{let e=St(460);t(e),Tt(e)},[])}}var Dt=`[data-terminal-panel]`,Ot=`dialog[open], [role="dialog"], [aria-modal="true"]`,kt=`input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]`,At=`data-focus-region`;function jt(e){return{"data-focus-region":e,tabIndex:-1}}function Mt(e){if(!(e instanceof Element)||e.closest(`[data-terminal-panel]`))return null;let t=e.closest(kt)??e;return{tagName:t.tagName,isContentEditable:It(t),role:t.getAttribute(`role`),type:Lt(t),inDialog:e.closest(Ot)!==null}}function Nt(e=document){return Pt(e)===`terminal`}function Pt(e=document){let t=e.activeElement;if(!t)return null;if(t.closest(`[data-terminal-panel]`))return`terminal`;let n=t.closest(`[${At}]`)?.getAttribute(At);return n===`list`||n===`content`?n:null}function Ft(e,t=document){let n=t.querySelector(`[${At}="${e}"]`);if(!n)return!1;let r=a(t.activeElement,t.querySelector(Dt));return Ce(r)?(n.focus(),!0):!1}function It(e){let t=e.getAttribute(`contenteditable`);return t===null?e.isContentEditable===!0:t!==`false`}function Lt(e){return e.tagName===`INPUT`?e.type?.toLowerCase()??null:null}var Rt=600;function zt(e){let[t,n]=(0,j.useState)({scrollTop:0,height:Rt}),r=(0,j.useCallback)(()=>{let t=e.current;if(!t)return;let r={scrollTop:t.scrollTop,height:t.clientHeight||Rt};n(e=>e.scrollTop===r.scrollTop&&e.height===r.height?e:r)},[e]);return(0,j.useLayoutEffect)(()=>{r();let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e,r]),{viewport:t,refresh:r}}function Bt(){let e=new Map;return{start(t){let n=(e.get(t)??0)+1;return e.set(t,n),n},isCurrent(t,n){return e.get(t)===n}}}var Vt={children:{},expanded:new Set};function Ht(e,t,n){return{...e,children:{...e.children,[t]:n}}}function Ut(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function Wt(e,t){return{...e,expanded:Ut(e.expanded,t)}}function Gt(e,t){let n=new Set(e.expanded);return t.forEach(e=>n.add(e)),{...e,expanded:n}}function Kt(e){let t=[],n=``;for(let r of e.split(`/`))n=n?`${n}/${r}`:r,t.push(n);return t}var qt=180,Jt={items:[],truncated:!1};function Yt({repo:e,authed:t,tab:n,filter:r,filterOpen:i,handle:a}){let[o,s]=(0,j.useState)(Vt),[c,l]=(0,j.useState)(Jt),[u,d]=(0,j.useState)(!1),[f]=(0,j.useState)(Bt);(0,j.useEffect)(()=>{if(!e||!t||n!==`tree`||!i||!r){l(Jt),d(!1);return}d(!0);let o=!0,s=setTimeout(()=>{A.treeSearch(e,r).then(e=>{o&&l({items:e.matches,truncated:e.truncated})}).catch(e=>{o&&a(e)}).finally(()=>{o&&d(!1)})},qt);return()=>{o=!1,clearTimeout(s)}},[e,t,n,r,i,a]);let p=(0,j.useCallback)((t,n)=>{if(!e)return;let r=f.start(t);A.tree(e,t).then(e=>{f.isCurrent(t,r)&&s(n=>Ht(n,t,e.entries))}).catch(e=>{if(!f.isCurrent(t,r)||n?.restoring)return Ne(e)?a(e):void 0;a(e)})},[e,a,f]);(0,j.useEffect)(()=>{e&&t&&n===`tree`&&p(``)},[e,t,n,p]);let m=(0,j.useCallback)(e=>{let t=!o.expanded.has(e);s(t=>Wt(t,e)),t&&!(e in o.children)&&p(e)},[o,p]),h=(0,j.useCallback)(e=>{s(t=>({...t,expanded:new Set(e)})),e.forEach(e=>{e in o.children||p(e,{restoring:!0})})},[o,p]),g=(0,j.useCallback)(e=>{let t=Kt(e);s(e=>Gt(e,t)),t.forEach(e=>{e in o.children||p(e)})},[o,p]);return{treeChildren:o.children,treeExpanded:o.expanded,treeMatches:c.items,treeTruncated:c.truncated,treeSearchLoading:u,loadTreeChildren:p,toggleTreeDir:m,revealTreeDir:g,seedTreeExpanded:h}}function Xt(e,t){let n=[],r=(i,a)=>{for(let o of e[i]??[]){let e=i?`${i}/${o.name}`:o.name;n.push({path:e,name:o.name,is_dir:o.is_dir,depth:a}),o.is_dir&&t.has(e)&&r(e,a+1)}};return r(``,0),n}var Zt=[`status`,`log`,`tree`],N={status:`Show the working-tree status`,log:`Show the commit log`,tree:`Show the file tree`};function Qt(e){return e===`log`?`view.toggleLog`:e===`tree`?`view.toggleTree`:null}function $t({tab:e,onChoose:t,filterOpen:n,onToggleFilter:r}){let i=f();return(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch border-b border-chrome-line px-2`,children:[Zt.map(n=>{let r=Qt(n);return(0,M.jsx)(`button`,{onClick:()=>t(n),"aria-current":n===e?`page`:void 0,...r&&n!==e?i(r,N[n]):{title:N[n]},className:`px-2 py-1.5 ${n===e?`text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:text-ink-200`}`,children:n},n)}),(0,M.jsx)(`button`,{onClick:r,"aria-pressed":n,title:n?`Hide the filter`:`Filter the list`,"aria-label":n?`Hide the filter`:`Filter the list`,className:`my-1 ml-auto flex shrink-0 items-center rounded-sm px-1.5 hover:text-accent ${n?`text-ink-50`:`text-ink-400`}`,children:(0,M.jsx)(ie,{})})]})}function en({path:e,from:t,className:n}){return(0,M.jsx)(`span`,{className:`whitespace-nowrap ${n??``}`,title:t?`${t} → ${e}`:e,children:t?`${t} → ${e}`:e})}var tn=1e3;function nn(e,t){return e===void 0||e<=0?0:e-t}function rn(e,t,n){let r=nn(t,n);return e===null||Math.abs(r-e)>=1e3?r:e}function an(e,t,n){if(e===void 0)return`cool`;let r=Math.max(0,t-e);return r>=n?`cool`:r<5e3?`fresh`:`warm`}function on(e,t,n){return e.some(e=>an(e,t,n)!==`cool`)}var sn={fresh:`text-accent font-bold`,warm:`text-accent`,cool:``};function cn(e,t,n){let[r,i]=(0,j.useState)(()=>Date.now()+n);return(0,j.useEffect)(()=>{if(t<=0||!e)return;let r=e.map(e=>e.mtime),a=Date.now()+n;if(i(a),!on(r,a,t))return;let o=setInterval(()=>{let e=Date.now()+n;i(e),on(r,e,t)||clearInterval(o)},tn);return()=>clearInterval(o)},[e,t,n]),r}function ln(e){return e.startsWith(`not a git repository`)?`Not a git repository. Run git init here to track changes.`:`Status unavailable: ${e}`}function un(e){let t=Math.max(0,Math.floor(Date.now()/1e3-e));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function dn(e){return e===`+`?`bg-added/10`:e===`-`?`bg-removed/10`:``}function fn(e){return e===`?`?`text-ink-400`:e===`D`?`text-removed`:e===`A`?`text-added`:`text-accent`}function pn(e,t,n,r=20,i=12){let a=Math.max(1,Math.ceil(n/r)),o=Math.min(Math.floor(Math.max(0,t)/r),Math.max(0,e-a)),s=o+a,c=Math.max(0,Math.min(e,o-i)),l=Math.max(c,Math.min(e,s+i));return{start:c,end:l,before:c*r,after:(e-l)*r}}function mn(e){return Math.max(0,e-1)*20}function hn({status:e,files:t,hotWindowMs:n,clockSkewMs:r,viewport:i,openDiff:a}){let o=cn(t,n,r);if(e===null)return(0,M.jsx)(_t,{as:`li`,rows:8});if(e.unavailable!==void 0)return(0,M.jsx)(`li`,{className:`nc-fade-in px-3 py-1 text-ink-400`,children:ln(e.unavailable)});let s=t.length>200?pn(t.length,i.scrollTop,i.height):null,c=s?.start??0,l=s?t.slice(s.start,s.end):t;return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":t.length,style:{height:s.before}}),l.map((e,t)=>{let r=c+t;return(0,M.jsx)(`li`,{"data-virtual-row":s?r:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>a(e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[(0,M.jsx)(`span`,{className:fn(e.index),children:e.index===` `?` `:e.index}),(0,M.jsx)(`span`,{className:fn(e.worktree),children:e.worktree===` `?` `:e.worktree})]}),(0,M.jsx)(en,{path:e.path,from:e.old_path,className:sn[an(e.mtime,o,n)]})]})},e.path)}),s&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:s.after}}),e.truncated&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,e.files.length,` changed files.`]})]})}var gn={merge:`MERGING`,rebase:`REBASING`,"cherry-pick":`CHERRY-PICKING`,revert:`REVERTING`,bisect:`BISECTING`,am:`APPLYING`};function _n(e){let t=e?.operation,n=t?t.step!==void 0&&t.total!==void 0?`${gn[t.kind]} ${t.step}/${t.total}`:gn[t.kind]:null,r=e?.conflicts??0,i=r===0?null:r===1?`1 conflict`:`${r} conflicts`;return n&&i?`${n} · ${i}`:n??i}function vn(e){return e.kind===`head`&&e.name!==`HEAD`?`HEAD → ${e.name}`:e.name}function yn(e){switch(e){case`head`:return`border-accent text-accent font-medium`;case`local`:return`border-added/60 text-added`;case`tag`:return`border-ink-600 text-ink-200`;case`remote`:return`border-ink-700 text-ink-400`}}function bn({visibleCommits:e,decorations:t,commits:n,commitDrillDown:r,visibleCommitFiles:i,logDone:a,logStalled:o,logPagingPaused:s,viewport:c,setLogStalled:l,logSentinelRef:u,openCommitFiles:d,openCommit:f,openCommitFileDiff:p,setCommitDrillDown:m,setPaneEmpty:h,bumpPaneRequest:g}){let _=!r&&e.length>200?pn(e.length,c.scrollTop,c.height):null,v=_?e.slice(_.start,_.end):e,y=_?.start??0,b=r&&i.length>200?pn(i.length,c.scrollTop,c.height):null,x=b?i.slice(b.start,b.end):i,S=b?.start??0;return(0,M.jsxs)(M.Fragment,{children:[!r&&_&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":e.length,style:{height:_.before}}),!r&&v.map((e,n)=>{let r=y+n,i=t.divergenceOf(e.oid);return(0,M.jsx)(`li`,{"data-virtual-row":_?r:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>void d(e),title:`${e.author} · ${e.summary}`,className:`flex w-max min-w-full items-baseline gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsx)(`span`,{className:`w-2 shrink-0 ${i===`behind`?`text-accent`:`text-added`}`,title:i===`ahead`?`Not on the upstream yet`:i===`behind`?`On the upstream, not here yet`:void 0,children:i===`ahead`?`↑`:i===`behind`?`↓`:``}),(0,M.jsx)(`span`,{className:`shrink-0 text-accent`,children:e.short_id}),(0,M.jsx)(`span`,{className:`w-10 shrink-0 text-right text-ink-400`,children:un(e.time)}),(0,M.jsx)(`span`,{className:`max-w-[6rem] shrink-0 truncate text-ink-400`,children:e.author}),t.refsOf(e.oid)?.map(e=>(0,M.jsx)(`span`,{className:`shrink-0 self-center rounded-sm border px-1 text-2xs ${yn(e.kind)}`,children:vn(e)},`${e.kind}:${e.name}`)),(0,M.jsx)(`span`,{className:`whitespace-nowrap ${e.merge?`text-ink-400`:``}`,children:e.summary})]})},e.oid)}),!r&&_&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:_.after}}),!r&&t.truncated&&(0,M.jsx)(`li`,{className:`px-3 py-1 text-2xs text-ink-400`,children:`Too many refs to mark them all — some branch, tag or upstream marks are not shown.`}),!r&&!a&&!o&&!s&&(0,M.jsxs)(`li`,{ref:u,className:`flex flex-col gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,M.jsx)(gt,{className:`w-3/5`}),(0,M.jsx)(gt,{className:`w-2/5`}),(0,M.jsx)(gt,{className:`w-1/2`})]}),!r&&!a&&!o&&s&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-ink-400`,children:[`filtering `,n.length,` loaded commits — clear the filter to load more`]}),!r&&o&&(0,M.jsx)(`li`,{className:`px-3 py-1`,children:(0,M.jsx)(`button`,{onClick:()=>l(!1),className:`text-ink-400 hover:text-accent`,children:`could not load more — retry`})}),r&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`li`,{className:`sticky top-0 z-10 flex w-max min-w-full items-center gap-1 bg-ink-900 px-2 py-1 text-ink-400`,children:[(0,M.jsx)(`button`,{onClick:()=>{g(),m(null),h()},className:`rounded-sm px-1 hover:text-accent`,title:`Back to commit log`,children:`< log`}),(0,M.jsx)(`span`,{className:`text-ink-600`,children:`·`}),(0,M.jsx)(`span`,{className:`shrink-0 text-accent`,children:r.commit.short_id}),(0,M.jsx)(`button`,{onClick:()=>f(r.commit.oid),className:`rounded-sm px-1 hover:text-accent`,title:`Show the complete commit diff`,children:`all changes`})]}),b&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":i.length,style:{height:b.before}}),x.map((e,t)=>{let n=S+t;return(0,M.jsx)(`li`,{"data-virtual-row":b?n:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>p(r.commit.oid,e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsx)(`span`,{className:fn(e.index),children:e.index}),(0,M.jsx)(en,{path:e.path,from:e.old_path})]})},e.path)}),b&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:b.after}}),r.files.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No changed files.`}),r.files.length>0&&i.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No matching files.`}),r.truncated&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,r.files.length,` files.`]})]})]})}function xn({treeSearching:e,treeMatches:t,treeTruncated:n,treeSearchLoading:r,treeRows:i,treeExpanded:a,openFile:o,revealTreeDir:s,toggleTreeDir:c}){return e?(0,M.jsxs)(M.Fragment,{children:[t.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{onClick:()=>{e.is_dir?s(e.path):o(e.path)},title:e.path,className:`w-max min-w-full whitespace-nowrap px-3 py-0.5 text-left hover:bg-ink-850`,children:e.is_dir?(0,M.jsxs)(`span`,{className:`text-accent`,children:[e.path,`/`]}):e.path})},e.path)),t.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:r?`searching…`:`no matches`}),n&&(0,M.jsxs)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:[`showing the first `,t.length,` matches`]})]}):(0,M.jsx)(M.Fragment,{children:i.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{onClick:()=>e.is_dir?c(e.path):o(e.path),title:e.path,style:{paddingLeft:`${e.depth*.75+.5}rem`},className:`flex w-max min-w-full items-center gap-1 py-0.5 pr-3 text-left hover:bg-ink-850`,children:[e.is_dir?(0,M.jsx)(He,{open:a.has(e.path)}):(0,M.jsx)(`span`,{className:`h-3.5 w-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`whitespace-nowrap ${e.is_dir?`text-accent`:``}`,children:e.is_dir?`${e.name}/`:e.name})]})},e.path))})}function Sn(e){let{tab:t,chooseTab:n,filter:r,setFilter:i,filterOpen:a,setFilterOpen:o,status:s,files:c,hotWindowMs:l,clockSkewMs:u,openDiff:d,openFile:f,openCommit:p,openCommitFileDiff:m,openCommitFiles:h,repo:g,authed:_,handle:v,sidebarRef:y,draggingSidebar:b,onSidebarDragStart:x,onSidebarDragMove:S,onSidebarDragEnd:C,onSidebarDragCancel:w,filesMax:T,bumpPaneRequest:E,commits:ee,logDone:te,logStalled:ne,setLogStalled:re,commitDrillDown:ie,setCommitDrillDown:ae,logSentinelRef:oe,visibleCommits:se,decorations:ce,logPagingPaused:le,visibleCommitFiles:ue,mobileView:de,restoreTree:fe,restoreKnown:pe,onTreeExpanded:me,clearPane:he,touched:ge}=e,_e=Yt({repo:g,authed:_,tab:t,filter:r,filterOpen:a,handle:v}),ve=(0,j.useRef)(null),{viewport:ye,refresh:be}=zt(ve),xe=t===`tree`&&a&&r!==``,D=Xt(_e.treeChildren,_e.treeExpanded),{seedTreeExpanded:O}=_e,Se=(0,j.useRef)(!1);(0,j.useEffect)(()=>{Se.current||pe&&!ge&&t===`tree`&&(Se.current=!0,fe.length!==0&&O(fe))},[t,pe,ge,fe,O]);let Ce=e=>{me([...Ut(_e.treeExpanded,e)]),_e.toggleTreeDir(e)},we=e=>{let t=new Set(_e.treeExpanded);Kt(e).forEach(e=>t.add(e)),me([...t]),_e.revealTreeDir(e)},Te=()=>{a&&i(``),o(e=>!e)};return(0,M.jsxs)(`section`,{ref:y,...jt(`list`),className:`nc-fade-in relative min-h-0 flex-col overflow-hidden ${de===`files`?`flex`:`hidden md:flex`} ${T?`md:flex`:`border-chrome-line md:border-r`}`,children:[!T&&(0,M.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the file sidebar (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:x,onPointerMove:S,onPointerUp:C,onPointerCancel:w,onLostPointerCapture:C,className:`absolute -right-px top-0 z-20 hidden h-full w-1.5 cursor-col-resize touch-none md:block ${b?`bg-accent`:`hover:bg-accent`}`}),(0,M.jsx)($t,{tab:t,onChoose:n,filterOpen:a,onToggleFilter:Te}),a&&(0,M.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`filter…`,autoFocus:!0,className:`mx-2 mb-1 shrink-0 rounded-sm bg-ink-850 px-2 py-1 outline-none placeholder:text-ink-400 focus:ring-1 focus:ring-accent`}),(0,M.jsxs)(`ul`,{ref:ve,onScroll:be,className:`nc-content min-h-0 flex-1 overflow-auto`,children:[t===`status`&&(0,M.jsx)(hn,{status:s,files:c,hotWindowMs:l,clockSkewMs:u,viewport:ye,openDiff:d}),t===`log`&&(0,M.jsx)(bn,{visibleCommits:se,decorations:ce,commits:ee,commitDrillDown:ie,visibleCommitFiles:ue,logDone:te,logStalled:ne,logPagingPaused:le,viewport:ye,setLogStalled:re,logSentinelRef:oe,openCommitFiles:h,openCommit:p,openCommitFileDiff:m,setCommitDrillDown:ae,setPaneEmpty:he,bumpPaneRequest:E}),t===`tree`&&(0,M.jsx)(xn,{treeSearching:xe,treeMatches:_e.treeMatches,treeTruncated:_e.treeTruncated,treeSearchLoading:_e.treeSearchLoading,treeRows:D,treeExpanded:_e.treeExpanded,openFile:f,revealTreeDir:we,toggleTreeDir:Ce})]})]})}function Cn(e){let t=[],n=[],r=[],i=()=>{let e=Math.max(n.length,r.length);for(let i=0;i{t(e=>e===`split`?`unified`:`split`)},[])}}var Tn=[`.md`,`.markdown`],En=[`.html`,`.htm`];function Dn(e){let t=e.toLowerCase();return Tn.some(e=>t.endsWith(e))}function On(e){let t=e.toLowerCase();return En.some(e=>t.endsWith(e))}function kn(e){return Dn(e)||On(e)}function An(e){return e.map(e=>e.map(e=>e.t).join(``)).join(` -`)}function jn(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function Mn(e){return Math.max(0,e-1-2)}function Nn(e,t){return t<=0?null:Math.min(e,t)}function Pn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Fn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function In(e){return e.index!==`D`&&e.worktree!==`D`}function Ln(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Rn(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function zn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=wn(),d=f();return(0,M.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Fn(e)&&(0,M.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,M.jsx)(b,{})}),e.kind===`diff`&&(0,M.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,M.jsx)(v,{})}),o&&(0,M.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,M.jsx)(fe,{})}),e.kind===`file`&&kn(e.value.path)&&!s&&(0,M.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,M.jsx)(p,{})}),(0,M.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,M.jsx)(u,{maximized:r})})]})}var Bn=3;function Vn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,Bn)}function Hn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Vn(t)}function P({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,M.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,M.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,M.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Un(){let e=`(min-width: 768px)`,[t,n]=(0,j.useState)(()=>window.matchMedia(e).matches);return(0,j.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Wn(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Cn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Gn({line:e}){return(0,M.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,M.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Kn({line:e,side:t,digits:n,stickyClass:r}){let i=e?dn(e.kind):`bg-ink-900/40`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,M.jsx)(P,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,M.jsx)(Gn,{line:e}):(0,M.jsx)(`span`,{className:`pr-3`,children:` `})]})}function qn({diff:e,split:t,viewport:n}){let r=Un(),i=(0,j.useMemo)(()=>Wn(e,t,r),[e,t,r]),a=Hn(e.hunks),o=pn(i.length,n.scrollTop,n.height);return(0,M.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,M.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=dn(e.line.kind);return(0,M.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,M.jsx)(P,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,M.jsx)(Gn,{line:e.line})]},n)}return e.kind===`pair`?(0,M.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,M.jsx)(Kn,{line:e.left,side:`old`,digits:a}),(0,M.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,M.jsx)(Kn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,M.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,M.jsx)(Kn,{line:e.line,side:e.side,digits:a})},n)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function Jn({line:e}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Yn({line:e,digits:t,side:n}){if(e===null)return(0,M.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,M.jsx)(P,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${r}`,children:[(0,M.jsx)(P,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]})}function Xn({cells:e,digits:t,side:n,border:r}){return(0,M.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,M.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,M.jsx)(Yn,{line:e,digits:t,side:n},r))})})}function Zn({lines:e,digits:t}){let n=Cn(e);return(0,M.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,M.jsx)(Xn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,M.jsx)(Xn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Qn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(qn,{diff:e,split:t,viewport:n}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Hn(e.hunks);return(0,M.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,M.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,M.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,M.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,M.jsxs)(M.Fragment,{children:[i,(0,M.jsx)(Zn,{lines:e.lines,digits:r})]}):(0,M.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${n}`,children:[(0,M.jsx)(P,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var $n=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function er(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return $n.some(e=>n.includes(e))}var tr=class extends j.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,M.jsx)(nr,{chunk:er(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function nr({chunk:e,region:t,className:n}){return(0,M.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,M.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,M.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,M.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function rr({lines:e}){let t=Vn(e.length);return(0,M.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,M.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,M.jsx)(P,{nos:[n+1],digits:t}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function ir({lines:e,viewport:t}){let n=Vn(e.length),r=pn(e.length,t.scrollTop,t.height);return(0,M.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,M.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,M.jsx)(P,{nos:[i+1],digits:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ar=`modulepreload`,or=function(e,t){return new URL(e,t).href},sr={},cr=function(e){return e.pathname.endsWith(`.css`)},lr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ur=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=or(t,n);let r=s(t),i=cr(r);return lr(sr,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ar,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function dr(e,t){return`${e??``}\u0000${Rn(t)}`}var fr=(0,j.lazy)(()=>ur(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),pr=(0,j.lazy)(()=>ur(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),mr=(0,j.lazy)(()=>ur(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function hr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=wn(),[d,f]=(0,j.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&On(p),g=(0,j.useRef)(null),{viewport:_,refresh:v}=zt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,j.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:dr(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Pn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,j.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===dr(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Nn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=mn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,j.useEffect)(()=>{f(!1)},[e,p,m]),(0,M.jsxs)(`section`,{...jt(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,M.jsx)(en,{path:t.value.path,className:`min-w-0 truncate`}),(0,M.jsx)(zn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,M.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):(0,M.jsxs)(M.Fragment,{children:[t.kind===`empty`&&(c===null?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):c.unavailable===void 0?(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:ln(c.unavailable)})),t.kind===`file`&&(0,M.jsxs)(M.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:(0,M.jsx)(mr,{repo:e,path:p})})},`edit:${p}`):kn(t.value.path)&&r?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:On(t.value.path)&&e!==null?(0,M.jsx)(pr,{src:A.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,M.jsx)(fr,{source:An(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,M.jsx)(ir,{lines:t.value.lines,viewport:_}):(0,M.jsx)(rr,{lines:t.value.lines}),t.value.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,M.jsx)(Qn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var gr=[{key:`files`,label:`Repo`,icon:Ue},{key:`diff`,label:`Content`,icon:We},{key:`terminal`,label:`Terminal`,icon:Ge}];function _r({view:e,onSelect:t}){return(0,M.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:gr.map(({key:n,label:r,icon:i})=>(0,M.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,M.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var vr=(0,j.lazy)(()=>ur(()=>import(`./Terminal-DiFTvhqh.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function yr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,j.useEffect)(()=>d,[e,d]),(0,j.useEffect)(()=>v,[v]);let w=(0,j.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,M.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${xt*100}vw)`},children:[(0,M.jsx)(Sn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,M.jsx)(hr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,M.jsx)(tr,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,M.jsx)(vr,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,M.jsx)(_r,{view:x,onSelect:S}),(0,M.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,M.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,M.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),_n(n)&&(0,M.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:_n(n)}),n?.tracking&&(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,M.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var br=`0.1.28`;function xr({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,j.useState)(t),[c,l]=(0,j.useState)(null);(0,j.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,M.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,M.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,M.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,M.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,M.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,M.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,M.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,M.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function Sr({keys:e}){return e?(0,M.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,M.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Cr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,M.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,M.jsx)(Sr,{keys:t})]}),e.note&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,M.jsx)(`li`,{children:(0,M.jsx)(`div`,{...s,className:a,children:o})}):(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var wr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},Tr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Er=`nc-shortcut-help-title`;function Dr({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,j.useRef)(null),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,j.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,M.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,M.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Er,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{id:Er,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,M.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,br]})]}),(0,M.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,M.jsx)(pe,{})})]}),(0,M.jsx)(xr,{settings:t}),(0,M.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[Tr.map(({group:e,actions:n})=>(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:wr[e]}),(0,M.jsx)(`ul`,{children:n.map(e=>(0,M.jsx)(Cr,{action:e,keys:C(e.id,t.leader),ariaKeys:ge(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,M.jsx)(`ul`,{children:w.map(e=>(0,M.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,M.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,M.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Or=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],kr={keys:`3-9,0`,label:`pane 1-8`,click:null},Ar={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},jr={keys:`esc`,label:`cancel`,click:null};function Mr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[Ar,jr]}:e.armed?{chip:`PREFIX`,segments:Pr(n)}:t?{chip:null,segments:Nr(t,n)}:{chip:null,segments:Fr(n)}}function Nr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Or.includes(e.id)&&t(e.id)&&r.push(Ir(e,`${n} ${e.leader}`));return r}function Pr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Ir(i,i.leader)):(n||t.push(kr),n=!0));return t.push(jr),t}function Fr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Ir(n,n.chord));return t}function Ir(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Lr=`shrink-0 whitespace-nowrap`;function Rr({state:e,onClick:t}){let n=Mr(e,c(),ee());return(0,M.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,M.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,M.jsxs)(j.Fragment,{children:[n>0&&(0,M.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,M.jsx)(zr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function zr({segment:e,onClick:t}){let n=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,M.jsx)(`span`,{className:Lr,children:n});let r=e.click;return(0,M.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Lr} rounded-sm hover:text-accent`,children:n})}function Br(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Vr(e,t){let n=Hr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Ur(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Ur(a,r)?null:a}function Hr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Ur(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Wr(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Gr={armed:!1},Kr={kind:`none`};function qr(e=Kr){return{state:Gr,effect:e}}function Jr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return qr();case`consumed`:return qr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Kr};case`literalLeader`:return qr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Yr(e,t.action.id);case`ignore`:return{state:e,effect:Kr}}}function Yr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?qr():qr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Kr}:qr({kind:`run`,action:t})}var Xr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Zr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Qr=229,$r=new Set([`Process`,`Unidentified`]),ei={kind:`ignore`};function ti(e){return e.isComposing===!0||e.keyCode===Qr||$r.has(e.key)}function ni(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ri(e,t){if(e.type!==`keydown`||ti(e)||e.repeat===!0||t.suppressed)return ei;if(t.armed){if(ni(e))return{kind:`cancel`};if(t.leader&&xe(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Zr.has(e.key)?ei:{kind:`consumed`}}if(t.leader&&xe(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Xr)if(xe(t,e))return{kind:`action`,action:n};return ei}var ii=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ai=new Set([`textbox`,`searchbox`,`combobox`]);function oi(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ai.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ii.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function si(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:oi(e.target)}function ci(e,t=!0){let n=(0,j.useRef)(e);n.current=e,(0,j.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function li({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,j.useRef)(Gr),[o,s]=(0,j.useState)(Gr),c=(0,j.useRef)(i);c.current=i;let l=(0,j.useCallback)(e=>{let t=Jr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&ui(t.effect,n)},[]);ci((0,j.useCallback)(e=>{let r=si({target:Mt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ri(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,j.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=Mt(e.target);(oi(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,j.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,j.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,j.useRef)(r);return(0,j.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,j.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,j.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,j.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,j.useCallback)(()=>l({kind:`cancel`}),[l])}}function ui(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var di=`nightcrow.shortcut.leader`;function fi(){let[e,t]=(0,j.useState)(pi),n=(0,j.useCallback)(e=>{t(e),hi(e===null?null:me(e))},[]),r=(0,j.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,j.useCallback)(()=>n(null),[n]),a=(0,j.useCallback)(()=>n(re),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ve(e):null,setLeader:r,disable:i,reset:a}}function pi(){let e=mi();return e?e.leader===null?null:E(e.leader)??re:re}function mi(){try{let e=localStorage.getItem(di);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function hi(e){try{localStorage.setItem(di,JSON.stringify({leader:e}))}catch{}}function gi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=fi(),[g,_]=(0,j.useState)(!1),v=(0,j.useCallback)(()=>_(!0),[]),y=(0,j.useCallback)(()=>_(!1),[]),b=(0,j.useCallback)(e=>{let i=Wr(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,j.useCallback)(()=>{Nt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,j.useCallback)(e=>{let t=m?.paneCursor()??null,n=Pt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Vr({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Ft(i.kind))},[m,d,p]),w=(0,j.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Ft(`list`),e[`focus.content`]=()=>void Ft(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=li({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,j.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var _i=1e3,vi=3,yi=2e3;function bi(e,t){let[n,r]=(0,j.useState)(!1),i=(0,j.useRef)(!1),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,j.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,_i)),a.current)return;let n;try{n=await A.cloneStatus(t)}catch(e){if(Ne(e)){i.current=!1,a.current||r(!1);return}if(e instanceof Oe&&e.status===404){if(a.current)return;T.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await A.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;T.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){T.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,j.useCallback)(async(e=()=>!1)=>{for(let t=0;t0&&await new Promise(e=>setTimeout(e,yi)),i.current||e()||a.current)return;let n;try{({job:n}=await A.runningClone())}catch(e){if(Ne(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,j.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,j.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await A.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof Oe&&e.status>=400;T.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function xi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function Si(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Ci(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function wi(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var Ti=`The viewer was updated on the server.`,Ei=null,Di=null,Oi=null;function ki(e,t){return e===null||t===null?!1:e!==t}function Ai(e){Ei=e}function ji(e){ki(Ei,e)?Di!==e&&(Di=e,Oi=T.info(Ti,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ei&&Di!==null&&(Oi!==null&&se(Oi),Di=null,Oi=null)}var Mi=3e3;function Ni({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,j.useState)([]),[y,b]=(0,j.useState)(null),[x,S]=(0,j.useState)(null),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(!0),{current:ne}=(0,j.useRef)(Si(A.setActiveRepo)),re=(0,j.useRef)(null),ie=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return A.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:ce,maximized:le,last_view:ue,now_ms:de,can_clone:fe,viewer_build:pe}=n;if(f)return;ji(pe),S(e=>Ci(e,ae)),te(fe),w(e=>rn(e,de,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(le),d.current===ee&&o(ue??{},y.map(e=>e.id)),t(!0),E(!0);let me=h.current||g.current!==null;p.current===ne&&!m.current&&!me?v(e=>wi(e,y)):v(e=>{let t=ye(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return wi(e,t.map(e=>n.get(e)).filter(Boolean))});let he=y.map(e=>e.id),ge=ce!==re.current;re.current=ce??null,ge&&ce&&he.includes(ce)&&(ie.current=ce),b(e=>xi(e,he,ce,ge)),f||(_=setTimeout(x,Mi))}).catch(e=>{f||(Ne(e)?(t(!1),E(!1)):(je(e)||n(e),_=setTimeout(x,Mi)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,j.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Pi=4;function Fi({ids:e,onReorder:t,draggingRef:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(null),a=(0,j.useRef)(null),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Ii({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,j.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;A.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,j.useCallback)(e=>{r.current+=1,t(t=>{let n=ye(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Fi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Li({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,j.useRef)(0),m=(0,j.useRef)(!1),h=(0,j.useRef)(!1),g=(0,j.useRef)(null),_=Ni({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Ii({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Ri(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);return{reload:(0,j.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{T.success(await A.reloadConfig())}catch(e){T.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function zi(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function Bi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,j.useRef)(t);l.current=t;let u=(0,j.useRef)(e);return u.current=e,{selectOpenedRepo:(0,j.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,j.useCallback)(async e=>{try{await A.close(e),c.current+=1;let t=zi(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Vi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Hi(e,t,n,r,i){(0,j.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Ui=5e3,Wi={refs:{},ahead:[],behind:[],truncated:!1};function Gi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,j.useState)({key:``,value:Wi}),[l,u]=(0,j.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,j.useRef)(s.key);f.current=s.key,(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return A.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Ui))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Wi;return(0,j.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Ki(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function qi({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,j.useRef)([]),[,s]=(0,j.useState)(0),c=(0,j.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(null),h=(0,j.useRef)(!1),g=(0,j.useRef)(!1),_=(0,j.useRef)(0),v=(0,j.useRef)(void 0),y=(0,j.useRef)(void 0),b=(0,j.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,j.useState)(null),C=(0,j.useRef)(u);C.current=u;let w=(0,j.useRef)(i);w.current=i;let T=(0,j.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await A.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Ki(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,j.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await A.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,j.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function Ji(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Yi({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,j.useState)(null),u=(0,j.useRef)(i);u.current=i;let d=(0,j.useRef)(r);d.current=r;let f=(0,j.useRef)(null),p=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,j.useEffect)(()=>{if(e&&t)return Ae(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,j.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,Ji(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=Ji(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return A.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:In(i)&&Ln(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Xi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,j.useState)(`status`),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)({kind:`empty`}),[m,h]=(0,j.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,j.useRef)(0),_=(0,j.useCallback)(()=>{g.current+=1},[]),v=(0,j.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Yi({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=qi({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Gi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,j.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,j.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,j.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Zi=`nightcrow.mobileView`;function Qi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function $i(){return Qi(m(Zi))}function ea(){let[e,t]=(0,j.useState)($i);return{mobileView:e,setMobileView:(0,j.useCallback)(e=>{h(Zi,e),t(e)},[])}}function ta({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,j.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?In(t):!1},[s]);return{openDiff:(0,j.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,A.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&Ln(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Ne(e)?t(e):void 0;if(!o?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,j.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,A.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,j.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,A.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,j.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,A.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:Ln(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,j.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,A.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,A.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,j.useCallback)((i,a=0)=>{let s=Fn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?jn(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?A.file(e,u.path):A.diff(e,u.path):d?A.commitFile(e,u.oid,u.path):A.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:Mn(f)+1}:{kind:`diff`,value:e,source:Ln(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function na(){let[e,t]=(0,j.useState)(null),n=(0,j.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function ra({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=ea(),[l,u]=(0,j.useState)(!0),{loading:d,track:f}=na(),p=(0,j.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ta({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,j.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,j.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ia=[`status`,`log`,`tree`];function aa(){return{tab:`status`,file:null,tree_expanded:[]}}function oa(e,t){return{path:e,commit:null,face:t}}function sa(e,t,n){return{path:t,commit:e,face:n}}function ca(e){return[...e].sort().slice(0,200)}function F(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function I(e){let t=e?.tab;return t&&ia.includes(t)?t:`status`}function la(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&ua(e.file,t.file):!1}function ua(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,j.useRef)(null),u=(0,j.useRef)(null),d=(0,j.useRef)(new Map),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(!1);(0,j.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??aa(),...r}:n;if(r&&i(e,f),m.current)return;a(I(f));let h=F(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,j.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??aa(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,j.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,j.useCallback)(e=>h({file:e}),[h]),noteTree:(0,j.useCallback)(e=>h({tree_expanded:ca(e)}),[h])}}function fa({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,j.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,j.useCallback)(()=>{l(null),o()},[l,o]),m=(0,j.useMemo)(()=>({openDiff:e=>{l(oa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(oa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(sa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,j.useCallback)((e,t)=>{l(e.kind===`commit`?sa(e.oid,e.path,t):oa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function pa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Xi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=ra({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=fa({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,j.useCallback)(e=>void Vi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Hi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,j.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,j.useCallback)(e=>{let t=Fn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function ma(){let[e,t]=(0,j.useState)(0);return(0,j.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ha=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ga=`nightcrow.viewer.accent`;function _a(e){if(!Number.isFinite(e))return 0;let t=ha.length;return(Math.trunc(e)%t+t)%t}function va(){let e=m(ga);return e===null?0:_a(Number(e))}function ya(e){h(ga,String(e))}function ba(){let[e,t]=(0,j.useState)(va);(0,j.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ha[e].color)},[e]);let n=(0,j.useCallback)(()=>{t(e=>{let t=_a(e+1);return ya(t),A.setAccent(t).catch(()=>{}),t})},[]),r=(0,j.useCallback)(e=>{t(t=>{let n=_a(e);return n===t?t:(ya(n),n)})},[]);return{accent:ha[e],next:ha[_a(e+1)],cycle:n,adopt:r}}function xa(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function Sa(e){return Math.round(xa(e))}function Ca(e,t,n,r){let i=n-t;return xa(i<=0?r:(e-t)/i*100)}var wa=`nightcrow.upperPct`;function Ta(){try{let e=Number(localStorage.getItem(wa));return Number.isFinite(e)&&e>0?Sa(e):55}catch{return 55}}function Ea(e){try{localStorage.setItem(wa,String(e))}catch{}}function Da(){let[e,t]=(0,j.useState)(Ta);return{pct:e,resize:(0,j.useCallback)(e=>{t(xa(e))},[]),commit:(0,j.useCallback)(e=>{let n=Sa(e);t(n),Ea(n),A.setUpperPct(n).catch(()=>{})},[]),reset:(0,j.useCallback)(()=>{t(55),Ea(55),A.setUpperPct(55).catch(()=>{})},[]),adopt:(0,j.useCallback)(e=>{t(t=>{let n=Sa(e);return n===t?t:(Ea(n),n)})},[])}}function Oa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,j.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,j.useCallback)(e=>{ka(n.current,e)||r(e)},[r]),writes:i}}function ka(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function Aa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{e!=null&&(la(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,j.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,j.useCallback)(e=>n.current[e],[]),u=(0,j.useRef)(new Set),[d,f]=(0,j.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,j.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!ja(n.current,e)&&r(e)},[r]),covers:(0,j.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function ja(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&la(e[n],t[n]))}function Ma(){let{accent:e,next:t,cycle:n,adopt:r}=ba(),{width:i,resize:a,commit:o,reset:s}=Et(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Da(),p=Oa(),m=Aa(),h=(0,j.useRef)(0),g=(0,j.useRef)(0);return{accent:e,next:t,cycle:(0,j.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,j.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,j.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,j.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Na=400;function Pa({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useRef)(!1),u=(0,j.useRef)(!1),d=(0,j.useRef)(0),[f,p]=(0,j.useState)(!1);return{dragging:f,onDragStart:(0,j.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,j.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,j.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function L({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,j.useRef)(0),o=(0,j.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Pa({value:t,valueAt:(0,j.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Pa({value:n,valueAt:(0,j.useCallback)(e=>Ca(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=Ma(),E=(0,j.useRef)(null),ee=(0,j.useRef)(null),te=(0,j.useRef)(null),ne=L({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return ft(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,j.useState)(Ra);return{side:e,toggle:(0,j.useCallback)(()=>{t(e=>{let t=pt(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null),o=(0,j.useCallback)(e=>{Ne(e)?t(!1):T.error(e instanceof Error?e.message:`request failed`)},[]),s=ma(),c=Ia(),l=Ba(),u=Li({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=pa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=Bi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=bi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,j.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,j.useCallback)(()=>a(null),[]),S=(0,j.useCallback)(()=>r(!0),[]),C=(0,j.useCallback)(()=>r(!1),[]),w=Ri(),E=gi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,j.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:Br(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:E.shortcutHelp,leader:E.settings,hint:E.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,M.jsx)(vt,{}):e.authed?e.reposLoaded?(0,M.jsx)(g,{children:(0,M.jsx)(ae,{children:(0,M.jsx)(x,{leader:e.leader.leader,children:(0,M.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,M.jsx)(mt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,M.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,M.jsx)(qe,{side:`left`,...e.header})}),(0,M.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(yr,{...e.repoShell}),(0,M.jsx)(Rr,{...e.hint})]}):(0,M.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,M.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,M.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,M.jsx)(Re,{...e.picker}),e.closeConfirm&&(0,M.jsx)(Se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,M.jsx)(Dr,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,M.jsx)(vt,{}):(0,M.jsx)(yt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,j.useState)([]);return(0,j.useEffect)(()=>oe(t),[]),e.length===0?null:(0,M.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,M.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>se(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,M.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,M.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,M.jsx)(pe,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&_e(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),Ai(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Ze(Ye()),await Ja(window.location,window.history,A.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Le.createRoot)(document.getElementById(`root`)).render((0,M.jsxs)(j.StrictMode,{children:[(0,M.jsx)(tr,{children:(0,M.jsx)(O,{children:(0,M.jsx)(Ha,{})})}),(0,M.jsx)(Ga,{})]})); \ No newline at end of file +`)}function jn(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function Mn(e){return Math.max(0,e-1-2)}function Nn(e,t){return t<=0?null:Math.min(e,t)}function Pn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Fn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function In(e){return e.index!==`D`&&e.worktree!==`D`}function Ln(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Rn(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function zn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=wn(),d=f();return(0,M.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Fn(e)&&(0,M.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,M.jsx)(b,{})}),e.kind===`diff`&&(0,M.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,M.jsx)(v,{})}),o&&(0,M.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,M.jsx)(fe,{})}),e.kind===`file`&&kn(e.value.path)&&!s&&(0,M.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,M.jsx)(p,{})}),(0,M.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,M.jsx)(u,{maximized:r})})]})}var Bn=3;function Vn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,Bn)}function Hn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Vn(t)}function P({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,M.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,M.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,M.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Un(){let e=`(min-width: 768px)`,[t,n]=(0,j.useState)(()=>window.matchMedia(e).matches);return(0,j.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Wn(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Cn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Gn({line:e}){return(0,M.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,M.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Kn({line:e,side:t,digits:n,stickyClass:r}){let i=e?dn(e.kind):`bg-ink-900/40`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,M.jsx)(P,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,M.jsx)(Gn,{line:e}):(0,M.jsx)(`span`,{className:`pr-3`,children:` `})]})}function qn({diff:e,split:t,viewport:n}){let r=Un(),i=(0,j.useMemo)(()=>Wn(e,t,r),[e,t,r]),a=Hn(e.hunks),o=pn(i.length,n.scrollTop,n.height);return(0,M.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,M.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=dn(e.line.kind);return(0,M.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,M.jsx)(P,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,M.jsx)(Gn,{line:e.line})]},n)}return e.kind===`pair`?(0,M.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,M.jsx)(Kn,{line:e.left,side:`old`,digits:a}),(0,M.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,M.jsx)(Kn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,M.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,M.jsx)(Kn,{line:e.line,side:e.side,digits:a})},n)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function Jn({line:e}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Yn({line:e,digits:t,side:n}){if(e===null)return(0,M.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,M.jsx)(P,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${r}`,children:[(0,M.jsx)(P,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]})}function Xn({cells:e,digits:t,side:n,border:r}){return(0,M.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,M.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,M.jsx)(Yn,{line:e,digits:t,side:n},r))})})}function Zn({lines:e,digits:t}){let n=Cn(e);return(0,M.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,M.jsx)(Xn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,M.jsx)(Xn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Qn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(qn,{diff:e,split:t,viewport:n}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Hn(e.hunks);return(0,M.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,M.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,M.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,M.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,M.jsxs)(M.Fragment,{children:[i,(0,M.jsx)(Zn,{lines:e.lines,digits:r})]}):(0,M.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${n}`,children:[(0,M.jsx)(P,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var $n=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function er(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return $n.some(e=>n.includes(e))}var tr=class extends j.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,M.jsx)(nr,{chunk:er(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function nr({chunk:e,region:t,className:n}){return(0,M.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,M.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,M.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,M.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function rr({lines:e}){let t=Vn(e.length);return(0,M.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,M.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,M.jsx)(P,{nos:[n+1],digits:t}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function ir({lines:e,viewport:t}){let n=Vn(e.length),r=pn(e.length,t.scrollTop,t.height);return(0,M.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,M.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,M.jsx)(P,{nos:[i+1],digits:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ar=`modulepreload`,or=function(e,t){return new URL(e,t).href},sr={},cr=function(e){return e.pathname.endsWith(`.css`)},lr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ur=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=or(t,n);let r=s(t),i=cr(r);return lr(sr,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ar,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function dr(e,t){return`${e??``}\u0000${Rn(t)}`}var fr=(0,j.lazy)(()=>ur(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),pr=(0,j.lazy)(()=>ur(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),mr=(0,j.lazy)(()=>ur(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function hr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=wn(),[d,f]=(0,j.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&On(p),g=(0,j.useRef)(null),{viewport:_,refresh:v}=zt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,j.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:dr(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Pn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,j.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===dr(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Nn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=mn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,j.useEffect)(()=>{f(!1)},[e,p,m]),(0,M.jsxs)(`section`,{...jt(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,M.jsx)(en,{path:t.value.path,className:`min-w-0 truncate`}),(0,M.jsx)(zn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,M.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):(0,M.jsxs)(M.Fragment,{children:[t.kind===`empty`&&(c===null?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):c.unavailable===void 0?(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:ln(c.unavailable)})),t.kind===`file`&&(0,M.jsxs)(M.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:(0,M.jsx)(mr,{repo:e,path:p})})},`edit:${p}`):kn(t.value.path)&&r?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:On(t.value.path)&&e!==null?(0,M.jsx)(pr,{src:A.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,M.jsx)(fr,{source:An(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,M.jsx)(ir,{lines:t.value.lines,viewport:_}):(0,M.jsx)(rr,{lines:t.value.lines}),t.value.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,M.jsx)(Qn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var gr=[{key:`files`,label:`Repo`,icon:Ue},{key:`diff`,label:`Content`,icon:We},{key:`terminal`,label:`Terminal`,icon:Ge}];function _r({view:e,onSelect:t}){return(0,M.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:gr.map(({key:n,label:r,icon:i})=>(0,M.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,M.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var vr=(0,j.lazy)(()=>ur(()=>import(`./Terminal-DiFTvhqh.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function yr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,j.useEffect)(()=>d,[e,d]),(0,j.useEffect)(()=>v,[v]);let w=(0,j.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,M.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${xt*100}vw)`},children:[(0,M.jsx)(Sn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,M.jsx)(hr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,M.jsx)(tr,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,M.jsx)(vr,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,M.jsx)(_r,{view:x,onSelect:S}),(0,M.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,M.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,M.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),_n(n)&&(0,M.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:_n(n)}),n?.tracking&&(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,M.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var br=`0.1.29`;function xr({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,j.useState)(t),[c,l]=(0,j.useState)(null);(0,j.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,M.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,M.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,M.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,M.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,M.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,M.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,M.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,M.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function Sr({keys:e}){return e?(0,M.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,M.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Cr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,M.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,M.jsx)(Sr,{keys:t})]}),e.note&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,M.jsx)(`li`,{children:(0,M.jsx)(`div`,{...s,className:a,children:o})}):(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var wr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},Tr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Er=`nc-shortcut-help-title`;function Dr({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,j.useRef)(null),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,j.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,M.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,M.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Er,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{id:Er,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,M.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,br]})]}),(0,M.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,M.jsx)(pe,{})})]}),(0,M.jsx)(xr,{settings:t}),(0,M.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[Tr.map(({group:e,actions:n})=>(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:wr[e]}),(0,M.jsx)(`ul`,{children:n.map(e=>(0,M.jsx)(Cr,{action:e,keys:C(e.id,t.leader),ariaKeys:ge(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,M.jsx)(`ul`,{children:w.map(e=>(0,M.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,M.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,M.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Or=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],kr={keys:`3-9,0`,label:`pane 1-8`,click:null},Ar={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},jr={keys:`esc`,label:`cancel`,click:null};function Mr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[Ar,jr]}:e.armed?{chip:`PREFIX`,segments:Pr(n)}:t?{chip:null,segments:Nr(t,n)}:{chip:null,segments:Fr(n)}}function Nr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Or.includes(e.id)&&t(e.id)&&r.push(Ir(e,`${n} ${e.leader}`));return r}function Pr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Ir(i,i.leader)):(n||t.push(kr),n=!0));return t.push(jr),t}function Fr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Ir(n,n.chord));return t}function Ir(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Lr=`shrink-0 whitespace-nowrap`;function Rr({state:e,onClick:t}){let n=Mr(e,c(),ee());return(0,M.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,M.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,M.jsxs)(j.Fragment,{children:[n>0&&(0,M.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,M.jsx)(zr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function zr({segment:e,onClick:t}){let n=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,M.jsx)(`span`,{className:Lr,children:n});let r=e.click;return(0,M.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Lr} rounded-sm hover:text-accent`,children:n})}function Br(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Vr(e,t){let n=Hr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Ur(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Ur(a,r)?null:a}function Hr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Ur(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Wr(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Gr={armed:!1},Kr={kind:`none`};function qr(e=Kr){return{state:Gr,effect:e}}function Jr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return qr();case`consumed`:return qr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Kr};case`literalLeader`:return qr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Yr(e,t.action.id);case`ignore`:return{state:e,effect:Kr}}}function Yr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?qr():qr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Kr}:qr({kind:`run`,action:t})}var Xr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Zr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Qr=229,$r=new Set([`Process`,`Unidentified`]),ei={kind:`ignore`};function ti(e){return e.isComposing===!0||e.keyCode===Qr||$r.has(e.key)}function ni(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ri(e,t){if(e.type!==`keydown`||ti(e)||e.repeat===!0||t.suppressed)return ei;if(t.armed){if(ni(e))return{kind:`cancel`};if(t.leader&&xe(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Zr.has(e.key)?ei:{kind:`consumed`}}if(t.leader&&xe(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Xr)if(xe(t,e))return{kind:`action`,action:n};return ei}var ii=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ai=new Set([`textbox`,`searchbox`,`combobox`]);function oi(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ai.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ii.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function si(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:oi(e.target)}function ci(e,t=!0){let n=(0,j.useRef)(e);n.current=e,(0,j.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function li({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,j.useRef)(Gr),[o,s]=(0,j.useState)(Gr),c=(0,j.useRef)(i);c.current=i;let l=(0,j.useCallback)(e=>{let t=Jr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&ui(t.effect,n)},[]);ci((0,j.useCallback)(e=>{let r=si({target:Mt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ri(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,j.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=Mt(e.target);(oi(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,j.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,j.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,j.useRef)(r);return(0,j.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,j.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,j.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,j.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,j.useCallback)(()=>l({kind:`cancel`}),[l])}}function ui(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var di=`nightcrow.shortcut.leader`;function fi(){let[e,t]=(0,j.useState)(pi),n=(0,j.useCallback)(e=>{t(e),hi(e===null?null:me(e))},[]),r=(0,j.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,j.useCallback)(()=>n(null),[n]),a=(0,j.useCallback)(()=>n(re),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ve(e):null,setLeader:r,disable:i,reset:a}}function pi(){let e=mi();return e?e.leader===null?null:E(e.leader)??re:re}function mi(){try{let e=localStorage.getItem(di);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function hi(e){try{localStorage.setItem(di,JSON.stringify({leader:e}))}catch{}}function gi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=fi(),[g,_]=(0,j.useState)(!1),v=(0,j.useCallback)(()=>_(!0),[]),y=(0,j.useCallback)(()=>_(!1),[]),b=(0,j.useCallback)(e=>{let i=Wr(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,j.useCallback)(()=>{Nt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,j.useCallback)(e=>{let t=m?.paneCursor()??null,n=Pt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Vr({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Ft(i.kind))},[m,d,p]),w=(0,j.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Ft(`list`),e[`focus.content`]=()=>void Ft(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=li({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,j.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var _i=1e3,vi=3,yi=2e3;function bi(e,t){let[n,r]=(0,j.useState)(!1),i=(0,j.useRef)(!1),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,j.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,_i)),a.current)return;let n;try{n=await A.cloneStatus(t)}catch(e){if(Ne(e)){i.current=!1,a.current||r(!1);return}if(e instanceof Oe&&e.status===404){if(a.current)return;T.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await A.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;T.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){T.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,j.useCallback)(async(e=()=>!1)=>{for(let t=0;t0&&await new Promise(e=>setTimeout(e,yi)),i.current||e()||a.current)return;let n;try{({job:n}=await A.runningClone())}catch(e){if(Ne(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,j.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,j.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await A.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof Oe&&e.status>=400;T.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function xi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function Si(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Ci(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function wi(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var Ti=`The viewer was updated on the server.`,Ei=null,Di=null,Oi=null;function ki(e,t){return e===null||t===null?!1:e!==t}function Ai(e){Ei=e}function ji(e){ki(Ei,e)?Di!==e&&(Di=e,Oi=T.info(Ti,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ei&&Di!==null&&(Oi!==null&&se(Oi),Di=null,Oi=null)}var Mi=3e3;function Ni({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,j.useState)([]),[y,b]=(0,j.useState)(null),[x,S]=(0,j.useState)(null),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(!0),{current:ne}=(0,j.useRef)(Si(A.setActiveRepo)),re=(0,j.useRef)(null),ie=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return A.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:ce,maximized:le,last_view:ue,now_ms:de,can_clone:fe,viewer_build:pe}=n;if(f)return;ji(pe),S(e=>Ci(e,ae)),te(fe),w(e=>rn(e,de,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(le),d.current===ee&&o(ue??{},y.map(e=>e.id)),t(!0),E(!0);let me=h.current||g.current!==null;p.current===ne&&!m.current&&!me?v(e=>wi(e,y)):v(e=>{let t=ye(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return wi(e,t.map(e=>n.get(e)).filter(Boolean))});let he=y.map(e=>e.id),ge=ce!==re.current;re.current=ce??null,ge&&ce&&he.includes(ce)&&(ie.current=ce),b(e=>xi(e,he,ce,ge)),f||(_=setTimeout(x,Mi))}).catch(e=>{f||(Ne(e)?(t(!1),E(!1)):(je(e)||n(e),_=setTimeout(x,Mi)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,j.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Pi=4;function Fi({ids:e,onReorder:t,draggingRef:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(null),a=(0,j.useRef)(null),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Ii({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,j.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;A.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,j.useCallback)(e=>{r.current+=1,t(t=>{let n=ye(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Fi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Li({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,j.useRef)(0),m=(0,j.useRef)(!1),h=(0,j.useRef)(!1),g=(0,j.useRef)(null),_=Ni({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Ii({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Ri(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);return{reload:(0,j.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{T.success(await A.reloadConfig())}catch(e){T.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function zi(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function Bi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,j.useRef)(t);l.current=t;let u=(0,j.useRef)(e);return u.current=e,{selectOpenedRepo:(0,j.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,j.useCallback)(async e=>{try{await A.close(e),c.current+=1;let t=zi(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Vi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Hi(e,t,n,r,i){(0,j.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Ui=5e3,Wi={refs:{},ahead:[],behind:[],truncated:!1};function Gi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,j.useState)({key:``,value:Wi}),[l,u]=(0,j.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,j.useRef)(s.key);f.current=s.key,(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return A.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Ui))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Wi;return(0,j.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Ki(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function qi({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,j.useRef)([]),[,s]=(0,j.useState)(0),c=(0,j.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(null),h=(0,j.useRef)(!1),g=(0,j.useRef)(!1),_=(0,j.useRef)(0),v=(0,j.useRef)(void 0),y=(0,j.useRef)(void 0),b=(0,j.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,j.useState)(null),C=(0,j.useRef)(u);C.current=u;let w=(0,j.useRef)(i);w.current=i;let T=(0,j.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await A.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Ki(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,j.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await A.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,j.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function Ji(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Yi({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,j.useState)(null),u=(0,j.useRef)(i);u.current=i;let d=(0,j.useRef)(r);d.current=r;let f=(0,j.useRef)(null),p=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,j.useEffect)(()=>{if(e&&t)return Ae(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,j.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,Ji(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=Ji(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return A.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:In(i)&&Ln(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Xi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,j.useState)(`status`),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)({kind:`empty`}),[m,h]=(0,j.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,j.useRef)(0),_=(0,j.useCallback)(()=>{g.current+=1},[]),v=(0,j.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Yi({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=qi({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Gi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,j.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,j.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,j.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Zi=`nightcrow.mobileView`;function Qi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function $i(){return Qi(m(Zi))}function ea(){let[e,t]=(0,j.useState)($i);return{mobileView:e,setMobileView:(0,j.useCallback)(e=>{h(Zi,e),t(e)},[])}}function ta({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,j.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?In(t):!1},[s]);return{openDiff:(0,j.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,A.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&Ln(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Ne(e)?t(e):void 0;if(!o?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,j.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,A.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,j.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,A.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,j.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,A.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:Ln(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,j.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,A.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,A.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,j.useCallback)((i,a=0)=>{let s=Fn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?jn(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?A.file(e,u.path):A.diff(e,u.path):d?A.commitFile(e,u.oid,u.path):A.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:Mn(f)+1}:{kind:`diff`,value:e,source:Ln(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function na(){let[e,t]=(0,j.useState)(null),n=(0,j.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function ra({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=ea(),[l,u]=(0,j.useState)(!0),{loading:d,track:f}=na(),p=(0,j.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ta({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,j.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,j.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ia=[`status`,`log`,`tree`];function aa(){return{tab:`status`,file:null,tree_expanded:[]}}function oa(e,t){return{path:e,commit:null,face:t}}function sa(e,t,n){return{path:t,commit:e,face:n}}function ca(e){return[...e].sort().slice(0,200)}function F(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function I(e){let t=e?.tab;return t&&ia.includes(t)?t:`status`}function la(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&ua(e.file,t.file):!1}function ua(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,j.useRef)(null),u=(0,j.useRef)(null),d=(0,j.useRef)(new Map),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(!1);(0,j.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??aa(),...r}:n;if(r&&i(e,f),m.current)return;a(I(f));let h=F(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,j.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??aa(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,j.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,j.useCallback)(e=>h({file:e}),[h]),noteTree:(0,j.useCallback)(e=>h({tree_expanded:ca(e)}),[h])}}function fa({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,j.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,j.useCallback)(()=>{l(null),o()},[l,o]),m=(0,j.useMemo)(()=>({openDiff:e=>{l(oa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(oa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(sa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,j.useCallback)((e,t)=>{l(e.kind===`commit`?sa(e.oid,e.path,t):oa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function pa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Xi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=ra({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=fa({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,j.useCallback)(e=>void Vi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Hi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,j.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,j.useCallback)(e=>{let t=Fn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function ma(){let[e,t]=(0,j.useState)(0);return(0,j.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ha=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ga=`nightcrow.viewer.accent`;function _a(e){if(!Number.isFinite(e))return 0;let t=ha.length;return(Math.trunc(e)%t+t)%t}function va(){let e=m(ga);return e===null?0:_a(Number(e))}function ya(e){h(ga,String(e))}function ba(){let[e,t]=(0,j.useState)(va);(0,j.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ha[e].color)},[e]);let n=(0,j.useCallback)(()=>{t(e=>{let t=_a(e+1);return ya(t),A.setAccent(t).catch(()=>{}),t})},[]),r=(0,j.useCallback)(e=>{t(t=>{let n=_a(e);return n===t?t:(ya(n),n)})},[]);return{accent:ha[e],next:ha[_a(e+1)],cycle:n,adopt:r}}function xa(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function Sa(e){return Math.round(xa(e))}function Ca(e,t,n,r){let i=n-t;return xa(i<=0?r:(e-t)/i*100)}var wa=`nightcrow.upperPct`;function Ta(){try{let e=Number(localStorage.getItem(wa));return Number.isFinite(e)&&e>0?Sa(e):55}catch{return 55}}function Ea(e){try{localStorage.setItem(wa,String(e))}catch{}}function Da(){let[e,t]=(0,j.useState)(Ta);return{pct:e,resize:(0,j.useCallback)(e=>{t(xa(e))},[]),commit:(0,j.useCallback)(e=>{let n=Sa(e);t(n),Ea(n),A.setUpperPct(n).catch(()=>{})},[]),reset:(0,j.useCallback)(()=>{t(55),Ea(55),A.setUpperPct(55).catch(()=>{})},[]),adopt:(0,j.useCallback)(e=>{t(t=>{let n=Sa(e);return n===t?t:(Ea(n),n)})},[])}}function Oa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,j.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,j.useCallback)(e=>{ka(n.current,e)||r(e)},[r]),writes:i}}function ka(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function Aa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{e!=null&&(la(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,j.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,j.useCallback)(e=>n.current[e],[]),u=(0,j.useRef)(new Set),[d,f]=(0,j.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,j.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!ja(n.current,e)&&r(e)},[r]),covers:(0,j.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function ja(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&la(e[n],t[n]))}function Ma(){let{accent:e,next:t,cycle:n,adopt:r}=ba(),{width:i,resize:a,commit:o,reset:s}=Et(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Da(),p=Oa(),m=Aa(),h=(0,j.useRef)(0),g=(0,j.useRef)(0);return{accent:e,next:t,cycle:(0,j.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,j.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,j.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,j.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Na=400;function Pa({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useRef)(!1),u=(0,j.useRef)(!1),d=(0,j.useRef)(0),[f,p]=(0,j.useState)(!1);return{dragging:f,onDragStart:(0,j.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,j.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,j.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function L({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,j.useRef)(0),o=(0,j.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Pa({value:t,valueAt:(0,j.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Pa({value:n,valueAt:(0,j.useCallback)(e=>Ca(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=Ma(),E=(0,j.useRef)(null),ee=(0,j.useRef)(null),te=(0,j.useRef)(null),ne=L({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return ft(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,j.useState)(Ra);return{side:e,toggle:(0,j.useCallback)(()=>{t(e=>{let t=pt(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null),o=(0,j.useCallback)(e=>{Ne(e)?t(!1):T.error(e instanceof Error?e.message:`request failed`)},[]),s=ma(),c=Ia(),l=Ba(),u=Li({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=pa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=Bi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=bi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,j.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,j.useCallback)(()=>a(null),[]),S=(0,j.useCallback)(()=>r(!0),[]),C=(0,j.useCallback)(()=>r(!1),[]),w=Ri(),E=gi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,j.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:Br(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:E.shortcutHelp,leader:E.settings,hint:E.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,M.jsx)(vt,{}):e.authed?e.reposLoaded?(0,M.jsx)(g,{children:(0,M.jsx)(ae,{children:(0,M.jsx)(x,{leader:e.leader.leader,children:(0,M.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,M.jsx)(mt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,M.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,M.jsx)(qe,{side:`left`,...e.header})}),(0,M.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(yr,{...e.repoShell}),(0,M.jsx)(Rr,{...e.hint})]}):(0,M.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,M.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,M.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,M.jsx)(Re,{...e.picker}),e.closeConfirm&&(0,M.jsx)(Se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,M.jsx)(Dr,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,M.jsx)(vt,{}):(0,M.jsx)(yt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,j.useState)([]);return(0,j.useEffect)(()=>oe(t),[]),e.length===0?null:(0,M.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,M.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>se(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,M.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,M.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,M.jsx)(pe,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&_e(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),Ai(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Ze(Ye()),await Ja(window.location,window.history,A.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Le.createRoot)(document.getElementById(`root`)).render((0,M.jsxs)(j.StrictMode,{children:[(0,M.jsx)(tr,{children:(0,M.jsx)(O,{children:(0,M.jsx)(Ha,{})})}),(0,M.jsx)(Ga,{})]})); \ No newline at end of file diff --git a/viewer-ui/dist/index.html b/viewer-ui/dist/index.html index fde9121c..0c02678c 100644 --- a/viewer-ui/dist/index.html +++ b/viewer-ui/dist/index.html @@ -14,7 +14,7 @@ nightcrow - + diff --git a/viewer-ui/package-lock.json b/viewer-ui/package-lock.json index 7a0f700e..65ae6877 100644 --- a/viewer-ui/package-lock.json +++ b/viewer-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "nightcrow-viewer-ui", - "version": "0.1.28", + "version": "0.1.29", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nightcrow-viewer-ui", - "version": "0.1.28", + "version": "0.1.29", "dependencies": { "@xterm/addon-fit": "^0.11.0", "@xterm/addon-webgl": "^0.19.0", diff --git a/viewer-ui/package.json b/viewer-ui/package.json index c0206011..44bb5159 100644 --- a/viewer-ui/package.json +++ b/viewer-ui/package.json @@ -1,7 +1,7 @@ { "name": "nightcrow-viewer-ui", "private": true, - "version": "0.1.28", + "version": "0.1.29", "type": "module", "scripts": { "dev": "vite",