Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) add remote
Egor Khindikaynenf5b70b29b266
diff --git a/.gitignore b/.gitignoreindex c4d42c9a..51c34a7a 100644--- a/.gitignore+++ b/.gitignore@@ -28,4 +28,4 @@ cmake_install.cmake# Nota project bundles created during testing*.nota/dist/-\ No newline at end of file+ src/managed/Nota.Remote/wwwroot/diff --git a/Nota.sln b/Nota.slnindex 60bbce48..850dbea2 100644--- a/Nota.sln+++ b/Nota.sln@@ -57,6 +57,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution items", "solutionEndProjectProject("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nota.Mcp", "src\managed\Nota.Mcp\Nota.Mcp.csproj", "{6025AE74-0180-4BD9-8DD5-0DBD18818C40}"EndProject+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nota.Remote", "src\managed\Nota.Remote\Nota.Remote.csproj", "{3A3E355E-D734-4DA7-A651-CF9E4CFC4177}"+EndProjectGlobalGlobalSection(SolutionConfigurationPlatforms) = preSolutionDebug|Any CPU = Debug|Any CPU@@ -151,6 +153,18 @@ Global{6025AE74-0180-4BD9-8DD5-0DBD18818C40}.Release|x64.Build.0 = Release|Any CPU{6025AE74-0180-4BD9-8DD5-0DBD18818C40}.Release|x86.ActiveCfg = Release|Any CPU{6025AE74-0180-4BD9-8DD5-0DBD18818C40}.Release|x86.Build.0 = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|Any CPU.ActiveCfg = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|Any CPU.Build.0 = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|x64.ActiveCfg = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|x64.Build.0 = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|x86.ActiveCfg = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Debug|x86.Build.0 = Debug|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|Any CPU.ActiveCfg = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|Any CPU.Build.0 = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|x64.ActiveCfg = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|x64.Build.0 = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|x86.ActiveCfg = Release|Any CPU+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177}.Release|x86.Build.0 = Release|Any CPUEndGlobalSectionGlobalSection(SolutionProperties) = preSolutionHideSolutionNode = FALSE@@ -164,5 +178,6 @@ Global{E7E451A8-60F6-487D-9DF0-7C413BEDF33D} = {740F2F8A-03DD-0AB5-5B09-13F1E599E4C1}{FA4A1512-3FA4-4C26-B73E-5EA8A9DCB601} = {740F2F8A-03DD-0AB5-5B09-13F1E599E4C1}{6025AE74-0180-4BD9-8DD5-0DBD18818C40} = {740F2F8A-03DD-0AB5-5B09-13F1E599E4C1}+ {3A3E355E-D734-4DA7-A651-CF9E4CFC4177} = {740F2F8A-03DD-0AB5-5B09-13F1E599E4C1}EndGlobalSectionEndGlobaldiff --git a/src/managed/Nota.App/App.axaml.cs b/src/managed/Nota.App/App.axaml.csindex 31b03522..5d54cbbe 100644--- a/src/managed/Nota.App/App.axaml.cs+++ b/src/managed/Nota.App/App.axaml.cs@@ -69,6 +69,7 @@ public partial class App : Avalonia.Applicationservices.AddSingleton<Nota.Mcp.IArrangementRefresh>(sp => sp.GetRequiredService<ArrangementRefresh>());services.AddSingleton<ProjectVersionsBridge>();services.AddSingleton<McpService>();+ services.AddSingleton<RemoteService>();// Presentation.services.AddSingleton<TransportViewModel>();services.AddSingleton<BrowserViewModel>();diff --git a/src/managed/Nota.App/ArrangementView.Vms.cs b/src/managed/Nota.App/ArrangementView.Vms.csindex 2fc69659..fd357d4a 100644--- a/src/managed/Nota.App/ArrangementView.Vms.cs+++ b/src/managed/Nota.App/ArrangementView.Vms.cs@@ -33,6 +33,7 @@ public sealed partial class ArrangementViewpublic bool Soloed;public bool Armed;public bool Frozen; // M7: playing a captured buffer instead of the live chain+ public string? Player; // Nota Remote: the phone(s) playing this trackpublic int LiveRole; // live-freeze (v1.1): 0 none, 1 sleeping source, 2 linked frozenpublic string Name = "";public List<ClipVM> Clips = new();diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex 49a32db0..5f0f1b40 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -200,6 +200,8 @@ public sealed partial class ArrangementView : UserControl/// <summary>Live-freeze (v1.1): per-track role for the header badge — 0 none, 1 sleeping/// source, 2 linked frozen. Set by MainWindow; queried while rebuilding headers.</summary>public Func<int, int>? FreezeRole;+ /// <summary>Who plays the track from a phone (Nota Remote), for the header badge; null = nobody.</summary>+ public Func<int, string?>? PlayerBadge;/// <summary>Freeze / Live Freeze entries for a track's context menu (empty when the track/// can't be frozen). Built by MainWindow, which owns the freeze state and commands.</summary>public Func<int, IReadOnlyList<Control>>? FreezeMenuItems;@@ -710,6 +712,7 @@ public sealed partial class ArrangementView : UserControlArmed = ti.Armed != 0,Frozen = !ti.IsReturn && !ti.IsGroup && eng.IsTrackFrozen(ti.Id), // M7LiveRole = FreezeRole?.Invoke(ti.Id) ?? 0, // live-freeze (v1.1)+ Player = PlayerBadge?.Invoke(ti.Id), // Nota Remote// A stored name (set via the header menu) wins; otherwise the derived default.Name = IsProcessingTrack(ti.Id) ? "Processing…" : TrackNames.Of(eng, ti),Volume = ti.Volume,@@ -1626,7 +1629,9 @@ public sealed partial class ArrangementView : UserControlVerticalAlignment = VerticalAlignment.Center,TextTrimming = TextTrimming.CharacterEllipsis,};- var typeTag = TypeTag(t.IsGroup ? "GROUP" : t.IsInstrument ? "MIDI" : "AUDIO");+ // A phone playing the track (Nota Remote) takes the type tag's place: during a jam+ // "who plays what" matters more than MIDI / AUDIO.+ Control typeTag = t.Player is { } player ? PlayerTag(player) : TypeTag(t.IsGroup ? "GROUP" : t.IsInstrument ? "MIDI" : "AUDIO");var nameRow = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto") };if (t.IsGroup){@@ -2172,6 +2177,31 @@ public sealed partial class ArrangementView : UserControlreturn tb;}+ // Nota Remote: the name of whoever plays this track from a phone, in a pill with a drawn+ // phone outline (design 5a) — "who plays what" during a jam.+ private Control PlayerTag(string who)+ {+ var phone = new Border+ {+ Width = 6, Height = 9, CornerRadius = NotaRadius.Bar, BorderThickness = new Thickness(1),+ BorderBrush = Brush("Brush.TextStrong"), VerticalAlignment = VerticalAlignment.Center,+ };+ var name = new TextBlock+ {+ Text = who, FontSize = 9, FontWeight = FontWeight.SemiBold, Foreground = Brush("Brush.TextStrong"),+ VerticalAlignment = VerticalAlignment.Center, MaxWidth = 70, TextTrimming = TextTrimming.CharacterEllipsis,+ };+ var pill = new Border+ {+ Height = 16, CornerRadius = NotaRadius.Pill, Padding = new Thickness(6, 0), Margin = new Thickness(6, 0, 0, 0),+ Background = Brush("Brush.TrackOff"), BorderBrush = Brush("Brush.BorderStrong"), BorderThickness = new Thickness(1),+ VerticalAlignment = VerticalAlignment.Center,+ Child = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 4, Children = { phone, name } },+ };+ ToolTip.SetTip(pill, $"Played from a phone: {who}");+ return pill;+ }+// A small 18×16 stateful chip toggle (M/S/●). Danger variant reds when active.// Record-arm, drawn to the almanac's record rule: at rest a neutral chip with a red// disc; armed, solid record red with a pale disc.diff --git a/src/managed/Nota.App/MainWindow.Recovery.cs b/src/managed/Nota.App/MainWindow.Recovery.csindex 16ea0c43..398aa573 100644--- a/src/managed/Nota.App/MainWindow.Recovery.cs+++ b/src/managed/Nota.App/MainWindow.Recovery.cs@@ -53,6 +53,7 @@ public partial class MainWindowCloseFloatingDetail(); // tear down the popped-out Devices/Clip window, if anyShutdownGamepad(); // stop the IOKit pad thread before the engine dies+ ShutdownRemote(); // phones leave (their held notes released) before the engine dies_recovery.EndSessionClean();}diff --git a/src/managed/Nota.App/MainWindow.Remote.cs b/src/managed/Nota.App/MainWindow.Remote.csnew file mode 100644index 00000000..0b598cc1--- /dev/null+++ b/src/managed/Nota.App/MainWindow.Remote.cs@@ -0,0 +1,170 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Nota Remote in the window: the top-bar Remote button (off / the number of phones, a dot that+// flashes on every touch, like the MIDI dot), the Connect Phone popup it opens, and the+// window's side of the hub — it is the IRemoteHost, and it ticks the hub on the UI clock.+// A phone is one more controller: transport through the transport view-model, mapped controls+// through MIDI Learn, notes into the engine on the socket thread (see RemoteHub).++using System;+using System.Collections.Generic;+using System.Linq;+using Avalonia.Controls;+using Avalonia.Controls.Primitives;+using Avalonia.Interactivity;+using Avalonia.Styling;+using Microsoft.Extensions.DependencyInjection;+using Nota.Remote;++namespace Nota.App;++public partial class MainWindow : IRemoteHost+{+ private RemoteService? _remote;+ private int _remoteSeenActivity;+ private DateTime _remoteLastActivity;++ private void InitRemote()+ {+ if (_vm is null) return;+ _remote = App.Services.GetRequiredService<RemoteService>();+ _remote.Hub.Host = this;+ _remote.Changed += () => Avalonia.Threading.Dispatcher.UIThread.Post(SyncRemoteButton);+ Timeline.PlayerBadge = id => _remote?.Hub.PlayersOf(id) is { Count: > 0 } p ? string.Join(", ", p) : null;+ _vm.PlayheadUpdated += _ =>+ {+ _remote?.Hub.Tick();+ SyncRemoteDot();+ };+ // Learn armed / a control picked: the phones show the banner and dashed outlines.+ SyncRemoteButton();+ _ = _remote.ApplyAsync();+ }++ private void OnRemoteClick(object? sender, RoutedEventArgs e) => ShowConnectPhone();++ private void OnMenuConnectPhone(object? sender, EventArgs e) => ShowConnectPhone();++ private void ShowConnectPhone()+ {+ if (_remote is null || _vm is null) return;+ var flyout = new Flyout+ {+ Placement = PlacementMode.BottomEdgeAlignedRight,+ Content = new ConnectPhoneView(_remote, _vm.Settings, Engine),+ FlyoutPresenterClasses = { "bare" },+ };+ flyout.ShowAt(RemoteBtn);+ }++ private void SyncRemoteButton()+ {+ if (_remote is null || _vm is null) return;+ bool on = _vm.Settings.Current.RemoteEnabled && _remote.Running;+ int n = _remote.Hub.Devices.Count;+ RemoteCount.Text = on ? n.ToString() : "Off";+ RemoteBtn.Classes.Set("lit", on);+ ToolTip.SetTip(RemoteBtn, !_vm.Settings.Current.RemoteEnabled ? "Play and control Nota from a phone"+ : _remote.Error ?? (n == 0 ? "Remote is on · scan the code with a phone" : $"{n} phone{(n == 1 ? "" : "s")} connected"));+ Timeline.Refresh();+ }++ private void SyncRemoteDot()+ {+ if (_remote is null) return;+ int a = _remote.Hub.ActivityCount;+ if (a != _remoteSeenActivity) { _remoteSeenActivity = a; _remoteLastActivity = DateTime.UtcNow; }+ bool connected = _remote.Running && _remote.Hub.Devices.Count > 0;+ bool lit = connected && (DateTime.UtcNow - _remoteLastActivity).TotalMilliseconds < 150;+ var want = lit ? NotaPalette.AccentBright : connected ? NotaPalette.AccentEdge : NotaPalette.BorderStrong;+ if (!ReferenceEquals(RemoteDot.Fill, want)) RemoteDot.Fill = want;+ }++ private void ShutdownRemote()+ {+ if (_remote is null) return;+ _remote.Hub.Host = null;+ _remote.ShutdownAsync().Wait(TimeSpan.FromSeconds(2));+ }++ // ---- IRemoteHost --------------------------------------------------------------++ string IRemoteHost.HostName => _remote?.Hub.HostName ?? Environment.MachineName;++ bool IRemoteHost.DarkTheme => Avalonia.Application.Current?.ActualThemeVariant != ThemeVariant.Light;++ string IRemoteHost.TrackColor(int trackId)+ {+ var c = ArrangementView.TrackBrush(ArrangementView.EffectiveColorIndex(Engine, trackId)).Color;+ return $"#{c.R:X2}{c.G:X2}{c.B:X2}";+ }++ int IRemoteHost.SelectedTrackId => Timeline.SelectedTrackId;+ int IRemoteHost.ProjectKeyCode => _vm?.Transport.KeyCode ?? -1;++ IReadOnlyList<(string Name, double StartBeat)> IRemoteHost.Sections =>+ Timeline.SectionList.OrderBy(s => s.StartBeat).Select(s => (s.Name, s.StartBeat)).ToList();++ bool IRemoteHost.Recording => _vm?.Transport.RecordOn ?? false;+ bool IRemoteHost.LoopOn => _vm?.Transport.LoopOn ?? false;+ bool IRemoteHost.MetronomeOn => _vm?.Transport.MetronomeOn ?? false;++ void IRemoteHost.Play() { if (_vm is { } vm && !Engine.IsPlaying) vm.Transport.PlayCommand.Execute(null); }++ // Stop as the transport bar does: a take ends first; pressed when stopped, back to the start.+ void IRemoteHost.Stop() => _vm?.Transport.StopCommand.Execute(null);++ void IRemoteHost.SetRecord(bool on) { if (_vm is { } vm) vm.Transport.RecordOn = on; }+ void IRemoteHost.SetLoop(bool on) { if (_vm is { } vm) vm.Transport.LoopOn = on; }++ void IRemoteHost.SetLoopRange(double startBeat, double endBeat)+ {+ Engine.SetLoop(Engine.LoopEnabled, startBeat, endBeat);+ _vm?.Transport.SyncLoop();+ Timeline.Refresh(rebuildHeaders: false);+ }++ void IRemoteHost.SetMetronome(bool on) { if (_vm is { } vm) vm.Transport.MetronomeOn = on; }+ void IRemoteHost.SetBpm(double bpm) { if (_vm is { } vm) vm.Transport.Bpm = (decimal)bpm; }++ double IRemoteHost.MasterVolume+ {+ get => _vm?.Transport.MasterVolume ?? 1.0;+ set { if (_vm is { } vm) vm.Transport.MasterVolume = value; }+ }++ bool IRemoteHost.Undo()+ {+ if (!Engine.Undo()) return false;+ RefreshAfterUndoRedo();+ if (_vm is not null) _vm.StatusText = "Undo (from a phone)";+ return true;+ }++ void IRemoteHost.Refresh()+ {+ Timeline.Refresh();+ _session?.Refresh();+ if (_mixer?.IsVisible == true) _mixer.Refresh();+ if (DetailBody.Content is MixerView mx && mx.IsEffectivelyVisible) mx.Refresh();+ if (_deviceChain is { } dc && dc.TrackId > 0) dc.Refresh();+ }++ bool IRemoteHost.LearnArmed => _learn?.Armed ?? false;+ string? IRemoteHost.LearnPendingName => _learn?.Pending?.Name;++ PhoneControlResult IRemoteHost.PhoneControl(int controlId, double norm)+ {+ if (_learn is null) return PhoneControlResult.None;+ var r = _learn.HandlePhoneControl(controlId, norm);+ if (r == PhoneControlResult.Bound) { LearnOverlay.Refresh(); Browser.ShowMidiMap(); }+ return r;+ }++ string? IRemoteHost.PhoneMappingName(int controlId) => _learn?.PhoneMappingFor(controlId)?.DisplayName;++ void IRemoteHost.DevicesChanged() => _remote?.RaiseChanged();++ void IRemoteHost.Activity() { }+}diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex 031c18d8..6c59db54 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -58,6 +58,7 @@<NativeMenuItem.Menu><NativeMenu><NativeMenuItem Header="Mixer" Click="OnMenuMixer" Gesture="Shift+Cmd+M"/>+ <NativeMenuItem Header="Connect Phone…" Click="OnMenuConnectPhone"/><NativeMenuItemSeparator/><NativeMenuItem Header="Toggle browser" Click="OnMenuToggleBrowser"/><NativeMenuItem Header="Toggle detail panel" Click="OnMenuToggleClip"/>@@ -309,17 +310,34 @@<!-- </Button.Flyout> --><!-- </Button> -->- <!-- MIDI learn + an input-activity dot, so a silent controller is diagnosable -->- <ToggleButton Grid.Column="6" x:Name="MidiLearnBtn" Classes="chip" Margin="8,0,0,0"- Click="OnToggleMidiLearn"- ToolTip.Tip="Map a controller — click a control, then move a knob on the controller">- <StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">- <TextBlock Text="MIDI" VerticalAlignment="Center"- Foreground="{Binding $parent[ToggleButton].Foreground}"/>- <Ellipse x:Name="MidiDot" Width="5" Height="5" VerticalAlignment="Center"- Fill="{DynamicResource Brush.BorderStrong}"/>- </StackPanel>- </ToggleButton>+ <!-- MIDI learn + an input-activity dot, so a silent controller is diagnosable;+ Remote (Nota Remote) beside it: off / the number of phones, a dot that flashes on+ each touch from a phone. Click opens Connect Phone. -->+ <StackPanel Grid.Column="6" Orientation="Horizontal" Spacing="6" Margin="8,0,0,0">+ <ToggleButton x:Name="MidiLearnBtn" Classes="chip"+ Click="OnToggleMidiLearn"+ ToolTip.Tip="Map a controller — click a control, then move a knob on the controller">+ <StackPanel Orientation="Horizontal" Spacing="6" VerticalAlignment="Center">+ <TextBlock Text="MIDI" VerticalAlignment="Center"+ Foreground="{Binding $parent[ToggleButton].Foreground}"/>+ <Ellipse x:Name="MidiDot" Width="5" Height="5" VerticalAlignment="Center"+ Fill="{DynamicResource Brush.BorderStrong}"/>+ </StackPanel>+ </ToggleButton>+ <Button x:Name="RemoteBtn" Classes="chip" Click="OnRemoteClick"+ ToolTip.Tip="Play and control Nota from a phone">+ <StackPanel Orientation="Horizontal" Spacing="7" VerticalAlignment="Center">+ <Border x:Name="RemoteGlyph" Width="8" Height="12" CornerRadius="2" BorderThickness="1.5"+ BorderBrush="{Binding $parent[Button].Foreground}" VerticalAlignment="Center"/>+ <TextBlock Text="Remote" VerticalAlignment="Center"+ Foreground="{Binding $parent[Button].Foreground}"/>+ <TextBlock x:Name="RemoteCount" Classes="Mono" Text="Off" FontSize="10" VerticalAlignment="Center"+ Foreground="{Binding $parent[Button].Foreground}"/>+ <Ellipse x:Name="RemoteDot" Width="5" Height="5" VerticalAlignment="Center"+ Fill="{DynamicResource Brush.BorderStrong}"/>+ </StackPanel>+ </Button>+ </StackPanel><Border Grid.Column="7" Width="1" Height="26" Margin="14,0"Background="{DynamicResource Brush.Hairline}"/>diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex bc7c576b..3ab36578 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -338,6 +338,7 @@ public partial class MainWindow : Windowvm.AutosaveRequested += OnAutosaveTick;vm.VersionHistoryTurnedOff += OnVersionHistoryTurnedOff;InitGamepad(); // poll pad buttons on each UI tick (live note source)+ InitRemote(); // Nota Remote: phones as controllers (ticked on the same clock)Closing += OnMainWindowClosing; // clean-shutdown marker (M7-7)Opened += OnOpenedRecoveryCheck; // offer recovery snapshot (M7-7)diff --git a/src/managed/Nota.App/MidiLearn.cs b/src/managed/Nota.App/MidiLearn.csindex 3df8dec7..a9499305 100644--- a/src/managed/Nota.App/MidiLearn.cs+++ b/src/managed/Nota.App/MidiLearn.cs@@ -23,9 +23,10 @@ using Nota.Application;namespace Nota.App;/// <summary>What a mapping listens to: a CC (continuous), a MIDI note (a controller-/// pad/button), or a gamepad button. Gamepad sources ride the same table and the same+/// pad/button), a gamepad control, or a Nota Remote phone control (a macro knob, an XY axis,+/// a tilt axis — id in <see cref="Nota.Remote.PhoneControls"/>). Gamepad sources ride the same table and the same/// apply path — a button edge is just a 0/127 momentary source.</summary>-public enum MidiSourceKind { Cc = 0, Note = 1, Gamepad = 2 }+public enum MidiSourceKind { Cc = 0, Note = 1, Gamepad = 2, Phone = 3 }/// <summary>The gamepad's mappable controls, flattened into one id space so a mapping/// needs no extra field to say which kind it is. Buttons keep the ids the native queue@@ -166,6 +167,7 @@ public sealed class MidiMapping{MidiSourceKind.Cc => $"CC {Number} · ch{Channel + 1}",MidiSourceKind.Gamepad => $"Pad · {GamepadControls.Name(Number)}",+ MidiSourceKind.Phone => $"Phone · {Nota.Remote.PhoneControls.Name(Number)}",_ => $"Note {Number} · ch{Channel + 1}",};}diff --git a/src/managed/Nota.App/MidiLearnService.cs b/src/managed/Nota.App/MidiLearnService.csindex 09bd019d..0314e3af 100644--- a/src/managed/Nota.App/MidiLearnService.cs+++ b/src/managed/Nota.App/MidiLearnService.cs@@ -136,6 +136,32 @@ public sealed class MidiLearnServicereturn Dispatch(MidiSourceKind.Gamepad, 0, axisId, value127) > 0;}+ /// <summary>The mapping a phone control drives, if any. Tied to the control, not the phone,+ /// so every connected phone drives the same target.</summary>+ public MidiMapping? PhoneMappingFor(int controlId)+ => _mappings.FirstOrDefault(m => m.SourceKind == MidiSourceKind.Phone && m.Number == controlId);++ /// <summary>Feed a Nota Remote control (normalized 0..1). Binds the pending control, or+ /// drives every mapping on it — at full resolution, not quantized to 0..127.</summary>+ public Nota.Remote.PhoneControlResult HandlePhoneControl(int controlId, double norm)+ {+ if (_pending is { } p)+ {+ Bind(p, MidiSourceKind.Phone, 0, controlId);+ LogMidi($"MIDI learn: phone {Nota.Remote.PhoneControls.Name(controlId)} → bound to '{p.Name}'");+ return Nota.Remote.PhoneControlResult.Bound;+ }+ int matched = 0;+ foreach (var m in _mappings)+ if (m.SourceKind == MidiSourceKind.Phone && m.Number == controlId)+ {+ ApplyNormalized(m, Math.Clamp(norm, 0, 1));+ matched++;+ }+ if (matched > 0) EventCount++;+ return matched > 0 ? Nota.Remote.PhoneControlResult.Mapped : Nota.Remote.PhoneControlResult.None;+ }+public void RemoveMapping(MidiMapping m){if (_mappings.Remove(m)) MappingsChanged?.Invoke();@@ -250,14 +276,25 @@ public sealed class MidiLearnService}private void Apply(MidiMapping m, int value127)+ {+ if (m.Target.IsButton && m.SourceKind == MidiSourceKind.Note)+ {+ // A note-on fires; anything else crosses the half-way point (ApplyNormalized).+ ApplyNormalized(m, value127 > 0 ? 1.0 : 0.0);+ return;+ }+ ApplyNormalized(m, Math.Clamp(value127 / 127.0, 0, 1));+ }++ private void ApplyNormalized(MidiMapping m, double norm){var t = m.Target;if (t.IsButton){- // A note-on, or anything else crossing the half-way point. Latch on the edge:- // a swept CC or a squeezed trigger sends a run of values past the threshold,- // and toggling on each one would make the target flutter.- bool on = m.SourceKind == MidiSourceKind.Note ? value127 > 0 : value127 >= 64;+ // Crossing the half-way point. Latch on the edge: a swept CC or a squeezed+ // trigger sends a run of values past the threshold, and toggling on each one+ // would make the target flutter.+ bool on = norm >= 0.5;if (m.Invert) on = !on;if (on == m.TriggerLatch) return;m.TriggerLatch = on;@@ -265,7 +302,6 @@ public sealed class MidiLearnServicereturn;}- double norm = Math.Clamp(value127 / 127.0, 0, 1);if (m.Invert) norm = 1.0 - norm;double outv = m.RangeMin + norm * (m.RangeMax - m.RangeMin); // 0..1 within the mapped windowdiff --git a/src/managed/Nota.App/MidiMapView.cs b/src/managed/Nota.App/MidiMapView.csindex 04385243..80add25d 100644--- a/src/managed/Nota.App/MidiMapView.cs+++ b/src/managed/Nota.App/MidiMapView.cs@@ -74,7 +74,17 @@ public sealed class MidiMapView : UserControl// Source on the left; the invert toggle rides the right of the same line so the// range row below has room for just MIN / MAX.var srcRow = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto") };- srcRow.Children.Add(src);+ if (m.SourceKind == MidiSourceKind.Phone)+ {+ // Nota Remote: a drawn phone outline marks the source, as the gamepad has its word.+ var phone = new Border+ {+ Width = 7, Height = 11, CornerRadius = NotaRadius.Bar, BorderThickness = new Avalonia.Thickness(1.3),+ BorderBrush = NotaPalette.AccentBright, VerticalAlignment = VerticalAlignment.Center,+ };+ srcRow.Children.Add(new StackPanel { Orientation = Orientation.Horizontal, Spacing = 6, Children = { phone, src } });+ }+ else srcRow.Children.Add(src);var body = new StackPanel { Spacing = 6 };body.Children.Add(top);diff --git a/src/managed/Nota.App/Nota.App.csproj b/src/managed/Nota.App/Nota.App.csprojindex e1552e2f..b9e2c567 100644--- a/src/managed/Nota.App/Nota.App.csproj+++ b/src/managed/Nota.App/Nota.App.csproj@@ -22,6 +22,8 @@</PackageReference><PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /><PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />+ <!-- QR code for Connect Phone (Nota Remote). MIT. -->+ <PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="3.2.1" /></ItemGroup><!-- App icon for the window / taskbar. The macOS .app dock & Finder icon comes@@ -43,6 +45,7 @@<ProjectReference Include="..\Nota.Presentation\Nota.Presentation.csproj" /><ProjectReference Include="..\Nota.Infrastructure\Nota.Infrastructure.csproj" /><ProjectReference Include="..\Nota.Mcp\Nota.Mcp.csproj" />+ <ProjectReference Include="..\Nota.Remote\Nota.Remote.csproj" /></ItemGroup><!-- Copy the native engine + scan worker next to the app binary so P/Invoke candiff --git a/src/managed/Nota.App/PreferencesWindow.Downloads.cs b/src/managed/Nota.App/PreferencesWindow.Downloads.csindex 53a05252..9d67d6c8 100644--- a/src/managed/Nota.App/PreferencesWindow.Downloads.cs+++ b/src/managed/Nota.App/PreferencesWindow.Downloads.cs@@ -19,7 +19,7 @@ namespace Nota.App;public sealed partial class PreferencesWindow{- private const int DownloadsIndex = 4;+ private const int DownloadsIndex = 5;private static readonly string[] DownloadSources = { "Plug-ins", "Sample Packs", "AI Models" };private int _downloadSource; // 0 = plug-ins, 1 = sample packs, 2 = AI models; kept for the window's lifediff --git a/src/managed/Nota.App/PreferencesWindow.Remote.cs b/src/managed/Nota.App/PreferencesWindow.Remote.csnew file mode 100644index 00000000..277a9813--- /dev/null+++ b/src/managed/Nota.App/PreferencesWindow.Remote.cs@@ -0,0 +1,182 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Settings → Remote (design 5b): the switch, the port, what phones may do, and the trusted+// phones — a trusted phone reconnects from its Home Screen icon without a code until it is+// forgotten here. The note at the end warns about the system's local-network / firewall prompt+// before it appears.++using System;+using System.Collections.Generic;+using System.Linq;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Controls.Shapes;+using Avalonia.Input;+using Avalonia.Layout;+using Avalonia.Media;+using Avalonia.Threading;+using Microsoft.Extensions.DependencyInjection;+using Nota.Application;+using Nota.Remote;++namespace Nota.App;++public sealed partial class PreferencesWindow+{+ private const int RemoteIndex = 3;++ /// <summary>Open Settings on the Remote page.</summary>+ public void ShowRemote() => Select(RemoteIndex);++ private Control RemotePane()+ {+ var settings = App.Services.GetRequiredService<ISettingsService>();+ var remote = App.Services.GetRequiredService<RemoteService>();++ var portBox = new TextBox+ {+ Text = settings.Current.RemotePort.ToString(), Width = 90, Classes = { "field" },+ FontSize = 12, FontFamily = NotaFonts.MonoFamily, HorizontalAlignment = HorizontalAlignment.Left,+ };+ var statusDot = Dot(BorderStrong);+ var status = new TextBlock { FontSize = 11, FontFamily = NotaFonts.MonoFamily, Foreground = TextSecondary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };++ // Phones may: play notes only, or play and control the project.+ var access = new StackPanel { Spacing = 6 };+ var radios = new List<(Ellipse ring, Ellipse dot)>();+ void PaintAccess()+ {+ for (int i = 0; i < radios.Count; i++)+ {+ bool on = settings.Current.RemoteAccess == i;+ radios[i].ring.Stroke = on ? Brass : BorderStrong;+ radios[i].dot.Fill = on ? Brass : Brushes.Transparent;+ }+ }+ foreach (var (i, name, sub) in new[]+ {+ (0, "Play notes only", "Pads and keys. Mixer, transport and mappings are read-only."),+ (1, "Play and control the project", "Also mixer, transport, macros, XY and Session."),+ })+ {+ var ring = new Ellipse { Width = 12, Height = 12, StrokeThickness = 1.5 };+ var dot = new Ellipse { Width = 6, Height = 6 };+ radios.Add((ring, dot));+ var text = new StackPanel { Spacing = 2 };+ text.Children.Add(new TextBlock { Text = name, FontSize = 12, Foreground = TextPrimary });+ text.Children.Add(new TextBlock { Text = sub, FontSize = 11, Foreground = TextMuted, TextWrapping = TextWrapping.Wrap });+ var row = new StackPanel+ {+ Orientation = Orientation.Horizontal, Spacing = 9, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),+ Margin = new Thickness(0, 4),+ Children = { new Panel { VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 2, 0, 0), Children = { ring, dot } }, text },+ };+ int idx = i;+ row.PointerPressed += (_, e) =>+ {+ if (!e.GetCurrentPoint(row).Properties.IsLeftButtonPressed) return;+ settings.Current.RemoteAccess = idx;+ settings.Save();+ PaintAccess();+ };+ access.Children.Add(row);+ }+ PaintAccess();++ var trustedHost = new ContentControl();+ void RenderTrusted()+ {+ var connected = remote.Hub.Devices.Select(d => d.DeviceId).ToHashSet();+ var list = remote.Pairing.Trusted.OrderByDescending(d => d.LastSeen).ToList();+ if (list.Count == 0) { trustedHost.Content = EmptyBox("No phone has paired yet. Turn Remote on and scan the code in Connect Phone."); return; }+ var rows = new List<Control>();+ foreach (var d in list)+ {+ bool live = connected.Contains(d.Id) && remote.Running;+ var name = new TextBlock { Text = d.Name, FontSize = 12, Foreground = TextPrimary, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };+ var seen = new TextBlock { Text = live ? "now" : Ago(d.LastSeen), FontSize = 10, FontFamily = NotaFonts.MonoFamily, Foreground = TextTertiary, VerticalAlignment = VerticalAlignment.Center };+ var forget = Btn("Forget");+ forget.Height = 24; forget.FontSize = 11; forget.Padding = new Thickness(10, 0);+ ToolTip.SetTip(forget, "Disconnect it and make it scan a new code to come back");+ string id = d.Id;+ forget.Click += (_, _) => { remote.Hub.Forget(id); RenderTrusted(); };+ rows.Add(ListRow(38, "Auto,*,Auto,Auto", Dot(live ? NotaPalette.SuccessDim : BorderStrong), name, seen, forget));+ }+ trustedHost.Content = Table(rows);+ }++ bool Enabled() => settings.Current.RemoteEnabled;+ var details = new StackPanel { Spacing = 10 };+ void Refresh()+ {+ bool on = Enabled();+ status.Text = !on ? "Off" : remote.Error ?? (remote.Url is { } u ? $"Listening on {u.Replace("http://", "")}" : "On · no network");+ statusDot.Fill = !on ? BorderStrong : remote.Error is null ? NotaPalette.SuccessDim : NotaPalette.Danger;+ Inactive.Set(details, !on);+ RenderTrusted();+ }+ void Apply(bool on)+ {+ settings.Current.RemoteEnabled = on;+ if (int.TryParse(portBox.Text, out var p) && p is >= 1024 and < 65536) settings.Current.RemotePort = p;+ else portBox.Text = settings.Current.RemotePort.ToString();+ settings.Save();+ _ = remote.ApplyAsync();+ Refresh();+ }+ var enable = SwitchRow("Allow control from a phone", Enabled(), Apply);+ portBox.LostFocus += (_, _) => Apply(Enabled());+ void OnChanged() => Dispatcher.UIThread.Post(Refresh);+ remote.Changed += OnChanged;+ Closed += (_, _) => remote.Changed -= OnChanged;+ DetachedFromVisualTree += (_, _) => remote.Changed -= OnChanged;++ details.Children.Add(Row("Port", portBox));+ details.Children.Add(Row("Status", new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { statusDot, status } }));+ var accessRow = new Grid { ColumnDefinitions = new ColumnDefinitions($"{LabelCol},*") };+ var accessLabel = RowLabel("Phones may");+ accessLabel.VerticalAlignment = VerticalAlignment.Top;+ accessLabel.Margin = new Thickness(0, 6, 0, 0);+ accessRow.Children.Add(accessLabel);+ Grid.SetColumn(access, 1);+ accessRow.Children.Add(access);+ details.Children.Add(accessRow);+ Refresh();++ string sysNote = OperatingSystem.IsMacOS()+ ? "When you turn this on, macOS asks whether Nota may find devices on the local network. Allow it, or phones can't reach Nota."+ : OperatingSystem.IsWindows()+ ? "When you turn this on, Windows asks whether Nota may use the network. Allow private networks, or phones can't reach Nota."+ : "Phones reach Nota on the port above: if a firewall is on, allow it.";+ var warn = new Border+ {+ Padding = new Thickness(14, 12), CornerRadius = NotaRadius.Panel, Background = RowBg, BorderBrush = Divider, BorderThickness = new Thickness(1),+ Child = new StackPanel+ {+ Orientation = Orientation.Horizontal, Spacing = 10,+ Children =+ {+ new Ellipse { Width = 6, Height = 6, Fill = NotaPalette.Warning, VerticalAlignment = VerticalAlignment.Top, Margin = new Thickness(0, 5, 0, 0) },+ new TextBlock { Text = sysNote + " Nota never shows files or paths to the phone, and serves nothing from your disk.", FontSize = 11, LineHeight = 17, Foreground = TextSecondary, TextWrapping = TextWrapping.Wrap, MaxWidth = 560 },+ },+ },+ };++ return Sections(+ Section("NOTA REMOTE", 10, enable, details),+ Section("TRUSTED DEVICES", 8, trustedHost,+ Caption("A trusted phone reconnects from its Home Screen icon without a code. Forget it and it has to scan again. Turning Remote off disconnects everyone.", muted: true)),+ warn);+ }++ private static string Ago(DateTime utc)+ {+ var d = DateTime.UtcNow - utc;+ if (d.TotalMinutes < 2) return "just now";+ if (d.TotalHours < 1) return $"{(int)d.TotalMinutes} min ago";+ if (d.TotalDays < 1) return $"{(int)d.TotalHours} h ago";+ if (d.TotalDays < 2) return "yesterday";+ return $"{(int)d.TotalDays} days ago";+ }+}diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.csindex 46b7338d..96ad8366 100644--- a/src/managed/Nota.App/PreferencesWindow.cs+++ b/src/managed/Nota.App/PreferencesWindow.cs@@ -2,7 +2,7 @@// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//// Settings (nota-design/Nota Settings.html): 880×640 with a 188px sidebar grouped as-// Devices (Audio / MIDI / Gamepads), Plug-ins (Plug-ins / Downloads: plug-ins + sample packs)+// Devices (Audio / MIDI / Gamepads / Remote), Plug-ins (Plug-ins / Downloads: plug-ins + sample packs)// and General (Library / Appearance / Shortcuts), and a content pane per section under a// title + subtitle header. Audio device / sample-rate / buffer are persisted natively (audio.json)// and applied by restarting the backend (MainWindowViewModel.ApplyAudioSettings); scan@@ -64,6 +64,7 @@ public sealed partial class PreferencesWindow : NotaWindownew Page("Audio", "Device, sample rate and buffer", "M4 10 V14 M8 7 V17 M12 4 V20 M16 8 V16 M20 11 V13"),new Page("MIDI", "Controllers Nota listens to", "M4 5 H20 V19 H4 Z M8 5 V13 M12 5 V13 M16 5 V13"),new Page("Gamepads", "Play notes or drive mapped controls", "M7 8 H17 A4 4 0 0 1 21 12 V13 A4 4 0 0 1 14 16 H10 A4 4 0 0 1 3 13 V12 A4 4 0 0 1 7 8 Z M7 11 V13 M6 12 H8 M16 11.5 H16.01 M18 12.5 H18.01"),+ new Page("Remote", "Phones and tablets on this network", "M8 3 H16 A1.5 1.5 0 0 1 17.5 4.5 V19.5 A1.5 1.5 0 0 1 16 21 H8 A1.5 1.5 0 0 1 6.5 19.5 V4.5 A1.5 1.5 0 0 1 8 3 Z M11 18 H13"),}),("PLUG-INS", new[]{@@ -257,9 +258,10 @@ public sealed partial class PreferencesWindow : NotaWindow0 => AudioPane(),1 => MidiPane(),2 => GamepadsPane(),- 3 => PluginsPane(),- 5 => LibraryPane(),- 6 => AppearancePane(),+ RemoteIndex => RemotePane(),+ 4 => PluginsPane(),+ 6 => LibraryPane(),+ 7 => AppearancePane(),_ => ShortcutsPane(),};diff --git a/src/managed/Nota.App/Remote/ConnectPhoneView.cs b/src/managed/Nota.App/Remote/ConnectPhoneView.csnew file mode 100644index 00000000..012ba9f3--- /dev/null+++ b/src/managed/Nota.App/Remote/ConnectPhoneView.cs@@ -0,0 +1,189 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Connect Phone (design 5a): the popup under the top bar's Remote button and View → Connect+// Phone…. One switch when Remote is off; when on, a large QR, the address and the four-digit+// code with its countdown ring, then the connected phones (signal, name, latency and screen,+// the track each plays, ✕ to drop it).++using System;+using System.Collections.Generic;+using System.Linq;+using Avalonia;+using Avalonia.Controls;+using Avalonia.Controls.Shapes;+using Avalonia.Input;+using Avalonia.Layout;+using Avalonia.Media;+using Avalonia.Threading;+using Nota.Application;+using Nota.Remote;++namespace Nota.App;++internal sealed class ConnectPhoneView : Border+{+ private readonly RemoteService _remote;+ private readonly ISettingsService _settings;+ private readonly IAudioEngine _engine;+ private readonly StackPanel _body = new();+ private readonly DispatcherTimer _timer = new() { Interval = TimeSpan.FromSeconds(1) };+ private QrView? _qr;+ private TextBlock? _code, _left;+ private Arc? _ring;+ private string _lastDevices = "";++ public ConnectPhoneView(RemoteService remote, ISettingsService settings, IAudioEngine engine)+ {+ _remote = remote;+ _settings = settings;+ _engine = engine;+ Width = 400;+ Background = NotaPalette.SurfaceRaised;+ BorderBrush = NotaPalette.BorderStrong;+ BorderThickness = new Thickness(1);+ CornerRadius = NotaRadius.Body;+ ClipToBounds = true;+ Child = _body;++ _timer.Tick += (_, _) => Tick();+ AttachedToVisualTree += (_, _) => { _remote.Changed += OnChanged; _timer.Start(); Build(); };+ DetachedFromVisualTree += (_, _) => { _remote.Changed -= OnChanged; _timer.Stop(); };+ }++ private void OnChanged() => Dispatcher.UIThread.Post(() =>+ {+ // The code rotating or a phone's latency moving only updates text; a phone coming or+ // going rebuilds the list.+ string sig = string.Join("|", _remote.Hub.Devices.Select(d => $"{d.ConnectionId}:{d.Name}:{d.TrackId}"));+ if (sig != _lastDevices || _qr is null != !_remote.Running) Build();+ else Tick();+ });++ private void Build()+ {+ _body.Children.Clear();+ _qr = null; _code = _left = null; _ring = null;+ bool on = _settings.Current.RemoteEnabled;++ var title = new TextBlock { Text = "Connect Phone", FontSize = 13, FontWeight = FontWeight.SemiBold, Foreground = NotaPalette.TextPrimary, VerticalAlignment = VerticalAlignment.Center };+ var sw = new ToggleSwitch(on) { VerticalAlignment = VerticalAlignment.Center };+ sw.Changed += v => { _settings.Current.RemoteEnabled = v; _settings.Save(); _ = _remote.ApplyAsync(); };+ var allow = new TextBlock { Text = "Allow", FontSize = 11, Foreground = NotaPalette.TextSecondary, VerticalAlignment = VerticalAlignment.Center };+ var head = new Grid { ColumnDefinitions = new ColumnDefinitions("*,Auto,Auto"), ColumnSpacing = 7, Margin = new Thickness(18, 16, 18, 12) };+ head.Children.Add(title);+ Grid.SetColumn(sw, 1); head.Children.Add(sw);+ Grid.SetColumn(allow, 2); head.Children.Add(allow);+ _body.Children.Add(head);++ if (!on)+ {+ _body.Children.Add(Note(OperatingSystem.IsMacOS()+ ? "Remote is off. Turn it on to show a QR code. The first time, macOS asks to allow Nota on the local network; click Allow."+ : OperatingSystem.IsWindows()+ ? "Remote is off. Turn it on to show a QR code. The first time, Windows asks whether Nota may use the network; allow private networks."+ : "Remote is off. Turn it on to show a QR code a phone on the same Wi-Fi can scan.", new Thickness(18, 0, 18, 18)));+ _lastDevices = "";+ return;+ }+ if (_remote.Error is { } err)+ {+ _body.Children.Add(Note(err, new Thickness(18, 0, 18, 18), NotaPalette.DangerBright));+ return;+ }+ if (_remote.Url is null)+ {+ _body.Children.Add(Note("This computer isn't on a network. Join the same Wi-Fi as the phone, or share the phone's hotspot with it.", new Thickness(18, 0, 18, 18)));+ return;+ }++ _qr = new QrView { Width = 150, Height = 150, Text = _remote.QrText };+ var info = new StackPanel { Spacing = 10 };+ info.Children.Add(Field("ADDRESS", new TextBlock { Text = _remote.Url!.Replace("http://", ""), FontSize = 13, FontFamily = NotaFonts.MonoFamily, Foreground = NotaPalette.TextPrimary }));+ _code = new TextBlock { FontSize = 24, FontWeight = FontWeight.Medium, LetterSpacing = 4.8, FontFamily = NotaFonts.MonoFamily, Foreground = NotaPalette.TextHeading, VerticalAlignment = VerticalAlignment.Center };+ _ring = new Arc { Width = 20, Height = 20, StrokeThickness = 2.5, Stroke = NotaPalette.AccentDim, StartAngle = -90, VerticalAlignment = VerticalAlignment.Center };+ var ringBack = new Ellipse { Width = 20, Height = 20, StrokeThickness = 2.5, Stroke = NotaPalette.TrackOff };+ _left = new TextBlock { FontSize = 10, FontFamily = NotaFonts.MonoFamily, Foreground = NotaPalette.TextTertiary, VerticalAlignment = VerticalAlignment.Center };+ var codeRow = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 10, Children = { _code, new Panel { Children = { ringBack, _ring } }, _left } };+ info.Children.Add(Field("CODE", codeRow));+ info.Children.Add(Note("Point the phone camera at the code. Same Wi-Fi only; the code changes every 2 minutes and after each connection.", new Thickness(0)));+ var top = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*"), ColumnSpacing = 16, Margin = new Thickness(18, 0, 18, 16) };+ top.Children.Add(_qr);+ Grid.SetColumn(info, 1); top.Children.Add(info);+ _body.Children.Add(top);++ var devices = _remote.Hub.Devices;+ _lastDevices = string.Join("|", devices.Select(d => $"{d.ConnectionId}:{d.Name}:{d.TrackId}"));+ if (devices.Count > 0)+ {+ var list = new StackPanel();+ for (int i = 0; i < devices.Count; i++) list.Children.Add(DeviceRow(devices[i], i > 0));+ _body.Children.Add(new Border { BorderBrush = NotaPalette.BorderDefault, BorderThickness = new Thickness(0, 1, 0, 0), Child = list });+ }+ Tick();+ }++ private Control DeviceRow(RemoteDeviceInfo d, bool rule)+ {+ bool weak = d.RttMs > 50;+ var c = weak ? NotaPalette.Warning : NotaPalette.SuccessDim;+ int bars = d.RttMs < 0 ? 1 : d.RttMs <= 20 ? 3 : d.RttMs <= 50 ? 2 : 1;+ var sig = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 2, VerticalAlignment = VerticalAlignment.Center, Height = 12 };+ for (int b = 0; b < 3; b++)+ sig.Children.Add(new Border { Width = 3, Height = 4 + b * 4, CornerRadius = NotaRadius.Bar, VerticalAlignment = VerticalAlignment.Bottom, Background = b < bars ? c : NotaPalette.BorderStrong });++ string sub = d.RttMs < 0 ? "connecting" : weak ? $"{d.RttMs} ms · weak network" : $"{d.RttMs} ms · {(d.Screen.Length > 0 ? d.Screen : "connected")}";+ var names = new StackPanel { Spacing = 1, VerticalAlignment = VerticalAlignment.Center };+ names.Children.Add(new TextBlock { Text = d.Name, FontSize = 12, FontWeight = FontWeight.Medium, Foreground = NotaPalette.TextPrimary, TextTrimming = TextTrimming.CharacterEllipsis });+ names.Children.Add(new TextBlock { Text = sub, FontSize = 10, FontFamily = NotaFonts.MonoFamily, Foreground = weak ? NotaPalette.Warning : NotaPalette.TextTertiary });++ var trackBar = new Border { Width = 4, Height = 18, CornerRadius = NotaRadius.Clip, VerticalAlignment = VerticalAlignment.Center, Background = d.TrackId > 0 ? TrackColorBrush(d.TrackId) : NotaPalette.BorderStrong };+ var trackName = new TextBlock { Text = d.TrackId > 0 ? _engine.GetTrackName(d.TrackId) : "—", FontSize = 11, Foreground = NotaPalette.TextSecondary, Width = 70, VerticalAlignment = VerticalAlignment.Center, TextTrimming = TextTrimming.CharacterEllipsis };++ var x = new Border+ {+ Width = 26, Height = 26, CornerRadius = NotaRadius.Tile, Background = Brushes.Transparent, Cursor = new Cursor(StandardCursorType.Hand),+ Child = new Glyph(GlyphKind.Close, 9) { Foreground = NotaPalette.TextMuted, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center },+ };+ ToolTip.SetTip(x, "Disconnect this phone (it stays trusted — forget it in Settings → Remote)");+ x.PointerEntered += (_, _) => x.Background = NotaPalette.SurfaceHover;+ x.PointerExited += (_, _) => x.Background = Brushes.Transparent;+ int conn = d.ConnectionId;+ x.PointerPressed += (_, e) => { if (e.GetCurrentPoint(x).Properties.IsLeftButtonPressed) { _remote.Hub.Disconnect(conn); e.Handled = true; } };++ var g = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto,Auto,Auto"), ColumnSpacing = 10, Height = 46, Margin = new Thickness(18, 0) };+ g.Children.Add(sig);+ Grid.SetColumn(names, 1); g.Children.Add(names);+ Grid.SetColumn(trackBar, 2); g.Children.Add(trackBar);+ Grid.SetColumn(trackName, 3); g.Children.Add(trackName);+ Grid.SetColumn(x, 4); g.Children.Add(x);+ return new Border { BorderBrush = NotaPalette.BorderDefault, BorderThickness = new Thickness(0, rule ? 1 : 0, 0, 0), Child = g };+ }++ private IBrush TrackColorBrush(int trackId) => ArrangementView.TrackBrush(ArrangementView.EffectiveColorIndex(_engine, trackId));++ // The code and its countdown move every second; the QR follows the code.+ private void Tick()+ {+ if (_code is null || _left is null || _ring is null || _qr is null) return;+ _code.Text = _remote.Pairing.Code;+ _qr.Text = _remote.QrText;+ var left = _remote.Pairing.CodeRemaining;+ _left.Text = $"{(int)left.TotalMinutes}:{left.Seconds:00}";+ _ring.SweepAngle = 360 * left.TotalSeconds / RemotePairing.CodeLifetime.TotalSeconds;+ }++ private static Control Field(string label, Control value)+ {+ var s = new StackPanel { Spacing = 3 };+ s.Children.Add(new TextBlock { Text = label, FontSize = 9, FontWeight = FontWeight.Bold, LetterSpacing = 1.1, Foreground = NotaPalette.TextTertiary });+ s.Children.Add(value);+ return s;+ }++ private static TextBlock Note(string text, Thickness margin, IBrush? ink = null) => new()+ {+ Text = text, FontSize = 11, LineHeight = 16.5, TextWrapping = TextWrapping.Wrap,+ Foreground = ink ?? NotaPalette.TextMuted, Margin = margin,+ };+}diff --git a/src/managed/Nota.App/Remote/QrView.cs b/src/managed/Nota.App/Remote/QrView.csnew file mode 100644index 00000000..507ec850--- /dev/null+++ b/src/managed/Nota.App/Remote/QrView.cs@@ -0,0 +1,63 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// A QR code drawn as geometry. Phone cameras read dark modules on a light ground reliably and+// an inverted code poorly, so the tile is light in both variants: Ink 0 under Graphite, Raised+// under Paper, with the modules in the opposite ink. Colours are read at render time.++using Avalonia;+using Avalonia.Controls;+using Avalonia.Media;+using Avalonia.Styling;+using Net.Codecrete.QrCodeGenerator;++namespace Nota.App;++internal sealed class QrView : Control+{+ private QrCode? _qr;+ private string? _text;++ public string? Text+ {+ get => _text;+ set+ {+ if (_text == value) return;+ _text = value;+ _qr = string.IsNullOrEmpty(value) ? null : QrCode.EncodeText(value, QrCode.Ecc.Medium);+ InvalidateVisual();+ }+ }++ public override void Render(DrawingContext ctx)+ {+ bool dark = Avalonia.Application.Current?.ActualThemeVariant != ThemeVariant.Light;+ var ground = dark ? NotaPalette.TextHeading : NotaPalette.SurfaceRaised;+ var ink = dark ? NotaPalette.BgApp : NotaPalette.TextHeading;+ var r = new Rect(Bounds.Size);+ ctx.DrawRectangle(ground, null, r, NotaRadius.Panel.TopLeft, NotaRadius.Panel.TopLeft);+ if (_qr is null) return;++ const int quiet = 3; // modules of margin; the tile's own padding adds the rest+ int n = _qr.Size + quiet * 2;+ double cell = System.Math.Floor(System.Math.Min(r.Width, r.Height) / n * 4) / 4;+ double ox = (r.Width - cell * _qr.Size) / 2, oy = (r.Height - cell * _qr.Size) / 2;+ var geo = new StreamGeometry();+ using (var g = geo.Open())+ {+ for (int y = 0; y < _qr.Size; y++)+ for (int x = 0; x < _qr.Size; x++)+ {+ if (!_qr.GetModule(x, y)) continue;+ double px = ox + x * cell, py = oy + y * cell;+ g.BeginFigure(new Point(px, py), true);+ g.LineTo(new Point(px + cell, py));+ g.LineTo(new Point(px + cell, py + cell));+ g.LineTo(new Point(px, py + cell));+ g.EndFigure(true);+ }+ }+ ctx.DrawGeometry(ink, null, geo);+ }+}diff --git a/src/managed/Nota.App/Remote/RemoteService.cs b/src/managed/Nota.App/Remote/RemoteService.csnew file mode 100644index 00000000..205d1f57--- /dev/null+++ b/src/managed/Nota.App/Remote/RemoteService.cs@@ -0,0 +1,126 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Owns Nota Remote's server, hub and pairing for the app, and keeps the server in step with+// Settings → Remote (on/off, port, access). The window ticks the hub on its UI clock and is+// its IRemoteHost; this class is what the top-bar button, the Connect Phone popup and the+// Settings page talk to.++using System;+using System.Diagnostics;+using System.IO;+using System.Threading.Tasks;+using Nota.Application;+using Nota.Infrastructure;+using Nota.Remote;++namespace Nota.App;++public sealed class RemoteService+{+ private readonly ISettingsService _settings;+ private readonly ILogSink _log;+ private readonly RemoteServer _server = new();++ public RemoteHub Hub { get; }+ public RemotePairing Pairing { get; }++ /// <summary>Started, stopped, failed, a phone came or went, the code rotated.</summary>+ public event Action? Changed;++ public bool Running => _server.Running;+ /// <summary>Why the server isn't running although Remote is on (the port is taken…).</summary>+ public string? Error { get; private set; }++ public RemoteService(IAudioEngine engine, ISettingsService settings, ILogSink log)+ {+ _settings = settings;+ _log = log;+ Pairing = new RemotePairing(Path.Combine(NotaPaths.SubDir("remote"), "trusted.json"));+ Hub = new RemoteHub(engine, Pairing)+ {+ Access = () => _settings.Current.RemoteAccess == 0 ? RemoteAccess.PlayNotes : RemoteAccess.Control,+ HostName = ComputerName(),+ };+ Pairing.Changed += RaiseChanged;+ }++ public void RaiseChanged() => Changed?.Invoke();++ /// <summary>The address a phone opens: http://192.168.1.5:7788 (null without a network).</summary>+ public string? Url+ {+ get+ {+ var ip = RemoteServer.LanAddress();+ return ip is null ? null : $"http://{ip}:{_server.Port}";+ }+ }++ /// <summary>What the QR holds: the address with the current code in the fragment, so the+ /// phone pairs the moment the page opens (a fragment never leaves the phone).</summary>+ public string? QrText => Url is { } u ? $"{u}/#p={Pairing.Code}" : null;++ /// <summary>Reconcile the server with Settings.</summary>+ public async Task ApplyAsync()+ {+ var s = _settings.Current;+ try+ {+ if (s.RemoteEnabled && _server.Running && _server.Port != s.RemotePort)+ {+ Hub.DisconnectAll();+ await _server.StopAsync();+ }+ if (s.RemoteEnabled && !_server.Running)+ {+ await _server.StartAsync(Hub, s.RemotePort);+ Error = null;+ _log.Info($"Nota Remote listening on port {s.RemotePort} ({Url ?? "no network"})");+ }+ else if (!s.RemoteEnabled && _server.Running)+ {+ Hub.DisconnectAll();+ await _server.StopAsync();+ Error = null;+ _log.Info("Nota Remote stopped");+ }+ }+ catch (Exception e)+ {+ Error = e is IOException || e.InnerException is System.Net.Sockets.SocketException+ ? $"Port {s.RemotePort} is in use by another app. Pick another port."+ : e.Message;+ _log.Error($"Nota Remote: {e.Message}");+ }+ RaiseChanged();+ }++ /// <summary>Stop on quit, releasing every phone's held notes before the engine goes.</summary>+ public async Task ShutdownAsync()+ {+ Hub.DisconnectAll();+ await _server.StopAsync();+ }++ // The name people know the computer by ("Studio Mac"), not its network host name.+ private static string ComputerName()+ {+ if (OperatingSystem.IsMacOS())+ {+ try+ {+ using var p = Process.Start(new ProcessStartInfo("/usr/sbin/scutil", "--get ComputerName")+ { RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true });+ if (p is not null)+ {+ string name = p.StandardOutput.ReadToEnd().Trim();+ p.WaitForExit(1000);+ if (name.Length > 0) return name;+ }+ }+ catch { /* fall back to the host name */ }+ }+ return Environment.MachineName;+ }+}diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axamlindex 54ed3f08..c7d92881 100644--- a/src/managed/Nota.App/Theme/NotaTheme.axaml+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml@@ -527,6 +527,18 @@<Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.AccentBright}"/></Style>+ <!-- A chip lit by a running feature (Remote on): the engaged look, without being a toggle. -->+ <Style Selector="Button.chip.lit">+ <Setter Property="Foreground" Value="{DynamicResource Brush.AccentBright}"/>+ <Setter Property="Background" Value="{DynamicResource Brush.AccentSubtle}"/>+ <Setter Property="BorderBrush" Value="{DynamicResource Brush.BorderBrass}"/>+ </Style>+ <Style Selector="Button.chip.lit /template/ ContentPresenter#PART_ContentPresenter">+ <Setter Property="Background" Value="{DynamicResource Brush.AccentSubtle}"/>+ <Setter Property="BorderBrush" Value="{DynamicResource Brush.BorderBrass}"/>+ <Setter Property="TextElement.Foreground" Value="{DynamicResource Brush.AccentBright}"/>+ </Style>+<!-- bg-sunken well (position / BPM / time-sig) --><Style Selector="Border.well"><Setter Property="BoxShadow" Value="{DynamicResource Shadow.Sunken}"/>@@ -1117,6 +1129,14 @@<Setter Property="CornerRadius" Value="{StaticResource Radius.Control}"/><Setter Property="Padding" Value="4"/></Style>+ <!-- A flyout whose content draws its own card (Connect Phone): no Fluent frame around it. -->+ <Style Selector="FlyoutPresenter.bare">+ <Setter Property="Background" Value="Transparent"/>+ <Setter Property="BorderThickness" Value="0"/>+ <Setter Property="Padding" Value="0"/>+ <Setter Property="MaxWidth" Value="480"/>+ <Setter Property="MaxHeight" Value="720"/>+ </Style><Style Selector="ContextMenu"><Setter Property="Background" Value="{DynamicResource Brush.SurfaceCard}"/><Setter Property="BorderBrush" Value="{DynamicResource Brush.BorderDefault}"/>diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.csindex a682ab5d..6d0d811d 100644--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs@@ -686,6 +686,10 @@ public interface IAudioEngine : IDisposablevoid SetTrackArmed(int trackId, bool armed);void NoteOn(int pitch, float velocity);void NoteOff(int pitch);+ /// <summary>A live note addressed to one track, armed or not (Nota Remote: each phone plays+ /// its own track). Recorded when that track holds the take. Safe to call from any thread.</summary>+ void TrackNoteOn(int trackId, int pitch, float velocity);+ void TrackNoteOff(int trackId, int pitch);/// <summary>Live notes also reach this track when unarmed (rack/drum pad audition). -1 = none.</summary>void SetAuditionTrack(int trackId);void SetRecording(bool enabled);diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.csindex befb38fb..04db128e 100644--- a/src/managed/Nota.Application/Settings.cs+++ b/src/managed/Nota.Application/Settings.cs@@ -41,6 +41,15 @@ public sealed class Settingspublic bool McpEnabled { get; set; }/// <summary>Loopback TCP port for the MCP HTTP server.</summary>public int McpPort { get; set; } = 3900;+ /// <summary>Nota Remote: serve the phone controller on the local network. Off by default;+ /// phones pair with a code from the QR. See Settings → Remote.</summary>+ public bool RemoteEnabled { get; set; }+ /// <summary>TCP port Nota Remote listens on (all interfaces).</summary>+ public int RemotePort { get; set; } = 7788;+ /// <summary>What a phone may do: 0 play notes only, 1 also control the project (mixer,+ /// transport, macros, XY, Session).</summary>+ public int RemoteAccess { get; set; } = 1;+/// <summary>Use a connected gamepad as a live note source. Off by default; the/// pads play through the armed/audition instrument track like the computer/// keyboard. See Preferences → Gamepads.</summary>diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.csindex b71d7cbb..96938e28 100644--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.cs+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.cs@@ -105,6 +105,12 @@ internal static partial class NativeMethods[LibraryImport(Lib, EntryPoint = "nota_engine_note_off")]internal static partial NotaResult NoteOff(IntPtr engine, int pitch);+ [LibraryImport(Lib, EntryPoint = "nota_track_note_on")]+ internal static partial NotaResult TrackNoteOn(IntPtr engine, int trackId, int pitch, float velocity);++ [LibraryImport(Lib, EntryPoint = "nota_track_note_off")]+ internal static partial NotaResult TrackNoteOff(IntPtr engine, int trackId, int pitch);+[LibraryImport(Lib, EntryPoint = "nota_engine_set_audition_track")]internal static partial void SetAuditionTrack(IntPtr engine, int trackId);diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.csindex eaab3492..8f00c877 100644--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.cs+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.cs@@ -110,6 +110,8 @@ public sealed partial class NotaEngine : IAudioEnginepublic void SetTrackArmed(int trackId, bool armed) { ThrowIfDisposed(); Check(NativeMethods.SetTrackArmed(_handle, trackId, armed ? 1 : 0)); }public void NoteOn(int pitch, float velocity) { ThrowIfDisposed(); Check(NativeMethods.NoteOn(_handle, pitch, velocity)); }public void NoteOff(int pitch) { ThrowIfDisposed(); Check(NativeMethods.NoteOff(_handle, pitch)); }+ public void TrackNoteOn(int trackId, int pitch, float velocity) { ThrowIfDisposed(); Check(NativeMethods.TrackNoteOn(_handle, trackId, pitch, velocity)); }+ public void TrackNoteOff(int trackId, int pitch) { ThrowIfDisposed(); Check(NativeMethods.TrackNoteOff(_handle, trackId, pitch)); }public void SetAuditionTrack(int trackId) { ThrowIfDisposed(); NativeMethods.SetAuditionTrack(_handle, trackId); }public void SetRecording(bool enabled) { ThrowIfDisposed(); Check(NativeMethods.SetRecording(_handle, enabled ? 1 : 0)); }public bool IsRecording { get { ThrowIfDisposed(); return NativeMethods.IsRecording(_handle) != 0; } }diff --git a/src/managed/Nota.Remote/Nota.Remote.csproj b/src/managed/Nota.Remote/Nota.Remote.csprojnew file mode 100644index 00000000..879c932c--- /dev/null+++ b/src/managed/Nota.Remote/Nota.Remote.csproj@@ -0,0 +1,50 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Nota Remote: serves the phone controller (a small PWA, built from src/web/remote) over the+ local network and keeps a WebSocket with every paired phone. Kept free of Avalonia like+ Nota.Mcp — the UI-thread side (transport view-model, MIDI Learn, refresh) is injected+ through IRemoteHost, implemented by Nota.App. -->+<Project Sdk="Microsoft.NET.Sdk">++ <PropertyGroup>+ <TargetFramework>net10.0</TargetFramework>+ <ImplicitUsings>enable</ImplicitUsings>+ <Nullable>enable</Nullable>+ <LangVersion>latest</LangVersion>+ </PropertyGroup>++ <ItemGroup>+ <FrameworkReference Include="Microsoft.AspNetCore.App" />+ </ItemGroup>++ <ItemGroup>+ <ProjectReference Include="..\Nota.Application\Nota.Application.csproj" />+ </ItemGroup>++ <!-- The phone app. `npm run build` in src/web/remote writes into wwwroot/; the files are+ embedded so the app ships as one assembly and needs no web root on disk. The build+ runs when its sources are newer than the output (and node is available); a checkout+ without node still builds and serves a page saying the controller wasn't built. -->+ <PropertyGroup>+ <RemoteWebDir>$(MSBuildProjectDirectory)/../../web/remote</RemoteWebDir>+ <RemoteWwwRoot>$(MSBuildProjectDirectory)/wwwroot</RemoteWwwRoot>+ </PropertyGroup>+ <ItemGroup>+ <RemoteWebSources Include="$(RemoteWebDir)/src/**/*;$(RemoteWebDir)/public/**/*;$(RemoteWebDir)/index.html;$(RemoteWebDir)/package.json;$(RemoteWebDir)/vite.config.ts" />+ </ItemGroup>+ <Target Name="BuildRemoteWeb" Inputs="@(RemoteWebSources)" Outputs="$(RemoteWwwRoot)/index.html"+ Condition="Exists('$(RemoteWebDir)/package.json') and '$(NotaSkipWebBuild)' != 'true' and '$(DesignTimeBuild)' != 'true'">+ <Exec Command="node --version" ContinueOnError="true" StandardOutputImportance="low">+ <Output TaskParameter="ExitCode" PropertyName="NodeExit" />+ </Exec>+ <Warning Condition="'$(NodeExit)' != '0'" Text="Node.js not found: the Nota Remote phone page is not built (install Node 20+ and rebuild)." />+ <Exec Condition="'$(NodeExit)' == '0' and !Exists('$(RemoteWebDir)/node_modules')" WorkingDirectory="$(RemoteWebDir)" Command="npm ci --no-audit --no-fund" />+ <Exec Condition="'$(NodeExit)' == '0'" WorkingDirectory="$(RemoteWebDir)" Command="npm run build" />+ </Target>+ <Target Name="EmbedRemoteWeb" BeforeTargets="BeforeBuild" DependsOnTargets="BuildRemoteWeb">+ <ItemGroup>+ <_RemoteWeb Include="$(RemoteWwwRoot)/**/*" />+ <EmbeddedResource Include="@(_RemoteWeb)" LogicalName="wwwroot/%(_RemoteWeb.RecursiveDir)%(_RemoteWeb.Filename)%(_RemoteWeb.Extension)" />+ </ItemGroup>+ </Target>++</Project>diff --git a/src/managed/Nota.Remote/RemoteClient.cs b/src/managed/Nota.Remote/RemoteClient.csnew file mode 100644index 00000000..8838804e--- /dev/null+++ b/src/managed/Nota.Remote/RemoteClient.cs@@ -0,0 +1,171 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// One connected phone. Its socket is read on a Kestrel thread: notes go straight to the engine+// from there (the engine's track-note entry is thread-safe), so a pad hit never waits for the UI+// tick; everything else is queued for the hub's UI-thread tick. Outgoing messages go through a+// channel drained by a single send loop, because a WebSocket allows one sender at a time.++using System.Net.WebSockets;+using System.Text;+using System.Text.Json;+using System.Threading.Channels;++namespace Nota.Remote;++public sealed class RemoteClient+{+ private static int _nextId;++ private readonly WebSocket _ws;+ private readonly Channel<byte[]> _out = Channel.CreateUnbounded<byte[]>(new UnboundedChannelOptions { SingleReader = true });+ private readonly object _notesGate = new();+ private readonly Dictionary<int, int> _held = new(); // pitch → track it started on++ public int ConnectionId { get; } = Interlocked.Increment(ref _nextId);+ public string Address { get; }+ public DateTime ConnectedAt { get; } = DateTime.UtcNow;++ /// <summary>The trusted device behind this connection (null until it says hello or pairs).</summary>+ public TrustedDevice? Device { get; internal set; }+ public string Name { get; internal set; } = "Phone";+ public string Model { get; internal set; } = "";++ /// <summary>The track this phone plays (0 = none yet). Read on the socket thread for notes.</summary>+ public volatile int TrackId;+ /// <summary>Where the track sat in the list, so a deleted track hands over to its neighbour.</summary>+ public int LastTrackIndex;+ /// <summary>The track follows Nota's selection.</summary>+ public volatile bool Follow;+ /// <summary>The screen the phone shows: what state it needs pushed.</summary>+ public volatile string Screen = "";+ /// <summary>The Macros screen's device (index into the track's macro devices).</summary>+ public int MacroDevice;+ /// <summary>Round-trip time the phone measured, ms (−1 = not yet).</summary>+ public volatile int RttMs = -1;+ public long LastActivityTicks;++ // What this phone was last sent, so a tick only sends what changed.+ internal string? SentProject;+ internal string? SentWho;+ internal string? SentTransport;+ internal string? SentLit;+ internal string? SentLearn;+ internal string? SentScreenState;++ public bool Authenticated => Device is not null;++ internal RemoteClient(WebSocket ws, string address)+ {+ _ws = ws;+ Address = address;+ }++ /// <summary>Queue a message. Dropped when the phone has stopped reading (a stale socket).</summary>+ public void Send(byte[] utf8Json)+ {+ if (_ws.State == WebSocketState.Open) _out.Writer.TryWrite(utf8Json);+ }++ public void Send(string json) => Send(Encoding.UTF8.GetBytes(json));++ /// <summary>Messages waiting to go out — the hub skips a phone's state tick while it lags.</summary>+ public int Backlog => _out.Reader.CanCount ? _out.Reader.Count : 0;++ internal async Task SendLoopAsync(CancellationToken ct)+ {+ try+ {+ await foreach (var msg in _out.Reader.ReadAllAsync(ct))+ {+ if (_ws.State != WebSocketState.Open) break;+ await _ws.SendAsync(msg, WebSocketMessageType.Text, true, ct);+ }+ }+ catch (OperationCanceledException) { }+ catch (WebSocketException) { }+ }++ internal void CompleteSend() => _out.Writer.TryComplete();++ /// <summary>Reads whole text messages until the socket closes.</summary>+ internal async Task ReceiveLoopAsync(Func<RemoteClient, JsonElement, Task> onMessage, CancellationToken ct)+ {+ var buf = new byte[16 * 1024];+ try+ {+ while (_ws.State == WebSocketState.Open && !ct.IsCancellationRequested)+ {+ int len = 0;+ WebSocketReceiveResult r;+ do+ {+ if (len == buf.Length) { await CloseAsync(WebSocketCloseStatus.MessageTooBig, "too big"); return; }+ r = await _ws.ReceiveAsync(new ArraySegment<byte>(buf, len, buf.Length - len), ct);+ if (r.MessageType == WebSocketMessageType.Close) return;+ len += r.Count;+ } while (!r.EndOfMessage);+ if (r.MessageType != WebSocketMessageType.Text) continue;++ JsonDocument doc;+ try { doc = JsonDocument.Parse(buf.AsMemory(0, len)); }+ catch (JsonException) { continue; }+ using (doc)+ {+ if (doc.RootElement.ValueKind == JsonValueKind.Object)+ await onMessage(this, doc.RootElement);+ }+ }+ }+ catch (OperationCanceledException) { }+ catch (WebSocketException) { }+ }++ public async Task CloseAsync(WebSocketCloseStatus status, string reason)+ {+ CompleteSend();+ try+ {+ if (_ws.State is WebSocketState.Open or WebSocketState.CloseReceived)+ await _ws.CloseOutputAsync(status, reason, CancellationToken.None);+ }+ catch { /* already gone */ }+ }++ // ---- held notes ---------------------------------------------------------+ // A note-off goes to the track its note-on went to, so switching tracks (or another phone+ // deleting the track) mid-hold never hangs a note.++ /// <summary>Remember a note-on to <paramref name="track"/>. Returns the track of the same+ /// pitch's earlier note if it was still held (a retrigger), which must end first.</summary>+ internal int? NoteOn(int pitch, int track)+ {+ lock (_notesGate)+ {+ int? prev = _held.Remove(pitch, out int p) ? p : null;+ _held[pitch] = track;+ return prev;+ }+ }++ internal bool NoteOff(int pitch, out int track)+ {+ lock (_notesGate) return _held.Remove(pitch, out track);+ }++ /// <summary>Every note still held (the link dropped, or the phone left): release them.</summary>+ internal List<(int track, int pitch)> TakeAllHeld()+ {+ lock (_notesGate)+ {+ var list = _held.Select(kv => (kv.Value, kv.Key)).ToList();+ _held.Clear();+ return list;+ }+ }++ internal int[] HeldPitches()+ {+ lock (_notesGate) return _held.Keys.ToArray();+ }+}diff --git a/src/managed/Nota.Remote/RemoteContracts.cs b/src/managed/Nota.Remote/RemoteContracts.csnew file mode 100644index 00000000..9f71160a--- /dev/null+++ b/src/managed/Nota.Remote/RemoteContracts.cs@@ -0,0 +1,98 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.++namespace Nota.Remote;++/// <summary>The phone's mappable controls, in one id space so a MIDI Learn mapping needs only a+/// number. Stable: the ids are stored in the project's MIDI map. A mapping belongs to the control,+/// not to a phone, so every connected phone drives the same targets.</summary>+public static class PhoneControls+{+ public const int Macro1 = 1; // Macro 1..8 = 1..8+ public const int XyX = 20, XyY = 21;+ public const int TiltX = 30, TiltY = 31;++ public static bool IsMacro(int id) => id is >= 1 and <= 8;++ public static string Name(int id) => id switch+ {+ >= 1 and <= 8 => $"Macro {id}",+ XyX => "XY ←→",+ XyY => "XY ↑↓",+ TiltX => "Tilt ←→",+ TiltY => "Tilt ↑↓",+ _ => $"Control {id}",+ };+}++/// <summary>What a phone control's move did in MIDI Learn.</summary>+public enum PhoneControlResult+{+ /// <summary>No mapping: the control drives its default target.</summary>+ None,+ /// <summary>It bound the control Nota was waiting for.</summary>+ Bound,+ /// <summary>It drove a learned mapping.</summary>+ Mapped,+}++/// <summary>The app side of Nota Remote: everything that lives above the engine (the transport+/// view-model, MIDI Learn, the arrangement's sections, track colours, redraws). Implemented by+/// Nota.App. Every member is called on the UI thread, from <see cref="RemoteHub.Tick"/>.</summary>+public interface IRemoteHost+{+ /// <summary>The computer's name, as the phone shows it ("Reconnecting to Studio Mac…").</summary>+ string HostName { get; }+ /// <summary>Nota's palette, which the phone follows unless set to follow its own theme.</summary>+ bool DarkTheme { get; }+ /// <summary>The track's colour as Nota draws it, "#RRGGBB".</summary>+ string TrackColor(int trackId);+ /// <summary>The track selected in Nota (0 = none), for "Follow Nota's selection".</summary>+ int SelectedTrackId { get; }+ /// <summary>The project key as a <c>MusicalKey.Code</c>, −1 = none.</summary>+ int ProjectKeyCode { get; }+ /// <summary>The arrangement's sections (Intro, Verse…), in time order.</summary>+ IReadOnlyList<(string Name, double StartBeat)> Sections { get; }++ bool Recording { get; }+ bool LoopOn { get; }+ bool MetronomeOn { get; }+ void Play();+ void Stop();+ void SetRecord(bool on);+ void SetLoop(bool on);+ void SetLoopRange(double startBeat, double endBeat);+ void SetMetronome(bool on);+ void SetBpm(double bpm);+ /// <summary>Master gain, linear 0..1.5 — through the transport view-model so the bar's+ /// fader follows.</summary>+ double MasterVolume { get; set; }+ /// <summary>Undo one step, redrawing what it changed. False when there was nothing to undo.</summary>+ bool Undo();++ /// <summary>A phone changed something Nota draws (a mute, a macro, a launched clip): redraw.</summary>+ void Refresh();++ /// <summary>Nota's MIDI Learn is on.</summary>+ bool LearnArmed { get; }+ /// <summary>The control Nota is waiting to bind ("Reverb · Decay"), or null.</summary>+ string? LearnPendingName { get; }+ /// <summary>A phone control moved to <paramref name="norm"/> (0..1).</summary>+ PhoneControlResult PhoneControl(int controlId, double norm);+ /// <summary>The name of what a phone control is mapped to, or null when it isn't.</summary>+ string? PhoneMappingName(int controlId);++ /// <summary>A phone connected, left, renamed itself or switched track.</summary>+ void DevicesChanged();+ /// <summary>A phone sent something (the Remote button flashes, like the gamepad dot).</summary>+ void Activity();+}++/// <summary>Who may do what from a phone (Settings → Remote).</summary>+public enum RemoteAccess+{+ /// <summary>Pads and keys only. Mixer, transport and mappings are read-only.</summary>+ PlayNotes = 0,+ /// <summary>Also mixer, transport, macros, XY and Session.</summary>+ Control = 1,+}diff --git a/src/managed/Nota.Remote/RemoteHub.Apply.cs b/src/managed/Nota.Remote/RemoteHub.Apply.csnew file mode 100644index 00000000..76170fc8--- /dev/null+++ b/src/managed/Nota.Remote/RemoteHub.Apply.cs@@ -0,0 +1,202 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Applying phone commands, on the UI thread. The phone is one more controller: transport goes+// through Nota's transport view-model (so the bar mirrors it), faders and knobs are+// hardware-style gestures (latching automation while recording, an override otherwise), and a+// mapped control goes through MIDI Learn first, exactly like a gamepad stick.++using System.Text.Json;+using Nota.Application;++namespace Nota.Remote;++public sealed partial class RemoteHub+{+ private const float VolumeMax = 1.5f; // track / master fader travel (VFader.Max)+ private static readonly TimeSpan FaderHold = TimeSpan.FromMilliseconds(700);++ // Faders a phone is moving right now: another phone sees "Anna has it" on that fader.+ private readonly Dictionary<int, (int Conn, string Name, long Until)> _heldFaders = new();++ private static bool NeedsControl(string t) => t is not ("track" or "follow" or "sub" or "name");++ private void Apply(IRemoteHost host, RemoteClient c, RemoteCommand cmd)+ {+ if (NeedsControl(cmd.T) && Access() != RemoteAccess.Control)+ {+ Toast(c, "Nota lets this phone play notes only. Change it in Settings → Remote.");+ return;+ }++ switch (cmd.T)+ {+ case "track":+ if (TrackExists(cmd.Id) && cmd.Id != c.TrackId)+ {+ c.TrackId = cmd.Id;+ c.Follow = false;+ _devicesDirty = true;+ }+ break;+ case "follow":+ c.Follow = cmd.On;+ if (cmd.On && host.SelectedTrackId > 0) c.TrackId = host.SelectedTrackId;+ _devicesDirty = true;+ break;+ case "sub":+ c.Screen = cmd.S;+ c.MacroDevice = Math.Max(0, cmd.I);+ c.SentScreenState = null;+ _devicesDirty = true;+ break;+ case "name":+ if (c.Device is { } d)+ {+ Pairing.Rename(d.Id, cmd.S);+ c.Name = RemotePairing.CleanName(cmd.S);+ _devicesDirty = true;+ }+ break;++ // ---- transport ------------------------------------------------------+ case "play": host.Play(); break;+ case "stop": host.Stop(); break;+ case "rec": host.SetRecord(cmd.On); break;+ case "loop": host.SetLoop(cmd.On); break;+ case "met": host.SetMetronome(cmd.On); break;+ case "bpm": if (cmd.V is >= 20 and <= 300) host.SetBpm(Math.Round(cmd.V, 2)); break;+ case "seek": _engine.Seek(Math.Max(0, cmd.V)); break;+ case "loopRange":+ if (cmd.V2 > cmd.V)+ {+ host.SetLoopRange(Math.Max(0, cmd.V), cmd.V2);+ host.SetLoop(cmd.On);+ }+ break;+ case "undo":+ Toast(c, host.Undo() ? "Undone" : "Nothing to undo");+ break;++ // ---- mixer ----------------------------------------------------------+ case "vol":+ if (!TrackExists(cmd.Id)) break;+ _engine.BeginAutomationWrite(cmd.Id, AutomationTarget.Volume, -1, -1, "", latch: true);+ _engine.SetTrackVolume(cmd.Id, (float)Math.Clamp(cmd.V, 0, VolumeMax));+ HoldFader(c, cmd.Id, cmd.Phase);+ if (cmd.Phase == 2) host.Refresh();+ break;+ case "pan":+ if (!TrackExists(cmd.Id)) break;+ _engine.BeginAutomationWrite(cmd.Id, AutomationTarget.Pan, -1, -1, "", latch: true);+ _engine.SetTrackPan(cmd.Id, (float)Math.Clamp(cmd.V, -1, 1));+ if (cmd.Phase == 2) host.Refresh();+ break;+ case "mute": if (TrackExists(cmd.Id)) { _engine.SetTrackMute(cmd.Id, cmd.On); host.Refresh(); } break;+ case "solo": if (TrackExists(cmd.Id)) { _engine.SetTrackSolo(cmd.Id, cmd.On); host.Refresh(); } break;+ case "arm": if (TrackExists(cmd.Id)) { _engine.SetTrackArmed(cmd.Id, cmd.On); host.Refresh(); } break;+ case "mvol":+ host.MasterVolume = Math.Clamp(cmd.V, 0, VolumeMax);+ HoldFader(c, MasterFaderId, cmd.Phase);+ break;++ // ---- XY / tilt --------------------------------------------------------+ case "xy": ApplyXy(host, c, cmd); break;++ // ---- macros -----------------------------------------------------------+ case "mac":+ {+ int knob = cmd.I;+ if (knob is < 0 or > 7) break;+ var r = host.PhoneControl(PhoneControls.Macro1 + knob, cmd.V);+ if (r == PhoneControlResult.Bound) Learned(host, c, PhoneControls.Macro1 + knob);+ if (r != PhoneControlResult.None) break;+ var devs = MacroDevicesFor(c.TrackId);+ if (c.MacroDevice < devs.Count && knob < devs[c.MacroDevice].Params.Count)+ RemoteParams.Set(_engine, devs[c.MacroDevice].Params[knob], cmd.V);+ if (cmd.Phase == 2) host.Refresh();+ break;+ }++ // ---- session ------------------------------------------------------------+ case "launch": if (TrackExists(cmd.Id) && cmd.I >= 0 && cmd.I < _engine.SceneCount) _engine.LaunchSlot(cmd.Id, cmd.I); break;+ case "scene": if (cmd.I >= 0 && cmd.I < _engine.SceneCount) _engine.LaunchScene(cmd.I); break;+ case "stopSlot": if (TrackExists(cmd.Id)) _engine.StopSlot(cmd.Id); break;+ case "stopAll": _engine.StopAllSession(); break;+ }+ }++ private const int MasterFaderId = -1;++ private void HoldFader(RemoteClient c, int faderId, int phase)+ {+ if (phase == 2) { _heldFaders.Remove(faderId); return; }+ _heldFaders[faderId] = (c.ConnectionId, ShortName(c.Name), DateTime.UtcNow.Add(FaderHold).Ticks);+ }++ private void ExpireHeldFaders()+ {+ if (_heldFaders.Count == 0) return;+ long now = DateTime.UtcNow.Ticks;+ foreach (var k in _heldFaders.Where(kv => kv.Value.Until < now || !_clients.ContainsKey(kv.Value.Conn)).Select(kv => kv.Key).ToList())+ _heldFaders.Remove(k);+ }++ /// <summary>The XY pad or the tilt moved. A mapped axis drives its mapping; an unmapped one+ /// drives the pad's default pair. Tilt that isn't mapped of its own moves the pad's axes.+ /// <c>I</c>: 0 both axes, 1 X only, 2 Y only (in learn mode the phone sends the axis the+ /// finger actually moved, so one gesture binds one axis).</summary>+ private void ApplyXy(IRemoteHost host, RemoteClient c, RemoteCommand cmd)+ {+ bool tilt = cmd.S == "tilt";+ bool doX = cmd.I != 2, doY = cmd.I != 1;+ (RemoteParam X, RemoteParam Y)? def = null;+ bool defResolved = false;++ void Axis(bool isX, double v)+ {+ int ctl = tilt ? (isX ? PhoneControls.TiltX : PhoneControls.TiltY) : (isX ? PhoneControls.XyX : PhoneControls.XyY);+ var r = host.PhoneControl(ctl, v);+ if (r == PhoneControlResult.Bound) { Learned(host, c, ctl); return; }+ if (r == PhoneControlResult.Mapped) return;+ if (tilt)+ {+ // Unmapped tilt stands in for the finger on the pad.+ int xy = isX ? PhoneControls.XyX : PhoneControls.XyY;+ var r2 = host.PhoneControl(xy, v);+ if (r2 == PhoneControlResult.Bound) { Learned(host, c, xy); return; }+ if (r2 == PhoneControlResult.Mapped) return;+ }+ if (!defResolved) { def = RemoteParams.DefaultXy(_engine, c.TrackId); defResolved = true; }+ if (def is { } d) RemoteParams.Set(_engine, isX ? d.X : d.Y, v);+ }++ if (doX) Axis(true, Math.Clamp(cmd.V, 0, 1));+ if (doY) Axis(false, Math.Clamp(cmd.V2, 0, 1));+ if (cmd.Phase == 2) host.Refresh();+ }++ private void Learned(IRemoteHost host, RemoteClient c, int controlId)+ {+ string target = host.PhoneMappingName(controlId) ?? "";+ c.Send(Json(w =>+ {+ w.WriteString("t", "learned");+ w.WriteString("src", PhoneControls.Name(controlId));+ w.WriteString("dst", target);+ }));+ c.SentScreenState = null;+ }++ internal static void Toast(RemoteClient c, string msg)+ => c.Send(Json(w => { w.WriteString("t", "toast"); w.WriteString("msg", msg); }));++ private bool TrackExists(int trackId)+ {+ if (trackId <= 0) return false;+ int n = _engine.TrackCount;+ for (int i = 0; i < n; i++)+ if (_engine.TryGetTrackInfo(i, out var ti) && ti.Id == trackId) return true;+ return false;+ }+}diff --git a/src/managed/Nota.Remote/RemoteHub.State.cs b/src/managed/Nota.Remote/RemoteHub.State.csnew file mode 100644index 00000000..e6618989--- /dev/null+++ b/src/managed/Nota.Remote/RemoteHub.State.cs@@ -0,0 +1,466 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// What the phones are told, built on the UI tick. A Snapshot computes each piece at most once+// per tick and only when some phone needs it; each phone is sent a piece only when it differs+// from the last one it got. The project (tracks, key, sections) is re-read a few times a second,+// the transport every tick while playing, a screen's live state (mixer meters, XY values, knobs,+// clip states) at 15 Hz to the phones showing that screen.++using System.Globalization;+using System.Text.Json;+using Nota.Application;+using Nota.Application.Samples;++namespace Nota.Remote;++public sealed partial class RemoteHub+{+ private string? _projectJson; // shared part of the project message, re-read every few ticks+ private List<TrackRow> _tracks = new();+ private readonly Dictionary<(int Track, int Scene), double> _slotStart = new(); // session launch beat (progress)++ internal sealed record TrackRow(int Id, string Name, string Color, string Kind, string Device, int Group, int Index);++ private sealed class Snapshot(RemoteHub hub, IRemoteHost host)+ {+ private string? _transport, _mixer, _session, _learn;+ private readonly Dictionary<int, string> _lit = new();+ private readonly Dictionary<int, NotaNote[]> _clipNotes = new();+ public readonly double Pos = hub._engine.PositionBeats;+ public readonly bool Playing = hub._engine.IsPlaying;++ public string Transport => _transport ??= hub.BuildTransport(host);+ public string Mixer => _mixer ??= hub.BuildMixer(host);+ public string Session => _session ??= hub.BuildSession(this);+ public string Learn => _learn ??= Json(w =>+ {+ w.WriteString("t", "learn");+ w.WriteBoolean("on", host.LearnArmed);+ if (host.LearnPendingName is { } p) w.WriteString("pend", p); else w.WriteNull("pend");+ });+ public string Lit(int track) => _lit.TryGetValue(track, out var s) ? s : _lit[track] = hub.BuildLit(this, track);+ public NotaNote[] ClipNotes(int track, int clip)+ {+ int key = track * 4096 + clip;+ return _clipNotes.TryGetValue(key, out var n) ? n : _clipNotes[key] = hub._engine.GetClipNotes(track, clip);+ }+ }++ private void Push(IRemoteHost host, Snapshot snap, RemoteClient c)+ {+ if (_projectJson is null || _tick % 6 == 0) RefreshProject(host);+ ResolveTrack(host, c);++ string project = _projectJson + $",\"access\":\"{(Access() == RemoteAccess.Control ? "control" : "play")}\",\"you\":{c.TrackId},\"follow\":{(c.Follow ? "true" : "false")}}}";+ if (project != c.SentProject) { c.Send(project); c.SentProject = project; c.SentScreenState = null; }++ string who = BuildWho(c);+ if (who != c.SentWho) { c.Send(who); c.SentWho = who; }++ if (snap.Transport != c.SentTransport) { c.Send(snap.Transport); c.SentTransport = snap.Transport; }+ if (snap.Learn != c.SentLearn) { c.Send(snap.Learn); c.SentLearn = snap.Learn; }++ string screen = c.Screen;+ if (screen is "Pads" or "Keys" && c.TrackId > 0)+ {+ string lit = snap.Lit(c.TrackId);+ if (lit != c.SentLit) { c.Send(lit); c.SentLit = lit; }+ }++ // A screen's live state at 15 Hz (every other UI tick); a new screen gets it at once.+ if (c.SentScreenState is not null && (_tick & 1) == 1) return;+ string? state = screen switch+ {+ "Mixer" => snap.Mixer,+ "Scenes" => snap.Session,+ "XY" => BuildXy(host, snap, c),+ "Macros" => BuildMacros(host, c),+ _ => null,+ };+ if (state is not null && state != c.SentScreenState) { c.Send(state); c.SentScreenState = state; }+ else if (state is null) c.SentScreenState = "";+ }++ // ---- project ------------------------------------------------------------------++ private void RefreshProject(IRemoteHost host)+ {+ var rows = new List<TrackRow>();+ int n = _engine.TrackCount;+ for (int i = 0; i < n; i++)+ {+ if (!_engine.TryGetTrackInfo(i, out var ti)) continue;+ string kind = ti.IsGroup ? "group" : ti.IsReturn ? "return" : !ti.IsInstrument ? "audio"+ : _engine.TrackInstrumentKind(ti.Id) is RemoteParams.DrumRackKind or RemoteParams.RhythmKind ? "drum" : "inst";+ string dev = kind switch+ {+ "audio" => "Audio",+ "group" => "Group",+ "return" => "Return",+ _ => RemoteParams.InstrumentName(_engine, ti.Id),+ };+ rows.Add(new TrackRow(ti.Id, _engine.GetTrackName(ti.Id), host.TrackColor(ti.Id), kind, dev, ti.GroupId, i));+ }+ _tracks = rows;++ _projectJson = Json(w =>+ {+ w.WriteString("t", "proj");+ w.WriteString("host", HostName);+ w.WriteBoolean("dark", host.DarkTheme);+ w.WriteStartArray("tracks");+ foreach (var r in rows)+ {+ w.WriteStartObject();+ w.WriteNumber("id", r.Id);+ w.WriteString("name", r.Name.Length > 0 ? r.Name : $"Track {r.Index + 1}");+ w.WriteString("color", r.Color);+ w.WriteString("kind", r.Kind);+ w.WriteString("dev", r.Device);+ w.WriteNumber("grp", r.Group);+ if (r.Kind == "drum") WritePads(w, r.Id);+ w.WriteEndObject();+ }+ w.WriteEndArray();++ var key = MusicalKey.FromCode(host.ProjectKeyCode);+ if (key is { Mode: not KeyMode.Note } k)+ {+ w.WriteStartObject("key");+ w.WriteNumber("root", k.Tonic);+ w.WriteBoolean("minor", k.Mode == KeyMode.Minor);+ w.WriteString("name", k.Long);+ w.WriteEndObject();+ }+ else w.WriteNull("key");++ w.WriteNumber("scenes", _engine.SceneCount);+ w.WriteStartArray("sections");+ foreach (var (name, beat) in host.Sections)+ {+ w.WriteStartArray();+ w.WriteStringValue(name);+ w.WriteNumberValue(Math.Round(beat, 3));+ w.WriteEndArray();+ }+ w.WriteEndArray();+ });+ // Left open: Push appends the per-phone fields and the closing brace.+ _projectJson = _projectJson[..^1];+ }++ // The pads a drum track has: a Drum Rack's chains by trigger note, Nota Rhythm's eight voices.+ private void WritePads(Utf8JsonWriter w, int trackId)+ {+ w.WriteStartArray("pads");+ if (_engine.TrackInstrumentKind(trackId) == RemoteParams.RhythmKind)+ {+ for (int v = 0; v < RhythmModel.MidiNotes.Length; v++)+ {+ w.WriteStartArray();+ w.WriteNumberValue(RhythmModel.MidiNotes[v]);+ w.WriteStringValue(RhythmModel.VoiceNames[v]);+ w.WriteEndArray();+ }+ }+ else+ {+ int chains = _engine.RackChainCount(trackId);+ for (int ch = 0; ch < chains; ch++)+ {+ int note = _engine.RackChainTriggerNote(trackId, ch);+ if (note is < 0 or > 127) continue;+ w.WriteStartArray();+ w.WriteNumberValue(note);+ w.WriteStringValue(_engine.RackChainName(trackId, ch));+ w.WriteEndArray();+ }+ }+ w.WriteEndArray();+ }++ /// <summary>Keep the phone on a real track: a new phone starts on Nota's selection (or the+ /// first instrument), a deleted track hands over to its neighbour, Follow tracks Nota.</summary>+ private void ResolveTrack(IRemoteHost host, RemoteClient c)+ {+ if (_tracks.Count == 0) { c.TrackId = 0; return; }+ bool Playable(TrackRow r) => r.Kind is "drum" or "inst" or "audio";+ if (c.Follow && host.SelectedTrackId > 0 && host.SelectedTrackId != c.TrackId+ && _tracks.FirstOrDefault(r => r.Id == host.SelectedTrackId) is { } sel && Playable(sel))+ {+ c.TrackId = sel.Id;+ _devicesDirty = true;+ return;+ }+ int idx = _tracks.FindIndex(r => r.Id == c.TrackId);+ if (idx >= 0) { c.LastTrackIndex = idx; return; }++ bool wasDeleted = c.TrackId > 0;+ TrackRow? pick = null;+ if (wasDeleted)+ pick = _tracks.Skip(Math.Min(c.LastTrackIndex, _tracks.Count - 1)).FirstOrDefault(Playable)+ ?? _tracks.LastOrDefault(Playable);+ else+ pick = _tracks.FirstOrDefault(r => r.Id == host.SelectedTrackId && r.Kind is "drum" or "inst")+ ?? _tracks.FirstOrDefault(r => r.Kind is "drum" or "inst")+ ?? _tracks.FirstOrDefault(Playable);+ c.TrackId = pick?.Id ?? 0;+ _devicesDirty = true;+ if (wasDeleted && pick is not null) Toast(c, $"That track was deleted in Nota. Now playing {pick.Name}.");+ }++ private string BuildWho(RemoteClient self)+ {+ var groups = _clients.Values.Where(c => c.Authenticated && c != self && c.TrackId > 0)+ .GroupBy(c => c.TrackId).OrderBy(g => g.Key);+ return Json(w =>+ {+ w.WriteString("t", "who");+ w.WriteStartObject("p");+ foreach (var g in groups)+ {+ w.WriteStartArray(g.Key.ToString(CultureInfo.InvariantCulture));+ foreach (var c in g) w.WriteStringValue(ShortName(c.Name));+ w.WriteEndArray();+ }+ w.WriteEndObject();+ });+ }++ // ---- transport -------------------------------------------------------------------++ private string BuildTransport(IRemoteHost host) => Json(w =>+ {+ w.WriteString("t", "tp");+ w.WriteBoolean("play", _engine.IsPlaying);+ w.WriteBoolean("rec", host.Recording);+ w.WriteBoolean("loop", host.LoopOn);+ w.WriteBoolean("met", host.MetronomeOn);+ w.WriteNumber("pos", Math.Round(_engine.PositionBeats, 3));+ w.WriteNumber("bpm", Math.Round(_engine.Bpm, 2));+ w.WriteNumber("ls", Math.Round(_engine.LoopStart, 3));+ w.WriteNumber("le", Math.Round(_engine.LoopEnd, 3));+ w.WriteBoolean("can", _engine.CanUndo);+ });++ // ---- sounding notes ----------------------------------------------------------------+ // The pads and keys light for what the track is playing: its arrangement MIDI clips and a+ // playing Session slot, plus what other phones hold on it. (Own touches light on the phone.)++ private string BuildLit(Snapshot snap, int trackId)+ {+ var set = new SortedSet<int>();+ if (snap.Playing && TrackInfo(trackId) is { } ti && ti.IsInstrument)+ {+ if (_engine.ArrangementActive)+ for (int ci = 0; ci < ti.ClipCount; ci++)+ {+ if (!_engine.TryGetClipInfo(trackId, ci, out var info) || !info.IsMidi || info.Active == 0) continue;+ double local = snap.Pos - info.StartBeat;+ if (local < 0 || local >= info.LengthBeats) continue;+ foreach (var n in snap.ClipNotes(trackId, ci))+ if (local >= n.StartBeat && local < n.StartBeat + n.LengthBeats) set.Add(n.Pitch);+ }+ int scenes = _engine.SceneCount;+ for (int s = 0; s < scenes; s++)+ {+ if (_engine.SessionSlotState(trackId, s) != 3) continue;+ double len = _engine.SessionSlotLength(trackId, s);+ if (len <= 0) continue;+ double start = SlotStart(trackId, s, snap.Pos);+ double local = ((snap.Pos - start) % len + len) % len;+ foreach (var n in _engine.GetSessionNotes(trackId, s))+ if (local >= n.StartBeat && local < n.StartBeat + n.LengthBeats) set.Add(n.Pitch);+ }+ }+ foreach (var c in _clients.Values)+ if (c.Authenticated && c.TrackId == trackId)+ foreach (int p in c.HeldPitches()) set.Add(p);+ return Json(w =>+ {+ w.WriteString("t", "lit");+ w.WriteNumber("id", trackId);+ w.WriteStartArray("n");+ foreach (int p in set) w.WriteNumberValue(p);+ w.WriteEndArray();+ });+ }++ private NotaTrackInfo? TrackInfo(int trackId)+ {+ var row = _tracks.FirstOrDefault(r => r.Id == trackId);+ if (row is not null && _engine.TryGetTrackInfo(row.Index, out var ti) && ti.Id == trackId) return ti;+ int n = _engine.TrackCount;+ for (int i = 0; i < n; i++)+ if (_engine.TryGetTrackInfo(i, out var t2) && t2.Id == trackId) return t2;+ return null;+ }++ // Where a playing slot started, for its progress line: first seen playing, on the bar.+ private double SlotStart(int trackId, int scene, double pos)+ {+ if (!_slotStart.TryGetValue((trackId, scene), out double s))+ _slotStart[(trackId, scene)] = s = Math.Floor(pos / 4) * 4;+ return s;+ }++ // ---- mixer ---------------------------------------------------------------------------++ private string BuildMixer(IRemoteHost host) => Json(w =>+ {+ w.WriteString("t", "mix");+ w.WriteStartArray("ch");+ int n = _engine.TrackCount;+ for (int i = 0; i < n; i++)+ {+ if (!_engine.TryGetTrackInfo(i, out var ti)) continue;+ _engine.TryGetTrackMeter(ti.Id, out var m);+ w.WriteStartArray();+ w.WriteNumberValue(ti.Id);+ w.WriteNumberValue(Math.Round(ti.Volume, 4));+ w.WriteNumberValue(Math.Round(ti.Pan, 3));+ w.WriteNumberValue(ti.Muted);+ w.WriteNumberValue(ti.Soloed);+ w.WriteNumberValue(ti.Armed);+ w.WriteNumberValue(MeterPos(m.PeakL));+ w.WriteNumberValue(MeterPos(m.PeakR));+ w.WriteStringValue(_heldFaders.TryGetValue(ti.Id, out var h) ? h.Name : "");+ w.WriteNumberValue(h.Conn);+ w.WriteEndArray();+ }+ w.WriteEndArray();+ var mm = _engine.MasterMeter();+ w.WriteStartArray("m");+ w.WriteNumberValue(Math.Round(host.MasterVolume, 4));+ w.WriteNumberValue(MeterPos(mm.PeakL));+ w.WriteNumberValue(MeterPos(mm.PeakR));+ w.WriteStringValue(_heldFaders.TryGetValue(MasterFaderId, out var mh) ? mh.Name : "");+ w.WriteNumberValue(mh.Conn);+ w.WriteEndArray();+ });++ // A meter's height: −60..+6 dBFS onto 0..1.+ private static double MeterPos(float peak)+ => peak <= 1e-6f ? 0 : Math.Round(Math.Clamp((20 * Math.Log10(peak) + 60) / 66, 0, 1), 3);++ // ---- XY -------------------------------------------------------------------------------++ private string BuildXy(IRemoteHost host, Snapshot snap, RemoteClient c)+ {+ var def = c.TrackId > 0 ? RemoteParams.DefaultXy(_engine, c.TrackId) : null;+ return Json(w =>+ {+ w.WriteString("t", "xy");+ w.WriteNumber("id", c.TrackId);+ w.WriteBoolean("ok", def is not null);+ w.WriteBoolean("auto", host.Recording && snap.Playing);+ void Axis(string name, RemoteParam? p, int ctl, int tiltCtl)+ {+ w.WriteStartObject(name);+ if (p is not null)+ {+ double v = RemoteParams.Get(_engine, p);+ w.WriteString("n", p.Name);+ w.WriteString("d", p.Device);+ w.WriteNumber("v", Math.Round(v, 4));+ w.WriteString("txt", RemoteParams.Text(_engine, p, v));+ }+ WriteMap(w, "map", host.PhoneMappingName(ctl));+ WriteMap(w, "tilt", host.PhoneMappingName(tiltCtl));+ w.WriteEndObject();+ }+ Axis("x", def?.X, PhoneControls.XyX, PhoneControls.TiltX);+ Axis("y", def?.Y, PhoneControls.XyY, PhoneControls.TiltY);+ });+ }++ private static void WriteMap(Utf8JsonWriter w, string name, string? value)+ {+ if (value is null) w.WriteNull(name); else w.WriteString(name, value);+ }++ // ---- macros -----------------------------------------------------------------------------++ private List<RemoteMacroDevice> MacroDevicesFor(int trackId)+ {+ var row = _tracks.FirstOrDefault(r => r.Id == trackId);+ if (row is null || row.Kind is "group") return new();+ return RemoteParams.MacroDevices(_engine, trackId, row.Kind is "drum" or "inst");+ }++ private string BuildMacros(IRemoteHost host, RemoteClient c)+ {+ var devs = MacroDevicesFor(c.TrackId);+ if (c.MacroDevice >= devs.Count) c.MacroDevice = 0;+ return Json(w =>+ {+ w.WriteString("t", "mac");+ w.WriteNumber("id", c.TrackId);+ w.WriteNumber("di", c.MacroDevice);+ w.WriteStartArray("devs");+ foreach (var d in devs) w.WriteStringValue(d.Name);+ w.WriteEndArray();+ w.WriteStartArray("k");+ if (devs.Count > 0)+ {+ var ps = devs[c.MacroDevice].Params;+ for (int i = 0; i < 8; i++)+ {+ w.WriteStartObject();+ if (i < ps.Count)+ {+ double v = RemoteParams.Get(_engine, ps[i]);+ w.WriteString("n", ps[i].Name);+ w.WriteNumber("v", Math.Round(v, 4));+ w.WriteString("txt", RemoteParams.Text(_engine, ps[i], v));+ w.WriteBoolean("a", RemoteParams.Automated(_engine, ps[i]));+ }+ WriteMap(w, "map", host.PhoneMappingName(PhoneControls.Macro1 + i));+ w.WriteEndObject();+ }+ }+ w.WriteEndArray();+ });+ }++ // ---- session --------------------------------------------------------------------------------++ private string BuildSession(Snapshot snap)+ {+ int scenes = _engine.SceneCount;+ return Json(w =>+ {+ w.WriteString("t", "ses");+ w.WriteNumber("n", scenes);+ w.WriteStartArray("tr");+ foreach (var r in _tracks)+ {+ if (r.Kind is "group" or "return") continue;+ w.WriteStartObject();+ w.WriteNumber("id", r.Id);+ w.WriteStartArray("c");+ for (int s = 0; s < scenes; s++)+ {+ int st = _engine.SessionSlotState(r.Id, s);+ if (st != 3) _slotStart.Remove((r.Id, s));+ double len = st == 0 ? 0 : _engine.SessionSlotLength(r.Id, s);+ double prog = 0;+ if (st == 3 && len > 0)+ {+ double start = SlotStart(r.Id, s, snap.Pos);+ prog = (((snap.Pos - start) % len) + len) % len / len;+ }+ w.WriteStartArray();+ w.WriteNumberValue(st);+ w.WriteNumberValue(Math.Round(len, 2));+ w.WriteNumberValue(Math.Round(prog, 3));+ w.WriteEndArray();+ }+ w.WriteEndArray();+ w.WriteEndObject();+ }+ w.WriteEndArray();+ });+ }+}diff --git a/src/managed/Nota.Remote/RemoteHub.cs b/src/managed/Nota.Remote/RemoteHub.csnew file mode 100644index 00000000..95d49d30--- /dev/null+++ b/src/managed/Nota.Remote/RemoteHub.cs@@ -0,0 +1,319 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The hub between the phones and Nota. Sockets run on Kestrel threads and only do three+// things there: authenticate, answer pings, and play notes (the engine's track-note entry is+// thread-safe, so a pad hit reaches the audio thread without waiting for the UI). Every other+// command is queued and applied in Tick(), which Nota calls on its UI clock (~30 Hz) — the+// thread that owns the engine. Tick also builds what each phone needs for the screen it shows+// and sends only what changed since the last message.++using System.Buffers;+using System.Collections.Concurrent;+using System.Net.WebSockets;+using System.Text;+using System.Text.Json;+using Nota.Application;+using Nota.Application.Samples;++namespace Nota.Remote;++/// <summary>A connected phone, as the popup and Settings list it.</summary>+public sealed record RemoteDeviceInfo(int ConnectionId, string DeviceId, string Name, string Model, int TrackId, int RttMs, string Screen);++public sealed partial class RemoteHub+{+ public const int ProtocolVersion = 1;+ /// <summary>A phone that has gone this long without a word has lost the link: its notes are+ /// released (it pings every second while it is up).</summary>+ private static readonly TimeSpan SilenceRelease = TimeSpan.FromMilliseconds(2500);+ private static readonly TimeSpan SilenceDrop = TimeSpan.FromSeconds(20);++ private readonly IAudioEngine _engine;+ private readonly ConcurrentDictionary<int, RemoteClient> _clients = new();+ private readonly ConcurrentQueue<(RemoteClient Client, RemoteCommand Cmd)> _inbox = new();+ private int _activity;+ private volatile bool _devicesDirty;+ private int _tick;++ public RemotePairing Pairing { get; }+ /// <summary>The app side. Until it is set, Tick does nothing (the window isn't up yet).</summary>+ public IRemoteHost? Host { get; set; }+ /// <summary>Settings → Remote → Phones may.</summary>+ public Func<RemoteAccess> Access { get; set; } = () => RemoteAccess.Control;+ /// <summary>The computer's name for the phone's banners, read off the UI thread.</summary>+ public string HostName { get; set; } = Environment.MachineName;++ public RemoteHub(IAudioEngine engine, RemotePairing pairing)+ {+ _engine = engine;+ Pairing = pairing;+ }++ /// <summary>The paired phones connected right now.</summary>+ public IReadOnlyList<RemoteDeviceInfo> Devices =>+ _clients.Values.Where(c => c.Authenticated).OrderBy(c => c.ConnectedAt)+ .Select(c => new RemoteDeviceInfo(c.ConnectionId, c.Device!.Id, c.Name, c.Model, c.TrackId, c.RttMs, c.Screen)).ToList();++ /// <summary>Names of the phones playing <paramref name="trackId"/> (the track-header badge).</summary>+ public IReadOnlyList<string> PlayersOf(int trackId) =>+ _clients.Values.Where(c => c.Authenticated && c.TrackId == trackId).Select(c => ShortName(c.Name)).ToList();++ /// <summary>"Egor's iPhone" → "Egor": what fits a badge.</summary>+ public static string ShortName(string name)+ {+ int apos = name.IndexOfAny(new[] { '\'', '’' });+ if (apos > 0) return name[..apos];+ int sp = name.IndexOf(' ');+ return sp > 0 && name.Length > 12 ? name[..sp] : name;+ }++ // ---- socket side ----------------------------------------------------------++ internal async Task RunClientAsync(WebSocket ws, string address, CancellationToken ct)+ {+ var c = new RemoteClient(ws, address);+ c.LastActivityTicks = DateTime.UtcNow.Ticks;+ _clients[c.ConnectionId] = c;+ var send = c.SendLoopAsync(ct);+ try+ {+ await c.ReceiveLoopAsync(OnMessageAsync, ct);+ }+ finally+ {+ _clients.TryRemove(c.ConnectionId, out _);+ ReleaseNotes(c);+ c.CompleteSend();+ await c.CloseAsync(WebSocketCloseStatus.NormalClosure, "bye");+ try { await send; } catch { }+ if (c.Authenticated) _devicesDirty = true;+ }+ }++ private Task OnMessageAsync(RemoteClient c, JsonElement m)+ {+ c.LastActivityTicks = DateTime.UtcNow.Ticks;+ string t = Str(m, "t");+ switch (t)+ {+ case "hello": Hello(c, m); return Task.CompletedTask;+ case "pair": PairWithCode(c, m); return Task.CompletedTask;+ case "ping":+ // Echo at once, from this thread: the round trip is the link, not the UI tick.+ if (m.TryGetProperty("rtt", out var rtt) && rtt.TryGetInt32(out int ms)) c.RttMs = ms;+ c.Send($"{{\"t\":\"pong\",\"c\":{Num(m, "c").ToString(System.Globalization.CultureInfo.InvariantCulture)}}}");+ return Task.CompletedTask;+ }+ if (!c.Authenticated) return Task.CompletedTask;++ Interlocked.Increment(ref _activity);+ switch (t)+ {+ case "on":+ {+ int p = Int(m, "p");+ if (p is < 0 or > 127) break;+ float v = (float)Math.Clamp(Num(m, "v", 0.8), 0.01, 1.0);+ int track = c.TrackId;+ if (track <= 0) break;+ if (c.NoteOn(p, track) is int prev) _engine.TrackNoteOff(prev, p);+ _engine.TrackNoteOn(track, p, v);+ break;+ }+ case "off":+ {+ int p = Int(m, "p");+ if (c.NoteOff(p, out int track)) _engine.TrackNoteOff(track, p);+ break;+ }+ case "panic": ReleaseNotes(c); break;+ case "bye": _ = c.CloseAsync(WebSocketCloseStatus.NormalClosure, "bye"); break;+ default:+ _inbox.Enqueue((c, RemoteCommand.Parse(t, m)));+ break;+ }+ return Task.CompletedTask;+ }++ private void Hello(RemoteClient c, JsonElement m)+ {+ if (Int(m, "v", ProtocolVersion) > ProtocolVersion) { Deny(c, "version"); return; }+ var dev = Pairing.Authenticate(Str(m, "token"));+ if (dev is null) { Deny(c, "forgotten"); return; }+ Accept(c, dev, token: null, m);+ }++ private void PairWithCode(RemoteClient c, JsonElement m)+ {+ var r = Pairing.Pair(Str(m, "code"), Str(m, "name"), c.Address, out var error);+ if (r is null) { Deny(c, error ?? "code"); return; }+ Accept(c, r.Value.Device, r.Value.Token, m);+ }++ private void Accept(RemoteClient c, TrustedDevice dev, string? token, JsonElement m)+ {+ // A phone that reconnects (screen unlock, Wi-Fi back) replaces its stale socket.+ foreach (var old in _clients.Values)+ if (old != c && old.Device?.Id == dev.Id)+ {+ ReleaseNotes(old);+ _ = old.CloseAsync(WebSocketCloseStatus.PolicyViolation, "replaced");+ }+ c.Name = dev.Name;+ c.Model = PairingModel(Str(m, "model"));+ c.TrackId = Int(m, "track");+ c.Follow = Bool(m, "follow");+ c.Screen = Str(m, "screen");+ c.Device = dev;+ c.SentProject = c.SentWho = c.SentTransport = c.SentLit = c.SentLearn = c.SentScreenState = null;+ c.Send(Json(w =>+ {+ w.WriteString("t", "welcome");+ w.WriteNumber("v", ProtocolVersion);+ w.WriteString("id", dev.Id);+ w.WriteString("name", dev.Name);+ w.WriteString("host", HostName);+ w.WriteNumber("conn", c.ConnectionId);+ if (token is not null) w.WriteString("token", token);+ }));+ _devicesDirty = true;+ }++ private static string PairingModel(string s) => s.Length > 40 ? s[..40] : s;++ private static void Deny(RemoteClient c, string why)+ => c.Send($"{{\"t\":\"denied\",\"why\":\"{why}\"}}");++ private void ReleaseNotes(RemoteClient c)+ {+ foreach (var (track, pitch) in c.TakeAllHeld()) _engine.TrackNoteOff(track, pitch);+ }++ // ---- UI thread ------------------------------------------------------------++ /// <summary>Drop a phone (the popup's ✕). It may reconnect while it is still trusted.</summary>+ public void Disconnect(int connectionId)+ {+ if (!_clients.TryGetValue(connectionId, out var c)) return;+ ReleaseNotes(c);+ c.Send("{\"t\":\"kicked\"}");+ _ = c.CloseAsync(WebSocketCloseStatus.NormalClosure, "disconnected in Nota");+ }++ /// <summary>Forget a phone: it is dropped and has to scan a new code.</summary>+ public void Forget(string deviceId)+ {+ Pairing.Forget(deviceId);+ foreach (var c in _clients.Values)+ if (c.Device?.Id == deviceId)+ {+ ReleaseNotes(c);+ c.Send("{\"t\":\"denied\",\"why\":\"forgotten\"}");+ _ = c.CloseAsync(WebSocketCloseStatus.NormalClosure, "forgotten");+ }+ _devicesDirty = true;+ }++ /// <summary>Remote turned off: everyone leaves at once, with their notes released.</summary>+ public void DisconnectAll()+ {+ foreach (var c in _clients.Values)+ {+ ReleaseNotes(c);+ _ = c.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "Remote is off");+ }+ _clients.Clear();+ _devicesDirty = true;+ }++ /// <summary>Count of messages from phones since start — the Remote button flashes while it moves.</summary>+ public int ActivityCount => Volatile.Read(ref _activity);++ /// <summary>Called on Nota's UI clock: apply what the phones asked for, then send each one+ /// the state its screen needs.</summary>+ public void Tick()+ {+ var host = Host;+ if (host is null) return;+ _tick++;++ while (_inbox.TryDequeue(out var item))+ {+ if (!item.Client.Authenticated || !_clients.ContainsKey(item.Client.ConnectionId)) continue;+ try { Apply(host, item.Client, item.Cmd); }+ catch (Exception) { /* a stale id from a phone must never take the UI clock down */ }+ }++ var clients = _clients.Values.Where(c => c.Authenticated).ToList();+ ExpireHeldFaders();+ long now = DateTime.UtcNow.Ticks;+ foreach (var c in clients)+ {+ var silent = TimeSpan.FromTicks(now - c.LastActivityTicks);+ if (silent > SilenceRelease) ReleaseNotes(c);+ if (silent > SilenceDrop) { _ = c.CloseAsync(WebSocketCloseStatus.EndpointUnavailable, "silent"); continue; }+ }++ if (clients.Count > 0)+ {+ var snap = new Snapshot(this, host);+ foreach (var c in clients)+ {+ if (c.Backlog > 16) continue; // the phone isn't keeping up: let it drain first+ try { Push(host, snap, c); }+ catch (Exception) { /* a track removed mid-tick; next tick sees the new list */ }+ }+ }++ if (_devicesDirty)+ {+ _devicesDirty = false;+ host.DevicesChanged();+ }+ if (_activity != _lastActivity) { _lastActivity = _activity; host.Activity(); }+ }++ private int _lastActivity;++ internal static string Json(Action<Utf8JsonWriter> body)+ {+ var buf = new ArrayBufferWriter<byte>(256);+ using (var w = new Utf8JsonWriter(buf))+ {+ w.WriteStartObject();+ body(w);+ w.WriteEndObject();+ }+ return Encoding.UTF8.GetString(buf.WrittenSpan);+ }++ // ---- JSON reading helpers ----------------------------------------------------++ internal static string Str(JsonElement m, string name)+ => m.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.String ? v.GetString() ?? "" : "";++ internal static int Int(JsonElement m, string name, int fallback = 0)+ => m.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.Number && v.TryGetDouble(out double d) && double.IsFinite(d)+ ? (int)Math.Clamp(Math.Round(d), int.MinValue, int.MaxValue) : fallback;++ internal static double Num(JsonElement m, string name, double fallback = 0)+ => m.TryGetProperty(name, out var v) && v.ValueKind == JsonValueKind.Number && v.TryGetDouble(out double d) && double.IsFinite(d) ? d : fallback;++ internal static bool Bool(JsonElement m, string name)+ => m.TryGetProperty(name, out var v) && (v.ValueKind == JsonValueKind.True || (v.ValueKind == JsonValueKind.Number && v.TryGetDouble(out double d) && d != 0));+}++/// <summary>A phone command, parsed on the socket thread and applied on the UI tick.</summary>+internal readonly record struct RemoteCommand(string T, int Id, int I, double V, double V2, bool On, int Phase, string S)+{+ public static RemoteCommand Parse(string t, JsonElement m) => new(+ t,+ RemoteHub.Int(m, "id"),+ RemoteHub.Int(m, "i"),+ RemoteHub.Num(m, "v"),+ RemoteHub.Num(m, "v2"),+ RemoteHub.Bool(m, "on"),+ RemoteHub.Int(m, "ph"),+ RemoteHub.Str(m, "s"));+}diff --git a/src/managed/Nota.Remote/RemotePairing.cs b/src/managed/Nota.Remote/RemotePairing.csnew file mode 100644index 00000000..ed3782df--- /dev/null+++ b/src/managed/Nota.Remote/RemotePairing.cs@@ -0,0 +1,225 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Pairing for Nota Remote. The server listens on the local network, so nothing is accepted+// without either the current four-digit code (shown in Nota, inside the QR) or a device token+// handed out by an earlier pairing. Codes rotate every two minutes and after every pairing;+// wrong guesses lock the sender out for a while, so 10 000 codes can't be walked. Tokens are+// stored hashed, with the device's name and when it was last seen — Settings → Remote lists+// them, and forgetting one makes that phone scan again.++using System.Security.Cryptography;+using System.Text;+using System.Text.Json;++namespace Nota.Remote;++/// <summary>A phone that paired once and may reconnect without a code.</summary>+public sealed class TrustedDevice+{+ public string Id { get; set; } = "";+ public string Name { get; set; } = "";+ /// <summary>SHA-256 of the device token, hex. The token itself only lives on the phone.</summary>+ public string TokenHash { get; set; } = "";+ public DateTime Paired { get; set; }+ public DateTime LastSeen { get; set; }+}++public sealed class RemotePairing+{+ public static readonly TimeSpan CodeLifetime = TimeSpan.FromMinutes(2);+ private const int MaxFailures = 5;+ private static readonly TimeSpan Lockout = TimeSpan.FromSeconds(30);++ private readonly object _gate = new();+ private readonly string? _storePath;+ private readonly List<TrustedDevice> _trusted = new();+ private readonly Dictionary<string, (int fails, DateTime until)> _failures = new();+ private string _code = "";+ private DateTime _codeIssued;++ /// <summary>The trusted list or the code changed (Settings and the popup redraw).</summary>+ public event Action? Changed;++ /// <param name="storePath">trusted.json; null keeps the list in memory (tests).</param>+ public RemotePairing(string? storePath)+ {+ _storePath = storePath;+ Load();+ NewCode();+ }++ /// <summary>The current code, rotated when it has expired.</summary>+ public string Code+ {+ get+ {+ lock (_gate)+ {+ if (DateTime.UtcNow - _codeIssued >= CodeLifetime) NewCodeLocked();+ return _code;+ }+ }+ }++ /// <summary>How long the current code has left.</summary>+ public TimeSpan CodeRemaining+ {+ get+ {+ lock (_gate)+ {+ var left = CodeLifetime - (DateTime.UtcNow - _codeIssued);+ return left < TimeSpan.Zero ? TimeSpan.Zero : left;+ }+ }+ }++ public void NewCode()+ {+ lock (_gate) NewCodeLocked();+ Changed?.Invoke();+ }++ private void NewCodeLocked()+ {+ string prev = _code;+ do _code = RandomNumberGenerator.GetInt32(0, 10000).ToString("D4");+ while (_code == prev);+ _codeIssued = DateTime.UtcNow;+ }++ public IReadOnlyList<TrustedDevice> Trusted+ {+ get { lock (_gate) return _trusted.Select(Clone).ToList(); }+ }++ /// <summary>Pair a new phone with the code. Returns its device id and token, or null with+ /// <paramref name="error"/> = "code" (wrong / expired) or "locked" (too many tries).</summary>+ public (TrustedDevice Device, string Token)? Pair(string code, string name, string sender, out string? error)+ {+ TrustedDevice dev;+ string token;+ lock (_gate)+ {+ var now = DateTime.UtcNow;+ _failures.TryGetValue(sender, out var f);+ if (f.until > now) { error = "locked"; return null; }+ if (now - _codeIssued >= CodeLifetime) NewCodeLocked();+ if (!CryptographicOperations.FixedTimeEquals(Encoding.ASCII.GetBytes(code ?? ""), Encoding.ASCII.GetBytes(_code)))+ {+ int fails = f.fails + 1;+ bool locked = fails >= MaxFailures;+ _failures[sender] = locked ? (0, now + Lockout) : (fails, DateTime.MinValue);+ error = locked ? "locked" : "code";+ return null;+ }+ _failures.Remove(sender);+ token = Convert.ToBase64String(RandomNumberGenerator.GetBytes(32)).TrimEnd('=').Replace('+', '-').Replace('/', '_');+ dev = new TrustedDevice+ {+ Id = Convert.ToHexString(RandomNumberGenerator.GetBytes(6)).ToLowerInvariant(),+ Name = CleanName(name),+ TokenHash = Hash(token),+ Paired = now,+ LastSeen = now,+ };+ _trusted.Add(dev);+ NewCodeLocked(); // a code is good for one phone+ SaveLocked();+ }+ error = null;+ Changed?.Invoke();+ return (Clone(dev), token);+ }++ /// <summary>The trusted device a token belongs to, or null (never paired, or forgotten).</summary>+ public TrustedDevice? Authenticate(string token)+ {+ if (string.IsNullOrEmpty(token)) return null;+ string h = Hash(token);+ lock (_gate)+ {+ var d = _trusted.FirstOrDefault(x => CryptographicOperations.FixedTimeEquals(+ Encoding.ASCII.GetBytes(x.TokenHash), Encoding.ASCII.GetBytes(h)));+ if (d is null) return null;+ d.LastSeen = DateTime.UtcNow;+ SaveLocked();+ return Clone(d);+ }+ }++ public void Rename(string id, string name)+ {+ lock (_gate)+ {+ var d = _trusted.FirstOrDefault(x => x.Id == id);+ if (d is null) return;+ d.Name = CleanName(name);+ SaveLocked();+ }+ Changed?.Invoke();+ }++ public void Touch(string id)+ {+ lock (_gate)+ {+ var d = _trusted.FirstOrDefault(x => x.Id == id);+ if (d is null) return;+ d.LastSeen = DateTime.UtcNow;+ SaveLocked();+ }+ }++ /// <summary>Forget a phone: its token stops working and it has to scan a code again.</summary>+ public bool Forget(string id)+ {+ bool removed;+ lock (_gate)+ {+ removed = _trusted.RemoveAll(x => x.Id == id) > 0;+ if (removed) SaveLocked();+ }+ if (removed) Changed?.Invoke();+ return removed;+ }++ public static string CleanName(string? name)+ {+ var s = new string((name ?? "").Where(c => !char.IsControl(c)).ToArray()).Trim();+ if (s.Length > 40) s = s[..40];+ return s.Length == 0 ? "Phone" : s;+ }++ private static string Hash(string token) => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(token)));++ private static TrustedDevice Clone(TrustedDevice d) => new()+ {+ Id = d.Id, Name = d.Name, TokenHash = d.TokenHash, Paired = d.Paired, LastSeen = d.LastSeen,+ };++ private void Load()+ {+ if (_storePath is null || !File.Exists(_storePath)) return;+ try+ {+ var list = JsonSerializer.Deserialize<List<TrustedDevice>>(File.ReadAllText(_storePath));+ if (list is not null) _trusted.AddRange(list.Where(d => d.Id.Length > 0 && d.TokenHash.Length > 0));+ }+ catch { /* an unreadable list means every phone pairs again — never block start-up */ }+ }++ private void SaveLocked()+ {+ if (_storePath is null) return;+ try+ {+ Directory.CreateDirectory(Path.GetDirectoryName(_storePath)!);+ string tmp = _storePath + ".tmp";+ File.WriteAllText(tmp, JsonSerializer.Serialize(_trusted, new JsonSerializerOptions { WriteIndented = true }));+ File.Move(tmp, _storePath, overwrite: true);+ }+ catch { /* best effort: the phone keeps working this session */ }+ }+}diff --git a/src/managed/Nota.Remote/RemoteParams.cs b/src/managed/Nota.Remote/RemoteParams.csnew file mode 100644index 00000000..59d2d10f--- /dev/null+++ b/src/managed/Nota.Remote/RemoteParams.cs@@ -0,0 +1,255 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// What the phone's XY pad and macro knobs drive when nothing is mapped to them, and how a+// parameter is read, written and printed. Engine-only (no Avalonia), so it runs inside the hub's+// UI-thread tick. A phone move is a hardware-style gesture: it latches automation while Record is+// on and overrides an automated lane otherwise — the same rule MIDI Learn applies to a knob.++using System.Globalization;+using Nota.Application;++namespace Nota.Remote;++/// <summary>One parameter a phone control drives.</summary>+public sealed record RemoteParam(RemoteParamKind Kind, int TrackId, int DeviceIndex, int ParamIndex, string Name, string Device);++public enum RemoteParamKind+{+ /// <summary>A built-in effect's parameter, in its own min..max units.</summary>+ DeviceParam,+ /// <summary>A plug-in or built-in instrument parameter, normalized 0..1 (device −1 = the instrument).</summary>+ PluginParam,+ /// <summary>An Instrument / Drum Rack macro (device −1) or an Effect Rack's (device ≥ 0).</summary>+ RackMacro,+}++/// <summary>A page of up to eight knobs from one device in the track's chain.</summary>+public sealed record RemoteMacroDevice(string Name, int DeviceIndex, IReadOnlyList<RemoteParam> Params);++public static class RemoteParams+{+ public const int AutoFilterKind = 7;+ public const int EffectRackKind = 5;+ public const int InstrumentRackKind = 3, DrumRackKind = 4, FluxKind = 11, RhythmKind = 12, SamplerKind = 1;++ private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;++ /// <summary>Built-in instrument names, by the engine's instrument kind.</summary>+ public static string InstrumentName(IAudioEngine e, int trackId)+ {+ int kind = e.TrackInstrumentKind(trackId);+ string name = kind switch+ {+ 0 => "Nota Synth", 1 => "Sampler", 2 => "Nota Physical", 3 => "Instrument Rack", 4 => "Drum Rack",+ 5 => "Nota Aurora", 6 => "Nota Volt", 7 => "Nota Bass", 8 => "Nota Pendulum", 9 => "Nota Operator",+ 10 => "Nota Grain", 11 => "Nota Flux", 12 => "Nota Rhythm", 13 => "Nota Monolith", 14 => "Nota Pentad",+ 15 => "Nota Consort", _ => "",+ };+ if (name.Length > 0) return name;+ string id = e.TrackInstrumentPluginId(trackId);+ return PluginDisplayName(id) ?? "Instrument";+ }++ // A JUCE identifier reads "<format>-<name>-<hash>-<uid>": the name is the useful part.+ private static string? PluginDisplayName(string? id)+ {+ if (string.IsNullOrEmpty(id)) return null;+ var parts = id.Split('-');+ return parts.Length >= 2 && parts[1].Length > 0 ? parts[1] : id;+ }++ public static string DeviceName(IAudioEngine e, int trackId, int deviceIndex)+ {+ string n = e.DeviceName(trackId, deviceIndex);+ return n.Length > 0 ? n : PluginDisplayName(e.TrackDevicePluginId(trackId, deviceIndex)) ?? $"Device {deviceIndex + 1}";+ }++ /// <summary>The XY pad's default pair: Nota Flux's vector, else Cutoff × Resonance of the first+ /// Auto Filter in the chain. Null when the track has neither.</summary>+ public static (RemoteParam X, RemoteParam Y)? DefaultXy(IAudioEngine e, int trackId)+ {+ if (e.TrackInstrumentKind(trackId) == FluxKind)+ {+ int n = e.PluginParamCount(trackId, -1);+ int xi = -1, yi = -1;+ for (int i = 0; i < n; i++)+ {+ string id = e.PluginParamId(trackId, -1, i);+ if (id == "vecx") xi = i; else if (id == "vecy") yi = i;+ }+ if (xi >= 0 && yi >= 0)+ return (new RemoteParam(RemoteParamKind.PluginParam, trackId, -1, xi, "Vector X", "Nota Flux"),+ new RemoteParam(RemoteParamKind.PluginParam, trackId, -1, yi, "Vector Y", "Nota Flux"));+ }+ int devs = e.TrackDeviceCount(trackId);+ for (int d = 0; d < devs; d++)+ {+ if (e.TrackDeviceBuiltinKind(trackId, d) != AutoFilterKind) continue;+ int n = e.DeviceParamCount(trackId, d);+ int cut = -1, res = -1;+ for (int i = 0; i < n; i++)+ {+ string pn = e.DeviceParamName(trackId, d, i).ToLowerInvariant();+ if (cut < 0 && (pn.Contains("cutoff") || pn == "freq" || pn.Contains("frequency"))) cut = i;+ else if (res < 0 && (pn.Contains("reso") || pn == "q")) res = i;+ }+ if (cut < 0) cut = 0;+ if (res < 0) res = Math.Min(1, n - 1);+ string dn = DeviceName(e, trackId, d);+ return (new RemoteParam(RemoteParamKind.DeviceParam, trackId, d, cut, e.DeviceParamName(trackId, d, cut), dn),+ new RemoteParam(RemoteParamKind.DeviceParam, trackId, d, res, e.DeviceParamName(trackId, d, res), dn));+ }+ return null;+ }++ /// <summary>The devices the Macros screen steps through: the rack's macros or the instrument's+ /// parameters first, then every effect. Plug-ins and long built-ins page by eight.</summary>+ public static List<RemoteMacroDevice> MacroDevices(IAudioEngine e, int trackId, bool isInstrumentTrack)+ {+ var list = new List<RemoteMacroDevice>();+ if (isInstrumentTrack)+ {+ int kind = e.TrackInstrumentKind(trackId);+ string inst = InstrumentName(e, trackId);+ if (kind is InstrumentRackKind or DrumRackKind)+ {+ var ps = new List<RemoteParam>();+ for (int m = 0; m < 8; m++)+ {+ string mn = e.RackMacroName(trackId, m);+ ps.Add(new RemoteParam(RemoteParamKind.RackMacro, trackId, -1, m, mn.Length > 0 ? mn : $"Macro {m + 1}", inst));+ }+ list.Add(new RemoteMacroDevice(inst + " · Macros", -1, ps));+ }+ else+ {+ int n = e.PluginParamCount(trackId, -1);+ AddPaged(list, inst, -1, n, i => new RemoteParam(RemoteParamKind.PluginParam, trackId, -1, i, e.PluginParamName(trackId, -1, i), inst));+ }+ }+ int devs = e.TrackDeviceCount(trackId);+ for (int d = 0; d < devs; d++)+ {+ string dn = DeviceName(e, trackId, d);+ int bk = e.TrackDeviceBuiltinKind(trackId, d);+ int di = d;+ if (bk == EffectRackKind)+ {+ var ps = new List<RemoteParam>();+ for (int m = 0; m < 8; m++)+ {+ string mn = e.RackDevMacroName(trackId, d, m);+ ps.Add(new RemoteParam(RemoteParamKind.RackMacro, trackId, d, m, mn.Length > 0 ? mn : $"Macro {m + 1}", dn));+ }+ list.Add(new RemoteMacroDevice(dn + " · Macros", d, ps));+ }+ else if (bk >= 0)+ AddPaged(list, dn, d, e.DeviceParamCount(trackId, d), i => new RemoteParam(RemoteParamKind.DeviceParam, trackId, di, i, e.DeviceParamName(trackId, di, i), dn));+ else+ AddPaged(list, dn, d, e.PluginParamCount(trackId, d), i => new RemoteParam(RemoteParamKind.PluginParam, trackId, di, i, e.PluginParamName(trackId, di, i), dn));+ }+ return list;+ }++ private static void AddPaged(List<RemoteMacroDevice> list, string name, int deviceIndex, int count, Func<int, RemoteParam> make)+ {+ if (count <= 0) return;+ int pages = (count + 7) / 8;+ for (int p = 0; p < pages; p++)+ {+ var ps = new List<RemoteParam>();+ for (int i = p * 8; i < Math.Min(count, p * 8 + 8); i++) ps.Add(make(i));+ list.Add(new RemoteMacroDevice(pages > 1 ? $"{name} · {p + 1}/{pages}" : name, deviceIndex, ps));+ }+ }++ public static double Get(IAudioEngine e, RemoteParam p)+ {+ switch (p.Kind)+ {+ case RemoteParamKind.DeviceParam:+ {+ float min = e.DeviceParamMin(p.TrackId, p.DeviceIndex, p.ParamIndex), max = e.DeviceParamMax(p.TrackId, p.DeviceIndex, p.ParamIndex);+ float v = e.DeviceGetParam(p.TrackId, p.DeviceIndex, p.ParamIndex);+ return max > min ? Math.Clamp((v - min) / (max - min), 0, 1) : 0;+ }+ case RemoteParamKind.PluginParam:+ return Math.Clamp(e.PluginParamGet(p.TrackId, p.DeviceIndex, p.ParamIndex), 0, 1);+ default:+ return Math.Clamp(p.DeviceIndex < 0 ? e.RackMacroGet(p.TrackId, p.ParamIndex) : e.RackDevMacroGet(p.TrackId, p.DeviceIndex, p.ParamIndex), 0, 1);+ }+ }++ /// <summary>Move a parameter to <paramref name="norm"/> as a hardware control would: a+ /// latching automation write (an override when Record is off).</summary>+ public static void Set(IAudioEngine e, RemoteParam p, double norm)+ {+ norm = Math.Clamp(norm, 0, 1);+ switch (p.Kind)+ {+ case RemoteParamKind.DeviceParam:+ {+ e.BeginAutomationWrite(p.TrackId, AutomationTarget.DeviceParam, p.DeviceIndex, p.ParamIndex, "", latch: true);+ float min = e.DeviceParamMin(p.TrackId, p.DeviceIndex, p.ParamIndex), max = e.DeviceParamMax(p.TrackId, p.DeviceIndex, p.ParamIndex);+ e.DeviceSetParam(p.TrackId, p.DeviceIndex, p.ParamIndex, (float)(min + norm * (max - min)));+ break;+ }+ case RemoteParamKind.PluginParam:+ e.BeginAutomationWrite(p.TrackId, AutomationTarget.PluginParam, p.DeviceIndex, -1,+ e.PluginParamId(p.TrackId, p.DeviceIndex, p.ParamIndex), latch: true);+ e.PluginParamSet(p.TrackId, p.DeviceIndex, p.ParamIndex, (float)norm);+ break;+ default:+ if (p.DeviceIndex < 0) e.RackMacroSet(p.TrackId, p.ParamIndex, (float)norm);+ else e.RackDevMacroSet(p.TrackId, p.DeviceIndex, p.ParamIndex, (float)norm);+ break;+ }+ }++ /// <summary>Whether the parameter has an automation lane with points (the brass dot).</summary>+ public static bool Automated(IAudioEngine e, RemoteParam p)+ {+ if (p.Kind == RemoteParamKind.RackMacro) return false;+ int n = e.AutomationLaneCount(p.TrackId);+ string pid = p.Kind == RemoteParamKind.PluginParam ? e.PluginParamId(p.TrackId, p.DeviceIndex, p.ParamIndex) : "";+ for (int i = 0; i < n; i++)+ {+ var li = e.AutomationLaneInfo(p.TrackId, i);+ if (li.PointCount == 0 || li.DeviceIndex != p.DeviceIndex) continue;+ if (p.Kind == RemoteParamKind.DeviceParam && li.Target == AutomationTarget.DeviceParam && li.ParamIndex == p.ParamIndex) return true;+ if (p.Kind == RemoteParamKind.PluginParam && li.Target == AutomationTarget.PluginParam && e.AutomationLaneParamId(p.TrackId, i) == pid) return true;+ }+ return false;+ }++ /// <summary>The value in the parameter's own units, as Nota prints it ("1.2 kHz", "42 %").</summary>+ public static string Text(IAudioEngine e, RemoteParam p, double norm)+ {+ if (p.Kind == RemoteParamKind.PluginParam)+ {+ string t = e.PluginParamText(p.TrackId, p.DeviceIndex, p.ParamIndex);+ if (!string.IsNullOrWhiteSpace(t)) return t.Trim();+ return Pct(norm);+ }+ if (p.Kind == RemoteParamKind.RackMacro) return Pct(norm);++ string name = p.Name.ToLowerInvariant();+ float min = e.DeviceParamMin(p.TrackId, p.DeviceIndex, p.ParamIndex), max = e.DeviceParamMax(p.TrackId, p.DeviceIndex, p.ParamIndex);+ double v = min + norm * (max - min);+ bool unit = min >= 0 && max <= 1.0001;+ bool isFreq = name.Contains("cutoff") || name.Contains("freq") || name.EndsWith(" hz") || name.Contains("hp") || name.Contains("lp");+ if (isFreq)+ {+ // A 0..1 frequency is the engine's log sweep (Auto Filter: 30 Hz · 600^v).+ double hz = unit ? 30 * Math.Pow(600, norm) : v;+ return hz >= 1000 ? (hz / 1000).ToString("0.0", Inv) + " kHz" : Math.Round(hz).ToString(Inv) + " Hz";+ }+ if (name.Contains("db") || name.Contains("gain") && !unit) return v.ToString("0.0", Inv) + " dB";+ if (unit) return Pct(norm);+ if (max - min >= 20 && Math.Abs(v - Math.Round(v)) < 1e-3) return Math.Round(v).ToString(Inv);+ return v.ToString("0.00", Inv);+ }++ private static string Pct(double norm) => Math.Round(norm * 100).ToString(Inv) + " %";+}diff --git a/src/managed/Nota.Remote/RemoteServer.cs b/src/managed/Nota.Remote/RemoteServer.csnew file mode 100644index 00000000..2c367d87--- /dev/null+++ b/src/managed/Nota.Remote/RemoteServer.cs@@ -0,0 +1,167 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Hosts Nota Remote: Kestrel on every interface (a phone on the Wi-Fi must reach it — unlike the+// MCP server, which is loopback-only), serving the phone app from embedded resources and a+// WebSocket at /ws. Nothing on the computer's disk is served; the hub accepts nothing from a+// socket until it pairs or presents a device token.++using System.Net;+using System.Net.NetworkInformation;+using System.Net.Sockets;+using System.Reflection;+using Microsoft.AspNetCore.Builder;+using Microsoft.AspNetCore.Hosting;+using Microsoft.AspNetCore.Http;+using Microsoft.Extensions.Hosting;+using Microsoft.Extensions.Logging;++namespace Nota.Remote;++public sealed class RemoteServer : IAsyncDisposable+{+ private WebApplication? _app;+ private CancellationTokenSource? _cts;+ private static readonly Assembly Asm = typeof(RemoteServer).Assembly;++ public bool Running => _app is not null;+ public int Port { get; private set; }++ /// <summary>Listen on <paramref name="port"/> on all interfaces. Throws when the port is taken.</summary>+ public async Task StartAsync(RemoteHub hub, int port)+ {+ if (_app is not null) return;+ var builder = WebApplication.CreateSlimBuilder();+ builder.Logging.ClearProviders();+ builder.WebHost.ConfigureKestrel(k =>+ {+ k.Listen(IPAddress.Any, port);+ k.AddServerHeader = false;+ });+ var app = builder.Build();+ var cts = new CancellationTokenSource();++ app.UseWebSockets(new WebSocketOptions { KeepAliveInterval = TimeSpan.FromSeconds(5) });+ app.Map("/ws", async (HttpContext ctx) =>+ {+ if (!ctx.WebSockets.IsWebSocketRequest) { ctx.Response.StatusCode = 400; return; }+ using var ws = await ctx.WebSockets.AcceptWebSocketAsync();+ string addr = ctx.Connection.RemoteIpAddress?.ToString() ?? "?";+ using var linked = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, ctx.RequestAborted);+ await hub.RunClientAsync(ws, addr, linked.Token);+ });+ app.MapFallback(ServeStaticAsync); // after /ws: everything else is the phone app++ await app.StartAsync();+ _app = app;+ _cts = cts;+ Port = port;+ }++ public async Task StopAsync()+ {+ if (_app is not { } a) return;+ _app = null;+ _cts?.Cancel();+ try { await a.StopAsync(TimeSpan.FromSeconds(1)); } catch { }+ await a.DisposeAsync();+ _cts?.Dispose();+ _cts = null;+ }++ public async ValueTask DisposeAsync() => await StopAsync();++ // ---- the phone app, from embedded resources ---------------------------------------++ private static readonly Dictionary<string, string> Types = new(StringComparer.OrdinalIgnoreCase)+ {+ [".html"] = "text/html; charset=utf-8",+ [".js"] = "text/javascript; charset=utf-8",+ [".css"] = "text/css; charset=utf-8",+ [".json"] = "application/json",+ [".webmanifest"] = "application/manifest+json",+ [".svg"] = "image/svg+xml",+ [".png"] = "image/png",+ [".woff2"] = "font/woff2",+ [".mp4"] = "video/mp4",+ [".ico"] = "image/x-icon",+ };++ private static readonly Lazy<Dictionary<string, string>> Resources = new(() =>+ Asm.GetManifestResourceNames()+ .Where(n => n.StartsWith("wwwroot", StringComparison.Ordinal))+ .ToDictionary(n => n["wwwroot".Length..].Replace('\\', '/').TrimStart('/'), n => n, StringComparer.Ordinal));++ private static async Task ServeStaticAsync(HttpContext ctx)+ {+ if (!HttpMethods.IsGet(ctx.Request.Method) && !HttpMethods.IsHead(ctx.Request.Method)) { ctx.Response.StatusCode = 405; return; }+ string path = (ctx.Request.Path.Value ?? "/").TrimStart('/');+ if (path.Length == 0) path = "index.html";+ if (path.Contains("..")) { ctx.Response.StatusCode = 400; return; }++ if (!Resources.Value.TryGetValue(path, out var res))+ {+ if (path == "index.html") { await NotBuiltAsync(ctx); return; }+ // An unknown route is the app (it has none of its own), so a bookmarked deep link still opens.+ if (!path.Contains('.') && Resources.Value.TryGetValue("index.html", out var index)) res = index;+ else { ctx.Response.StatusCode = 404; return; }+ path = "index.html";+ }++ string ext = Path.GetExtension(path);+ ctx.Response.ContentType = Types.TryGetValue(ext, out var ct) ? ct : "application/octet-stream";+ // Vite fingerprints everything under assets/; the shell, the worker and the manifest+ // must be re-checked so an updated Nota serves its updated page.+ ctx.Response.Headers.CacheControl = path.StartsWith("assets/", StringComparison.Ordinal)+ ? "public, max-age=31536000, immutable" : "no-cache";+ ctx.Response.Headers["X-Content-Type-Options"] = "nosniff";+ if (path == "index.html") ctx.Response.Headers["Referrer-Policy"] = "no-referrer";++ await using var s = Asm.GetManifestResourceStream(res)!;+ ctx.Response.ContentLength = s.Length;+ if (HttpMethods.IsHead(ctx.Request.Method)) return;+ await s.CopyToAsync(ctx.Response.Body);+ }++ private static Task NotBuiltAsync(HttpContext ctx)+ {+ ctx.Response.ContentType = "text/html; charset=utf-8";+ return ctx.Response.WriteAsync("<!doctype html><meta name=viewport content='width=device-width'>" ++ "<body style='background:#0B0A09;color:#E9E4D8;font:15px system-ui;padding:28px'>" ++ "<h2>Nota Remote</h2><p>This build of Nota was made without the phone app (Node.js wasn't available). " ++ "Build src/web/remote and rebuild Nota.</p>");+ }++ // ---- the address a phone should use ---------------------------------------------++ /// <summary>The computer's address on the local network: the IPv4 of an interface that is up+ /// and has a gateway (Wi-Fi or Ethernet), skipping loopback, VPN tunnels and VM bridges.</summary>+ public static IPAddress? LanAddress()+ {+ IPAddress? fallback = null;+ try+ {+ foreach (var ni in NetworkInterface.GetAllNetworkInterfaces()+ .Where(n => n.OperationalStatus == OperationalStatus.Up)+ .OrderBy(n => n.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ? 0+ : n.NetworkInterfaceType == NetworkInterfaceType.Ethernet ? 1 : 2))+ {+ if (ni.NetworkInterfaceType is NetworkInterfaceType.Loopback or NetworkInterfaceType.Tunnel) continue;+ string n = ni.Name.ToLowerInvariant();+ if (n.StartsWith("utun") || n.StartsWith("bridge") || n.StartsWith("vmnet") || n.StartsWith("docker")+ || n.StartsWith("veth") || n.StartsWith("awdl") || n.StartsWith("llw") || n.Contains("virtual")) continue;+ var props = ni.GetIPProperties();+ foreach (var ua in props.UnicastAddresses)+ {+ if (ua.Address.AddressFamily != AddressFamily.InterNetwork || IPAddress.IsLoopback(ua.Address)) continue;+ var b = ua.Address.GetAddressBytes();+ if (b[0] == 169 && b[1] == 254) continue; // link-local: no DHCP+ if (props.GatewayAddresses.Any(g => g.Address.AddressFamily == AddressFamily.InterNetwork)) return ua.Address;+ fallback ??= ua.Address;+ }+ }+ }+ catch (NetworkInformationException) { }+ return fallback;+ }+}diff --git a/src/managed/Nota.Remote/wwwroot/assets/index-BNuDspFI.js b/src/managed/Nota.Remote/wwwroot/assets/index-BNuDspFI.jsnew file mode 100644index 00000000..d58f4a81--- /dev/null+++ b/src/managed/Nota.Remote/wwwroot/assets/index-BNuDspFI.js@@ -0,0 +1,2 @@+(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible,d=()=>{};function f(e){return e()}function p(e){for(var t=0;t<e.length;t++)e[t]()}function m(){var e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}var h=1024,g=2048,_=4096,v=8192,y=16384,b=32768,x=1<<25,S=65536,C=1<<19,w=1<<20,T=1<<25,ee=1<<21,E=1<<22,D=1<<23,te=Symbol(`$state`),ne=Symbol(`component`),re=Symbol(``),ie=Symbol(`attributes`),ae=Symbol(`class`),oe=Symbol(`style`),se=Symbol(`text`),ce=Symbol(`form reset`),le=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},ue=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),de={},O=Symbol(`uninitialized`),fe=`http://www.w3.org/1999/xhtml`;function pe(){console.warn(`https://svelte.dev/e/derived_inert`)}function me(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function he(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var k=!1;function ge(e){k=e}var A;function _e(e){if(e===null)throw me(),de;return A=e}function ve(){return _e(Xt(A))}function j(e){if(k){if(Xt(A)!==null)throw me(),de;A=e}}function ye(e=1){if(k){for(var t=e,n=A;t--;)n=Xt(n);A=n}}function be(e=!0){for(var t=0,n=A;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=Xt(n);e&&n.remove(),n=i}}function xe(e){if(!e||e.nodeType!==8)throw me(),de;return e.data}function Se(e){return e===this.v}function Ce(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function we(e){return!Ce(e,this.v)}function Te(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Ee(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function De(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Oe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function ke(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ae(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function je(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Me(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Ne(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Pe(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Fe=!1;function Ie(){Fe=!0}var M=null;function Le(e){M=e}function Re(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:H,l:Fe&&!t?{s:null,u:null,$:[]}:null}}function ze(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)dn(r)}return e!==void 0&&(t.x=e),t.i=!0,M=t.p,Be(e)}function Be(e={}){return i(e,ne,{value:!0}),e}function Ve(){return!Fe||M!==null&&M.l===null}var He=[];function Ue(){var e=He;He=[],p(e)}function We(e){if(He.length===0&&!_t){var t=He;queueMicrotask(()=>{t===He&&Ue()})}He.push(e)}function Ge(){for(;He.length>0;)Ue()}var Ke=~(g|_|h);function qe(e,t){e.f=e.f&Ke|t}function Je(e){e.f&512||e.deps===null?qe(e,h):qe(e,_)}function Ye(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),qe(e,h)}var Xe=!1;function Ze(){Xe||(Xe=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[ce]?.()})},{capture:!0}))}function Qe(e){var t=V,n=H;In(null),Ln(null);try{return e()}finally{In(t),Ln(n)}}function $e(e,t,n,r=n){e.addEventListener(t,()=>Qe(n));let i=e[ce];e[ce]=i?()=>{i(),r(!0)}:()=>r(!0),Ze()}function et(e,t,n,r){let i=Ve()?it:st;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=H,c=tt(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){rn(e,s)}nt()}}var d=rt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>ot(e))).then(u).catch(e=>rn(e,s)).finally(d)}l?l.then(()=>{c(),f(),nt()}):f()}function tt(){var e=H,t=V,n=M,r=P;return function(i=!0){Ln(e),In(t),Le(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function nt(e=!0){Ln(null),In(null),Le(null),e&&P?.deactivate()}function rt(){var e=H,t=e.b,n=P,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function it(e){var t=2|g;return H!==null&&(H.f|=C),{ctx:M,deps:null,effects:null,equals:Se,f:t,fn:e,reactions:null,rv:0,v:O,wv:0,parent:H,ac:null}}var at=Symbol(`obsolete`);function ot(e,t,n){let r=H;r===null&&Te();var i=void 0,a=Pt(O),o=!V,s=new Set;return gn(()=>{var t=H,n=m();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==le&&n.reject(e)}).finally(nt)}catch(e){n.reject(e),nt()}var c=P;if(o){if(t.f&32768)var l=rt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(at);else for(let e of s.values())e.reject(at);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==at&&(c.activate(),t?(a.f|=D,Rt(a,t)):(a.f&8388608&&(a.f^=D),Rt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),ln(()=>{for(let e of s)e.reject(at)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=it(e);return zn(t),t}function st(e){let t=it(e);return t.equals=we,t}function ct(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n<t.length;n+=1)Cn(t[n])}}function lt(e){var t,n=H,r=e.parent;if(!Nn&&r!==null&&e.v!==O&&r.f&24576)return pe(),e.v;Ln(r);try{ct(e),t=Zn(e)}finally{Ln(n)}return t}function ut(e){var t=lt(e);if(!e.equals(t)&&(e.wv=Jn(),(!P?.is_fork||e.deps===null)&&(P===null?e.v=t:(P.capture(e,t,!0),mt?.capture(e,t,!0)),e.deps===null))){qe(e,h);return}Nn||(ht===null?Je(e):(cn()||P?.is_fork)&&ht.set(e,t))}function dt(e){if(e.effects!==null)for(let t of e.effects)(t.teardown||t.ac)&&(t.teardown?.(),t.ac!==null&&Qe(()=>{t.ac.abort(le),t.ac=null}),t.fn!==null&&(t.teardown=d),er(t,0),xn(t))}function ft(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&tr(t)}var pt=null,P=null,mt=null,ht=null,gt=null,_t=!1,vt=!1,yt=null,bt=null,xt=0,St=1,Ct=class e{id=St++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){pt===null?pt=this:(pt.#n=this,this.#t=pt),pt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)qe(r,g),t(r);for(r of n.m)qe(r,_),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=h}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),qe(e,g),this.schedule(e);for(let e of this.#d)qe(e,_),this.schedule(e);this.apply();for(var t=yt=[],n=[],r=bt=[];this.#c.length>0;){xt++>1e3&&(this.#S(),Tt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw At(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(yt=null,bt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)kt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),mt=this,Dt(n),Dt(t),mt=null,this.#s?.resolve();var o=P;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(Mt.clear(),o.#_())}#v(e,t,n){e.f^=h;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=h:i&4?t.push(r):Yn(r)&&(i&16&&this.#d.add(r),tr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),qe(i,g),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=this,this.#_()}#x(e){for(var t=0;t<e.length;t+=1)Ye(e[t],this.#u,this.#d)}capture(e,t,n=!1){e.v!==O&&!this.previous.has(e)&&this.previous.set(e,e.v),e.f&8388608||(this.current.set(e,[t,n]),ht?.set(e,t)),this.is_fork||(e.v=t)}activate(){P=this}deactivate(){P=null,ht=null}flush(){try{vt=!0,P=this,this.#_()}finally{xt=0,gt=null,yt=null,bt=null,vt=!1,P=null,ht=null,Mt.clear()}}discard(){for(let e of this.#i)e(this);this.#i.clear();for(let e of this.async_deriveds.values())e.reject(at);this.#S(),this.#s?.resolve()}register_created_effect(e){this.#l.push(e)}increment(e,t){if(this.#a+=1,e){let e=this.#o.get(t)??0;this.#o.set(t,e+1)}}decrement(e,t){if(--this.#a,e){let e=this.#o.get(t)??0;e===1?this.#o.delete(t):this.#o.set(t,e-1)}this.#m||(this.#m=!0,We(()=>{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=m()).promise}static ensure(){if(P===null){let t=P=new e;!vt&&!_t&&We(()=>{t.#e||t.flush()})}return P}apply(){ht=null}schedule(e){if(gt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?pt=e:t.#t=e,this.linked=!1}}};function wt(e){var t=_t;_t=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Ge(),P===null)return n;P.flush()}}finally{_t=t}}function Tt(){try{Ae()}catch(e){rn(e,gt)}}var Et=null;function Dt(e){var t=e.length;if(t!==0){for(var n=0;n<t;){var r=e[n++];if(!(r.f&24576)&&Yn(r)&&(Et=new Set,tr(r),r.deps===null&&r.first===null&&r.nodes===null&&r.teardown===null&&r.ac===null&&Tn(r),Et?.size>0)){Mt.clear();for(let e of Et){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Et.has(n)&&(Et.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||tr(n)}}Et.clear()}}Et=null}}function Ot(e){P.schedule(e)}function kt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),qe(e,h);for(var n=e.first;n!==null;)kt(n,t),n=n.next}}function At(e){qe(e,h);for(var t=e.first;t!==null;)At(t),t=t.next}var jt=new Set,Mt=new Map,Nt=!1;function Pt(e,t){return{f:0,v:e,reactions:null,equals:Se,rv:0,wv:0}}function F(e,t){let n=Pt(e,t);return zn(n),n}function Ft(e,t=!1,n=!0){let r=Pt(e);return t||(r.equals=we),Fe&&n&&M!==null&&M.l!==null&&(M.l.s??=[]).push(r),r}function I(e,t,n=!1){return V!==null&&(!Fn||V.f&131072)&&Ve()&&V.f&4325394&&(Rn===null||!Rn.has(e))&&Ne(),Rt(e,n?Ht(t):t,bt)}var It=null,Lt=0;function Rt(e,t,n=null){if(!e.equals(t)){Nn?Mt.set(e,t):Mt.has(e)||Mt.set(e,e.v);var r=Ct.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&<(t),ht===null&&Je(t)}e.wv=Jn(),It=null,Lt=0,Vt(e,g,n),It=null,Ve()&&H!==null&&H.f&1024&&!(H.f&96)&&(Hn===null?Un([e]):Hn.push(e)),!r.is_fork&&jt.size>0&&!Nt&&zt()}return t}function zt(){Nt=!1;for(let e of jt){e.f&1024&&qe(e,_);let t;try{t=Yn(e)}catch{t=!0}t&&tr(e)}jt.clear()}function Bt(e){I(e,e.v+1)}function Vt(e,t,n){var r=e.reactions;if(r!==null){var i=Ve(),a=r.length;if(Lt+=a,Lt>1e5&&It===null&&(It=new Set),It!==null){if(It.has(e))return;It.add(e)}for(var o=0;o<a;o++){var s=r[o],c=s.f;if(i||s!==H){var l=(c&g)===0;if(l&&qe(s,t),c&131072)jt.add(s);else if(c&2){var u=s;ht?.delete(u),Vt(u,_,n)}else if(l){var d=s;c&16&&Et!==null&&Et.add(d),n===null?Ot(d):n.push(d)}}}}}function Ht(t){if(typeof t!=`object`||!t||te in t||ne in t)return t;let n=l(t);if(n!==s&&n!==c)return t;var r=new Map,i=e(t),o=F(0),u=null,d=Kn,f=e=>{if(Kn===d)return e();var t=V,n=Kn;In(null),qn(d);var r=e();return In(t),qn(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&je();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(O,u));r.set(t,e),Bt(o)}}else I(n,O),Bt(o);return!0},get(e,n,i){if(n===te)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Ht(s?e[n]:O),u)),r.set(n,o)),o!==void 0){var c=U(o);return c===O?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=U(i);if(a===O)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===te)return!0;var n=r.get(t),i=n!==void 0&&n.v!==O||Reflect.has(e,t);return(n!==void 0||H!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Ht(e[t]):O,u)),r.set(t,n)),U(n)===O)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;d<c.v;d+=1){var p=r.get(d+``);p===void 0?d in e&&(p=f(()=>F(O,u)),r.set(d+``,p)):I(p,O)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Ht(n)),r.set(t,c));else{l=c.v!==O;var m=f(()=>Ht(n));I(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&I(g,_+1)}Bt(o)}return!0},ownKeys(e){U(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==O});for(var[n,i]of r)i.v!==O&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Me()}})}var Ut,Wt,Gt,Kt;function qt(){if(Ut===void 0){Ut=window,Wt=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;Gt=a(t,`firstChild`).get,Kt=a(t,`nextSibling`).get,u(e)&&(e[ae]=void 0,e[ie]=null,e[oe]=void 0,e.__e=void 0),u(n)&&(n[se]=void 0)}}function Jt(e=``){return document.createTextNode(e)}function Yt(e){return Gt.call(e)}function Xt(e){return Kt.call(e)}function L(e,t){if(!k)return Yt(e);var n=Yt(A);if(n===null)n=A.appendChild(Jt());else if(t&&n.nodeType!==3){var r=Jt();return n?.before(r),_e(r),r}return t&&tn(n),_e(n),n}function Zt(e,t=!1){if(!k){var n=Yt(e);return n instanceof Comment&&n.data===``?Xt(n):n}if(t){if(A?.nodeType!==3){var r=Jt();return A?.before(r),_e(r),r}tn(A)}return A}function R(e,t=!1){if(!k)return Yt(e);var n=L(e,t);return j(e),n}function z(e,t=1,n=!1){let r=k?A:e;for(var i;t--;)i=r,r=Xt(r);if(!k)return r;if(n){if(r?.nodeType!==3){var a=Jt();return r===null?i?.after(a):r.before(a),_e(a),a}tn(r)}return _e(r),r}function Qt(e){e.textContent=``}function $t(){return!1}function en(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function tn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function nn(e){var t=H;if(t===null)return V.f|=D,e;if(!(t.f&32768)&&!(t.f&4))throw e;rn(e,t)}function rn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function an(e){H===null&&(V===null&&ke(e),Oe()),Nn&&De(e)}function on(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function sn(e,t){var n=H;n!==null&&n.f&8192&&(e|=v);var r={ctx:M,deps:null,nodes:null,f:e|g|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};P?.register_created_effect(r);var i=r;if(e&4)yt===null?Ct.ensure().schedule(r):yt.push(r);else if(t!==null){try{tr(r)}catch(e){throw Cn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=S))}if(i!==null&&(i.parent=n,n!==null&&on(i,n),V!==null&&V.f&2&&!(e&64))){var a=V;(a.effects??=[]).push(i)}return r}function cn(){return V!==null&&!Fn}function ln(e){let t=sn(8,null);return qe(t,h),t.teardown=e,t}function un(e){an(`$effect`);var t=H.f;if(!V&&t&32&&M!==null&&!M.i){var n=M;(n.e??=[]).push(e)}else return dn(e)}function dn(e){return sn(4|w,e)}function fn(e){return an(`$effect.pre`),sn(8|w,e)}function pn(e){Ct.ensure();let t=sn(64|C,e);return()=>{Cn(t)}}function mn(e){Ct.ensure();let t=sn(64|C,e);return(e={})=>new Promise(n=>{e.outro?En(t,()=>{Cn(t),n(void 0)}):(Cn(t),n(void 0))})}function hn(e){return sn(4,e)}function gn(e){return sn(E|C,e)}function _n(e,t=0){return sn(8|t,e)}function B(e,t=[],n=[],r=[]){et(r,t,n,t=>{sn(8,()=>{e(...t.map(U))})})}function vn(e,t=0){return sn(16|t,e)}function yn(e){return sn(32|C,e)}function bn(e){var t=e.teardown;if(t!==null){let n=Nn,r=V;Pn(!0),In(null);try{t.call(null)}catch(t){rn(t,e.parent)}finally{Pn(n),In(r)}}}function xn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&Qe(()=>{e.abort(le)});var r=n.next;n.f&64?n.parent=null:Cn(n,t),n=r}}function Sn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Cn(t),t=n}}function Cn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(wn(e.nodes.start,e.nodes.end),n=!0),e.f|=x,xn(e,t&&!n),er(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();bn(e),e.f^=x,e.f|=y;var i=e.parent;i!==null&&i.first!==null&&Tn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function wn(e,t){for(;e!==null;){var n=e===t?null:Xt(e);e.remove(),e=n}}function Tn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function En(e,t,n=!0){var r=[];e.f|=256,Dn(e,r,!0);var i=()=>{n&&Cn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Dn(e,t,n){if(!(e.f&8192)){e.f^=v;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Dn(i,t,o?n:!1)}i=a}}}function On(e){e.f&=-257,kn(e,!0)}function kn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=v,e.f&1024||(qe(e,g),Ct.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);kn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function An(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:Xt(n);t.append(n),n=i}}var jn=null,Mn=!1,Nn=!1;function Pn(e){Nn=e}var V=null,Fn=!1;function In(e){V=e}var H=null;function Ln(e){H=e}var Rn=null;function zn(e){V!==null&&(V.f&2097152||V.f&2)&&(Rn??=new Set).add(e)}var Bn=null,Vn=0,Hn=null;function Un(e){Hn=e}var Wn=1,Gn=0,Kn=Gn;function qn(e){Kn=e}function Jn(){return++Wn}function Yn(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;i<r;i++){var a=n[i];if(Yn(a)&&ut(a),a.wv>e.wv)return!0}t&512&&ht===null&&qe(e,h)}return!1}function Xn(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Rn!==null&&Rn.has(e)))for(var i=0;i<r.length;i++){var a=r[i];a.f&2?Xn(a,t,!1):t===a&&(n?qe(a,g):a.f&1024&&qe(a,_),Ot(a))}}function Zn(e){var t=Bn,n=Vn,r=Hn,i=V,a=Rn,o=M,s=Fn,c=Kn,l=e.f;Bn=null,Vn=0,Hn=null,V=l&96?null:e,Rn=null,Le(e.ctx),Fn=!1,Kn=++Gn,e.ac!==null&&(Qe(()=>{e.ac.abort(le)}),e.ac=null);try{e.f|=ee;var u=e.fn,d=u();e.f|=b;var f=Qn(e);if(Ve()&&Hn!==null&&!Fn&&f!==null&&!(e.f&6146))for(var p=0;p<Hn.length;p++)Xn(Hn[p],e);if(i!==null&&i!==e){if(Gn++,i.deps!==null)for(let e=0;e<n;e+=1)i.deps[e].rv=Gn;if(t!==null)for(let e of t)e.rv=Gn;Hn!==null&&(r===null?r=Hn:r.push(...Hn))}return e.f&8388608&&(e.f^=D),d}catch(t){return Qn(e),nn(t)}finally{e.f^=ee,Bn=t,Vn=n,Hn=r,V=i,Rn=a,Le(o),Fn=s,Kn=c}}function Qn(e){var t=e.deps,n=P?.is_fork;if(Bn!==null){var r;if(n||er(e,Vn),t!==null&&Vn>0)for(t.length=Vn+Bn.length,r=0;r<Bn.length;r++)t[Vn+r]=Bn[r];else e.deps=t=Bn;if(cn()&&e.f&512)for(r=Vn;r<t.length;r++)(t[r].reactions??=[]).push(e)}else!n&&t!==null&&Vn<t.length&&(er(e,Vn),t.length=Vn);return t}function $n(e,r){let i=r.reactions;if(i!==null){var a=t.call(i,e);if(a!==-1){var o=i.length-1;o===0?i=r.reactions=null:(i[a]=i[o],i.pop())}}if(i===null&&r.f&2&&(Bn===null||!n.call(Bn,r))){var s=r;s.f&512&&(s.f^=512),s.v!==O&&Je(s),s.ac!==null&&Qe(()=>{s.ac.abort(le),s.ac=null,qe(s,g)}),dt(s),er(s,0)}}function er(e,t){var n=e.deps;if(n!==null)for(var r=t;r<n.length;r++)$n(e,n[r])}function tr(e){var t=e.f;if(!(t&16384)){qe(e,h);var n=H,r=Mn;H=e,Mn=!(t&96);try{t&16777232?Sn(e):xn(e),bn(e);var i=Zn(e);e.teardown=typeof i==`function`?i:null,e.wv=Wn}finally{Mn=r,H=n}}}async function nr(){await Promise.resolve(),wt()}function U(e){var t=!!(e.f&2);if(jn?.add(e),V!==null&&!Fn&&!(H!==null&&H.f&16384)&&(Rn===null||!Rn.has(e))){var r=V.deps;if(V.f&2097152)e.rv<Gn&&(e.rv=Gn,Bn===null&&r!==null&&r[Vn]===e?Vn++:Bn===null?Bn=[e]:Bn.push(e));else{V.deps??=[],n.call(V.deps,e)||V.deps.push(e);var i=e.reactions;i===null?e.reactions=[V]:n.call(i,V)||i.push(V)}}if(Nn&&Mt.has(e))return Mt.get(e);if(t){var a=e;if(Nn){var o=a.v;return(!(a.f&1024)&&a.reactions!==null||ir(a))&&(o=lt(a)),Mt.set(a,o),o}var s=!(a.f&512)&&!Fn&&V!==null&&(Mn||!!(V.f&512)),c=(a.f&b)===0;Yn(a)&&(s&&(a.f|=512),ut(a)),s&&!c&&(ft(a),rr(a))}if(ht?.has(e))return ht.get(e);if(e.f&8388608)throw e.v;return e.v}function rr(e){if(e.f|=512,e.deps!==null)for(let t of e.deps)(t.reactions??=[]).push(e),t.f&2&&!(t.f&512)&&(ft(t),rr(t))}function ir(e){if(e.v===O)return!0;if(e.deps===null)return!1;for(let t of e.deps)if(Mt.has(t)||t.f&2&&ir(t))return!0;return!1}function ar(e){var t=Fn;try{return Fn=!0,e()}finally{Fn=t}}function or(e){if(!(typeof e!=`object`||!e||e instanceof EventTarget)){if(te in e)sr(e);else if(!Array.isArray(e))for(let t in e){let n=e[t];typeof n==`object`&&n&&te in n&&sr(n)}}}function sr(e,t=new Set){if(typeof e==`object`&&e&&!(e instanceof EventTarget)&&!t.has(e)){t.add(e),e instanceof Date&&e.getTime();for(let n in e)try{sr(e[n],t)}catch{}let n=l(e);if(n!==Object.prototype&&n!==Array.prototype&&n!==Map.prototype&&n!==Set.prototype&&n!==Date.prototype){let t=o(n);for(let n in t){let r=t[n].get;if(r)try{r.call(e)}catch{}}}}}[...`allowfullscreen.async.autofocus.autoplay.checked.controls.default.disabled.formnovalidate.indeterminate.inert.ismap.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.seamless.selected.webkitdirectory.defer.disablepictureinpicture.disableremoteplayback`.split(`.`)];var cr=[`touchstart`,`touchmove`];function lr(e){return cr.includes(e)}var ur=Symbol(`events`),dr=new Set,fr=new Set;function pr(e,t,n,r={}){function i(e){if(r.capture||vr.call(t,e),!e.cancelBubble)return Qe(()=>n?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,We(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function mr(e,t,n,r,i){var a={capture:r,passive:i},o=pr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&ln(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function W(e,t,n){(t[ur]??={})[e]=n}function hr(e){for(var t=0;t<e.length;t++)dr.add(e[t]);for(var n of fr)n(e)}var gr=null,_r=!1;function vr(e){var t=this,n=t.ownerDocument,r=e.type,a=e.composedPath?.()||[],o=a[0]||e.target;gr=e,_r||(_r=!0,setTimeout(()=>{_r=!1,gr=null}));var s=0,c=gr===e&&e[ur];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[ur]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=V,f=H;In(null),Ln(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[ur]?.[r];h!=null&&(!o.disabled||e.target===o)&&h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s<a.length?a[s]:null}if(p){for(let e of m)queueMicrotask(()=>{throw e});throw p}}finally{e[ur]=t,delete e.currentTarget,In(d),Ln(f)}}}var yr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function br(e){return yr?.createHTML(e)??e}function xr(e){var t=en(`template`);return t.innerHTML=br(e.replaceAll(`<!>`,`<!---->`)),t.content}function Sr(e,t){var n=H;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function G(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(`<!>`);return()=>{if(k)return Sr(A,null),A;i===void 0&&(i=xr(a?e:`<!>`+e),n||(i=Yt(i)));var t=r||Wt?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=Yt(t),s=t.lastChild;Sr(o,s)}else Sr(t,t);return t}}function Cr(e,t,n=`svg`){var r=!e.startsWith(`<!>`),i=!!(t&1),a=`<${n}>${r?e:`<!>`+e}</${n}>`,o;return()=>{if(k)return Sr(A,null),A;if(!o){var e=Yt(xr(a));if(i)for(o=document.createDocumentFragment();Yt(e);)o.appendChild(Yt(e));else o=Yt(e)}var t=o.cloneNode(!0);if(i){var n=Yt(t),r=t.lastChild;Sr(n,r)}else Sr(t,t);return t}}function wr(e,t){return Cr(e,t,`svg`)}function Tr(){if(k)return Sr(A,null),A;var e=document.createDocumentFragment(),t=document.createComment(``),n=Jt();return e.append(t,n),Sr(t,n),e}function K(e,t){if(k){var n=H;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=A),ve();return}e!==null&&e.before(t)}function Er(e){let t=0,n=Pt(0),r;return()=>{cn()&&(U(n),_n(()=>(t===0&&(r=ar(()=>e(()=>Bt(n)))),t+=1,()=>{We(()=>{--t,t===0&&(r?.(),r=void 0,Bt(n))})})))}}var Dr=S|C;function Or(e,t,n,r){new kr(e,t,n,r)}var kr=class{parent;is_pending=!1;transform_error;#e;#t=k?A:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Er(()=>(this.#m=Pt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=H;t.b=this,t.f|=128,n(e)},this.parent=H.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=vn(()=>{if(k){let e=this.#t;ve();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Dr),k&&(this.#e=A)}#g(){try{this.#a=yn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);We(r),t&&(this.#s=yn(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){he();return}t=!0,n&&Pe(),this.#s!==null&&En(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()})};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){rn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=yn(()=>e(this.#e)),We(()=>{var e=this.#c=document.createDocumentFragment(),t=Jt(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return yn(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){rn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,En(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=yn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();An(this.#a,e);let t=this.#n.pending;this.#o=yn(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){Ye(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=H,n=V,r=M;Ln(this.#i),In(this.#i),Le(this.#i.ctx);try{return Ct.ensure(),e()}finally{Ln(t),In(n),Le(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&En(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,We(()=>{this.#d=!1,this.#m&&Rt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),U(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Cn(this.#a),null),this.#o&&=(Cn(this.#o),null),this.#s&&=(Cn(this.#s),null),k&&(_e(this.#t),ye(),_e(be()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return yn(()=>{var r=H;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return rn(e,this.#i.parent),null}}))};We(()=>{var t;try{t=this.transform_error(e)}catch(e){rn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>rn(e,this.#i&&this.#i.parent)):n(t)})}};function q(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[se]??=e.nodeValue)&&(e[se]=n,e.nodeValue=`${n}`)}function Ar(e,t){return Mr(e,t)}var jr=new Map;function Mr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){qt();var l=void 0,u=mn(()=>{var s=n??t.appendChild(Jt());Or(s,{pending:()=>{}},t=>{Re({});var n=M;if(o&&(n.c=o),a&&(i.$$events=a),k&&Sr(t,null),l=e(t,i)||Be(),k&&(H.nodes.end=A,A===null||A.nodeType!==8||A.data!==`]`))throw me(),de;ze()},c);var u=new Set,d=e=>{for(var n=0;n<e.length;n++){var r=e[n];if(!u.has(r)){u.add(r);var i=lr(r);for(let e of[t,document]){var a=jr.get(e);a===void 0&&(a=new Map,jr.set(e,a));var o=a.get(r);o===void 0?(e.addEventListener(r,vr,{passive:i}),a.set(r,1)):a.set(r,o+1)}}}};return d(r(dr)),fr.add(d),()=>{for(var e of u)for(let n of[t,document]){var r=jr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,vr),r.delete(e),r.size===0&&jr.delete(n)):r.set(e,i)}fr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Nr.set(l,u),l}var Nr=new WeakMap,Pr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)On(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(On(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(Cn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();An(r,t),t.append(Jt()),this.#n.set(e,{effect:r,fragment:t})}else Cn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),En(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(Cn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=$t();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=Jt();i.append(a),this.#n.set(e,{effect:yn(()=>t(a)),fragment:i})}else this.#t.set(e,yn(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else k&&(this.anchor=A),this.#a(n)}};function J(e,t,n=!1){var r;k&&(r=A,ve());var i=new Pr(e),a=n?S:0;function o(e,t){if(k){var n=xe(r);if(e!==parseInt(n.substring(1))){var a=be();_e(a),i.anchor=a,ge(!1),i.ensure(e,t),ge(!0);return}}i.ensure(e,t)}vn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}function Fr(e,t){return t}function Ir(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c<a;c++){let n=t[c];En(n,()=>{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Lr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;Qt(d),d.append(u),e.items.clear()}Lr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Lr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i<t.length;i++){var a=t[i];r?.has(a)?(a.f|=T,An(a,document.createDocumentFragment())):Cn(t[i],n)}}var Rr;function Y(t,n,i,a,o,s=null){var c=t,l=new Map;if(n&4){var u=t;c=k?_e(Yt(u)):u.appendChild(Jt())}k&&ve();var d=null,f=st(()=>{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Br(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=T,Hr(d,null,c)):On(d):En(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:vn(()=>{p=U(f);var e=p.length;let t=!1;k&&xe(c)===`[!`!=(e===0)&&(c=be(),_e(c),ge(!1),t=!0);for(var r=new Set,u=P,v=$t(),y=0;y<e;y+=1){k&&A.nodeType===8&&A.data===`]`&&(c=A,t=!0,ge(!1));var b=p[y],x=a(b,y),S=h?null:l.get(x);S?(S.v&&Rt(S.v,b),S.i&&Rt(S.i,y),v&&u.unskip_effect(S.e)):(S=Vr(l,h?c:Rr??=Jt(),b,x,y,o,n,i),h||(S.e.f|=T),l.set(x,S)),r.add(x)}if(e===0&&s&&!d&&(h?d=yn(()=>s(c)):(d=yn(()=>s(Rr??=Jt())),d.f|=T)),e>r.size&&Ee(``,``,``),k&&e>0&&_e(be()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&ge(!0),U(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,k&&(c=A)}function zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Br(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v<s;v+=1)h=t[v],g=a(h,v),_=c.get(g).e,_.f&33554432||(_.nodes?.a?.measure(),(f??=new Set).add(_));for(v=0;v<s;v+=1){if(h=t[v],g=a(h,v),_=c.get(g).e,e.outrogroups!==null)for(let t of e.outrogroups)t.pending.delete(_),t.done.delete(_);if(_.f&8192&&(On(_),o&&(_.nodes?.a?.unfix(),(f??=new Set).delete(_))),_.f&33554432){if(_.f^=T,_===l)Hr(_,null,n);else{var y=d?d.next:l;_===e.effect.last&&(e.effect.last=_.prev),_.prev&&(_.prev.next=_.next),_.next&&(_.next.prev=_.prev),Ur(e,d,_),Ur(e,_,y),Hr(_,y,n),d=_,p=[],m=[],l=zr(d.next);continue}}if(_!==l){if(u!==void 0&&u.has(_)){if(p.length<m.length){var b=m[0],x;d=b.prev;var S=p[0],C=p[p.length-1];for(x=0;x<p.length;x+=1)Hr(p[x],b,n);for(x=0;x<m.length;x+=1)u.delete(m[x]);Ur(e,S.prev,C.next),Ur(e,d,S),Ur(e,C,b),l=b,d=C,--v,p=[],m=[]}else u.delete(_),Hr(_,l,n),Ur(e,_.prev,_.next),Ur(e,_,d===null?e.effect.first:d.next),Ur(e,d,_),d=_;continue}for(p=[],m=[];l!==null&&l!==_;)(u??=new Set).add(l),m.push(l),l=zr(l.next);if(l===null)continue}_.f&33554432||p.push(_),d=_,l=zr(_.next)}if(e.outrogroups!==null){for(let t of e.outrogroups)t.pending.size===0&&(Lr(e,r(t.done)),e.outrogroups?.delete(t));e.outrogroups.size===0&&(e.outrogroups=null)}if(l!==null||u!==void 0){var w=[];if(u!==void 0)for(_ of u)_.f&8192||w.push(_);for(;l!==null;)!(l.f&8192)&&l!==e.fallback&&w.push(l),l=zr(l.next);var ee=w.length;if(ee>0){var E=i&4&&s===0?n:null;if(o){for(v=0;v<ee;v+=1)w[v].nodes?.a?.measure();for(v=0;v<ee;v+=1)w[v].nodes?.a?.fix()}Ir(e,w,E)}}o&&We(()=>{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function Vr(e,t,n,r,i,a,o,s){var c=o&1?o&16?Pt(n):Ft(n,!1,!1):null,l=o&2?Pt(i):null;return{v:c,i:l,e:yn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function Hr(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=Xt(r);if(a.before(r),r===i)return;r=o}}function Ur(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Wr(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Wr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Gr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Wr(e))&&(r&&(r+=` `),r+=t);return r}function Kr(e){return typeof e==`object`?Gr(e):e??``}var qr=[...`+\r\f\xA0\v`];function Jr(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||qr.includes(r[o-1]))&&(s===r.length||qr.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function Yr(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function Xr(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function Zr(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(Xr)),i&&c.push(...Object.keys(i).map(Xr));var l=0,u=-1;let t=e.length;for(var d=0;d<t;d++){var f=e[d];if(s?f===`/`&&e[d-1]===`*`&&(s=!1):a?a===f&&(a=!1):f===`/`&&e[d+1]===`*`?s=!0:f===`"`||f===`'`?a=f:f===`(`?o++:f===`)`&&o--,!s&&a===!1&&o===0){if(f===`:`&&u===-1)u=d;else if(f===`;`||d===t-1){if(u!==-1){var p=Xr(e.substring(l,u).trim());if(!c.includes(p)){f!==`;`&&d++;var m=e.substring(l,d).trim();n+=` `+m+`;`}}l=d+1,u=-1}}}}return r&&(n+=Yr(r)),i&&(n+=Yr(i,!0)),n=n.trim(),n===``?null:n}return e==null?null:String(e)}function X(e,t,n,r,i,a){var o=e[ae];if(k||o!==n||o===void 0){var s=Jr(n,r,a);(!k||s!==e.getAttribute(`class`))&&(s==null?e.removeAttribute(`class`):t?e.className=s:e.setAttribute(`class`,s)),e[ae]=n}else if(a&&i!==a)for(var c in a){var l=!!a[c];(i==null||l!==!!i[c])&&e.classList.toggle(c,l)}return a}function Qr(e,t={},n,r){for(var i in n){var a=n[i];t[i]!==a&&(n[i]==null?e.style.removeProperty(i):e.style.setProperty(i,a,r))}}function Z(e,t,n,r){var i=e[oe];if(k||i!==t){var a=Zr(t,r);(!k||a!==e.getAttribute(`style`))&&(a==null?e.removeAttribute(`style`):e.style.cssText=a),e[oe]=t}else r&&(Array.isArray(r)?(Qr(e,n?.[0],r[0]),Qr(e,n?.[1],r[1],`important`)):Qr(e,n,r));return r}var $r=Symbol(`is custom element`),ei=Symbol(`is html`),ti=ue?`link`:`LINK`;function ni(e){if(k){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[ce]=n,We(n),Ze()}}function Q(e,t,n,r){var i=ri(e);k&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===ti)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[re]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&ai(e).has(t)?e[t]=n:e.setAttribute(t,n))}function ri(e){return e[ie]??={[$r]:e.nodeName.includes(`-`),[ei]:e.namespaceURI===fe}}var ii=new Map;function ai(e){var t=e.getAttribute(`is`)||e.nodeName,n=ii.get(t);if(n)return n;ii.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function oi(e,t,n=t){var r=new WeakSet;$e(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=si(e)?ci(a):a,n(a),P!==null&&r.add(P),await nr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(k&&e.defaultValue!==e.value||ar(t)==null&&e.value)&&(n(si(e)?ci(e.value):e.value),P!==null&&r.add(P)),_n(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}si(e)&&n===ci(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}function si(e){var t=e.type;return t===`number`||t===`range`}function ci(e){return e===``?null:+e}function li(e,t){return e===t||e?.[te]===t}function ui(e=Be(),t,n,r){var i=M.r,a=H;return hn(()=>{var o,s;return _n(()=>{o=s,s=r?.()||[],ar(()=>{li(n(...s),e)||(t(e,...s),o&&li(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&li(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function di(e=!1){let t=M,n=t.l.u;if(!n)return;let r=()=>or(t.s);if(e){let e=0,n={},i=it(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>U(i)}n.b.length&&fn(()=>{fi(t,r),p(n.b)}),un(()=>{let e=ar(()=>n.m.map(f));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&un(()=>{fi(t,r),p(n.a)})}function fi(e,t){if(e.l.s)for(let t of e.l.s)U(t);t()}function pi(e){var t=Pt(0);return function(){return arguments.length===1?(I(t,U(t)+1),arguments[0]):(U(t),e())}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);var mi=`nota-remote:`,hi={get(e,t=``){try{return localStorage.getItem(mi+e)??t}catch{return t}},set(e,t){try{localStorage.setItem(mi+e,t)}catch{}},del(e){try{localStorage.removeItem(mi+e)}catch{}}},gi={theme:`nota`,haptics:!0,countIn:!0,fullVel:!1,keysMode:`Scale`,octave:3,key:null,xyHold:!0,bank:0,groupsOpen:[]};function _i(){let e=navigator.userAgent;return/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/iPhone/.test(e)?`iPhone`:/Android/.test(e)?/Mobile/.test(e)?`Android phone`:`Android tablet`:`Phone`}var $=new class{#e=F(null);get proj(){return U(this.#e)}set proj(e){I(this.#e,e,!0)}#t=F(Ht({play:!1,rec:!1,loop:!1,met:!1,pos:0,bpm:120,ls:0,le:16,can:!1}));get tp(){return U(this.#t)}set tp(e){I(this.#t,e,!0)}#n=F(Ht([]));get lit(){return U(this.#n)}set lit(e){I(this.#n,e,!0)}#r=F(Ht({}));get who(){return U(this.#r)}set who(e){I(this.#r,e,!0)}#i=F(null);get mix(){return U(this.#i)}set mix(e){I(this.#i,e,!0)}#a=F(null);get xy(){return U(this.#a)}set xy(e){I(this.#a,e,!0)}#o=F(null);get mac(){return U(this.#o)}set mac(e){I(this.#o,e,!0)}#s=F(null);get ses(){return U(this.#s)}set ses(e){I(this.#s,e,!0)}#c=F(Ht({on:!1,pend:null}));get learn(){return U(this.#c)}set learn(e){I(this.#c,e,!0)}#l=F(null);get learned(){return U(this.#l)}set learned(e){I(this.#l,e,!0)}#u=F(`connecting`);get link(){return U(this.#u)}set link(e){I(this.#u,e,!0)}#d=F(-1);get rtt(){return U(this.#d)}set rtt(e){I(this.#d,e,!0)}#f=F(0);get conn(){return U(this.#f)}set conn(e){I(this.#f,e,!0)}#p=F(Ht(hi.get(`host`,`Nota`)));get host(){return U(this.#p)}set host(e){I(this.#p,e,!0)}#m=F(null);get deny(){return U(this.#m)}set deny(e){I(this.#m,e,!0)}everConnected=!1;#h=F(Ht(hi.get(`screen`,``)||`Pads`));get screen(){return U(this.#h)}set screen(e){I(this.#h,e,!0)}#g=F(!1);get bigTransport(){return U(this.#g)}set bigTransport(e){I(this.#g,e,!0)}#_=F(null);get sheet(){return U(this.#_)}set sheet(e){I(this.#_,e,!0)}#v=F(null);get toast(){return U(this.#v)}set toast(e){I(this.#v,e,!0)}#y=F(null);get countIn(){return U(this.#y)}set countIn(e){I(this.#y,e,!0)}#b=F(Ht(hi.get(`name`,_i())));get name(){return U(this.#b)}set name(e){I(this.#b,e,!0)}#x=F(Ht({...gi,...JSON.parse(hi.get(`prefs`,`{}`)||`{}`)}));get prefs(){return U(this.#x)}set prefs(e){I(this.#x,e,!0)}posAt=0;posBase=0;ws=null;pingTimer=0;retryTimer=0;lostSince=0;lastPong=0;rtts=[];toastTimer=0;learnedTimer=0;pairCode=null;screenChosen=!!hi.get(`screen`,``);constructor(){let e=/[#&]p=(\d{4})/.exec(location.hash);e&&(this.pairCode=e[1],history.replaceState(null,``,location.pathname+location.search)),pn(()=>{un(()=>{hi.set(`prefs`,JSON.stringify(this.prefs))}),un(()=>{hi.set(`screen`,this.screen)})})}get token(){return hi.get(`token`)}get track(){let e=this.proj;return e?e.tracks.find(t=>t.id===e.you)??null:null}get playable(){return this.proj?.tracks.filter(e=>e.kind===`drum`||e.kind===`inst`||e.kind===`audio`)??[]}get canControl(){return this.proj?.access!==`play`}get dark(){return this.prefs.theme===`phone`?matchMedia(`(prefers-color-scheme: dark)`).matches:this.proj?.dark??!0}connect(){clearTimeout(this.retryTimer),this.ws&&(this.ws.onclose=null,this.ws.close());let e=location.protocol===`https:`?`wss:`:`ws:`,t;try{t=new WebSocket(`${e}//${location.host}/ws`)}catch{this.retry();return}this.ws=t;let n=Date.now();t.onopen=()=>{let e={v:1,name:this.name,model:_i(),track:Number(hi.get(`track`,`0`)),screen:this.screen,follow:hi.get(`follow`)===`1`};this.pairCode?this.raw({t:`pair`,code:this.pairCode,...e}):this.token?this.raw({t:`hello`,token:this.token,...e}):(this.link=`expired`,this.deny=`new`)},t.onmessage=e=>{try{this.onMessage(JSON.parse(e.data))}catch{}},t.onclose=()=>{this.ws=null,clearInterval(this.pingTimer),this.link!==`left`&&this.link!==`expired`&&(this.link===`ok`||this.link===`weak`?(this.link=`lost`,this.lostSince=Date.now()):(this.link===`connecting`&&Date.now()-n>0&&!this.everConnected&&Date.now()-this.firstTry>4e3||this.link===`lost`&&Date.now()-this.lostSince>1e4)&&(this.link=`down`),this.retry())}}firstTry=Date.now();retry(){clearTimeout(this.retryTimer);let e=this.link===`down`?3e3:this.link===`lost`?700:1200;this.retryTimer=window.setTimeout(()=>this.connect(),e)}wake(){this.link!==`left`&&(!this.ws||this.ws.readyState>1||Date.now()-this.lastPong>3e3)&&((this.link===`ok`||this.link===`weak`)&&(this.link=`lost`,this.lostSince=Date.now()),this.connect())}startPing(){clearInterval(this.pingTimer),this.lastPong=Date.now();let e=()=>{if(Date.now()-this.lastPong>3500&&(this.link===`ok`||this.link===`weak`)){this.link=`lost`,this.lostSince=Date.now(),this.connect();return}this.raw({t:`ping`,c:performance.now(),rtt:this.rtt})};e(),this.pingTimer=window.setInterval(e,1e3)}pairWith(e){this.pairCode=e,this.deny=null,this.link=`connecting`,this.connect()}leave(){this.raw({t:`bye`}),this.link=`left`,this.sheet=null,clearInterval(this.pingTimer),this.ws?.close()}rejoin(){this.link=`connecting`,this.firstTry=Date.now(),this.connect()}onMessage(e){switch(e.t){case`welcome`:e.token&&hi.set(`token`,e.token),this.pairCode=null,this.deny=null,this.host=e.host,hi.set(`host`,e.host),this.conn=e.conn,this.name=e.name,hi.set(`name`,e.name),this.link=`ok`,this.everConnected=!0,this.startPing();break;case`denied`:this.deny=e.why,e.why===`forgotten`&&hi.del(`token`),this.pairCode=null,this.link=`expired`,clearInterval(this.pingTimer);break;case`kicked`:this.link=`left`,this.showToast(`Disconnected in Nota`);break;case`pong`:{this.lastPong=Date.now();let t=Math.max(0,Math.round(performance.now()-e.c));this.rtts.push(t),this.rtts.length>5&&this.rtts.shift();let n=Math.round(this.rtts.reduce((e,t)=>e+t,0)/this.rtts.length);this.rtt=n,(this.link===`ok`||this.link===`weak`)&&(this.link=n>50?`weak`:`ok`);break}case`proj`:{let t=!this.proj,n=this.proj?.you;delete e.t,this.proj=e,hi.set(`track`,String(e.you)),hi.set(`follow`,e.follow?`1`:`0`),(t||n!==e.you)&&this.onTrackChanged(t);break}case`tp`:delete e.t,this.tp=e,this.posBase=e.pos,this.posAt=performance.now();break;case`lit`:this.lit=e.n;break;case`who`:this.who=e.p;break;case`mix`:delete e.t,this.mix=e;break;case`xy`:delete e.t,this.xy=e;break;case`mac`:delete e.t,this.mac=e;break;case`ses`:delete e.t,this.ses=e;break;case`learn`:this.learn={on:e.on,pend:e.pend},e.on||(this.learned=null);break;case`learned`:this.learned=`${e.src} → ${e.dst}`,clearTimeout(this.learnedTimer),this.learnedTimer=window.setTimeout(()=>this.learned=null,6e3);break;case`toast`:this.showToast(e.msg)}}onTrackChanged(e){let t=this.track;if(t){if(e&&this.screenChosen){this.sub();return}t.kind===`audio`&&(this.bigTransport=!0),(!e||!this.screenChosen)&&(t.kind===`drum`&&(this.screen===`Keys`||this.screen===`Pads`)?this.screen=`Pads`:t.kind===`inst`&&(this.screen===`Pads`||this.screen===`Keys`)&&(this.screen=`Keys`)),this.sub()}}setScreen(e){this.screen=e,this.screenChosen=!0,this.bigTransport=!1,this.sub()}sub(){this.raw({t:`sub`,s:this.screen,i:this.macroDevice})}macroDevice=0;selectTrack(e){this.sheet=null,this.proj&&this.proj.you!==e&&(this.proj={...this.proj,you:e,follow:!1},this.onTrackChanged(!1)),this.send({t:`track`,id:e})}stepTrack(e){let t=this.playable;if(t.length===0)return;let n=t[(t.findIndex(e=>e.id===this.proj?.you)+e+t.length)%t.length];this.selectTrack(n.id)}raw(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}send(e){(this.link===`ok`||this.link===`weak`)&&this.raw(e)}get live(){return this.link===`ok`||this.link===`weak`}noteOn(e,t){if(!(e<0||e>127)&&(this.send({t:`on`,p:e,v:Math.round(t*1e3)/1e3}),this.prefs.haptics&&navigator.vibrate))try{navigator.vibrate(8)}catch{}}noteOff(e){e<0||e>127||this.send({t:`off`,p:e})}position(e=performance.now()){return this.tp.play?this.posBase+(e-this.posAt)/6e4*this.tp.bpm:this.tp.pos}record(){if(this.tp.rec){this.send({t:`rec`,on:!1});return}!this.tp.play&&this.prefs.countIn?this.runCountIn():this.send({t:`rec`,on:!0})}countTimer=0;runCountIn(){if(this.countIn!==null){clearInterval(this.countTimer),this.countIn=null;return}let e=6e4/Math.max(20,this.tp.bpm);this.countIn=4,this.countTimer=window.setInterval(()=>{this.countIn!==null&&(this.countIn<=1?(clearInterval(this.countTimer),this.countIn=null,this.send({t:`rec`,on:!0})):--this.countIn)},e)}rename(e){e=e.trim(),e&&e!==this.name&&(this.name=e,hi.set(`name`,e),this.send({t:`name`,s:e}))}setFollow(e){this.send({t:`follow`,on:e}),this.proj&&={...this.proj,follow:e}}showToast(e){this.toast=e,clearTimeout(this.toastTimer),this.toastTimer=window.setTimeout(()=>this.toast=null,2600)}},vi=new class{#e=F(Ht(window.innerWidth));get w(){return U(this.#e)}set w(e){I(this.#e,e,!0)}#t=F(Ht(window.innerHeight));get h(){return U(this.#t)}set h(e){I(this.#t,e,!0)}constructor(){let e=()=>{this.w=window.innerWidth,this.h=window.innerHeight};window.addEventListener(`resize`,e),window.addEventListener(`orientationchange`,()=>setTimeout(e,120))}get form(){return Math.min(this.w,this.h)>=600?`tablet`:this.w>this.h?`phoneLand`:`phone`}},yi=null,bi=null;async function xi(){let e=navigator.wakeLock;if(e&&window.isSecureContext)try{yi||=await e.request(`screen`),yi?.addEventListener?.(`release`,()=>yi=null);return}catch{}bi||(bi=document.createElement(`video`),bi.setAttribute(`playsinline`,``),bi.setAttribute(`muted`,``),bi.muted=!0,bi.loop=!0,bi.src=`./keepawake.mp4`,bi.style.cssText=`position:fixed;width:1px;height:1px;opacity:0;pointer-events:none;left:-10px;top:-10px`,document.body.appendChild(bi)),bi.paused&&bi.play().catch(()=>{})}function Si(){return typeof DeviceOrientationEvent>`u`?`no`:window.isSecureContext?typeof DeviceOrientationEvent.requestPermission==`function`?`ask`:`yes`:`insecure`}async function Ci(){let e=Si();if(e===`yes`)return!0;if(e!==`ask`)return!1;try{return await DeviceOrientationEvent.requestPermission()===`granted`}catch{return!1}}function wi(e){let t=null,n=e=>Math.min(1,Math.max(0,e)),r=r=>{if(r.beta==null||r.gamma==null)return;let i=Math.abs((screen.orientation?.angle??window.orientation??0)%180)===90,a=screen.orientation?.angle??window.orientation??0,o=i?a===90||a===-270?r.beta:-r.beta:r.gamma,s=i?a===90||a===-270?-r.gamma:r.gamma:r.beta;t||={b:s,g:o},e(n(.5+(o-t.g)/60),n(.5-(s-t.b)/50))};return window.addEventListener(`deviceorientation`,r),()=>window.removeEventListener(`deviceorientation`,r)}var Ti=[`Pads`,`Keys`,`XY`,`Mixer`,`Macros`,`Scenes`],Ei=G(`<header><div class="picker svelte-oiwvqb"><button class="step svelte-oiwvqb" aria-label="Previous track"><svg width="10" height="14" viewBox="0 0 10 14" class="svelte-oiwvqb"><path d="M7 2 L2 7 L7 12" class="svelte-oiwvqb"></path></svg></button> <button class="track svelte-oiwvqb" aria-label="Choose the track to play"><span class="bar svelte-oiwvqb"></span> <span class="names svelte-oiwvqb"><span class="name svelte-oiwvqb"> </span> <span class="sub mono svelte-oiwvqb"> </span></span> <svg width="10" height="10" viewBox="0 0 10 10" class="svelte-oiwvqb"><path d="M2 3.5 L5 6.5 L8 3.5" class="svelte-oiwvqb"></path></svg></button> <button class="step svelte-oiwvqb" aria-label="Next track"><svg width="10" height="14" viewBox="0 0 10 14" class="svelte-oiwvqb"><path d="M3 2 L8 7 L3 12" class="svelte-oiwvqb"></path></svg></button></div> <div class="transport svelte-oiwvqb"><button class="tbtn svelte-oiwvqb" aria-label="Stop"><span class="sq svelte-oiwvqb"></span></button> <button><span class="tri svelte-oiwvqb"></span></button> <button aria-label="Record"><span class="dot svelte-oiwvqb"></span></button> <button aria-label="Big transport"><span class="mono p svelte-oiwvqb"> </span> <span class="mono bpm svelte-oiwvqb"> </span> <svg width="10" height="10" viewBox="0 0 10 10" class="svelte-oiwvqb"><path d="M2 3.5 L5 6.5 L8 3.5" class="svelte-oiwvqb"></path></svg></button></div> <div class="status svelte-oiwvqb"><button class="link svelte-oiwvqb"><span></span> <span class="mono svelte-oiwvqb"> </span></button> <button aria-label="Menu"><span class="svelte-oiwvqb"></span><span class="svelte-oiwvqb"></span><span class="svelte-oiwvqb"></span></button></div></header>`);function Di(e,t){Re(t,!0);let n=N(()=>$.track),r=N(()=>{if(!U(n))return $.proj?`No track to play`:`Connecting…`;let e=($.who[String(U(n).id)]??[]).join(`, `);return U(n).dev+($.proj?.follow?` · following Nota`:``)+(e?` · with ${e}`:``)}),i=F(`1.1`);un(()=>{let e=0,t=()=>{let n=Math.max(0,$.position());I(i,`${Math.floor(n/4)+1}.${Math.floor(n%4)+1}`),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)});let a=N(()=>{switch($.link){case`ok`:return{dot:`var(--success-dim)`,ink:`var(--ink4)`,label:$.rtt>=0?`${$.rtt} ms`:`Connected`};case`weak`:return{dot:`var(--warning)`,ink:`var(--warning)`,label:`Weak · ${$.rtt} ms`};case`lost`:case`connecting`:return{dot:`var(--ink4)`,ink:`var(--ink3)`,label:$.link===`lost`?`Reconnecting`:`Connecting`,blink:!0};case`down`:return{dot:`var(--danger)`,ink:`var(--danger-bright)`,label:`No connection`,blink:!0};default:return{dot:`var(--danger)`,ink:`var(--danger-bright)`,label:`Not paired`}}});function o(){$.link===`weak`?$.showToast(`Latency is ${$.rtt} ms. Move closer to the router or put the phone on 5 GHz Wi-Fi.`):$.link===`ok`?$.showToast(`Connected to ${$.host} · ${$.rtt} ms`):$.link===`lost`&&$.showToast(`Touches are not sent until the link is back.`)}function s(){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);$.send({t:$.tp.play?`stop`:`play`})}function c(){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);$.send({t:`stop`})}function l(){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);$.record()}var u=Ei(),d=L(u),f=L(d),p=z(f,2),m=L(p);let h;var g=z(m,2),_=L(g),v=R(_,!0),y=R(z(_,2),!0);j(g),ye(2),j(p);var b=z(p,2);j(d);var x=z(d,2),S=L(x),C=z(S,2);let w;var T=z(C,2);let ee;var E=z(T,2);let D;var te=L(E),ne=R(te,!0),re=R(z(te,2),!0);ye(2),j(E),j(x);var ie=z(x,2),ae=L(ie),oe=L(ae);let se,ce;var le=z(oe,2);let ue;var de=R(le,!0);j(ae);var O=z(ae,2);let fe;j(ie),j(u),B(e=>{X(u,1,Kr(t.form),`svelte-oiwvqb`),h=Z(m,``,h,{background:U(n)?.color??`var(--border-strong)`}),q(v,U(n)?.name??`—`),q(y,U(r)),w=X(C,1,`tbtn play svelte-oiwvqb`,null,w,{on:$.tp.play}),Q(C,`aria-label`,$.tp.play?`Stop playback`:`Play`),Q(C,`aria-pressed`,$.tp.play),ee=X(T,1,`tbtn rec svelte-oiwvqb`,null,ee,{on:$.tp.rec,count:$.countIn!==null}),Q(T,`aria-pressed`,$.tp.rec),D=X(E,1,`pos svelte-oiwvqb`,null,D,{open:$.bigTransport}),q(ne,U(i)),q(re,e),Q(ae,`aria-label`,`Connection: ${U(a).label??``}`),se=X(oe,1,`ldot svelte-oiwvqb`,null,se,{blink:U(a).blink}),ce=Z(oe,``,ce,{background:U(a).dot}),ue=Z(le,``,ue,{color:U(a).ink}),q(de,U(a).label),fe=X(O,1,`menu svelte-oiwvqb`,null,fe,{open:$.sheet===`menu`})},[()=>$.tp.bpm.toFixed(0)]),W(`click`,f,()=>$.stepTrack(-1)),W(`click`,p,()=>$.sheet=`tracks`),W(`click`,b,()=>$.stepTrack(1)),W(`click`,S,c),W(`click`,C,s),W(`click`,T,l),W(`click`,E,()=>$.bigTransport=!$.bigTransport),W(`click`,ae,o),W(`click`,O,()=>$.sheet=`menu`),K(e,u),ze()}hr([`click`]);var Oi=G(`<div role="status"><span></span> <div class="svelte-4gizvm"><div class="t svelte-4gizvm"> </div> <div class="s svelte-4gizvm"> </div></div></div>`);function ki(e,t){Re(t,!0);let n=N(()=>$.link===`lost`?{kind:`quiet`,title:`Reconnecting to ${$.host}…`,sub:`Touches are not sent until the link is back`}:$.learn.on&&$.live?$.learned?{kind:`brass`,title:`Mapped ${$.learned}`,sub:`Click another control in Nota to keep mapping`}:{kind:`brass`,title:$.learn.pend?`Nota is listening: ${$.learn.pend}`:`MIDI Learn is on in Nota`,sub:$.learn.pend?`Move a macro, an XY axis or tilt the phone. Pads, keys and the mixer can’t be mapped.`:`Click a control in Nota, then move a macro, an XY axis or tilt the phone.`}:null);var r=Tr(),i=Zt(r),a=e=>{var t=Oi(),r=L(t);let i;var a=z(r,2),o=L(a),s=R(o,!0),c=R(z(o,2),!0);j(a),j(t),B(()=>{X(t,1,`banner ${U(n).kind??``}`,`svelte-4gizvm`),i=X(r,1,`dot svelte-4gizvm`,null,i,{blink:U(n).kind===`quiet`}),q(s,U(n).title),q(c,U(n).sub)}),K(e,t)};J(i,e=>{U(n)&&e(a)}),K(e,r),ze()}var Ai=[`C`,`C#`,`D`,`D#`,`E`,`F`,`F#`,`G`,`G#`,`A`,`A#`,`B`],ji=[`C`,`Db`,`D`,`Eb`,`E`,`F`,`F#`,`G`,`Ab`,`A`,`Bb`,`B`],Mi=[0,2,4,5,7,9,11],Ni=[0,2,3,5,7,8,10],Pi=e=>Ai[(e%12+12)%12]+(Math.floor(e/12)-1),Fi=e=>(e.minor?Ai:ji)[e.root]+(e.minor?` minor`:` major`),Ii=e=>e.minor?Ni:Mi;function Li(e,t,n){let r=Ii(e),i=Math.floor(n/7),a=(n%7+7)%7;return t+e.root+r[a]+12*i}var Ri=[`i`,`ii`,`iii`,`iv`,`v`,`vi`,`vii`];function zi(e,t){let n=Ii(e);return n.map((r,i)=>{let a=n[i],o=n[(i+2)%7]+(i+2>=7?12:0),s=n[(i+4)%7]+(i+4>=7?12:0),c=o-a,l=s-a,u=c===4?``:l===6?`°`:`m`,d=t+e.root+a;return{roman:(u===``?Ri[i].toUpperCase():Ri[i])+(u===`°`?`°`:``),name:(e.minor?Ai:ji)[(e.root+a)%12]+u,notes:[d,t+e.root+o,t+e.root+s]}})}var Bi=G(`<button class="scrim svelte-tyq0v8" aria-label="Close"></button>`),Vi=G(`<span class="who svelte-tyq0v8">You</span>`),Hi=G(`<span class="who svelte-tyq0v8"> </span>`),Ui=G(`<button><span class="bar svelte-tyq0v8"></span> <span class="names svelte-tyq0v8"><span class="n svelte-tyq0v8"> </span><span class="d mono svelte-tyq0v8"> </span></span> <!> <!></button>`),Wi=G(`<div class="empty svelte-tyq0v8">The project has no tracks yet.</div>`),Gi=G(`<div role="dialog" aria-label="Play on track"><div class="caps head svelte-tyq0v8">Play on track</div> <div class="list svelte-tyq0v8"><!> <!></div> <button class="toggle svelte-tyq0v8"><span></span> <span><span class="n2 svelte-tyq0v8">Follow Nota’s selection</span><span class="d2 svelte-tyq0v8">Off: this phone keeps its own track</span></span></button></div>`),Ki=G(`<div class="sheet menu svelte-tyq0v8" role="dialog" aria-label="Menu"><div class="block svelte-tyq0v8"><label class="caps" for="devname">Device name</label> <input id="devname" class="field svelte-tyq0v8" maxlength="40" enterkeyhint="done"/></div> <div class="block svelte-tyq0v8"><span class="caps">Theme</span> <div class="seg"><button>Follow Nota</button> <button>Follow phone</button></div></div> <button class="toggle svelte-tyq0v8"><span></span><span class="n2 svelte-tyq0v8">Haptics on pads</span></button> <button class="toggle svelte-tyq0v8"><span></span><span class="n2 svelte-tyq0v8">Count-in before recording</span></button> <button class="disconnect svelte-tyq0v8">Disconnect</button></div>`),qi=G(`<button> </button>`),Ji=G(`<div role="dialog" aria-label="Key"><div class="caps head svelte-tyq0v8">Key on this phone</div> <div class="block svelte-tyq0v8"><button><span class="names svelte-tyq0v8"><span class="n svelte-tyq0v8">Project key</span><span class="d mono svelte-tyq0v8"> </span></span></button> <div class="seg"><button>Major</button> <button>Minor</button></div> <div class="tonics svelte-tyq0v8"></div></div></div>`),Yi=G(`<button><span class="names svelte-tyq0v8"><span class="n svelte-tyq0v8"> </span></span></button>`),Xi=G(`<div role="dialog" aria-label="Device"><div class="caps head svelte-tyq0v8"> </div> <div class="list svelte-tyq0v8"></div></div>`),Zi=G(`<!> <!>`,1);function Qi(e,t){Re(t,!0);let n=N(()=>t.form===`phone`),r=F(``);un(()=>{$.sheet===`menu`&&I(r,$.name,!0)});function i(){$.sheet===`menu`&&$.rename(U(r)),$.sheet=null}let a=N(()=>$.proj?.key??null);var o=Zi(),s=Zt(o),c=e=>{var t=Bi();W(`click`,t,i),K(e,t)};J(s,e=>{$.sheet&&e(c)});var l=z(s,2),u=e=>{var t=Gi();let r;var i=z(L(t),2),a=L(i);Y(a,17,()=>$.playable,e=>e.id,(e,t)=>{let n=N(()=>$.who[String(U(t).id)]??[]);var r=Ui();let i;var a=L(r);let o;var s=z(a,2),c=L(s),l=R(c,!0),u=R(z(c),!0);j(s);var d=z(s,2),f=e=>{K(e,Vi())};J(d,e=>{U(t).id===$.proj?.you&&e(f)}),Y(z(d,2),17,()=>U(n),Fr,(e,t)=>{var n=Hi(),r=R(n,!0);B(()=>q(r,U(t))),K(e,n)}),j(r),B(()=>{i=X(r,1,`row svelte-tyq0v8`,null,i,{on:U(t).id===$.proj?.you}),o=Z(a,``,o,{background:U(t).color}),q(l,U(t).name),q(u,U(t).dev)}),W(`click`,r,()=>$.selectTrack(U(t).id)),K(e,r)});var o=z(a,2),s=e=>{K(e,Wi())};J(o,e=>{$.playable.length===0&&e(s)}),j(i);var c=z(i,2),l=L(c);let u;ye(2),j(c),j(t),B(()=>{r=X(t,1,`sheet svelte-tyq0v8`,null,r,{bottom:U(n)}),u=X(l,1,`switch`,null,u,{on:$.proj?.follow})}),W(`click`,c,()=>$.setFollow(!$.proj?.follow)),K(e,t)},d=e=>{var t=Ki(),n=L(t),i=z(L(n),2);ni(i),j(n);var a=z(n,2),o=z(L(a),2),s=L(o);let c;var l=z(s,2);let u;j(o),j(a);var d=z(a,2),f=L(d);let p;ye(),j(d);var m=z(d,2),h=L(m);let g;ye(),j(m);var _=z(m,2);j(t),B(()=>{c=X(s,1,``,null,c,{on:$.prefs.theme===`nota`}),u=X(l,1,``,null,u,{on:$.prefs.theme===`phone`}),p=X(f,1,`switch`,null,p,{on:$.prefs.haptics}),g=X(h,1,`switch`,null,g,{on:$.prefs.countIn})}),W(`keydown`,i,e=>{e.key===`Enter`&&e.target.blur()}),mr(`blur`,i,()=>$.rename(U(r))),oi(i,()=>U(r),e=>I(r,e)),W(`click`,s,()=>$.prefs.theme=`nota`),W(`click`,l,()=>$.prefs.theme=`phone`),W(`click`,d,()=>$.prefs.haptics=!$.prefs.haptics),W(`click`,m,()=>$.prefs.countIn=!$.prefs.countIn),W(`click`,_,()=>$.leave()),K(e,t)},f=e=>{var t=Ji();let r;var i=z(L(t),2),o=L(i);let s;var c=L(o),l=R(z(L(c)),!0);j(c),j(o);var u=z(o,2),d=L(u);let f;var p=z(d,2);let m;j(u);var h=z(u,2);Y(h,21,()=>Ai,Fr,(e,t,n)=>{var r=qi();let i;var o=R(r,!0);B(()=>{i=X(r,1,`btn svelte-tyq0v8`,null,i,{on:$.prefs.key?.root===n}),q(o,U(t))}),W(`click`,r,()=>$.prefs.key={root:n,minor:$.prefs.key?.minor??U(a)?.minor??!1}),K(e,r)}),j(h),j(i),j(t),B(()=>{r=X(t,1,`sheet svelte-tyq0v8`,null,r,{bottom:U(n)}),s=X(o,1,`row slim svelte-tyq0v8`,null,s,{on:!$.prefs.key}),q(l,U(a)?U(a).name:`Not set in Nota — C major`),f=X(d,1,``,null,f,{on:!($.prefs.key?.minor??U(a)?.minor??!1)}),m=X(p,1,``,null,m,{on:$.prefs.key?.minor??U(a)?.minor??!1})}),W(`click`,o,()=>{$.prefs.key=null,$.sheet=null}),W(`click`,d,()=>$.prefs.key={root:$.prefs.key?.root??U(a)?.root??0,minor:!1}),W(`click`,p,()=>$.prefs.key={root:$.prefs.key?.root??U(a)?.root??0,minor:!0}),K(e,t)},p=e=>{var t=Xi();let r;var i=L(t),a=R(i),o=z(i,2);Y(o,21,()=>$.mac?.devs??[],Fr,(e,t,n)=>{var r=Yi();let i;var a=L(r),o=R(L(a),!0);j(a),j(r),B(()=>{i=X(r,1,`row svelte-tyq0v8`,null,i,{on:n===($.mac?.di??0)}),q(o,U(t))}),W(`click`,r,()=>{$.macroDevice=n,$.sub(),$.sheet=null}),K(e,r)}),j(o),j(t),B(()=>{r=X(t,1,`sheet svelte-tyq0v8`,null,r,{bottom:U(n)}),q(a,`Device on ${$.track?.name??`this track`??``}`)}),K(e,t)};J(l,e=>{$.sheet===`tracks`?e(u):$.sheet===`menu`?e(d,1):$.sheet===`key`?e(f,2):$.sheet===`devices`&&e(p,3)}),K(e,o),ze()}hr([`click`,`keydown`]);var $i=G(`<div class="cover svelte-17f2qxr" role="alert"><h1 class="svelte-17f2qxr">Nota isn’t responding</h1> <ol class="svelte-17f2qxr"><li class="svelte-17f2qxr"><span class="mono svelte-17f2qxr">1</span> </li> <li class="svelte-17f2qxr"><span class="mono svelte-17f2qxr">2</span>Remote is on: the Remote button in Nota’s top bar is lit</li> <li class="svelte-17f2qxr"><span class="mono svelte-17f2qxr">3</span>The phone is on the same Wi-Fi. Guest networks often keep devices apart; share the phone’s hotspot with the computer instead.</li></ol> <div class="retry svelte-17f2qxr"><span class="dot blink svelte-17f2qxr"></span>Retrying every few seconds</div></div>`),ea=G(`<span class="mono svelte-17f2qxr"> </span>`),ta=G(`<span class="caret svelte-17f2qxr"></span>`),na=G(`<span><!></span>`),ra=G(`<div class="cover svelte-17f2qxr" role="alert"><h1 class="svelte-17f2qxr"> </h1> <p class="svelte-17f2qxr"> </p> <label class="code svelte-17f2qxr" aria-label="Four-digit code"><input inputmode="numeric" pattern="[0-9]*" maxlength="4" autocomplete="one-time-code" class="svelte-17f2qxr"/> <!></label></div>`),ia=G(`<div class="cover svelte-17f2qxr" role="alert"><h1 class="svelte-17f2qxr">Disconnected</h1> <p class="svelte-17f2qxr">This phone has left Nota. It is still trusted, so connecting again needs no code.</p> <button class="btn on big svelte-17f2qxr">Connect again</button></div>`),aa=G(`<button class="count svelte-17f2qxr" aria-label="Cancel count-in"><span> </span> <span class="caps rec svelte-17f2qxr">Count-in · recording starts on 1</span></button>`),oa=G(`<div role="status"> </div>`),sa=G(`<!> <!> <!>`,1);function ca(e,t){Re(t,!0);let n=F(``),r=F(void 0);un(()=>{$.link===`expired`&&(I(n,``),setTimeout(()=>U(r)?.focus(),50))}),un(()=>{U(n).length===4&&$.link===`expired`&&$.pairWith(U(n))});let i=N(()=>$.deny===`code`?`That code didn’t match. Codes change every two minutes — check the one Nota shows now.`:$.deny===`locked`?`Too many wrong codes. Wait half a minute, then try the code Nota shows.`:$.deny===`version`?`This page is older than Nota. Reload it.`:$.deny===`new`?`In Nota, click Remote in the top bar and scan the QR code with the camera, or type its four digits here.`:`This phone was removed from trusted devices, or the code has expired. In Nota, click Remote to show a fresh QR, or type its four digits here.`);var a=sa(),o=Zt(a),s=e=>{var t=$i(),n=z(L(t),2),r=L(n),i=z(L(r));j(r),ye(4),j(n),ye(2),j(t),B(()=>q(i,`Nota is open on ${$.host??``}`)),K(e,t)},c=e=>{var t=ra(),a=L(t),o=R(a,!0),s=z(a,2),c=R(s,!0),l=z(s,2),u=L(l);ni(u),ui(u,e=>I(r,e),()=>U(r)),Y(z(u,2),16,()=>[0,1,2,3],Fr,(e,t)=>{var r=na();let i;var a=L(r),o=e=>{var r=ea(),i=R(r,!0);B(()=>q(i,U(n)[t])),K(e,r)},s=e=>{K(e,ta())};J(a,e=>{U(n)[t]?e(o):U(n).length===t&&e(s,1)}),j(r),B(()=>i=X(r,1,`cell svelte-17f2qxr`,null,i,{cur:U(n).length===t})),K(e,r)}),j(l),j(t),B(()=>{q(o,$.deny===`new`?`Pair with Nota`:`Scan a new code in Nota`),q(c,U(i))}),W(`input`,u,()=>I(n,U(n).replace(/\D/g,``).slice(0,4),!0)),oi(u,()=>U(n),e=>I(n,e)),K(e,t)},l=e=>{var t=ia(),n=z(L(t),4);j(t),W(`click`,n,()=>$.rejoin()),K(e,t)};J(o,e=>{$.link===`down`?e(s):$.link===`expired`?e(c,1):$.link===`left`&&e(l,2)});var u=z(o,2),d=e=>{var n=aa(),r=L(n),i=R(r,!0);ye(2),j(n),B(()=>{X(r,1,`mono num ${t.form??``}`,`svelte-17f2qxr`),q(i,$.countIn)}),W(`click`,n,()=>$.record()),K(e,n)};J(u,e=>{$.countIn!==null&&e(d)});var f=z(u,2),p=e=>{var n=oa();let r;var i=R(n,!0);B(()=>{r=X(n,1,`toast svelte-17f2qxr`,null,r,{low:t.form===`phone`}),q(i,$.toast)}),K(e,n)};J(f,e=>{$.toast&&e(p)}),K(e,a),ze()}hr([`input`,`click`]);var la=G(`<button><span class="sn svelte-1hrivqy"> </span> <span class="mono si svelte-1hrivqy"> </span></button>`),ua=G(`<div class="secs svelte-1hrivqy"><span class="caps svelte-1hrivqy">Sections · tap to jump, hold to loop</span> <div class="sgrid svelte-1hrivqy"></div></div>`),da=G(`<div><div class="top svelte-1hrivqy"><div class="pblock svelte-1hrivqy"><span class="caps svelte-1hrivqy">Position</span> <span> </span></div> <button class="tap svelte-1hrivqy"><span class="mono svelte-1hrivqy"> </span> <span class="caps svelte-1hrivqy">Tap tempo</span></button></div> <div class="btns svelte-1hrivqy"><button><span class="tri svelte-1hrivqy"></span>Play</button> <button class="b svelte-1hrivqy"><span class="sq svelte-1hrivqy"></span>Stop</button> <button><span class="dot svelte-1hrivqy"></span>Record</button> <button><svg width="30" height="26" viewBox="0 0 30 26" class="svelte-1hrivqy"><path d="M7 9 H21 A5 5 0 0 1 21 19 H9 M9 19 L12 16 M9 19 L12 22 M7 9 A5 5 0 0 0 5 14" class="svelte-1hrivqy"></path></svg>Loop</button> <button><svg width="26" height="28" viewBox="0 0 26 28" class="svelte-1hrivqy"><path d="M8 25 L11 3 H15 L18 25 Z M13 18 L21 8" class="svelte-1hrivqy"></path></svg>Click</button> <button><svg width="28" height="24" viewBox="0 0 28 24" class="svelte-1hrivqy"><path d="M9 5 L4 10 L9 15 M4 10 H17 A6 6 0 0 1 17 22 H12" class="svelte-1hrivqy"></path></svg>Undo</button></div> <!></div>`);function fa(e,t){Re(t,!0);let n=F(`1.1.1`);un(()=>{let e=0,t=()=>{let r=Math.max(0,$.position());I(n,`${Math.floor(r/4)+1}.${Math.floor(r%4)+1}.${Math.floor(r*4%4)+1}`),e=requestAnimationFrame(t)};return t(),()=>cancelAnimationFrame(e)});let r=N(()=>$.proj?.sections??[]),i=N(()=>$.position()),a=N(()=>U(r).reduce((e,t,n)=>U(i)>=t[1]?n:e,-1)),o=N(()=>$.tp.loop?U(r).findIndex((e,t)=>Math.abs(e[1]-$.tp.ls)<.01&&Math.abs((U(r)[t+1]?.[1]??e[1]+16)-$.tp.le)<.01):-1);function s(e){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);$.send(e)}let c=[];function l(){let e=performance.now();if(c=[...c.filter(t=>e-t<2500),e],c.length>=3){let e=(c[c.length-1]-c[0])/(c.length-1);s({t:`bpm`,v:Math.round(Math.min(220,Math.max(50,6e4/e))*100)/100})}}let u=0,d=!1;function f(e){d=!1,u=window.setTimeout(()=>{d=!0;let t=U(r)[e],n=U(r)[e+1]?.[1]??t[1]+16;U(o)===e?s({t:`loop`,on:!1}):s({t:`loopRange`,v:t[1],v2:n,on:!0})},450)}function p(e){clearTimeout(u),d||s({t:`seek`,v:U(r)[e][1]})}let m=N(()=>$.tp.bpm.toFixed($.tp.bpm%1?2:0));var h=da(),g=L(h),_=L(g),v=z(L(_),2);let y;var b=R(v,!0);j(_);var x=z(_,2),S=R(L(x),!0);ye(2),j(x),j(g);var C=z(g,2);let w;var T=L(C);let ee;var E=z(T,2),D=z(E,2);let te;var ne=z(D,2);let re;var ie=z(ne,2);let ae;var oe=z(ie,2);let se;j(C);var ce=z(C,2),le=e=>{var t=ua(),n=z(L(t),2);Y(n,21,()=>U(r),Fr,(e,t,n)=>{var r=la();let i;var s=L(r),c=R(s,!0),l=R(z(s,2),!0);j(r),B(e=>{i=X(r,1,`sec svelte-1hrivqy`,null,i,{cur:U(a)===n,looping:U(o)===n}),q(c,U(t)[0]),q(l,e)},[()=>U(o)===n?`LOOPING`:`BAR ${Math.floor(U(t)[1]/4)+1}`]),W(`pointerdown`,r,()=>f(n)),W(`pointerup`,r,()=>p(n)),mr(`pointercancel`,r,()=>clearTimeout(u)),K(e,r)}),j(n),j(t),K(e,t)};J(ce,e=>{U(r).length>0&&e(le)}),j(h),B(()=>{X(h,1,`big ${t.form??``}`,`svelte-1hrivqy`),y=X(v,1,`mono pos svelte-1hrivqy`,null,y,{rec:$.tp.rec}),q(b,U(n)),q(S,U(m)),w=Z(C,``,w,{"grid-template-columns":`repeat(${t.form===`phone`?3:6}, minmax(0, 1fr))`}),ee=X(T,1,`b play svelte-1hrivqy`,null,ee,{on:$.tp.play}),Q(T,`aria-pressed`,$.tp.play),te=X(D,1,`b recb svelte-1hrivqy`,null,te,{on:$.tp.rec}),Q(D,`aria-pressed`,$.tp.rec),re=X(ne,1,`b svelte-1hrivqy`,null,re,{on:$.tp.loop}),Q(ne,`aria-pressed`,$.tp.loop),ae=X(ie,1,`b svelte-1hrivqy`,null,ae,{on:$.tp.met}),Q(ie,`aria-pressed`,$.tp.met),se=X(oe,1,`b svelte-1hrivqy`,null,se,{dim:!$.tp.can})}),W(`click`,x,l),W(`click`,T,()=>s({t:$.tp.play?`stop`:`play`})),W(`click`,E,()=>s({t:`stop`})),W(`click`,D,()=>$.canControl?$.record():s({})),W(`click`,ne,()=>s({t:`loop`,on:!$.tp.loop})),W(`click`,ie,()=>s({t:`met`,on:!$.tp.met})),W(`click`,oe,()=>s({t:`undo`})),K(e,h),ze()}hr([`click`,`pointerdown`,`pointerup`]);var pa=G(`<button> </button>`),ma=G(`<button><span class="num mono svelte-1puq9zz"> </span> <span class="label svelte-1puq9zz"><span class="name svelte-1puq9zz"> </span> <span class="note mono svelte-1puq9zz"> </span></span></button>`),ha=G(`<div class="pads svelte-1puq9zz"><div class="bar svelte-1puq9zz"><div class="seg banks svelte-1puq9zz" role="group" aria-label="Bank"></div> <button>Full vel.</button> <button>Repeat <span class="rate mono svelte-1puq9zz" role="button" tabindex="0" aria-label="Repeat rate"> </span></button></div> <div class="grid svelte-1puq9zz"></div></div>`);function ga(e,t){Re(t,!0);let n=[{n:`1/8`,div:2},{n:`1/16`,div:4},{n:`1/32`,div:8}],r=F(1),i=F(!1),a=Ht({}),o=new Map,s=new Map,c=N(()=>t.form===`phone`?4:8),l=N(()=>t.form===`tablet`?32:16),u=N(()=>36+Math.min($.prefs.bank,t.form===`tablet`?2:3)*16),d=N(()=>new Map(($.track?.pads??[]).map(([e,t])=>[e,t]))),f=N(()=>new Set($.lit)),p=N(()=>$.track?.color??`var(--accent)`),m=N(()=>{let e=U(l)/U(c),t=[];for(let n=e-1;n>=0;n--)for(let e=0;e<U(c);e++)t.push(U(u)+n*U(c)+e);return t}),h=N(()=>Array.from({length:t.form===`tablet`?3:4},(e,t)=>({i:t,name:Pi(36+t*16)})));function g(e,t){e.preventDefault();let c=e.currentTarget.getBoundingClientRect(),l=$.prefs.fullVel?1:Math.max(.2,Math.min(1,1-(e.clientY-c.top)/c.height+.15));if(s.set(e.pointerId,t),a[t]=!0,$.noteOn(t,l),U(i)){let e=()=>6e4/Math.max(20,$.tp.bpm)/n[U(r)].div,i=()=>{$.noteOff(t),$.noteOn(t,l),o.set(t,window.setTimeout(i,e()))};o.set(t,window.setTimeout(i,e()))}}function _(e){let t=s.get(e.pointerId);t!==void 0&&(s.delete(e.pointerId),![...s.values()].includes(t)&&(clearTimeout(o.get(t)),o.delete(t),a[t]=!1,$.noteOff(t)))}un(()=>()=>{for(let e of o.values())clearTimeout(e)});var v=ha(),y=L(v),b=L(y);Y(b,21,()=>U(h),Fr,(e,t)=>{var n=pa();let r;var i=R(n,!0);B(()=>{r=X(n,1,`mono svelte-1puq9zz`,null,r,{on:$.prefs.bank===U(t).i}),q(i,U(t).name)}),W(`click`,n,()=>$.prefs.bank=U(t).i),K(e,n)}),j(b);var x=z(b,2);let S;var C=z(x,2);let w;var T=z(L(C)),ee=R(T,!0);j(C),j(y);var E=z(y,2);let D;Y(E,20,()=>U(m),e=>e,(e,t)=>{let n=N(()=>a[t]),r=N(()=>!U(n)&&U(f).has(t));var i=ma();let o,s;var c=L(i),l=R(c,!0),u=z(c,2),m=L(u),h=R(m,!0),v=R(z(m,2),!0);j(u),j(i),B((e,a,c)=>{o=X(i,1,`pad svelte-1puq9zz`,null,o,{on:U(n),playing:U(r)}),Q(i,`aria-label`,e),s=Z(i,``,s,{"--tc":U(p)}),q(l,t-35),q(h,a),q(v,c)},[()=>U(d).get(t)??Pi(t),()=>U(d).get(t)??Pi(t),()=>Pi(t)]),W(`pointerdown`,i,e=>g(e,t)),W(`pointerup`,i,_),mr(`pointercancel`,i,_),mr(`pointerleave`,i,_),K(e,i)}),j(E),j(v),B(()=>{S=X(x,1,`btn`,null,S,{on:$.prefs.fullVel}),Q(x,`aria-pressed`,$.prefs.fullVel),w=X(C,1,`btn rep svelte-1puq9zz`,null,w,{on:U(i)}),Q(C,`aria-pressed`,U(i)),q(ee,n[U(r)].n),D=Z(E,``,D,{"grid-template-columns":`repeat(${U(c)??``}, minmax(0, 1fr))`})}),W(`click`,x,()=>$.prefs.fullVel=!$.prefs.fullVel),W(`click`,C,()=>I(i,!U(i))),W(`click`,T,e=>{e.stopPropagation(),I(r,(U(r)+1)%n.length)}),W(`keydown`,T,()=>{}),K(e,v),ze()}hr([`click`,`keydown`,`pointerdown`,`pointerup`]);var _a=G(`<button> </button>`),va=G(`<span class="mono lbl svelte-12d1dcp"> </span>`),ya=G(`<span class="band svelte-12d1dcp"></span>`),ba=G(`<div><!> <!></div>`),xa=G(`<div><!></div>`),Sa=G(`<div class="kb svelte-12d1dcp"><!> <!></div>`),Ca=G(`<div><span class="mono svelte-12d1dcp"> </span></div>`),wa=G(`<div class="grid svelte-12d1dcp"></div>`),Ta=G(`<div><span class="mono roman svelte-12d1dcp"> </span> <span class="cn svelte-12d1dcp"> </span></div>`),Ea=G(`<div class="grid chords svelte-12d1dcp"></div>`),Da=G(`<span class="hint svelte-12d1dcp">Turn the phone sideways for 1.5 octaves.</span>`),Oa=G(`<div class="keys svelte-12d1dcp"><div class="bar svelte-12d1dcp"><div class="seg modes svelte-12d1dcp" role="group" aria-label="Mode"></div> <button class="btn keybtn svelte-12d1dcp"><span class="caps k svelte-12d1dcp">Key</span> <span class="kn svelte-12d1dcp"> </span> <span class="mono src svelte-12d1dcp"> </span></button> <div class="oct svelte-12d1dcp"><button class="btn sq svelte-12d1dcp" aria-label="Octave down"><svg width="12" height="12" viewBox="0 0 12 12"><path d="M2 6 H10" class="svelte-12d1dcp"></path></svg></button> <span class="mono svelte-12d1dcp"> </span> <button class="btn sq svelte-12d1dcp" aria-label="Octave up"><svg width="12" height="12" viewBox="0 0 12 12"><path d="M2 6 H10 M6 2 V10" class="svelte-12d1dcp"></path></svg></button></div></div> <div class="surface svelte-12d1dcp" role="application" aria-label="Keys"><!></div> <!></div>`);function ka(e,t){Re(t,!0);let n=[`Keyboard`,`Scale`,`Chords`],r=[0,2,4,5,7,9,11],i=N(()=>$.prefs.key??($.proj?.key?{root:$.proj.key.root,minor:$.proj.key.minor}:{root:0,minor:!1})),a=N(()=>$.prefs.key?`PHONE`:$.proj?.key?`PROJECT`:`DEFAULT`),o=N(()=>12*($.prefs.octave+1)),s=N(()=>new Set($.lit)),c=N(()=>$.track?.color??`var(--accent)`),l=N(()=>$.prefs.keysMode),u=N(()=>t.form===`phone`?8:t.form===`phoneLand`?11:15),d=N(()=>Array.from({length:U(u)},(e,t)=>U(o)+r[t%7]+12*Math.floor(t/7))),f=N(()=>{let e=[];for(let t=0;t<U(u)-1;t++)[0,1,3,4,5].includes(t%7)&&e.push({note:U(o)+r[t%7]+12*Math.floor(t/7)+1,left:`calc(${(t+1)/U(u)*100}% - ${.62/U(u)*50}%)`,w:`${.62/U(u)*100}%`});return e}),p=N(()=>t.form===`phone`?5:8),m=N(()=>t.form===`phoneLand`?4:6),h=N(()=>{let e=[];for(let t=U(m)-1;t>=0;t--)for(let n=0;n<U(p);n++){let r=t*3+n;e.push({note:Li(U(i),U(o),r),tonic:r%7==0})}return e}),g=N(()=>zi(U(i),U(o))),_=new Map,v=F(Ht({}));function y(e,t){return(document.elementFromPoint(e,t)?.closest(`[data-t]`))?.dataset.t??null}function b(e){return e[0]===`n`?[Number(e.slice(1))]:U(g)[Number(e.slice(1))]?.notes??[]}let x=new Map;function S(e,t=.85){if(x.has(e))return;U(v)[e]=!0;let n=b(e);x.set(e,n);for(let e of n)$.noteOn(e,t)}function C(e){if(![..._.values()].includes(e)){U(v)[e]=!1;for(let t of x.get(e)??[])$.noteOff(t);x.delete(e)}}let w=new Set;function T(e){e.currentTarget.setPointerCapture(e.pointerId),w.add(e.pointerId);let t=y(e.clientX,e.clientY);t&&(_.set(e.pointerId,t),S(t))}function ee(e){if(!w.has(e.pointerId))return;let t=_.get(e.pointerId),n=y(e.clientX,e.clientY);n!==t&&(t!==void 0&&(_.delete(e.pointerId),C(t)),n&&(_.set(e.pointerId,n),S(n)))}function E(e){w.delete(e.pointerId);let t=_.get(e.pointerId);_.delete(e.pointerId),t!==void 0&&C(t)}un(()=>(U(o),U(l),U(i),()=>{for(let e of x.values())for(let t of e)$.noteOff(t);x.clear(),_.clear(),w.clear(),I(v,{},!0)}));var D=Oa(),te=L(D),ne=L(te);Y(ne,21,()=>n,Fr,(e,t)=>{var n=_a();let r;var i=R(n,!0);B(()=>{r=X(n,1,`svelte-12d1dcp`,null,r,{on:U(l)===U(t)}),q(i,U(t))}),W(`click`,n,()=>$.prefs.keysMode=U(t)),K(e,n)}),j(ne);var re=z(ne,2),ie=z(L(re),2),ae=R(ie,!0),oe=R(z(ie,2),!0);j(re);var se=z(re,2),ce=L(se),le=z(ce,2),ue=R(le),de=z(le,2);j(se),j(te);var O=z(te,2);let fe;var pe=L(O),me=e=>{var t=Sa(),n=L(t);Y(n,16,()=>U(d),e=>e,(e,t)=>{var n=ba();let r;var i=L(n),a=e=>{var n=va(),r=R(n,!0);B(e=>q(r,e),[()=>Pi(t)]),K(e,n)};J(i,e=>{t%12==0&&e(a)});var o=z(i,2),c=e=>{K(e,ya())},l=N(()=>U(s).has(t));J(o,e=>{U(l)&&e(c)}),j(n),B(()=>{r=X(n,1,`white svelte-12d1dcp`,null,r,{on:U(v)[`n`+t]}),Q(n,`data-t`,`n`+t)}),K(e,n)}),Y(z(n,2),17,()=>U(f),e=>e.note,(e,t)=>{var n=xa();let r,i;var a=L(n),o=e=>{K(e,ya())},c=N(()=>U(s).has(U(t).note));J(a,e=>{U(c)&&e(o)}),j(n),B(()=>{r=X(n,1,`black svelte-12d1dcp`,null,r,{on:U(v)[`n`+U(t).note]}),Q(n,`data-t`,`n`+U(t).note),i=Z(n,``,i,{left:U(t).left,width:U(t).w})}),K(e,n)}),j(t),K(e,t)},he=e=>{var t=wa();let n;Y(t,21,()=>U(h),Fr,(e,t)=>{var n=Ca();let r;var i=R(L(n));j(n),B((e,a)=>{r=X(n,1,`cell svelte-12d1dcp`,null,r,{tonic:U(t).tonic,on:U(v)[`n`+U(t).note],lit:e}),Q(n,`data-t`,`n`+U(t).note),q(i,`${Ai[U(t).note%12]??``}${a??``}`)},[()=>U(s).has(U(t).note),()=>U(t).tonic?Math.floor(U(t).note/12)-1:``]),K(e,n)}),j(t),B(()=>n=Z(t,``,n,{"grid-template-columns":`repeat(${U(p)??``}, minmax(0, 1fr))`})),K(e,t)},k=e=>{var n=Ea();let r;Y(n,21,()=>U(g),Fr,(e,t,n)=>{var r=Ta();let i;Q(r,`data-t`,`c`+n);var a=L(r),o=R(a,!0),c=R(z(a,2),!0);j(r),B(e=>{i=X(r,1,`chord svelte-12d1dcp`,null,i,{on:U(v)[`c`+n],lit:e}),q(o,U(t).roman),q(c,U(t).name)},[()=>U(t).notes.every(e=>U(s).has(e))]),K(e,r)}),j(n),B(()=>r=Z(n,``,r,{"grid-template-columns":`repeat(${t.form===`phone`?2:7}, minmax(0, 1fr))`})),K(e,n)};J(pe,e=>{U(l)===`Keyboard`?e(me):U(l)===`Scale`?e(he,1):e(k,-1)}),j(O);var ge=z(O,2),A=e=>{K(e,Da())};J(ge,e=>{t.form===`phone`&&U(l)===`Keyboard`&&e(A)}),j(D),B((e,t)=>{Q(re,`aria-label`,`Key: ${e??``}`),q(ae,t),q(oe,U(a)),q(ue,`Oct ${$.prefs.octave??``}`),fe=Z(O,``,fe,{"--tc":U(c)})},[()=>Fi(U(i)),()=>Fi(U(i))]),W(`click`,re,()=>$.sheet=`key`),W(`click`,ce,()=>$.prefs.octave=Math.max(0,$.prefs.octave-1)),W(`click`,de,()=>$.prefs.octave=Math.min(7,$.prefs.octave+1)),W(`pointerdown`,O,T),W(`pointermove`,O,ee),W(`pointerup`,O,E),mr(`pointercancel`,O,E),K(e,D),ze()}hr([`click`,`pointerdown`,`pointermove`,`pointerup`]);var Aa=G(`<span class="pill svelte-19m1tsu">Tilt is moving the point</span>`),ja=G(`<div><span class="mono an svelte-19m1tsu"> </span> <span class="names svelte-19m1tsu"><span class="pn svelte-19m1tsu"> </span><span class="pd svelte-19m1tsu"> </span></span> <span class="mono av svelte-19m1tsu"> </span></div>`),Ma=G(`<button><span class="ph svelte-19m1tsu"></span>Tilt</button>`),Na=G(`<span class="note dim svelte-19m1tsu">Tilt needs a secure (HTTPS) page, which a local Nota can’t offer yet.</span>`),Pa=G(`<div class="auto svelte-19m1tsu"><span class="rd svelte-19m1tsu"></span>Writing automation · latch</div>`),Fa=G(`<div><div role="slider" tabindex="0" aria-label="XY pad"><div class="gridlines svelte-19m1tsu"></div> <div class="fill svelte-19m1tsu"></div> <div class="vl svelte-19m1tsu"></div> <div class="hl svelte-19m1tsu"></div> <div class="pt svelte-19m1tsu"><span class="svelte-19m1tsu"></span></div> <span class="ax ax-x mono svelte-19m1tsu"> </span> <span class="ax ax-y mono svelte-19m1tsu"> </span> <!></div> <div class="panel svelte-19m1tsu"><div class="axes svelte-19m1tsu"></div> <div class="row svelte-19m1tsu"><div class="seg svelte-19m1tsu"><button>Hold</button> <button>Return</button></div> <!></div> <span class="note svelte-19m1tsu"> </span> <!> <!></div></div>`);function Ia(e,t){Re(t,!0);let n=N(()=>t.form===`phone`),r=F(.5),i=F(.5),a=F(!1),o=F(!1),s=!1,c={x:.5,y:.5},l={x:0,y:0},u=0,d=0,f=null,p=Si();un(()=>{let e=$.xy;!e||U(a)||U(o)||s||(e.x.v!==void 0&&!e.x.map&&I(r,e.x.v,!0),e.y.v!==void 0&&!e.y.map&&I(i,e.y.v,!0))});function m(e,t=`xy`){let n=performance.now();e===0&&n-d<30||(d=n,$.send({t:`xy`,v:U(r),v2:U(i),ph:e,s:t,i:$.learn.on?u:0}))}function h(e,t){let n=t.getBoundingClientRect();I(r,Math.min(1,Math.max(0,(e.clientX-n.left)/n.width)),!0),I(i,Math.min(1,Math.max(0,1-(e.clientY-n.top)/n.height)),!0)}function g(e){if(U(o)||!$.canControl){$.canControl||$.showToast(`Nota lets this phone play notes only.`);return}let t=e.currentTarget;t.setPointerCapture(e.pointerId),s=!1,c={x:U(r),y:U(i)},l={x:e.clientX,y:e.clientY},u=0,I(a,!0),h(e,t),$.learn.on||m(1)}function _(e){if(U(a)){if($.learn.on&&u===0){let t=Math.abs(e.clientX-l.x),n=Math.abs(e.clientY-l.y);if(Math.max(t,n)<14)return;u=t>=n?1:2}h(e,e.currentTarget),m(0)}}function v(){U(a)&&(I(a,!1),m(2),$.prefs.xyHold||y())}function y(){s=!0;let e=()=>{if(s&&!U(a)){if(I(r,U(r)+(c.x-U(r))*.2),I(i,U(i)+(c.y-U(i))*.2),Math.abs(c.x-U(r))+Math.abs(c.y-U(i))<.003){I(r,c.x,!0),I(i,c.y,!0),s=!1,m(2);return}m(0),requestAnimationFrame(e)}};requestAnimationFrame(e)}async function b(){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);if(U(o)){I(o,!1),f?.(),f=null,m(2,`tilt`);return}if(!await Ci()){$.showToast(`Motion access was refused. Allow it in Settings → Safari → Motion & Orientation Access, then reload.`);return}I(o,!0),f=wi((e,t)=>{I(r,e,!0),I(i,t,!0),m(0,`tilt`)})}un(()=>()=>f?.());let x=e=>{let t=$.xy?.[e];return t?U(o)&&t.tilt?t.tilt:t.map??t.n??(e===`x`?`X`:`Y`):e===`x`?`X`:`Y`},S=e=>{let t=$.xy?.[e];return t?U(o)&&t.tilt||t.map?`Mapped in Nota`:t.d??`Not assigned`:``},C=e=>{let t=$.xy?.[e],n=U(e===`x`?r:i);return t&&!t.map&&!(U(o)&&t.tilt)&&t.txt&&!U(a)&&!U(o)?t.txt:Math.round(n*100)+` %`},w=N(()=>U(o)?`Tilt the phone to move the point. Tap Tilt again to use your finger.`:!$.xy?.ok&&!$.xy?.x.map&&!$.xy?.y.map?`This track has no Auto Filter or Nota Flux. Add one in Nota, or map the axes with MIDI Learn.`:$.prefs.xyHold?`The point stays where you lift your finger.`:`On release the point glides back to where it started.`);var T=Fa();let ee;var E=L(T);let D;var te=z(L(E),2);let ne;var re=z(te,2);let ie;var ae=z(re,2);let oe;var se=z(ae,2);let ce;var le=z(se,2),ue=R(le),de=z(le,2),O=R(de),fe=z(de,2),pe=e=>{K(e,Aa())};J(fe,e=>{U(o)&&e(pe)}),j(E);var me=z(E,2),he=L(me);Y(he,20,()=>[`x`,`y`],Fr,(e,t)=>{var n=ja();let r;var i=L(n),a=R(i,!0),o=z(i,2),s=L(o),c=R(s,!0),l=R(z(s),!0);j(o);var u=R(z(o,2),!0);j(n),B((e,t,i,o)=>{r=X(n,1,`axis svelte-19m1tsu`,null,r,{learnable:$.learn.on}),q(a,e),q(c,t),q(l,i),q(u,o)},[()=>t.toUpperCase(),()=>x(t),()=>S(t),()=>C(t)]),K(e,n)}),j(he);var k=z(he,2),ge=L(k),A=L(ge);let _e;var ve=z(A,2);let ye;j(ge);var be=z(ge,2),xe=e=>{var t=Ma();let n;B(()=>{n=X(t,1,`btn tilt svelte-19m1tsu`,null,n,{on:U(o),learnable:$.learn.on}),Q(t,`aria-pressed`,U(o))}),W(`click`,t,b),K(e,t)};J(be,e=>{(p===`yes`||p===`ask`)&&e(xe)}),j(k);var Se=z(k,2),Ce=R(Se,!0),we=z(Se,2),Te=e=>{K(e,Na())};J(we,e=>{p===`insecure`&&e(Te)});var Ee=z(we,2),De=e=>{K(e,Pa())};J(Ee,e=>{$.xy?.auto&&e(De)}),j(me),j(T),B((e,t,a)=>{ee=X(T,1,`xy svelte-19m1tsu`,null,ee,{col:U(n)}),D=X(E,1,`field svelte-19m1tsu`,null,D,{learnable:$.learn.on}),Q(E,`aria-valuenow`,e),ne=Z(te,``,ne,{width:`${U(r)*100}%`,height:`${U(i)*100}%`,background:$.track?.color??`var(--accent)`}),ie=Z(re,``,ie,{left:`${U(r)*100}%`}),oe=Z(ae,``,oe,{top:`${(1-U(i))*100}%`}),ce=Z(se,``,ce,{left:`${U(r)*100}%`,top:`${(1-U(i))*100}%`}),q(ue,`${t??``} →`),q(O,`↑ ${a??``}`),_e=X(A,1,`svelte-19m1tsu`,null,_e,{on:$.prefs.xyHold}),ye=X(ve,1,`svelte-19m1tsu`,null,ye,{on:!$.prefs.xyHold}),q(Ce,U(w))},[()=>Math.round(U(r)*100),()=>x(`x`),()=>x(`y`)]),W(`pointerdown`,E,g),W(`pointermove`,E,_),W(`pointerup`,E,v),mr(`pointercancel`,E,v),W(`click`,A,()=>$.prefs.xyHold=!0),W(`click`,ve,()=>$.prefs.xyHold=!1),K(e,T),ze()}hr([`pointerdown`,`pointermove`,`pointerup`,`click`]);var La=G(`<span class="tag mono svelte-4q66aa"><svg width="8" height="8" viewBox="0 0 8 8"><path d="M2.5 1.5 L5.5 4 L2.5 6.5" class="svelte-4q66aa"></path></svg> </span>`),Ra=G(`<span class="held svelte-4q66aa"> </span>`),za=G(`<button><span class="svelte-4q66aa"></span>ARM</button>`),Ba=G(`<div><button class="head svelte-4q66aa"><span class="cbar svelte-4q66aa"></span> <span class="nm svelte-4q66aa"> </span> <!></button> <div class="pan svelte-4q66aa" role="slider" tabindex="0"><div class="pbar svelte-4q66aa"><span class="svelte-4q66aa"></span></div> <span class="mono pv svelte-4q66aa"> </span></div> <div class="fz svelte-4q66aa"><!> <div class="meters svelte-4q66aa"><div class="svelte-4q66aa"><span class="svelte-4q66aa"></span></div><div class="svelte-4q66aa"><span class="svelte-4q66aa"></span></div></div> <div class="fader svelte-4q66aa" role="slider" tabindex="0"><div class="slot svelte-4q66aa"></div> <div class="travel svelte-4q66aa"><span><i class="svelte-4q66aa"></i></span></div></div></div> <span> </span> <div class="btns svelte-4q66aa"><button>M</button> <button>S</button> <!></div></div>`),Va=G(`<div role="group" aria-label="Mixer"><div class="strips svelte-4q66aa"></div> <div class="rule svelte-4q66aa"></div> <div class="strip masterstrip svelte-4q66aa"><div class="head mh svelte-4q66aa"><span class="caps svelte-4q66aa">Master</span></div> <div class="fz svelte-4q66aa"><!> <div class="meters wide svelte-4q66aa"><div class="svelte-4q66aa"><span class="svelte-4q66aa"></span></div><div class="svelte-4q66aa"><span class="svelte-4q66aa"></span></div></div> <div class="fader svelte-4q66aa" role="slider" tabindex="0" aria-label="Master volume"><div class="slot svelte-4q66aa"></div> <div class="travel svelte-4q66aa"><span class="cap svelte-4q66aa"><i class="svelte-4q66aa"></i></span></div></div></div> <span class="mono dbv svelte-4q66aa"> </span></div></div>`);function Ha(e,t){Re(t,!0);let n=1.5,r=N(()=>new Map(($.mix?.ch??[]).map(e=>[e[0],e]))),i=N(()=>$.proj?.tracks??[]),a=N(()=>new Set($.prefs.groupsOpen)),o=N(()=>{let e=new Map(U(i).map(e=>[e.id,e]));return U(i).filter(t=>{let n=t.grp,r=0;for(;n>0&&r++<16;){if(!U(a).has(n))return!1;n=e.get(n)?.grp??-1}return!0})}),s=e=>U(i).filter(t=>t.grp===e).length,c=Ht({}),l=F(null),u=new Map;function d(e,t,n,r,i){if(!$.canControl){$.showToast(`Nota lets this phone play notes only.`);return}let a=e.currentTarget;a.setPointerCapture(e.pointerId);let o=performance.now();if(o-(u.get(t)??0)<300){u.delete(t);let e=r===`pan`?0:1;c[t]=e,$.send({t:r,id:n,v:e,ph:2}),setTimeout(()=>delete c[t],400),I(l,null);return}u.set(t,o);let s=a.getBoundingClientRect();I(l,{key:t,id:n,kind:r,start:i,y:e.clientY,x:e.clientX,size:r===`pan`?s.width:s.height},!0),c[t]=i,$.send({t:r,id:n,v:i,ph:1})}let f=0;function p(e){if(!U(l))return;let t=U(l).kind===`pan`?Math.max(-1,Math.min(1,U(l).start+(e.clientX-U(l).x)/U(l).size*2)):Math.max(0,Math.min(n,U(l).start+(U(l).y-e.clientY)/U(l).size*n));c[U(l).key]=t;let r=performance.now();r-f>30&&(f=r,$.send({t:U(l).kind,id:U(l).id,v:t,ph:0}))}function m(){if(!U(l))return;let e=U(l);I(l,null),$.send({t:e.kind,id:e.id,v:c[e.key],ph:2}),setTimeout(()=>{U(l)?.key!==e.key&&delete c[e.key]},400)}function h(e,t,n){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);$.send({t:e,id:t.id,on:n})}function g(e){let t=new Set($.prefs.groupsOpen);t.has(e.id)?t.delete(e.id):t.add(e.id),$.prefs.groupsOpen=[...t]}let _=e=>{if(e<1e-4)return`−∞`;let t=20*Math.log10(e);return(t>=.05?`+`:t<=-.05?`−`:``)+Math.abs(t).toFixed(1)},v=e=>Math.abs(e)<.01?`C`:(e<0?`L`:`R`)+Math.round(Math.abs(e)*50),y=e=>e&&e[8]&&e[9]!==$.conn?e[8]:``,b=N(()=>$.mix?.m);var x=Va(),S=L(x);Y(S,21,()=>U(o),e=>e.id,(e,t)=>{let i=N(()=>U(r).get(U(t).id)),o=N(()=>c[`v`+U(t).id]??U(i)?.[1]??1),u=N(()=>c[`p`+U(t).id]??U(i)?.[2]??0),f=N(()=>y(U(i))),p=N(()=>U(t).kind===`group`);var m=Ba();let b;var x=L(m),S=L(x);let C;var w=z(S,2),T=R(w,!0),ee=z(w,2),E=e=>{var n=La(),r=L(n);let i;var o=z(r,1,!0);j(n),B((e,t)=>{i=Z(r,``,i,{transform:e}),q(o,t)},[()=>U(a).has(U(t).id)?`rotate(90deg)`:`none`,()=>s(U(t).id)]),K(e,n)};J(ee,e=>{U(p)&&e(E)}),j(x);var D=z(x,2),te=L(D),ne=L(te);let re;j(te);var ie=R(z(te,2),!0);j(D);var ae=z(D,2),oe=L(ae),se=e=>{var t=Ra(),n=R(t);B(()=>q(n,`${U(f)??``} has it`)),K(e,t)};J(oe,e=>{U(f)&&e(se)});var ce=z(oe,2),le=L(ce),ue=L(le);let de;j(le);var O=z(le),fe=L(O);let pe;j(O),j(ce);var me=z(ce,2),he=z(L(me),2),k=L(he);let ge,A;j(he),j(me),j(ae);var _e=z(ae,2);let ve;var ye=R(_e,!0),be=z(_e,2),xe=L(be);let Se;var Ce=z(xe,2);let we;var Te=z(Ce,2),Ee=e=>{var n=za();let r;B(()=>{r=X(n,1,`arm svelte-4q66aa`,null,r,{on:U(i)?.[5]}),Q(n,`aria-pressed`,!!U(i)?.[5]),Q(n,`aria-label`,`Arm ${U(t).name??``}`)}),W(`click`,n,()=>h(`arm`,U(t),!U(i)?.[5])),K(e,n)};J(Te,e=>{U(t).kind!==`group`&&U(t).kind!==`return`&&e(Ee)}),j(be),j(m),B((e,r,a,s,c)=>{b=X(m,1,`strip svelte-4q66aa`,null,b,{group:U(p),active:U(l)?.key===`v`+U(t).id}),Q(x,`aria-label`,e),C=Z(S,``,C,{background:U(t).color}),q(T,U(t).name),Q(D,`aria-label`,`${U(t).name??``} pan`),Q(D,`aria-valuetext`,r),Q(D,`aria-valuenow`,U(u)),re=Z(ne,``,re,{left:`${50+U(u)*50}%`}),q(ie,a),de=Z(ue,``,de,{height:`${(U(i)?.[6]??0)*100}%`}),pe=Z(fe,``,pe,{height:`${(U(i)?.[7]??0)*100}%`}),Q(me,`aria-label`,`${U(t).name??``} volume`),Q(me,`aria-valuetext`,`${s??``} dB`),Q(me,`aria-valuenow`,U(o)),ge=X(k,1,`cap svelte-4q66aa`,null,ge,{held:!!U(f)}),A=Z(k,``,A,{bottom:`${U(o)/n*100}%`}),ve=X(_e,1,`mono dbv svelte-4q66aa`,null,ve,{act:U(l)?.key===`v`+U(t).id}),q(ye,c),Se=X(xe,1,`ms svelte-4q66aa`,null,Se,{mute:U(i)?.[3]}),Q(xe,`aria-pressed`,!!U(i)?.[3]),Q(xe,`aria-label`,`Mute ${U(t).name??``}`),we=X(Ce,1,`ms svelte-4q66aa`,null,we,{solo:U(i)?.[4]}),Q(Ce,`aria-pressed`,!!U(i)?.[4]),Q(Ce,`aria-label`,`Solo ${U(t).name??``}`)},[()=>U(p)?`${U(t).name}: ${U(a).has(U(t).id)?`fold`:`unfold`}`:U(t).name,()=>v(U(u)),()=>v(U(u)),()=>_(U(o)),()=>_(U(o))]),W(`click`,x,()=>U(p)&&g(U(t))),W(`pointerdown`,D,e=>d(e,`p`+U(t).id,U(t).id,`pan`,U(u))),W(`pointerdown`,me,e=>d(e,`v`+U(t).id,U(t).id,`vol`,U(o))),W(`click`,xe,()=>h(`mute`,U(t),!U(i)?.[3])),W(`click`,Ce,()=>h(`solo`,U(t),!U(i)?.[4])),K(e,m)}),j(S);var C=z(S,4),w=z(L(C),2),T=L(w),ee=e=>{var t=Ra(),n=R(t);B(()=>q(n,`${U(b)?.[3]??``} has it`)),K(e,t)},E=N(()=>y(U(b)));J(T,e=>{U(E)&&e(ee)});var D=z(T,2),te=L(D),ne=L(te);let re;j(te);var ie=z(te),ae=L(ie);let oe;j(ie),j(D);var se=z(D,2),ce=z(L(se),2),le=L(ce);let ue;j(ce),j(se),j(w);var de=R(z(w,2),!0);j(C),j(x),B(e=>{X(x,1,`mixer ${t.form??``}`,`svelte-4q66aa`),re=Z(ne,``,re,{height:`${(U(b)?.[1]??0)*100}%`}),oe=Z(ae,``,oe,{height:`${(U(b)?.[2]??0)*100}%`}),Q(se,`aria-valuenow`,c.m??U(b)?.[0]??1),ue=Z(le,``,ue,{bottom:`${(c.m??U(b)?.[0]??1)/n*100}%`}),q(de,e)},[()=>_(c.m??U(b)?.[0]??1)]),W(`pointermove`,x,p),W(`pointerup`,x,m),mr(`pointercancel`,x,m),W(`pointerdown`,se,e=>d(e,`m`,0,`mvol`,c.m??U(b)?.[0]??1)),K(e,x),ze()}hr([`pointermove`,`pointerup`,`click`,`pointerdown`]);var Ua=G(`<span class="mono pos svelte-1x69070"> </span>`),Wa=G(`<div class="empty svelte-1x69070"> </div>`),Ga=G(`<span class="auto svelte-1x69070"></span>`),Ka=wr(`<circle cx="26" cy="26" r="21" class="arc svelte-1x69070" transform="rotate(135 26 26)"></circle>`),qa=wr(`<line x1="26" y1="26" x2="26" y2="14" class="ptr svelte-1x69070"></line>`),Ja=G(`<div role="slider" tabindex="0"><!> <svg viewBox="0 0 52 52"><circle cx="26" cy="26" r="21" class="trk svelte-1x69070" transform="rotate(135 26 26)"></circle><!><circle cx="26" cy="26" r="14" class="capc svelte-1x69070"></circle><!></svg> <span class="kn svelte-1x69070"> </span> <span class="mono kv svelte-1x69070"> </span></div>`),Ya=G(`<div class="grid svelte-1x69070"></div>`),Xa=G(`<div class="macros svelte-1x69070" role="group" aria-label="Macros"><button class="dev svelte-1x69070"><span class="caps svelte-1x69070">Device</span> <span class="dn svelte-1x69070"> </span> <!> <svg width="10" height="10" viewBox="0 0 10 10"><path d="M2 3.5 L5 6.5 L8 3.5" class="svelte-1x69070"></path></svg></button> <!></div>`);function Za(e,t){Re(t,!0);let n=N(()=>t.form===`phone`?2:4),r=N(()=>t.form===`phone`?64:t.form===`phoneLand`?52:112),i=N(()=>$.mac?.id===$.proj?.you?$.mac:null),a=N(()=>U(i)?.devs[U(i).di]??`No devices`),o=Ht({}),s=Ht({}),c=null,l=F(-1),u=0;function d(e,t,n){if(!$.canControl)return $.showToast(`Nota lets this phone play notes only.`);U(i)&&(e.currentTarget.setPointerCapture(e.pointerId),c={i:t,y:e.clientY,v:n},I(l,t,!0),o[t]=n,$.send({t:`mac`,i:t,v:n,ph:1}))}function f(e){if(!c)return;let t=Math.min(1,Math.max(0,c.v+(c.y-e.clientY)/200));o[c.i]=t,U(i)?.k[c.i]?.map&&(s[c.i]=t);let n=performance.now();n-u>30&&(u=n,$.send({t:`mac`,i:c.i,v:t,ph:0}))}function p(){if(!c)return;let e=c.i;$.send({t:`mac`,i:e,v:o[e],ph:2}),c=null,I(l,-1),setTimeout(()=>{U(l)!==e&&delete o[e]},500)}var m=Xa(),h=L(m),g=z(L(h),2),_=R(g,!0),v=z(g,2),y=e=>{var t=Ua(),n=R(t);B(()=>q(n,`${U(i).di+1}/${U(i).devs.length??``}`)),K(e,t)};J(v,e=>{U(i)&&U(i).devs.length>1&&e(y)}),ye(2),j(h);var b=z(h,2),x=e=>{var t=Wa(),n=R(t,!0);B(()=>q(n,U(i)?`This track has no instrument or effects to control.`:`Loading…`)),K(e,t)},S=e=>{var t=Ya();let a;Y(t,21,()=>U(i).k,Fr,(e,t,n)=>{let i=N(()=>o[n]??(U(t).map?s[n]??.5:U(t).v??0)),a=N(()=>U(l)===n),c=N(()=>U(t).n===void 0&&!U(t).map);var u=Ja();let f;var p=L(u),m=e=>{K(e,Ga())};J(p,e=>{U(t).a&&!U(t).map&&e(m)});var h=z(p,2),g=L(h);Q(g,`stroke-dasharray`,`98.9 131.9`);var _=z(g),v=e=>{var t=Ka();B(()=>Q(t,`stroke-dasharray`,`${U(i)*98.9} 131.9`)),K(e,t)};J(_,e=>{U(c)||e(v)});var y=z(_,2),b=e=>{var t=qa();B(()=>Q(t,`transform`,`rotate(${-135+270*U(i)} 26 26)`)),K(e,t)};J(y,e=>{U(c)||e(b)}),j(h);var x=z(h,2),S=R(x,!0),C=R(z(x,2),!0);j(u),B((e,i,o,s)=>{f=X(u,1,`knob svelte-1x69070`,null,f,{on:U(a),empty:U(c),learnable:$.learn.on&&!U(c)}),Q(u,`aria-label`,U(t).map??U(t).n??`Macro ${n+1}`),Q(u,`aria-valuenow`,e),Q(u,`aria-valuetext`,i),Q(h,`width`,U(r)),Q(h,`height`,U(r)),q(S,o),q(C,s)},[()=>Math.round(U(i)*100),()=>U(t).map?`${Math.round(U(i)*100)} %`:U(t).txt,()=>(U(t).map??U(t).n??`Macro ${n+1}`).toUpperCase(),()=>U(c)?`—`:U(t).map||U(a)?`${Math.round(U(i)*100)} %`:U(t).txt]),W(`pointerdown`,u,e=>!U(c)&&d(e,n,U(i))),K(e,u)}),j(t),B(()=>a=Z(t,``,a,{"grid-template-columns":`repeat(${U(n)??``}, minmax(0, 1fr))`})),K(e,t)};J(b,e=>{!U(i)||U(i).devs.length===0?e(x):e(S,-1)}),j(m),B(()=>q(_,U(a))),W(`pointermove`,m,f),W(`pointerup`,m,p),mr(`pointercancel`,m,p),W(`click`,h,()=>U(i)&&U(i).devs.length>1&&($.sheet=`devices`)),K(e,m),ze()}hr([`pointermove`,`pointerup`,`click`,`pointerdown`]);var Qa=G(`<div class="empty svelte-he2l50">Loading…</div>`),$a=G(`<div class="th svelte-he2l50"><span class="svelte-he2l50"></span><b class="svelte-he2l50"> </b></div>`),eo=G(`<div class="clip empty svelte-he2l50"></div>`),to=G(`<span class="ptri svelte-he2l50"></span>`),no=G(`<span class="prog svelte-he2l50"></span>`),ro=G(`<button><span class="cn svelte-he2l50"><!> </span> <span class="mono cs svelte-he2l50"> </span> <!></button>`),io=G(`<button class="scene svelte-he2l50"><span class="tri svelte-he2l50"></span> </button> <!>`,1),ao=G(`<button class="stop svelte-he2l50"><span class="sq svelte-he2l50"></span>Stop</button>`),oo=G(`<div class="grid svelte-he2l50"><div class="caps corner svelte-he2l50">Scene</div> <!> <!> <button class="stopall svelte-he2l50"><span class="sq svelte-he2l50"></span>All</button> <!></div>`),so=G(`<div class="scroll svelte-he2l50"><!></div>`);function co(e,t){Re(t,!0);let n=N(()=>$.ses),r=N(()=>new Map(($.proj?.tracks??[]).map(e=>[e.id,e]))),i=N(()=>U(n)?.tr??[]),a=N(()=>t.form===`phone`?96:t.form===`phoneLand`?104:132),o=N(()=>t.form===`phone`?58:t.form===`phoneLand`?50:84),s=e=>{let t=e/4;return t===Math.round(t)?`${t} bar${t===1?``:`s`}`:`${e} beats`};function c(){return $.canControl?!0:($.showToast(`Nota lets this phone play notes only.`),!1)}var l=so(),u=L(l),d=e=>{K(e,Qa())},f=e=>{var l=oo();let u;var d=z(L(l),2);Y(d,17,()=>U(i),e=>e.id,(e,t)=>{let n=N(()=>U(r).get(U(t).id));var i=$a(),a=L(i);let o;var s=R(z(a),!0);j(i),B(()=>{o=Z(a,``,o,{background:U(n)?.color}),q(s,U(n)?.name??``)}),K(e,i)});var f=z(d,2);Y(f,16,()=>Array.from({length:U(n).n},(e,t)=>t),e=>e,(e,t)=>{var n=io(),a=Zt(n);let l;var u=z(L(a));j(a),Y(z(a,2),17,()=>U(i),e=>e.id,(e,n)=>{let i=N(()=>U(r).get(U(n).id)),a=N(()=>{let[e,r,i]=U(n).c[t]??[0,0,0];return{st:e,len:r,prog:i}});var l=Tr(),u=Zt(l),d=e=>{var t=eo();let n;B(()=>n=Z(t,``,n,{height:`${U(o)??``}px`})),K(e,t)},f=e=>{var r=ro();let l,u;var d=L(r),f=L(d),p=e=>{K(e,to())};J(f,e=>{U(a).st===3&&e(p)});var m=z(f,1,!0);j(d);var h=z(d,2),g=R(h,!0),_=z(h,2),v=e=>{var t=no();let n;B(()=>n=Z(t,``,n,{width:`${U(a).prog*100}%`})),K(e,t)};J(_,e=>{U(a).st===3&&e(v)}),j(r),B(e=>{l=X(r,1,`clip svelte-he2l50`,null,l,{playing:U(a).st===3,queued:U(a).st===2,rec:U(a).st===4}),Q(r,`aria-label`,`${U(i)?.name??``} scene ${t+1}: ${U(a).st===3?`playing`:U(a).st===2?`queued`:U(a).st===4?`recording`:`stopped`}`),u=Z(r,``,u,{height:`${U(o)??``}px`,"--tc":U(i)?.color}),q(m,e),q(g,U(a).st===3?`PLAYING`:U(a).st===2?`QUEUED`:U(a).st===4?`RECORDING`:``)},[()=>s(U(a).len)]),W(`click`,r,()=>c()&&$.send({t:`launch`,id:U(n).id,i:t})),K(e,r)};J(u,e=>{U(a).st===0?e(d):e(f,-1)}),K(e,l)}),B(()=>{Q(a,`aria-label`,`Launch scene ${t+1}`),l=Z(a,``,l,{height:`${U(o)??``}px`}),q(u,`Scene ${t+1}`)}),W(`click`,a,()=>c()&&$.send({t:`scene`,i:t})),K(e,n)});var p=z(f,2);Y(z(p,2),17,()=>U(i),e=>e.id,(e,t)=>{var n=ao();B(e=>Q(n,`aria-label`,`Stop ${e??``}`),[()=>U(r).get(U(t).id)?.name]),W(`click`,n,()=>c()&&$.send({t:`stopSlot`,id:U(t).id})),K(e,n)}),j(l),B(()=>u=Z(l,``,u,{"grid-template-columns":`${t.form===`phone`?92:110}px repeat(${U(i).length??``}, minmax(${U(a)??``}px, 1fr))`})),W(`click`,p,()=>c()&&$.send({t:`stopAll`})),K(e,l)};J(u,e=>{U(n)?e(f,-1):e(d)}),j(l),K(e,l),ze()}hr([`click`]),Ie();var lo=pi(()=>$),uo=G(`<div class="empty svelte-i7n35i"><span class="t svelte-i7n35i"> </span> <span class="s svelte-i7n35i">There is no instrument to play. Pick an instrument track, or use the transport to record.</span> <button class="btn svelte-i7n35i">Choose another track</button></div>`);function fo(e,t){Re(t,!1),di();var n=uo(),r=L(n),i=R(r),a=z(r,4);j(n),B(()=>q(i,`${lo().track?.name??`This track`??``} is an audio track`)),W(`click`,a,()=>lo(lo().sheet=`tracks`)),K(e,n),ze()}hr([`click`]);var po=G(`<button> </button>`),mo=G(`<nav class="rail svelte-1n46o8q" aria-label="Screens"></nav>`),ho=G(`<nav class="tabs svelte-1n46o8q" aria-label="Screens"><div class="seg svelte-1n46o8q"></div></nav>`),go=G(`<div><!> <!> <div class="body svelte-1n46o8q"><!> <main><!> <!></main></div> <!> <!> <!></div>`);function _o(e,t){Re(t,!0);let n=N(()=>vi.form),r=N(()=>U(n)!==`phone`),i=N(()=>$.track),a=N(()=>U(i)?.kind===`audio`&&($.screen===`Pads`||$.screen===`Keys`)),o=N(()=>$.link===`lost`||$.link===`connecting`);un(()=>{document.documentElement.dataset.theme=$.dark?`dark`:`light`,document.querySelector(`meta[name=theme-color]`)?.setAttribute(`content`,$.dark?`#0B0A09`:`#DCD6C5`)});var s=go(),c=L(s);Di(c,{get form(){return U(n)}});var l=z(c,2);ki(l,{});var u=z(l,2),d=L(u),f=e=>{var t=mo();Y(t,21,()=>Ti,Fr,(e,t)=>{var n=po();let r;var i=R(n,!0);B(()=>{r=X(n,1,`svelte-1n46o8q`,null,r,{on:$.screen===U(t)&&!$.bigTransport}),q(i,U(t))}),W(`click`,n,()=>$.setScreen(U(t))),K(e,n)}),j(t),K(e,t)};J(d,e=>{U(r)&&e(f)});var p=z(d,2);let m;var h=L(p),g=e=>{fo(e,{})},_=e=>{ga(e,{get form(){return U(n)}})},v=e=>{ka(e,{get form(){return U(n)}})},y=e=>{Ia(e,{get form(){return U(n)}})},b=e=>{Ha(e,{get form(){return U(n)}})},x=e=>{Za(e,{get form(){return U(n)}})},S=e=>{co(e,{get form(){return U(n)}})};J(h,e=>{U(a)?e(g):$.screen===`Pads`?e(_,1):$.screen===`Keys`?e(v,2):$.screen===`XY`?e(y,3):$.screen===`Mixer`?e(b,4):$.screen===`Macros`?e(x,5):e(S,-1)});var C=z(h,2),w=e=>{fa(e,{get form(){return U(n)}})};J(C,e=>{$.bigTransport&&e(w)}),j(p),j(u);var T=z(u,2),ee=e=>{var t=ho(),n=L(t);Y(n,21,()=>Ti,Fr,(e,t)=>{var n=po();let r;var i=R(n,!0);B(()=>{r=X(n,1,`svelte-1n46o8q`,null,r,{on:$.screen===U(t)&&!$.bigTransport}),q(i,U(t))}),W(`click`,n,()=>$.setScreen(U(t))),K(e,n)}),j(n),j(t),K(e,t)};J(T,e=>{U(r)||e(ee)});var E=z(T,2);Qi(E,{get form(){return U(n)}}),ca(z(E,2),{get form(){return U(n)}}),j(s),B(()=>{X(s,1,`shell ${U(n)??``}`,`svelte-1n46o8q`),Q(p,`aria-busy`,U(o)),m=X(p,1,`svelte-1n46o8q`,null,m,{dim:U(o)})}),mr(`pointerdown`,s,function(...e){xi?.apply(this,e)},!0),K(e,s),ze()}hr([`click`]);for(let e of[`gesturestart`,`gesturechange`,`contextmenu`,`dblclick`])document.addEventListener(e,e=>e.preventDefault(),{passive:!1});document.addEventListener(`touchmove`,e=>{e.touches.length>1&&e.preventDefault()},{passive:!1}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&$.wake()}),window.addEventListener(`online`,()=>$.wake()),`serviceWorker`in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`./sw.js`).catch(()=>{}),Ar(_o,{target:document.getElementById(`app`)}),$.connect();\ No newline at end of filediff --git a/src/managed/Nota.Remote/wwwroot/assets/index-WqkYRGtE.css b/src/managed/Nota.Remote/wwwroot/assets/index-WqkYRGtE.cssnew file mode 100644index 00000000..699fbc26--- /dev/null+++ b/src/managed/Nota.Remote/wwwroot/assets/index-WqkYRGtE.css@@ -0,0 +1 @@+@font-face{font-family:Geist;font-weight:400;font-display:swap;src:url(../fonts/Geist-Regular.woff2)format("woff2")}@font-face{font-family:Geist;font-weight:500 700;font-display:swap;src:url(../fonts/Geist-SemiBold.woff2)format("woff2")}@font-face{font-family:Geist Mono;font-weight:400 700;font-display:swap;src:url(../fonts/GeistMono-Medium.woff2)format("woff2")}:root,[data-theme=dark]{--abyss:#0a0908;--app:#0b0a09;--gutter:#0c0b09;--well:#100f0d;--panel:#141310;--card:#171613;--raised:#1c1a16;--hover:#252219;--track-off:#26231e;--selected:#241f17;--hairline:#221f1a;--border:#2c2923;--border-strong:#3a362d;--border-brass:#6b5326;--grid:#1e1c18;--ink0:#f2ede1;--ink1:#e9e4d8;--ink2:#c7c0b0;--ink3:#a39d8f;--ink4:#8d8779;--ink5:#6e6a5e;--ink6:#55514a;--on-accent:#171613;--accent:#d8a03d;--accent-bright:#f0c060;--accent-dim:#8a6b2e;--accent-edge:#5e4a22;--accent-wash:#241f17;--record:#c25b44;--record-wash:#2a1a16;--record-ink:#e08a72;--danger:#c2554a;--danger-bright:#e08a72;--warning:#d9c34c;--success:#58b368;--success-dim:#7fb069;--steel:#6d8fb5;--white-key:#d9d3c5;--white-key-ink:#55514a;--scrim:#0a090899;--lightningcss-light: ;--lightningcss-dark:initial;color-scheme:dark}[data-theme=light]{--abyss:#d8d1be;--app:#dcd6c5;--gutter:#e0dac9;--well:#e4dfd1;--panel:#eae5d7;--card:#efeade;--raised:#f8f5ec;--hover:#e7e1d0;--track-off:#dbd4c0;--selected:#f2e4c4;--hairline:#d5cfbe;--border:#d5cebb;--border-strong:#bdb5a0;--border-brass:#c9a254;--grid:#ded8c8;--ink0:#1a150e;--ink1:#241f17;--ink2:#3e382c;--ink3:#5e5849;--ink4:#746d5c;--ink5:#8a8474;--ink6:#9e9786;--on-accent:#fffbf2;--accent:#a87415;--accent-bright:#744d07;--accent-dim:#9c8034;--accent-edge:#d3b173;--accent-wash:#f2e4c4;--record:#b54a32;--record-wash:#f3ddd4;--record-ink:#a3391b;--danger:#b13e33;--danger-bright:#a3391b;--warning:#837010;--success:#2c7a3e;--success-dim:#609548;--steel:#3e6288;--white-key:#fbf9f3;--white-key-ink:#8a8474;--scrim:#241f1759;--lightningcss-light:initial;--lightningcss-dark: ;color-scheme:light}*{box-sizing:border-box;margin:0;padding:0}html,body{background:var(--app);height:100%;color:var(--ink1);-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;overscroll-behavior:none;touch-action:none;font-family:Geist,system-ui,-apple-system,sans-serif;font-size:13px;overflow:hidden}body,#app{position:fixed;inset:0}button{font:inherit;color:inherit;cursor:pointer;touch-action:manipulation;background:0 0;border:none}input{font:inherit;color:inherit;-webkit-user-select:text;user-select:text;touch-action:manipulation}.mono{font-variant-numeric:tabular-nums;font-family:Geist Mono,ui-monospace,monospace}.caps{letter-spacing:.14em;color:var(--ink5);text-transform:uppercase;font-size:10px;font-weight:700}.sr{clip:rect(0 0 0 0);width:1px;height:1px;position:absolute;overflow:hidden}.btn{background:var(--raised);border:1px solid var(--border);height:42px;color:var(--ink2);border-radius:5px;justify-content:center;align-items:center;gap:7px;padding:0 12px;font-size:12px;font-weight:600;transition:background-color .12s ease-out,border-color .12s ease-out,color .12s ease-out;display:inline-flex}.btn.on{background:var(--accent-wash);border-color:var(--border-brass);color:var(--accent-bright)}.seg{background:var(--well);border:1px solid var(--hairline);border-radius:6px;gap:2px;padding:3px;display:flex}.seg>button{height:36px;color:var(--ink4);border-radius:4px;flex:1;padding:0 11px;font-size:12px;font-weight:600;transition:background-color .12s ease-out,color .12s ease-out}.seg>button.on{background:var(--raised);color:var(--ink1)}.switch{background:var(--track-off);border-radius:5px;flex:none;width:18px;height:10px;display:block;position:relative}.switch:after{content:"";background:var(--ink5);border-radius:50%;width:7px;height:7px;transition:left .12s ease-out;position:absolute;top:1.5px;left:1.5px}.switch.on{background:var(--accent)}.switch.on:after{background:var(--on-accent);left:9.5px}.learnable{outline:1px dashed var(--accent-dim);outline-offset:2px}header.svelte-oiwvqb{border-bottom:1px solid var(--hairline);background:var(--app);z-index:6;flex-wrap:wrap;flex:none;align-items:center;gap:8px 10px;padding:6px 10px 10px;display:flex;position:relative}header.phoneLand.svelte-oiwvqb{flex-wrap:nowrap;padding:6px 10px}header.tablet.svelte-oiwvqb{flex-wrap:nowrap;padding:10px 16px}svg.svelte-oiwvqb path:where(.svelte-oiwvqb){fill:none;stroke:var(--ink4);stroke-width:1.6px;stroke-linecap:round;stroke-linejoin:round}.picker.svelte-oiwvqb{flex:1;order:1;align-items:center;gap:4px;min-width:0;display:flex}.step.svelte-oiwvqb{border-radius:5px;flex:none;justify-content:center;align-items:center;width:36px;height:44px;display:flex}.track.svelte-oiwvqb{background:var(--panel);border:1px solid var(--border);text-align:left;border-radius:6px;flex:1;align-items:center;gap:10px;min-width:0;height:44px;padding:0 10px;display:flex}.bar.svelte-oiwvqb{border-radius:2px;flex:none;width:4px;height:24px}.names.svelte-oiwvqb{flex-direction:column;flex:1;gap:1px;min-width:0;display:flex}.name.svelte-oiwvqb{color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;font-size:14px;font-weight:600;overflow:hidden}.sub.svelte-oiwvqb{color:var(--ink5);white-space:nowrap;text-overflow:ellipsis;font-size:10px;overflow:hidden}.transport.svelte-oiwvqb{flex-basis:100%;order:3;align-items:center;gap:6px;display:flex}.phoneLand.svelte-oiwvqb .transport:where(.svelte-oiwvqb){flex:0 0 330px;order:2}.tablet.svelte-oiwvqb .transport:where(.svelte-oiwvqb){flex:0 0 460px;order:2}.tbtn.svelte-oiwvqb{background:var(--raised);border:1px solid var(--border);border-radius:5px;flex:none;justify-content:center;align-items:center;width:44px;height:40px;transition:background-color .12s ease-out,border-color .12s ease-out;display:flex}.tbtn.play.svelte-oiwvqb{width:54px}.sq.svelte-oiwvqb{background:var(--ink2);border-radius:1px;width:11px;height:11px}.tri.svelte-oiwvqb{border-left:12px solid var(--ink2);border-top:7px solid #0000;border-bottom:7px solid #0000;width:0;height:0;margin-left:3px}.play.on.svelte-oiwvqb{background:var(--accent);border-color:var(--accent)}.play.on.svelte-oiwvqb .tri:where(.svelte-oiwvqb){border-left-color:var(--on-accent)}.dot.svelte-oiwvqb{background:var(--ink4);border-radius:50%;width:12px;height:12px}.rec.on.svelte-oiwvqb,.rec.count.svelte-oiwvqb{background:var(--record-wash);border-color:var(--record)}.rec.on.svelte-oiwvqb .dot:where(.svelte-oiwvqb),.rec.count.svelte-oiwvqb .dot:where(.svelte-oiwvqb){background:var(--record)}.pos.svelte-oiwvqb{background:var(--well);border:1px solid var(--border);border-radius:5px;flex:1;align-items:center;gap:10px;min-width:0;height:40px;padding:0 10px;display:flex;box-shadow:inset 0 1px #00000080}.pos.open.svelte-oiwvqb{border-color:var(--border-brass)}.pos.open.svelte-oiwvqb svg:where(.svelte-oiwvqb){transform:rotate(180deg)}.pos.svelte-oiwvqb svg:where(.svelte-oiwvqb){margin-left:auto}.p.svelte-oiwvqb{color:var(--ink1);font-size:16px;font-weight:500}.bpm.svelte-oiwvqb{color:var(--ink4);font-size:11px}.status.svelte-oiwvqb{order:2;align-items:center;gap:4px;display:flex}.phoneLand.svelte-oiwvqb .status:where(.svelte-oiwvqb),.tablet.svelte-oiwvqb .status:where(.svelte-oiwvqb){order:3}.link.svelte-oiwvqb{border-radius:5px;align-items:center;gap:6px;height:44px;padding:0 8px;display:flex}.link.svelte-oiwvqb .mono:where(.svelte-oiwvqb){white-space:nowrap;font-size:10px}.ldot.svelte-oiwvqb{border-radius:50%;width:7px;height:7px}.blink.svelte-oiwvqb{animation:.8s step-end infinite svelte-oiwvqb-blink}@keyframes svelte-oiwvqb-blink{50%{opacity:.35}}.menu.svelte-oiwvqb{border-radius:5px;justify-content:center;align-items:center;gap:3px;width:44px;height:44px;display:flex}.menu.open.svelte-oiwvqb{background:var(--raised)}.menu.svelte-oiwvqb span:where(.svelte-oiwvqb){background:var(--ink3);border-radius:50%;width:4px;height:4px}.banner.svelte-4gizvm{border-bottom:1px solid var(--border-brass);background:var(--accent-wash);flex:none;align-items:center;gap:10px;padding:9px 16px;display:flex}.banner.quiet.svelte-4gizvm{background:var(--panel);border-color:var(--border)}.dot.svelte-4gizvm{background:var(--accent);border-radius:50%;flex:none;width:8px;height:8px}.quiet.svelte-4gizvm .dot:where(.svelte-4gizvm){background:var(--ink4)}.blink.svelte-4gizvm{animation:.8s step-end infinite svelte-4gizvm-blink}@keyframes svelte-4gizvm-blink{50%{opacity:.35}}.t.svelte-4gizvm{color:var(--accent-bright);font-size:12px;font-weight:600}.quiet.svelte-4gizvm .t:where(.svelte-4gizvm){color:var(--ink1)}.s.svelte-4gizvm{color:var(--ink3);font-size:11px}.scrim.svelte-tyq0v8{z-index:20;background:var(--scrim);position:absolute;inset:0}.sheet.svelte-tyq0v8{z-index:21;left:12px;top:calc(env(safe-area-inset-top) + 64px);background:var(--panel);border:1px solid var(--border-strong);border-radius:8px;flex-direction:column;width:360px;max-width:calc(100% - 24px);max-height:calc(100% - 88px);display:flex;position:absolute;overflow:hidden}.sheet.bottom.svelte-tyq0v8{width:auto;top:auto;right:12px;bottom:max(24px, env(safe-area-inset-bottom));max-height:75%}.sheet.menu.svelte-tyq0v8{width:300px;left:auto;right:12px}.head.svelte-tyq0v8{padding:14px 16px 8px}.list.svelte-tyq0v8{touch-action:pan-y;overscroll-behavior:contain;overflow-y:auto}.row.svelte-tyq0v8{border-top:1px solid var(--hairline);text-align:left;align-items:center;gap:12px;width:100%;height:52px;padding:0 16px;display:flex;position:relative}.row.slim.svelte-tyq0v8{border:none;height:44px;padding:0}.row.on.svelte-tyq0v8{background:var(--accent-wash)}.row.on.svelte-tyq0v8:before{content:"";background:var(--accent);width:2px;position:absolute;top:10px;bottom:10px;left:0}.row.slim.on.svelte-tyq0v8:before{display:none}.bar.svelte-tyq0v8{border-radius:2px;flex:none;width:4px;height:22px}.names.svelte-tyq0v8{flex-direction:column;flex:1;gap:1px;min-width:0;display:flex}.n.svelte-tyq0v8{color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;font-size:13px;font-weight:600;overflow:hidden}.d.svelte-tyq0v8{color:var(--ink5);font-size:10px}.who.svelte-tyq0v8{background:var(--track-off);height:20px;color:var(--ink2);border-radius:10px;align-items:center;padding:0 8px;font-size:10px;font-weight:600;display:flex}.empty.svelte-tyq0v8{color:var(--ink5);padding:16px;font-size:12px}.toggle.svelte-tyq0v8{border-top:1px solid var(--border);text-align:left;align-items:center;gap:10px;width:100%;min-height:52px;padding:0 16px;display:flex}.n2.svelte-tyq0v8{color:var(--ink1);font-size:12px;display:block}.d2.svelte-tyq0v8{color:var(--ink5);font-size:10px;display:block}.block.svelte-tyq0v8{flex-direction:column;gap:8px;padding:14px 16px;display:flex}.field.svelte-tyq0v8{background:var(--well);border:1px solid var(--border);border-radius:4px;outline:none;height:40px;padding:0 12px;font-size:13px;box-shadow:inset 0 1px #00000080}.field.svelte-tyq0v8:focus{border-color:var(--border-brass)}.tonics.svelte-tyq0v8{grid-template-columns:repeat(6,1fr);gap:6px;display:grid}.tonics.svelte-tyq0v8 .btn:where(.svelte-tyq0v8){height:44px;padding:0}.disconnect.svelte-tyq0v8{border-top:1px solid var(--border);height:52px;color:var(--danger-bright);text-align:left;padding:0 16px;font-size:13px;font-weight:600}.cover.svelte-17f2qxr{z-index:40;background:var(--app);padding:28px;padding-top:calc(env(safe-area-inset-top) + 28px);flex-direction:column;justify-content:center;gap:18px;display:flex;position:absolute;inset:0}h1.svelte-17f2qxr{color:var(--ink0);font-size:22px;font-weight:600}p.svelte-17f2qxr{color:var(--ink3);max-width:420px;font-size:13px;line-height:1.6}ol.svelte-17f2qxr{border:1px solid var(--border);border-radius:6px;max-width:420px;list-style:none;overflow:hidden}li.svelte-17f2qxr{background:var(--panel);color:var(--ink2);gap:12px;padding:12px 14px;font-size:12px;line-height:1.5;display:flex}li.svelte-17f2qxr+li:where(.svelte-17f2qxr){border-top:1px solid var(--hairline)}li.svelte-17f2qxr .mono:where(.svelte-17f2qxr){color:var(--accent-dim);font-size:11px}.retry.svelte-17f2qxr{color:var(--ink4);align-items:center;gap:10px;font-size:12px;display:flex}.dot.svelte-17f2qxr{background:var(--ink5);border-radius:50%;width:7px;height:7px}.blink.svelte-17f2qxr{animation:.8s step-end infinite svelte-17f2qxr-blink}@keyframes svelte-17f2qxr-blink{50%{opacity:.35}}.code.svelte-17f2qxr{grid-template-columns:repeat(4,64px);gap:10px;display:grid;position:relative}.code.svelte-17f2qxr input:where(.svelte-17f2qxr){opacity:0;font-size:16px;position:absolute;inset:0}.cell.svelte-17f2qxr{background:var(--well);border:1px solid var(--hairline);pointer-events:none;border-radius:6px;justify-content:center;align-items:center;height:68px;display:flex;box-shadow:inset 0 1px #00000080}.cell.cur.svelte-17f2qxr{border-color:var(--border-brass)}.cell.svelte-17f2qxr .mono:where(.svelte-17f2qxr){color:var(--ink0);font-size:28px}.caret.svelte-17f2qxr{background:var(--accent);width:2px;height:28px;animation:1s step-end infinite svelte-17f2qxr-blink}.big.svelte-17f2qxr{align-self:flex-start;height:48px;padding:0 20px;font-size:13px}.count.svelte-17f2qxr{z-index:35;background:var(--app);flex-direction:column;justify-content:center;align-items:center;gap:12px;display:flex;position:absolute;inset:0}.num.svelte-17f2qxr{color:var(--accent-bright);font-size:200px;font-weight:500;line-height:1}.num.phoneLand.svelte-17f2qxr{font-size:150px}.num.tablet.svelte-17f2qxr{font-size:260px}.rec.svelte-17f2qxr{color:var(--record);font-size:12px}.toast.svelte-17f2qxr{z-index:50;background:var(--raised);border:1px solid var(--border-strong);max-width:86%;color:var(--ink1);text-align:center;border-radius:6px;padding:10px 14px;font-size:12px;line-height:1.45;position:absolute;bottom:24px;left:50%;transform:translate(-50%)}.toast.low.svelte-17f2qxr{bottom:calc(env(safe-area-inset-bottom) + 84px)}.big.svelte-1hrivqy{z-index:4;background:var(--app);flex-direction:column;gap:14px;padding:12px;display:flex;position:absolute;inset:0}.phoneLand.big.svelte-1hrivqy{gap:10px;padding:8px 10px}.tablet.big.svelte-1hrivqy{padding:18px}.top.svelte-1hrivqy{justify-content:space-between;align-items:flex-end;gap:12px;display:flex}.pblock.svelte-1hrivqy{flex-direction:column;gap:4px;display:flex}.pos.svelte-1hrivqy{color:var(--ink1);font-size:52px;font-weight:500;line-height:1}.phoneLand.svelte-1hrivqy .pos:where(.svelte-1hrivqy){font-size:40px}.tablet.svelte-1hrivqy .pos:where(.svelte-1hrivqy){font-size:88px}.pos.rec.svelte-1hrivqy{color:var(--record-ink)}.tap.svelte-1hrivqy{background:var(--raised);border:1px solid var(--border);border-radius:6px;flex-direction:column;justify-content:center;align-items:center;gap:2px;height:56px;padding:0 16px;display:flex}.tap.svelte-1hrivqy .mono:where(.svelte-1hrivqy){color:var(--ink1);font-size:18px;font-weight:500}.tap.svelte-1hrivqy .caps:where(.svelte-1hrivqy){letter-spacing:.1em;font-size:9px}.btns.svelte-1hrivqy{flex:1;grid-auto-rows:minmax(0,1fr);gap:8px;min-height:0;display:grid}.b.svelte-1hrivqy{background:var(--raised);border:1px solid var(--border);min-height:0;color:var(--ink2);border-radius:8px;flex-direction:column;justify-content:center;align-items:center;gap:10px;font-size:14px;font-weight:600;display:flex}.b.svelte-1hrivqy svg:where(.svelte-1hrivqy) path:where(.svelte-1hrivqy){fill:none;stroke:currentColor;stroke-width:2.2px;stroke-linecap:round;stroke-linejoin:round}.b.on.svelte-1hrivqy{background:var(--accent-wash);border-color:var(--border-brass);color:var(--accent-bright)}.b.dim.svelte-1hrivqy{color:var(--ink6)}.tri.svelte-1hrivqy{border-top:16px solid #0000;border-bottom:16px solid #0000;border-left:26px solid;width:0;height:0;margin-left:6px}.sq.svelte-1hrivqy{background:currentColor;border-radius:3px;width:26px;height:26px}.dot.svelte-1hrivqy{background:var(--record);border-radius:50%;width:28px;height:28px}.play.on.svelte-1hrivqy{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}.recb.on.svelte-1hrivqy{background:var(--record-wash);border-color:var(--record);color:var(--record-ink)}.secs.svelte-1hrivqy{flex-direction:column;gap:6px;display:flex}.sgrid.svelte-1hrivqy{grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;display:grid}.sec.svelte-1hrivqy{background:var(--panel);border:1px solid var(--border);border-radius:5px;flex-direction:column;justify-content:center;align-items:center;gap:2px;height:52px;display:flex}.sec.cur.svelte-1hrivqy{background:var(--raised);border-color:var(--border-strong)}.sec.looping.svelte-1hrivqy{background:var(--accent-wash);border-color:var(--border-brass)}.sn.svelte-1hrivqy{color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;max-width:92%;font-size:13px;font-weight:600;overflow:hidden}.looping.svelte-1hrivqy .sn:where(.svelte-1hrivqy){color:var(--accent-bright)}.si.svelte-1hrivqy{color:var(--ink5);font-size:9px}.looping.svelte-1hrivqy .si:where(.svelte-1hrivqy){color:var(--accent)}.pads.svelte-1puq9zz{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex}.bar.svelte-1puq9zz{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.banks.svelte-1puq9zz button:where(.svelte-1puq9zz){flex:none;min-width:42px;font-size:11px;font-weight:500}.rep.svelte-1puq9zz{gap:8px;padding:0 6px 0 10px}.rate.svelte-1puq9zz{background:var(--well);height:30px;color:var(--ink3);border-radius:3px;align-items:center;padding:0 7px;font-size:11px;display:flex}.rep.on.svelte-1puq9zz .rate:where(.svelte-1puq9zz){color:var(--accent-bright)}.grid.svelte-1puq9zz{flex:1;grid-auto-rows:minmax(0,1fr);gap:8px;min-height:0;display:grid}.pad.svelte-1puq9zz{background:var(--raised);border:1px solid var(--border);text-align:left;touch-action:none;border-radius:6px;flex-direction:column;justify-content:space-between;align-items:stretch;min-width:0;min-height:0;padding:8px;display:flex;overflow:hidden;box-shadow:inset 0 1px #ffffff08}.num.svelte-1puq9zz,.note.svelte-1puq9zz{color:var(--ink5);font-size:10px}.note.svelte-1puq9zz{font-size:9px}.label.svelte-1puq9zz{flex-direction:column;gap:1px;min-width:0;display:flex}.name.svelte-1puq9zz{color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;font-size:12px;font-weight:600;overflow:hidden}.tablet .name.svelte-1puq9zz{font-size:14px}.pad.playing.svelte-1puq9zz{background:var(--tc);border-color:var(--tc)}.pad.on.svelte-1puq9zz{background:var(--accent);border-color:var(--accent)}.pad.on.svelte-1puq9zz :where(.svelte-1puq9zz),.pad.playing.svelte-1puq9zz :where(.svelte-1puq9zz){color:var(--on-accent)}.pad.playing.svelte-1puq9zz :where(.svelte-1puq9zz){color:#171613}.keys.svelte-12d1dcp{flex-direction:column;flex:1;gap:10px;min-height:0;display:flex}.bar.svelte-12d1dcp{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.modes.svelte-12d1dcp button:where(.svelte-12d1dcp){flex:none}.keybtn.svelte-12d1dcp{gap:7px;padding:0 10px}.k.svelte-12d1dcp{letter-spacing:.1em;font-size:9px}.kn.svelte-12d1dcp{color:var(--ink1);font-size:12px;font-weight:600}.src.svelte-12d1dcp{color:var(--accent-dim);font-size:9px}.oct.svelte-12d1dcp{align-items:center;gap:2px;margin-left:auto;display:flex}.oct.svelte-12d1dcp .mono:where(.svelte-12d1dcp){text-align:center;width:46px;color:var(--ink1);font-size:12px}.sq.svelte-12d1dcp{width:42px;padding:0}.sq.svelte-12d1dcp path:where(.svelte-12d1dcp){stroke:var(--ink2);stroke-width:1.6px;stroke-linecap:round;fill:none}.surface.svelte-12d1dcp{touch-action:none;flex:1;min-height:0;display:flex}.kb.svelte-12d1dcp{flex:1;gap:3px;min-width:0;display:flex;position:relative}.white.svelte-12d1dcp{background:var(--white-key);border-radius:0 0 6px 6px;flex-direction:column;flex:1;justify-content:flex-end;align-items:center;min-width:0;padding-bottom:12px;display:flex;position:relative;overflow:hidden}.white.on.svelte-12d1dcp{background:var(--accent)}.lbl.svelte-12d1dcp{color:var(--white-key-ink);font-size:10px}.white.on.svelte-12d1dcp .lbl:where(.svelte-12d1dcp){color:var(--on-accent)}.black.svelte-12d1dcp{background:var(--raised);border:1px solid var(--border-strong);z-index:1;border-top:none;border-radius:0 0 5px 5px;height:58%;position:absolute;top:0;overflow:hidden}.black.on.svelte-12d1dcp{background:var(--accent);border-color:var(--accent)}.band.svelte-12d1dcp{background:var(--tc);height:5px;position:absolute;bottom:0;left:0;right:0}.grid.svelte-12d1dcp{flex:1;grid-auto-rows:minmax(0,1fr);gap:6px;min-width:0;display:grid}.cell.svelte-12d1dcp{background:var(--raised);border:1px solid var(--border);border-radius:5px;justify-content:center;align-items:center;min-height:0;display:flex}.cell.svelte-12d1dcp .mono:where(.svelte-12d1dcp){color:var(--ink3);pointer-events:none;font-size:12px}.cell.tonic.svelte-12d1dcp{background:var(--track-off);border-color:var(--border-strong)}.cell.tonic.svelte-12d1dcp .mono:where(.svelte-12d1dcp){color:var(--ink0);font-weight:600}.cell.lit.svelte-12d1dcp{border-color:var(--tc)}.cell.on.svelte-12d1dcp{background:var(--accent);border-color:var(--accent)}.cell.on.svelte-12d1dcp .mono:where(.svelte-12d1dcp){color:var(--on-accent)}.chords.svelte-12d1dcp{gap:8px}.chord.svelte-12d1dcp{background:var(--raised);border:1px solid var(--border);border-radius:6px;flex-direction:column;justify-content:center;align-items:center;gap:4px;min-height:0;display:flex}.chord.svelte-12d1dcp :where(.svelte-12d1dcp){pointer-events:none}.roman.svelte-12d1dcp{color:var(--accent-dim);font-size:12px}.cn.svelte-12d1dcp{color:var(--ink1);font-size:20px;font-weight:600}.chord.lit.svelte-12d1dcp{border-color:var(--tc)}.chord.on.svelte-12d1dcp{background:var(--accent);border-color:var(--accent)}.chord.on.svelte-12d1dcp .cn:where(.svelte-12d1dcp),.chord.on.svelte-12d1dcp .roman:where(.svelte-12d1dcp){color:var(--on-accent)}.hint.svelte-12d1dcp{color:var(--ink5);font-size:11px}.white.svelte-12d1dcp :where(.svelte-12d1dcp),.black.svelte-12d1dcp :where(.svelte-12d1dcp){pointer-events:none}.xy.svelte-19m1tsu{flex:1;gap:12px;min-height:0;display:flex}.xy.col.svelte-19m1tsu{flex-direction:column}.field.svelte-19m1tsu{background:var(--well);border:1px solid var(--hairline);touch-action:none;border-radius:6px;flex:1;min-width:0;min-height:0;position:relative;overflow:hidden;box-shadow:inset 0 1px #00000080}.gridlines.svelte-19m1tsu{background-image:linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);background-position:-1px -1px;background-size:25% 25%;position:absolute;inset:0}.fill.svelte-19m1tsu{opacity:.08;position:absolute;bottom:0;left:0}.vl.svelte-19m1tsu{background:var(--accent-edge);width:1px;position:absolute;top:0;bottom:0}.hl.svelte-19m1tsu{background:var(--accent-edge);height:1px;position:absolute;left:0;right:0}.pt.svelte-19m1tsu{border:2px solid var(--accent);background:var(--accent-wash);border-radius:50%;justify-content:center;align-items:center;width:40px;height:40px;margin:-20px 0 0 -20px;display:flex;position:absolute}.pt.svelte-19m1tsu span:where(.svelte-19m1tsu){background:var(--accent-bright);border-radius:50%;width:10px;height:10px}.ax.svelte-19m1tsu{color:var(--ink5);pointer-events:none;font-size:10px;position:absolute}.ax-x.svelte-19m1tsu{bottom:8px;right:10px}.ax-y.svelte-19m1tsu{top:8px;left:10px}.pill.svelte-19m1tsu{background:var(--accent-wash);border:1px solid var(--border-brass);height:24px;color:var(--accent-bright);white-space:nowrap;border-radius:12px;align-items:center;padding:0 10px;font-size:11px;font-weight:600;display:flex;position:absolute;top:12px;left:50%;transform:translate(-50%)}.panel.svelte-19m1tsu{flex-direction:column;flex:none;gap:10px;width:290px;display:flex}.tablet .panel.svelte-19m1tsu{width:340px}.col.svelte-19m1tsu .panel:where(.svelte-19m1tsu){width:auto}.axes.svelte-19m1tsu{border:1px solid var(--border);border-radius:6px;overflow:hidden}.axis.svelte-19m1tsu{background:var(--panel);outline-offset:-3px;align-items:center;gap:12px;height:50px;padding:0 12px;display:flex}.axis.svelte-19m1tsu+.axis:where(.svelte-19m1tsu){border-top:1px solid var(--hairline)}.an.svelte-19m1tsu{color:var(--accent-dim);width:12px;font-size:13px}.names.svelte-19m1tsu{flex-direction:column;flex:1;gap:2px;min-width:0;display:flex}.pn.svelte-19m1tsu{color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;font-size:12px;font-weight:600;overflow:hidden}.pd.svelte-19m1tsu{color:var(--ink5);white-space:nowrap;text-overflow:ellipsis;font-size:10px;overflow:hidden}.av.svelte-19m1tsu{color:var(--ink1);white-space:nowrap;font-size:13px}.row.svelte-19m1tsu{gap:8px;display:flex}.row.svelte-19m1tsu .seg:where(.svelte-19m1tsu){flex:1}.row.svelte-19m1tsu .seg:where(.svelte-19m1tsu) button:where(.svelte-19m1tsu){height:38px}.tilt.svelte-19m1tsu{height:46px;padding:0 14px}.ph.svelte-19m1tsu{border:1.5px solid;border-radius:2px;width:10px;height:14px;transform:rotate(-18deg)}.note.svelte-19m1tsu{color:var(--ink4);font-size:11px;line-height:1.5}.note.dim.svelte-19m1tsu{color:var(--ink5)}.auto.svelte-19m1tsu{background:var(--raised);border:1px solid var(--border);height:30px;color:var(--ink1);border-radius:4px;align-self:flex-start;align-items:center;gap:8px;padding:0 10px;font-size:11px;font-weight:600;display:flex}.rd.svelte-19m1tsu{background:var(--record);border-radius:50%;width:7px;height:7px}.mixer.svelte-4q66aa{touch-action:none;flex:1;gap:8px;min-height:0;display:flex}.strips.svelte-4q66aa{touch-action:pan-x;overscroll-behavior:contain;flex:1;gap:6px;min-width:0;display:flex;overflow:auto hidden}.strip.svelte-4q66aa{background:var(--panel);border:1px solid var(--border);border-radius:6px;flex-direction:column;flex:0 0 88px;gap:6px;min-width:0;padding:8px 6px;display:flex}.phoneLand.svelte-4q66aa .strip:where(.svelte-4q66aa){flex-basis:84px}.tablet.svelte-4q66aa .strip:where(.svelte-4q66aa){flex:1 1 0;min-width:84px}.strip.group.svelte-4q66aa{background:var(--well);border-color:var(--hairline)}.strip.active.svelte-4q66aa{border-color:var(--border-brass)}.head.svelte-4q66aa{text-align:left;align-items:center;gap:6px;min-width:0;height:28px;display:flex}.cbar.svelte-4q66aa{border-radius:2px;flex:none;width:3px;height:16px}.nm.svelte-4q66aa{min-width:0;color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;flex:1;font-size:12px;font-weight:600;overflow:hidden}.tag.svelte-4q66aa{color:var(--ink5);align-items:center;gap:2px;font-size:9px;display:flex}.tag.svelte-4q66aa path:where(.svelte-4q66aa){fill:none;stroke:var(--ink5);stroke-width:1.4px;stroke-linecap:round}.pan.svelte-4q66aa{touch-action:none;align-items:center;gap:4px;height:22px;display:flex}.pbar.svelte-4q66aa{background:var(--well);border-radius:2px;flex:1;height:4px;position:relative}.pbar.svelte-4q66aa span:where(.svelte-4q66aa){background:var(--ink2);border-radius:1px;width:3px;height:10px;margin-left:-1.5px;position:absolute;top:-3px}.pv.svelte-4q66aa{color:var(--ink4);text-align:right;width:22px;font-size:9px}.fz.svelte-4q66aa{flex:1;justify-content:center;gap:6px;min-height:0;display:flex;position:relative}.held.svelte-4q66aa{z-index:2;background:var(--track-off);border:1px solid var(--border-strong);height:18px;color:var(--ink1);white-space:nowrap;border-radius:9px;align-items:center;padding:0 6px;font-size:9px;font-weight:600;display:flex;position:absolute;top:0;left:50%;transform:translate(-50%)}.meters.svelte-4q66aa{gap:2px;padding:4px 0;display:flex}.meters.svelte-4q66aa div:where(.svelte-4q66aa){background:var(--well);border-radius:2px;width:4px;height:100%;position:relative;overflow:hidden}.meters.wide.svelte-4q66aa div:where(.svelte-4q66aa){width:5px}.meters.svelte-4q66aa span:where(.svelte-4q66aa){background:var(--success);position:absolute;bottom:0;left:0;right:0}.fader.svelte-4q66aa{touch-action:none;justify-content:center;width:40px;padding:10px 0;display:flex;position:relative}.slot.svelte-4q66aa{background:var(--well);border:1px solid var(--hairline);border-radius:2px;width:4px;height:100%}.travel.svelte-4q66aa{position:absolute;inset:10px 0}.cap.svelte-4q66aa{background:var(--raised);border:1px solid var(--border-strong);border-radius:4px;justify-content:center;align-items:center;height:20px;margin-bottom:-10px;display:flex;position:absolute;left:4px;right:4px}.cap.held.svelte-4q66aa{border-color:var(--steel)}.cap.svelte-4q66aa i:where(.svelte-4q66aa){background:var(--ink3);border-radius:1px;width:18px;height:2px}.active.svelte-4q66aa .cap:where(.svelte-4q66aa) i:where(.svelte-4q66aa){background:var(--accent-bright)}.dbv.svelte-4q66aa{color:var(--ink2);text-align:center;font-size:11px}.dbv.act.svelte-4q66aa{color:var(--accent-bright)}.btns.svelte-4q66aa{grid-template-columns:1fr 1fr;gap:4px;display:grid}.ms.svelte-4q66aa{background:var(--raised);border:1px solid var(--border);height:34px;color:var(--ink4);border-radius:4px;font-size:12px;font-weight:700}.ms.mute.svelte-4q66aa{background:var(--track-off);border-color:var(--ink5);color:var(--ink0)}.ms.solo.svelte-4q66aa{background:var(--accent);border-color:var(--accent);color:var(--on-accent)}.arm.svelte-4q66aa{background:var(--raised);border:1px solid var(--border);letter-spacing:.08em;height:30px;color:var(--ink4);border-radius:4px;grid-column:span 2;justify-content:center;align-items:center;gap:5px;font-size:10px;font-weight:700;display:flex}.arm.svelte-4q66aa span:where(.svelte-4q66aa){background:var(--ink6);border-radius:50%;width:8px;height:8px}.arm.on.svelte-4q66aa{background:var(--record-wash);border-color:var(--record);color:var(--record-ink)}.arm.on.svelte-4q66aa span:where(.svelte-4q66aa){background:var(--record)}.rule.svelte-4q66aa{background:var(--hairline);width:1px}.masterstrip.svelte-4q66aa{flex:0 0 84px}.tablet.svelte-4q66aa .masterstrip:where(.svelte-4q66aa){flex-basis:110px}.mh.svelte-4q66aa{justify-content:center}.macros.svelte-1x69070{touch-action:none;flex-direction:column;flex:1;gap:10px;min-height:0;display:flex}.dev.svelte-1x69070{background:var(--well);border:1px solid var(--border);text-align:left;border-radius:5px;align-items:center;gap:10px;height:44px;padding:0 12px;display:flex;box-shadow:inset 0 1px #00000080}.dev.svelte-1x69070 .caps:where(.svelte-1x69070){letter-spacing:.1em;font-size:9px}.dn.svelte-1x69070{min-width:0;color:var(--ink1);white-space:nowrap;text-overflow:ellipsis;flex:1;font-size:13px;font-weight:600;overflow:hidden}.pos.svelte-1x69070{color:var(--ink5);font-size:10px}.dev.svelte-1x69070 path:where(.svelte-1x69070){fill:none;stroke:var(--ink4);stroke-width:1.4px;stroke-linecap:round}.grid.svelte-1x69070{flex:1;grid-auto-rows:minmax(0,1fr);gap:8px;min-height:0;display:grid}.knob.svelte-1x69070{background:var(--card);border:1px solid var(--border);touch-action:none;border-radius:6px;flex-direction:column;justify-content:center;align-items:center;gap:4px;min-height:0;display:flex;position:relative}.knob.on.svelte-1x69070{border-color:var(--border-brass)}.auto.svelte-1x69070{background:var(--accent);border-radius:50%;width:6px;height:6px;position:absolute;top:8px;right:8px}.trk.svelte-1x69070{fill:none;stroke:var(--well);stroke-width:5px;stroke-linecap:round}.arc.svelte-1x69070{fill:none;stroke:var(--accent);stroke-width:5px;stroke-linecap:round}.on.svelte-1x69070 .arc:where(.svelte-1x69070){stroke:var(--accent-bright)}.capc.svelte-1x69070{fill:var(--panel);stroke:var(--border-strong)}.ptr.svelte-1x69070{stroke:var(--accent-bright);stroke-width:2.4px;stroke-linecap:round}.kn.svelte-1x69070{letter-spacing:.08em;color:var(--ink5);white-space:nowrap;text-overflow:ellipsis;max-width:92%;font-size:10px;font-weight:700;overflow:hidden}.kv.svelte-1x69070{color:var(--ink1);font-size:12px}.on.svelte-1x69070 .kn:where(.svelte-1x69070),.on.svelte-1x69070 .kv:where(.svelte-1x69070){color:var(--accent-bright)}.empty.svelte-1x69070 .kv:where(.svelte-1x69070){color:var(--ink6)}.empty.svelte-1x69070{color:var(--ink5);flex:1;justify-content:center;align-items:center;font-size:12px;display:flex}.knob.empty.svelte-1x69070{flex:initial;display:flex}.scroll.svelte-he2l50{touch-action:pan-x pan-y;overscroll-behavior:contain;flex:1;min-height:0;overflow:auto}.grid.svelte-he2l50{gap:6px;min-width:min-content;display:grid}.corner.svelte-he2l50{align-items:center;height:36px;padding-left:4px;font-size:9px;display:flex}.th.svelte-he2l50{align-items:center;gap:6px;min-width:0;height:36px;padding:0 6px;display:flex}.th.svelte-he2l50 span:where(.svelte-he2l50){border-radius:2px;flex:none;width:3px;height:14px}.th.svelte-he2l50 b:where(.svelte-he2l50){color:var(--ink2);white-space:nowrap;text-overflow:ellipsis;font-size:12px;font-weight:600;overflow:hidden}.scene.svelte-he2l50{background:var(--raised);border:1px solid var(--border);color:var(--ink1);border-radius:5px;align-items:center;gap:8px;padding:0 10px;font-size:12px;font-weight:600;display:flex}.tri.svelte-he2l50{border-left:9px solid var(--ink3);border-top:6px solid #0000;border-bottom:6px solid #0000;width:0;height:0}.clip.svelte-he2l50{background:var(--raised);border:1px solid var(--border);text-align:left;border-radius:5px;flex-direction:column;justify-content:center;align-items:flex-start;gap:3px;min-width:0;padding:0 10px;display:flex;position:relative;overflow:hidden}.clip.empty.svelte-he2l50{background:var(--well);border:1px dashed var(--hairline)}.cn.svelte-he2l50{color:var(--ink2);white-space:nowrap;align-items:center;gap:6px;font-size:12px;font-weight:600;display:flex}.cs.svelte-he2l50{opacity:.8;font-size:9px}.clip.playing.svelte-he2l50,.clip.queued.svelte-he2l50{background:var(--tc);border-color:var(--tc)}.clip.playing.svelte-he2l50{border-color:var(--ink0)}.clip.playing.svelte-he2l50 :where(.svelte-he2l50),.clip.queued.svelte-he2l50 :where(.svelte-he2l50){color:#171613}.clip.queued.svelte-he2l50{animation:.8s step-end infinite svelte-he2l50-blink}.clip.rec.svelte-he2l50{border-color:var(--record)}.clip.rec.svelte-he2l50 .cs:where(.svelte-he2l50){color:var(--record-ink)}@keyframes svelte-he2l50-blink{50%{opacity:.35}}.ptri.svelte-he2l50{border-top:5px solid #0000;border-bottom:5px solid #0000;border-left:8px solid #171613;width:0;height:0}.prog.svelte-he2l50{opacity:.75;background:#f2ede1;height:4px;position:absolute;bottom:0;left:0}.stop.svelte-he2l50,.stopall.svelte-he2l50{background:var(--raised);border:1px solid var(--border);height:44px;color:var(--ink3);border-radius:5px;justify-content:center;align-items:center;gap:6px;font-size:11px;font-weight:600;display:flex}.sq.svelte-he2l50{background:var(--ink3);border-radius:1px;width:9px;height:9px}.empty.svelte-he2l50{color:var(--ink5);padding:20px;font-size:12px}.empty.svelte-i7n35i{text-align:center;border:1px dashed var(--border);border-radius:6px;flex-direction:column;flex:1;justify-content:center;align-items:center;gap:12px;padding:24px;display:flex}.t.svelte-i7n35i{color:var(--ink1);font-size:15px;font-weight:600}.s.svelte-i7n35i{color:var(--ink4);max-width:280px;font-size:12px;line-height:1.6}.btn.svelte-i7n35i{height:44px;color:var(--ink1);padding:0 18px;font-size:13px}.shell.svelte-1n46o8q{background:var(--app);padding:env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);flex-direction:column;display:flex;position:absolute;inset:0}.body.svelte-1n46o8q{flex:1;min-height:0;display:flex}main.svelte-1n46o8q{flex-direction:column;flex:1;min-width:0;padding:12px;transition:opacity .2s ease-out;display:flex;position:relative}.phoneLand.svelte-1n46o8q main:where(.svelte-1n46o8q){padding:8px 10px max(10px, env(safe-area-inset-bottom)) 10px}.tablet.svelte-1n46o8q main:where(.svelte-1n46o8q){padding:18px 18px max(18px, env(safe-area-inset-bottom))}main.dim.svelte-1n46o8q{opacity:.35;pointer-events:none}.rail.svelte-1n46o8q{border-right:1px solid var(--hairline);flex-direction:column;flex:none;gap:4px;width:104px;padding:8px;display:flex}.tablet.svelte-1n46o8q .rail:where(.svelte-1n46o8q){padding:12px 10px}.rail.svelte-1n46o8q button:where(.svelte-1n46o8q){height:44px;color:var(--ink4);border-radius:5px;font-size:11px;font-weight:600;transition:background-color .12s ease-out,color .12s ease-out;position:relative}.tablet.svelte-1n46o8q .rail:where(.svelte-1n46o8q) button:where(.svelte-1n46o8q){height:56px;font-size:13px}.rail.svelte-1n46o8q button.on:where(.svelte-1n46o8q){background:var(--raised);color:var(--ink1)}.rail.svelte-1n46o8q button.on:where(.svelte-1n46o8q):before{content:"";background:var(--accent);border-radius:1px;width:2px;position:absolute;top:10px;bottom:10px;left:0}.tabs.svelte-1n46o8q{padding:8px 12px max(12px, env(safe-area-inset-bottom));border-top:1px solid var(--hairline);flex:none}.tabs.svelte-1n46o8q .seg:where(.svelte-1n46o8q){border-radius:8px}.tabs.svelte-1n46o8q .seg:where(.svelte-1n46o8q) button:where(.svelte-1n46o8q){border-radius:5px;min-width:0;height:44px;padding:0;font-size:11px}diff --git a/src/managed/Nota.Remote/wwwroot/fonts/Geist-Regular.woff2 b/src/managed/Nota.Remote/wwwroot/fonts/Geist-Regular.woff2new file mode 100644index 00000000..db1b8c66Binary files /dev/null and b/src/managed/Nota.Remote/wwwroot/fonts/Geist-Regular.woff2 differdiff --git a/src/managed/Nota.Remote/wwwroot/fonts/Geist-SemiBold.woff2 b/src/managed/Nota.Remote/wwwroot/fonts/Geist-SemiBold.woff2new file mode 100644index 00000000..258771caBinary files /dev/null and b/src/managed/Nota.Remote/wwwroot/fonts/Geist-SemiBold.woff2 differdiff --git a/src/managed/Nota.Remote/wwwroot/fonts/GeistMono-Medium.woff2 b/src/managed/Nota.Remote/wwwroot/fonts/GeistMono-Medium.woff2new file mode 100644index 00000000..6b9e1228Binary files /dev/null and b/src/managed/Nota.Remote/wwwroot/fonts/GeistMono-Medium.woff2 differdiff --git a/src/managed/Nota.Remote/wwwroot/icons/icon-180.png b/src/managed/Nota.Remote/wwwroot/icons/icon-180.pngnew file mode 100644index 00000000..d6c3a0d4Binary files /dev/null and b/src/managed/Nota.Remote/wwwroot/icons/icon-180.png differdiff --git a/src/managed/Nota.Remote/wwwroot/icons/icon-192.png b/src/managed/Nota.Remote/wwwroot/icons/icon-192.pngnew file mode 100644index 00000000..273c77aeBinary files /dev/null and b/src/managed/Nota.Remote/wwwroot/icons/icon-192.png differdiff --git a/src/managed/Nota.Remote/wwwroot/icons/icon-512.png b/src/managed/Nota.Remote/wwwroot/icons/icon-512.pngnew file mode 100644index 00000000..7ba72c36Binary files /dev/null and b/src/managed/Nota.Remote/wwwroot/icons/icon-512.png differdiff --git a/src/managed/Nota.Remote/wwwroot/index.html b/src/managed/Nota.Remote/wwwroot/index.htmlnew file mode 100644index 00000000..d782ad4b--- /dev/null+++ b/src/managed/Nota.Remote/wwwroot/index.html@@ -0,0 +1,22 @@+<!doctype html>+<html lang="en" data-theme="dark">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">+ <meta name="theme-color" content="#0B0A09">+ <meta name="apple-mobile-web-app-capable" content="yes">+ <meta name="mobile-web-app-capable" content="yes">+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">+ <meta name="apple-mobile-web-app-title" content="Nota Remote">+ <meta name="format-detection" content="telephone=no">+ <link rel="manifest" href="./manifest.webmanifest">+ <link rel="apple-touch-icon" href="./icons/icon-180.png">+ <link rel="preload" href="./fonts/Geist-SemiBold.woff2" as="font" type="font/woff2" crossorigin>+ <title>Nota Remote</title>+ <script type="module" crossorigin src="./assets/index-BNuDspFI.js"></script>+ <link rel="stylesheet" crossorigin href="./assets/index-WqkYRGtE.css">+</head>+<body>+ <div id="app"></div>+</body>+</html>diff --git a/src/managed/Nota.Remote/wwwroot/keepawake.mp4 b/src/managed/Nota.Remote/wwwroot/keepawake.mp4new file mode 100644index 00000000..7709a6b0Binary files /dev/null and b/src/managed/Nota.Remote/wwwroot/keepawake.mp4 differdiff --git a/src/managed/Nota.Remote/wwwroot/manifest.webmanifest b/src/managed/Nota.Remote/wwwroot/manifest.webmanifestnew file mode 100644index 00000000..cfa49749--- /dev/null+++ b/src/managed/Nota.Remote/wwwroot/manifest.webmanifest@@ -0,0 +1,16 @@+{+ "name": "Nota Remote",+ "short_name": "Nota",+ "description": "Play and control Nota from your phone",+ "start_url": "./",+ "scope": "./",+ "display": "standalone",+ "orientation": "any",+ "background_color": "#0B0A09",+ "theme_color": "#0B0A09",+ "icons": [+ { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png" },+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png" },+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }+ ]+}diff --git a/src/managed/Nota.Remote/wwwroot/sw.js b/src/managed/Nota.Remote/wwwroot/sw.jsnew file mode 100644index 00000000..5f076140--- /dev/null+++ b/src/managed/Nota.Remote/wwwroot/sw.js@@ -0,0 +1,27 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Nota Remote service worker. Browsers only run it on a secure origin (HTTPS or localhost),+// so over plain LAN HTTP the page simply works without it. Where it does run, it keeps the+// app shell so a Home Screen launch still opens — and can say "Nota isn't responding" — while+// Nota is closed. Network first: the page always comes from the running Nota when it can.+const CACHE = 'nota-remote-v1';++self.addEventListener('install', (e) => {+ e.waitUntil(caches.open(CACHE).then((c) => c.addAll(['./', './index.html', './manifest.webmanifest'])).then(() => self.skipWaiting()));+});++self.addEventListener('activate', (e) => {+ e.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim()));+});++self.addEventListener('fetch', (e) => {+ const req = e.request;+ if (req.method !== 'GET' || new URL(req.url).pathname.endsWith('/ws')) return;+ e.respondWith(+ fetch(req)+ .then((res) => {+ if (res.ok) { const copy = res.clone(); caches.open(CACHE).then((c) => c.put(req, copy)); }+ return res;+ })+ .catch(() => caches.match(req).then((r) => r || caches.match('./index.html')))+ );+});diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.hindex 38ec1bd1..1470cd65 100644--- a/src/native/nota.engine/include/nota/nota_engine.h+++ b/src/native/nota.engine/include/nota/nota_engine.h@@ -641,6 +641,10 @@ NOTA_API NotaResult nota_track_set_armed(NotaEngine* engine, int32_t track_id, i* tracks; captured into the record clip while recording. Lock-free. */NOTA_API NotaResult nota_engine_note_on(NotaEngine* engine, int32_t pitch, float velocity);NOTA_API NotaResult nota_engine_note_off(NotaEngine* engine, int32_t pitch);+/* Live notes addressed to one track, armed or not (Nota Remote: each phone plays its+ * own track). Recorded only when that track holds the take. Safe from any thread. */+NOTA_API NotaResult nota_track_note_on(NotaEngine* engine, int32_t track_id, int32_t pitch, float velocity);+NOTA_API NotaResult nota_track_note_off(NotaEngine* engine, int32_t track_id, int32_t pitch);/* Audition target: live notes also reach this track even when unarmed (rack/drum* pad preview). Pass -1 to clear. */NOTA_API void nota_engine_set_audition_track(NotaEngine* engine, int32_t track_id);diff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex dcec9bb5..773943d6 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -28,6 +28,7 @@#include <functional>#include <list>#include <memory>+#include <mutex>#include <string>#include <vector>@@ -37,7 +38,9 @@ namespace nota {class RackCore; // shared rack guts (RackInstrument / RackDevice; see RackCore.h)class ClipWarpStream; // offline warp-cache builder (WarpStream.h); held by unique_ptr in wb_-struct MidiEvent { bool on; int32_t pitch; float velocity; };+// trackId -1 = ordinary live input (armed / audition tracks); >= 0 = addressed to that+// one track whatever its arm state (a Nota Remote phone playing its own track).+struct MidiEvent { bool on; int32_t pitch; float velocity; int32_t trackId = -1; };using MidiQueue = SpscRingBuffer<MidiEvent, 1024>;// Recorded note (audio -> message), lock-free up-queue. startBeat is absolute.@@ -845,6 +848,10 @@ public:int32_t trackMidiSource(int32_t trackId) const;void noteOn(int32_t pitch, float velocity); // lock-freevoid noteOff(int32_t pitch); // lock-free+ // Live notes addressed to one track (Nota Remote). Callable from any thread: producers+ // serialize on remoteMidiMx_; the audio thread only pops (AR-6).+ void trackNoteOn(int32_t trackId, int32_t pitch, float velocity);+ void trackNoteOff(int32_t trackId, int32_t pitch);// Audition target: live notes also reach this track even when it isn't armed// (for clicking rack/drum pads). -1 = none. Lock-free.void setAuditionTrack(int32_t trackId) { auditionTrackId_.store(trackId, std::memory_order_relaxed); }@@ -995,6 +1002,8 @@ private:std::unique_ptr<GamepadInput> gamepadInput_; // game controller note inputCommandQueue commands_;MidiQueue liveMidi_;+ MidiQueue remoteMidi_; // track-addressed notes (any thread → audio)+ std::mutex remoteMidiMx_; // producer side onlyRecordedQueue recorded_;ControlEventQueue midiControl_; // incoming CC/note-on for MIDI-learn (AR-6)Transport transport_;@@ -1135,6 +1144,7 @@ private:// recording target (message thread)int32_t recordTrackId_ = 0;+ std::atomic<int32_t> recordTrackRt_{-1}; // recordTrackId_ for the audio threadint32_t recordClipIndex_ = -1;int32_t recordStartStatus_ = 0; // 0 ok, 1 no armed track, 2 audio input failed// When recording auto-starts the transport, stopping the take returns thediff --git a/src/native/nota.engine/src/Engine_Recording.cpp b/src/native/nota.engine/src/Engine_Recording.cppindex 2a3e29a9..0a3a6cc7 100644--- a/src/native/nota.engine/src/Engine_Recording.cpp+++ b/src/native/nota.engine/src/Engine_Recording.cpp@@ -31,6 +31,7 @@ void Engine::setTrackArmed(int32_t trackId, bool armed) {if (audioRecording_ && trackId == audioRecordTrackId_) stopAudioRecording();if (recording_.load(std::memory_order_relaxed) && trackId == recordTrackId_) {recordTrackId_ = -1;+ recordTrackRt_.store(-1, std::memory_order_relaxed);recordClipIndex_ = -1;recording_.store(false, std::memory_order_relaxed);}@@ -153,6 +154,23 @@ void Engine::noteOff(int32_t pitch) {liveHeld_[pitch >> 5].fetch_and(~(1u << (pitch & 31)), std::memory_order_relaxed);}+void Engine::trackNoteOn(int32_t trackId, int32_t pitch, float velocity) {+ {+ std::lock_guard<std::mutex> lk(remoteMidiMx_);+ remoteMidi_.push(MidiEvent{true, pitch, velocity, trackId});+ }+ if (pitch >= 0 && pitch < 128)+ liveHeld_[pitch >> 5].fetch_or(1u << (pitch & 31), std::memory_order_relaxed);+}+void Engine::trackNoteOff(int32_t trackId, int32_t pitch) {+ {+ std::lock_guard<std::mutex> lk(remoteMidiMx_);+ remoteMidi_.push(MidiEvent{false, pitch, 0.0f, trackId});+ }+ if (pitch >= 0 && pitch < 128)+ liveHeld_[pitch >> 5].fetch_and(~(1u << (pitch & 31)), std::memory_order_relaxed);+}+// Currently-pressed live-input pitches (keyboard + MIDI), oldest bit order. Lock-free.int32_t Engine::liveHeldNotes(int32_t* out, int32_t maxN) const {if (!out || maxN <= 0) return 0;@@ -204,6 +222,7 @@ void Engine::setRecording(bool on) {if (instT) {recordTrackId_ = instT->id();+ recordTrackRt_.store(recordTrackId_, std::memory_order_relaxed);// Overdub into a clip that already spans the playhead, else open one there.int32_t idx = -1;for (int32_t i = 0; i < static_cast<int32_t>(instT->midiClips.size()); ++i) {diff --git a/src/native/nota.engine/src/Engine_Render.cpp b/src/native/nota.engine/src/Engine_Render.cppindex e76544d6..62ee1045 100644--- a/src/native/nota.engine/src/Engine_Render.cpp+++ b/src/native/nota.engine/src/Engine_Render.cpp@@ -250,10 +250,13 @@ void Engine::drainLiveMidi(double blockStartBeat, bool playing) {const double nowBeat = slot ? (slotLen > 0.0 ? std::fmod(slot->localBeats, slotLen) : slot->localBeats): blockStartBeat;+ // Track-addressed notes (Nota Remote) are recorded only when they play the take's+ // track; ordinary live input records onto it whatever it is.+ const int32_t recTrack = recordTrackRt_.load(std::memory_order_relaxed);MidiEvent e;- while (liveMidi_.pop(e)) {+ while (liveMidi_.pop(e) || remoteMidi_.pop(e)) {if (liveCount_ < kMaxLive) liveEvents_[liveCount_++] = e;- if (rec && playing && e.pitch >= 0 && e.pitch < 128) {+ if (rec && playing && e.pitch >= 0 && e.pitch < 128 && (e.trackId < 0 || e.trackId == recTrack)) {if (e.on) {pendingActive_[e.pitch] = true;pendingStart_[e.pitch] = nowBeat;@@ -323,9 +326,12 @@ int Engine::gatherInstrumentNotes(Track& t, MidiEv* evs, int n, int32_t frames,}// Live notes reach a track when it's armed, or when it's the audition target// (so clicking a rack/drum pad plays it without arming/recording).- if (t.armed() || t.id() == auditionTrackId_.load(std::memory_order_relaxed)) {- for (int i = 0; i < liveCount_ && n < 1024; ++i)- evs[n++] = {0, liveEvents_[i].on, liveEvents_[i].pitch, liveEvents_[i].velocity};+ // A track-addressed event (Nota Remote) plays only its own track.+ const bool takesLive = t.armed() || t.id() == auditionTrackId_.load(std::memory_order_relaxed);+ for (int i = 0; i < liveCount_ && n < 1024; ++i) {+ const MidiEvent& le = liveEvents_[i];+ if (le.trackId < 0 ? takesLive : le.trackId == t.id())+ evs[n++] = {0, le.on, le.pitch, le.velocity};}return n;}diff --git a/src/native/nota.engine/src/nota_engine_core.cpp b/src/native/nota.engine/src/nota_engine_core.cppindex ade7b638..7d61d7c8 100644--- a/src/native/nota.engine/src/nota_engine_core.cpp+++ b/src/native/nota.engine/src/nota_engine_core.cpp@@ -165,6 +165,14 @@ NotaResult nota_engine_note_off(NotaEngine* e, int32_t pitch) {if (!e || pitch < 0 || pitch > 127) return NOTA_ERR_INVALID_ARG;ENG(e)->noteOff(pitch); return NOTA_OK;}+NotaResult nota_track_note_on(NotaEngine* e, int32_t track_id, int32_t pitch, float velocity) {+ if (!e || pitch < 0 || pitch > 127) return NOTA_ERR_INVALID_ARG;+ ENG(e)->trackNoteOn(track_id, pitch, velocity); return NOTA_OK;+}+NotaResult nota_track_note_off(NotaEngine* e, int32_t track_id, int32_t pitch) {+ if (!e || pitch < 0 || pitch > 127) return NOTA_ERR_INVALID_ARG;+ ENG(e)->trackNoteOff(track_id, pitch); return NOTA_OK;+}void nota_engine_set_audition_track(NotaEngine* e, int32_t track_id) {if (e) ENG(e)->setAuditionTrack(track_id);}diff --git a/src/web/remote/.gitignore b/src/web/remote/.gitignorenew file mode 100644index 00000000..c2658d7d--- /dev/null+++ b/src/web/remote/.gitignore@@ -0,0 +1 @@+node_modules/diff --git a/src/web/remote/index.html b/src/web/remote/index.htmlnew file mode 100644index 00000000..45c8e7ed--- /dev/null+++ b/src/web/remote/index.html@@ -0,0 +1,21 @@+<!doctype html>+<html lang="en" data-theme="dark">+<head>+ <meta charset="utf-8">+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">+ <meta name="theme-color" content="#0B0A09">+ <meta name="apple-mobile-web-app-capable" content="yes">+ <meta name="mobile-web-app-capable" content="yes">+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">+ <meta name="apple-mobile-web-app-title" content="Nota Remote">+ <meta name="format-detection" content="telephone=no">+ <link rel="manifest" href="./manifest.webmanifest">+ <link rel="apple-touch-icon" href="./icons/icon-180.png">+ <link rel="preload" href="./fonts/Geist-SemiBold.woff2" as="font" type="font/woff2" crossorigin>+ <title>Nota Remote</title>+</head>+<body>+ <div id="app"></div>+ <script type="module" src="/src/main.ts"></script>+</body>+</html>diff --git a/src/web/remote/package-lock.json b/src/web/remote/package-lock.jsonnew file mode 100644index 00000000..9c81a2ac--- /dev/null+++ b/src/web/remote/package-lock.json@@ -0,0 +1,1212 @@+{+ "name": "nota-remote",+ "version": "1.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "nota-remote",+ "version": "1.0.0",+ "license": "AGPL-3.0-only",+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.1",+ "svelte": "^5.57.1",+ "svelte-check": "^4.7.6",+ "typescript": "^6.0.0",+ "vite": "^8.3.2"+ }+ },+ "node_modules/@jridgewell/gen-mapping": {+ "version": "0.3.13",+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.0",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/remapping": {+ "version": "2.3.5",+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/gen-mapping": "^0.3.5",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/resolve-uri": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.0.0"+ }+ },+ "node_modules/@jridgewell/sourcemap-codec": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@jridgewell/trace-mapping": {+ "version": "0.3.31",+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/resolve-uri": "^3.1.0",+ "@jridgewell/sourcemap-codec": "^1.4.14"+ }+ },+ "node_modules/@oxc-project/types": {+ "version": "0.152.0",+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.152.0.tgz",+ "integrity": "sha512-oM/5rLBm2tPkg0iBgkH/FOeR3PCDpY19GTgAZjMFM8h9WI9VW7cLgzp6nwtarYKmovavIQZ+Fe/RKX/8C8O/Rw==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/oxc-project"+ }+ },+ "node_modules/@rolldown/binding-android-arm-eabi": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.12.tgz",+ "integrity": "sha512-dB/a1214qKfHMXCpgqR4OZT+jS4kTyEXbQGJPqzobt5EwH5rX080pxE37alt3RzvR1bf1Yz/yGqRfrYAxuPw0A==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-android-arm64": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.12.tgz",+ "integrity": "sha512-7KHFgQ5VJxIHcLlrwrc3Xbds7oTNQT7Pgi9gQCJKrd2VGab/UksIOYp6VD8MzCstGxOKMgNamPwUCfxPdP1OHg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-arm64": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.12.tgz",+ "integrity": "sha512-3YIhqHD96nA5SaYNRBR16HnGv4oavZvXfD/ayHM+oYZ0WD/8lBAtf6zQua4kEyAvpqrluKXl0lnOBoiNby7x9w==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-x64": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.12.tgz",+ "integrity": "sha512-UuuJ35MFw4gmFOrE9pEqIV+K3syIKveph+Qc1/ljHZVdoDW4pz/JHR/eMVom+TZGl/5OOvGJOWaOCVt3ZfqhxA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-freebsd-x64": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.12.tgz",+ "integrity": "sha512-uMvssit0a4W+/7D8CbHUvG719mH3R2jwXAlh/XcPvuHTE0g++LymF88DCGNX0HM2rBOn0xrzgXktIB6fLSJBTQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.12.tgz",+ "integrity": "sha512-XcFu0R0xWnwzSf4IQgFH1rJIckPN1pLy2R+4r9IDB7Yfu/ys9cVqfa4pBrMHj7a3gl8mIR4nRNPg0e5IvEVs6g==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-gnu": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.12.tgz",+ "integrity": "sha512-260UrKgn8tz39ak+SMDOirKzr7V04M9dWPw5llW00SwBivCZoWcRBKV1d8cXnRkUmSZA3BdiUmBHWk7734Ulpw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-musl": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.12.tgz",+ "integrity": "sha512-5YK1I9SqDkbPgc1IA8BgDl34suqUS2q0KWnBrirm0E51YjOs6eo6dV6jbQfNE/argHRSvd0QUGgtpIoYx+WWpw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.12.tgz",+ "integrity": "sha512-Rkcrmp7eFRg74yL5fXEU91JEWbdEPLevWwGtXpmhbjlD1StScbWTmO94Bhly+Mo+ketKYkdmM1vNUKeWSlx8cQ==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-s390x-gnu": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.12.tgz",+ "integrity": "sha512-qvK4DuAsQc2BSjlx+Xr+IzOIvvxbGZqxFwdWfG6F518Erj0GGISyQbJ6pIappnOxlNPzNHvo/L0BwB30GZ+zVw==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-gnu": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.12.tgz",+ "integrity": "sha512-Q9uLBO53Xd4QIq1WOycVQyPP1O4HhraEV2qqb3uTrnVw6QZih9duY4vNXOivL1xoUS1/z+W8eF4NMfl2a8Sdjw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-musl": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.12.tgz",+ "integrity": "sha512-3IBxWFMjbOZskDPKv8Lf9BCnahlKuHthWkYnyIxOH/QcJrFcS4EmcenthApkwr/5+nEqZlLzeYbxeMaX7A5u4g==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-openharmony-arm64": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.12.tgz",+ "integrity": "sha512-xtX61xg4LKPkPWilZU1ynKClz5Gj4bf74LML4r3eVLWumKnGjoEr1OSHQhMdbBDoYTi+yjrujvpZe2pUnqCrrA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-arm64-msvc": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.12.tgz",+ "integrity": "sha512-At7fPB6PCaIjzgIhEZFxuT+BBFqiQibJDT4d3PhiR3f4E7bbMZF4aKblbFfEM3sETRDd1YiQx/+U/g/B/ou5Ew==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-x64-msvc": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.12.tgz",+ "integrity": "sha512-WIw2haVKwjuYdXkHaoC0mF8Le71TuCBxjrdKqLbJGctbBABj+ClfmNvtbOnzpq3RokNo5+V1qhtSzJyXorsklQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/pluginutils": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@sveltejs/acorn-typescript": {+ "version": "1.0.13",+ "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz",+ "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==",+ "dev": true,+ "license": "MIT",+ "peerDependencies": {+ "acorn": "^8.9.0"+ }+ },+ "node_modules/@sveltejs/load-config": {+ "version": "0.2.3",+ "resolved": "https://registry.npmjs.org/@sveltejs/load-config/-/load-config-0.2.3.tgz",+ "integrity": "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 18.0.0"+ }+ },+ "node_modules/@sveltejs/vite-plugin-svelte": {+ "version": "7.3.1",+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-7.3.1.tgz",+ "integrity": "sha512-ZPsLN8B1e/En+Ak5s4V7srFDT532oS0qieLsQwu63NGKsS+iAjoO2Js1BochlHlglcU+Pt7WAO3C5Ee+4f6gVA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "deepmerge": "^4.3.1",+ "magic-string": "^1.0.0",+ "obug": "^2.1.0",+ "vitefu": "^1.1.2"+ },+ "engines": {+ "node": "^20.19 || ^22.12 || >=24"+ },+ "peerDependencies": {+ "svelte": "^5.46.4",+ "vite": "^8.0.0-beta.7 || ^8.0.0"+ }+ },+ "node_modules/@types/estree": {+ "version": "1.0.9",+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",+ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/acorn": {+ "version": "8.18.0",+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",+ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "acorn": "bin/acorn"+ },+ "engines": {+ "node": ">=0.4.0"+ }+ },+ "node_modules/aria-query": {+ "version": "5.3.1",+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",+ "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/axobject-query": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",+ "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/chokidar": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "readdirp": "^4.0.1"+ },+ "engines": {+ "node": ">= 14.16.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/clsx": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/deepmerge": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/detect-libc": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/devalue": {+ "version": "5.9.4",+ "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.4.tgz",+ "integrity": "sha512-sPAT4pztbu6586/hrhOnMKS17IJrvg12mXiSPSS3W5qDeN2RGgvZ0diZCm31dBbnevfVmujNO3IM2wrS4Y2Rhg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/esm-env": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",+ "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/esrap": {+ "version": "2.4.0",+ "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.4.0.tgz",+ "integrity": "sha512-CQPcneEHw/czj32uwQC52nYnax8H4SXt25FCM+LIwGZ49cMIxpOj3bP8wmzcI+Z0HIy5KkClaPhRLfCySzwHPA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.4.15"+ },+ "peerDependencies": {+ "@typescript-eslint/types": "^8.2.0"+ },+ "peerDependenciesMeta": {+ "@typescript-eslint/types": {+ "optional": true+ }+ }+ },+ "node_modules/fdir": {+ "version": "6.5.0",+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12.0.0"+ },+ "peerDependencies": {+ "picomatch": "^3 || ^4"+ },+ "peerDependenciesMeta": {+ "picomatch": {+ "optional": true+ }+ }+ },+ "node_modules/fsevents": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },+ "node_modules/is-reference": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",+ "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/estree": "^1.0.6"+ }+ },+ "node_modules/lightningcss": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",+ "dev": true,+ "license": "MPL-2.0",+ "dependencies": {+ "detect-libc": "^2.0.3"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ },+ "optionalDependencies": {+ "lightningcss-android-arm64": "1.33.0",+ "lightningcss-darwin-arm64": "1.33.0",+ "lightningcss-darwin-x64": "1.33.0",+ "lightningcss-freebsd-x64": "1.33.0",+ "lightningcss-linux-arm-gnueabihf": "1.33.0",+ "lightningcss-linux-arm64-gnu": "1.33.0",+ "lightningcss-linux-arm64-musl": "1.33.0",+ "lightningcss-linux-x64-gnu": "1.33.0",+ "lightningcss-linux-x64-musl": "1.33.0",+ "lightningcss-win32-arm64-msvc": "1.33.0",+ "lightningcss-win32-x64-msvc": "1.33.0"+ }+ },+ "node_modules/lightningcss-android-arm64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-arm64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-x64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-freebsd-x64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm-gnueabihf": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-gnu": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-musl": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-gnu": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-musl": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-arm64-msvc": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-x64-msvc": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/locate-character": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/magic-string": {+ "version": "1.4.2",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.2.tgz",+ "integrity": "sha512-vG+rjFRj1PqdIBozIxAGMjPlOhaVe+GXpbttY/iSK7rGcJRMlwNJO7dcUwmUqkymsFLJiNGI06t4D7Fr7yRC9g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.6.0"+ }+ },+ "node_modules/mri": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=4"+ }+ },+ "node_modules/nanoid": {+ "version": "3.3.19",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz",+ "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "bin": {+ "nanoid": "bin/nanoid.cjs"+ },+ "engines": {+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"+ }+ },+ "node_modules/obug": {+ "version": "2.2.1",+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.2.1.tgz",+ "integrity": "sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==",+ "dev": true,+ "funding": [+ "https://github.com/sponsors/sxzz",+ "https://opencollective.com/debug"+ ],+ "license": "MIT",+ "engines": {+ "node": ">=12.20.0"+ }+ },+ "node_modules/picocolors": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/picomatch": {+ "version": "4.0.7",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",+ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },+ "node_modules/postcss": {+ "version": "8.5.28",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",+ "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.18",+ "picocolors": "^1.1.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/readdirp": {+ "version": "4.1.2",+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 14.18.0"+ },+ "funding": {+ "type": "individual",+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/rolldown": {+ "version": "1.2.12",+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.12.tgz",+ "integrity": "sha512-8wafseiaG80xmXSfqidUNqZcylTlhmPZZt+za2m+js2sFZ8dTNlhIOV2WcbIPx2hgwPBJpEUGFAMZ9bgBBLTSQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@oxc-project/types": "=0.152.0",+ "@rolldown/pluginutils": "^1.0.0"+ },+ "bin": {+ "rolldown": "bin/cli.mjs"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "optionalDependencies": {+ "@rolldown/binding-android-arm-eabi": "1.2.12",+ "@rolldown/binding-android-arm64": "1.2.12",+ "@rolldown/binding-darwin-arm64": "1.2.12",+ "@rolldown/binding-darwin-x64": "1.2.12",+ "@rolldown/binding-freebsd-x64": "1.2.12",+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.12",+ "@rolldown/binding-linux-arm64-gnu": "1.2.12",+ "@rolldown/binding-linux-arm64-musl": "1.2.12",+ "@rolldown/binding-linux-ppc64-gnu": "1.2.12",+ "@rolldown/binding-linux-s390x-gnu": "1.2.12",+ "@rolldown/binding-linux-x64-gnu": "1.2.12",+ "@rolldown/binding-linux-x64-musl": "1.2.12",+ "@rolldown/binding-openharmony-arm64": "1.2.12",+ "@rolldown/binding-win32-arm64-msvc": "1.2.12",+ "@rolldown/binding-win32-x64-msvc": "1.2.12"+ }+ },+ "node_modules/sade": {+ "version": "1.8.1",+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "mri": "^1.1.0"+ },+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/source-map-js": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",+ "dev": true,+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/svelte": {+ "version": "5.57.1",+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.57.1.tgz",+ "integrity": "sha512-Uqj49lWKB+iSSnneuwiYYJ7MZgkB+eXr0LXBhv4uDuAkXqnWmq65Sxflfvp0Lc6MdKjMUxGaeOKWJqz5SNiVIA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/remapping": "^2.3.5",+ "@jridgewell/sourcemap-codec": "^1.6.0",+ "@sveltejs/acorn-typescript": "^1.0.13",+ "@types/estree": "^1.0.9",+ "acorn": "^8.18.0",+ "aria-query": "5.3.1",+ "axobject-query": "^4.1.0",+ "clsx": "^2.1.1",+ "devalue": "^5.9.2",+ "esm-env": "^1.2.1",+ "esrap": "^2.3.6",+ "is-reference": "^3.0.3",+ "locate-character": "^3.0.0",+ "magic-string": "^0.30.11",+ "zimmerframe": "^1.1.2"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/svelte-check": {+ "version": "4.7.6",+ "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.6.tgz",+ "integrity": "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/trace-mapping": "^0.3.25",+ "@sveltejs/load-config": "^0.2.3",+ "chokidar": "^4.0.1",+ "fdir": "^6.2.0",+ "picocolors": "^1.0.0",+ "sade": "^1.7.4"+ },+ "bin": {+ "svelte-check": "bin/svelte-check"+ },+ "engines": {+ "node": ">= 18.0.0"+ },+ "peerDependencies": {+ "svelte": "^4.0.0 || ^5.0.0-next.0",+ "typescript": "^5.0.0 || ^6.0.0"+ }+ },+ "node_modules/svelte/node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/tinyglobby": {+ "version": "0.2.17",+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "fdir": "^6.5.0",+ "picomatch": "^4.0.4"+ },+ "engines": {+ "node": ">=12.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/SuperchupuDev"+ }+ },+ "node_modules/typescript": {+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",+ "dev": true,+ "license": "Apache-2.0",+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/vite": {+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.2.tgz",+ "integrity": "sha512-SQr1x6W5vVSbROg7vsyXIaxK9b0G7zsT68acdWWRmnBUsgDieLCRG+Rep9WdZgcposvv/GSnr4GUUBqB3vXq6w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "lightningcss": "^1.33.0",+ "picomatch": "^4.0.7",+ "postcss": "^8.5.28",+ "rolldown": "~1.2.11",+ "tinyglobby": "^0.2.17"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "funding": {+ "url": "https://github.com/vitejs/vite?sponsor=1"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.3"+ },+ "peerDependencies": {+ "@types/node": "^20.19.0 || >=22.12.0",+ "@vitejs/devtools": "^0.7.1",+ "esbuild": "^0.27.0 || ^0.28.0",+ "jiti": ">=1.21.0",+ "less": "^4.0.0",+ "sass": "^1.70.0",+ "sass-embedded": "^1.70.0",+ "stylus": ">=0.54.8",+ "sugarss": "^5.0.0",+ "terser": "^5.16.0",+ "tsx": "^4.8.1",+ "yaml": "^2.4.2"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "@vitejs/devtools": {+ "optional": true+ },+ "esbuild": {+ "optional": true+ },+ "jiti": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "sass-embedded": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ },+ "tsx": {+ "optional": true+ },+ "yaml": {+ "optional": true+ }+ }+ },+ "node_modules/vitefu": {+ "version": "1.1.3",+ "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz",+ "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==",+ "dev": true,+ "license": "MIT",+ "workspaces": [+ "tests/deps/*",+ "tests/projects/*",+ "tests/projects/workspace/packages/*"+ ],+ "peerDependencies": {+ "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "vite": {+ "optional": true+ }+ }+ },+ "node_modules/zimmerframe": {+ "version": "1.1.5",+ "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.5.tgz",+ "integrity": "sha512-msJxIvYDYcoNL+PJsu+7qmpDWsYmAxTY+2TNYXXF0hzBzBk0BMecOqDOG/EckUoKCuKwObfbugIl8QpqHDXeFA==",+ "dev": true,+ "license": "MIT"+ }+ }+}diff --git a/src/web/remote/package.json b/src/web/remote/package.jsonnew file mode 100644index 00000000..c5b692d5--- /dev/null+++ b/src/web/remote/package.json@@ -0,0 +1,21 @@+{+ "name": "nota-remote",+ "private": true,+ "version": "1.0.0",+ "description": "Nota Remote — the phone controller Nota serves over the local network",+ "license": "AGPL-3.0-only",+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "vite build",+ "check": "svelte-check --tsconfig ./tsconfig.json",+ "preview": "vite preview"+ },+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.1",+ "svelte": "^5.57.1",+ "svelte-check": "^4.7.6",+ "typescript": "^6.0.0",+ "vite": "^8.3.2"+ }+}diff --git a/src/web/remote/public/fonts/Geist-Regular.woff2 b/src/web/remote/public/fonts/Geist-Regular.woff2new file mode 100644index 00000000..db1b8c66Binary files /dev/null and b/src/web/remote/public/fonts/Geist-Regular.woff2 differdiff --git a/src/web/remote/public/fonts/Geist-SemiBold.woff2 b/src/web/remote/public/fonts/Geist-SemiBold.woff2new file mode 100644index 00000000..258771caBinary files /dev/null and b/src/web/remote/public/fonts/Geist-SemiBold.woff2 differdiff --git a/src/web/remote/public/fonts/GeistMono-Medium.woff2 b/src/web/remote/public/fonts/GeistMono-Medium.woff2new file mode 100644index 00000000..6b9e1228Binary files /dev/null and b/src/web/remote/public/fonts/GeistMono-Medium.woff2 differdiff --git a/src/web/remote/public/icons/icon-180.png b/src/web/remote/public/icons/icon-180.pngnew file mode 100644index 00000000..d6c3a0d4Binary files /dev/null and b/src/web/remote/public/icons/icon-180.png differdiff --git a/src/web/remote/public/icons/icon-192.png b/src/web/remote/public/icons/icon-192.pngnew file mode 100644index 00000000..273c77aeBinary files /dev/null and b/src/web/remote/public/icons/icon-192.png differdiff --git a/src/web/remote/public/icons/icon-512.png b/src/web/remote/public/icons/icon-512.pngnew file mode 100644index 00000000..7ba72c36Binary files /dev/null and b/src/web/remote/public/icons/icon-512.png differdiff --git a/src/web/remote/public/keepawake.mp4 b/src/web/remote/public/keepawake.mp4new file mode 100644index 00000000..7709a6b0Binary files /dev/null and b/src/web/remote/public/keepawake.mp4 differdiff --git a/src/web/remote/public/manifest.webmanifest b/src/web/remote/public/manifest.webmanifestnew file mode 100644index 00000000..cfa49749--- /dev/null+++ b/src/web/remote/public/manifest.webmanifest@@ -0,0 +1,16 @@+{+ "name": "Nota Remote",+ "short_name": "Nota",+ "description": "Play and control Nota from your phone",+ "start_url": "./",+ "scope": "./",+ "display": "standalone",+ "orientation": "any",+ "background_color": "#0B0A09",+ "theme_color": "#0B0A09",+ "icons": [+ { "src": "icons/icon-192.png", "sizes": "192x192", "type": "image/png" },+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png" },+ { "src": "icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" }+ ]+}diff --git a/src/web/remote/public/sw.js b/src/web/remote/public/sw.jsnew file mode 100644index 00000000..5f076140--- /dev/null+++ b/src/web/remote/public/sw.js@@ -0,0 +1,27 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Nota Remote service worker. Browsers only run it on a secure origin (HTTPS or localhost),+// so over plain LAN HTTP the page simply works without it. Where it does run, it keeps the+// app shell so a Home Screen launch still opens — and can say "Nota isn't responding" — while+// Nota is closed. Network first: the page always comes from the running Nota when it can.+const CACHE = 'nota-remote-v1';++self.addEventListener('install', (e) => {+ e.waitUntil(caches.open(CACHE).then((c) => c.addAll(['./', './index.html', './manifest.webmanifest'])).then(() => self.skipWaiting()));+});++self.addEventListener('activate', (e) => {+ e.waitUntil(caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))).then(() => self.clients.claim()));+});++self.addEventListener('fetch', (e) => {+ const req = e.request;+ if (req.method !== 'GET' || new URL(req.url).pathname.endsWith('/ws')) return;+ e.respondWith(+ fetch(req)+ .then((res) => {+ if (res.ok) { const copy = res.clone(); caches.open(CACHE).then((c) => c.put(req, copy)); }+ return res;+ })+ .catch(() => caches.match(req).then((r) => r || caches.match('./index.html')))+ );+});diff --git a/src/web/remote/src/App.svelte b/src/web/remote/src/App.sveltenew file mode 100644index 00000000..ef5edd0b--- /dev/null+++ b/src/web/remote/src/App.svelte@@ -0,0 +1,96 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<script lang="ts">+ import { app } from './lib/app.svelte';+ import { device, keepAwake } from './lib/device.svelte';+ import { SCREENS } from './lib/types';+ import Header from './components/Header.svelte';+ import Banner from './components/Banner.svelte';+ import Sheets from './components/Sheets.svelte';+ import Overlays from './components/Overlays.svelte';+ import BigTransport from './screens/BigTransport.svelte';+ import Pads from './screens/Pads.svelte';+ import Keys from './screens/Keys.svelte';+ import XY from './screens/XY.svelte';+ import Mixer from './screens/Mixer.svelte';+ import Macros from './screens/Macros.svelte';+ import Scenes from './screens/Scenes.svelte';+ import Empty from './screens/Empty.svelte';++ const form = $derived(device.form);+ const rail = $derived(form !== 'phone');+ const t = $derived(app.track);+ const noInstrument = $derived(t?.kind === 'audio' && (app.screen === 'Pads' || app.screen === 'Keys'));+ const dim = $derived(app.link === 'lost' || app.link === 'connecting');++ $effect(() => {+ document.documentElement.dataset.theme = app.dark ? 'dark' : 'light';+ document.querySelector('meta[name=theme-color]')?.setAttribute('content', app.dark ? '#0B0A09' : '#DCD6C5');+ });+</script>++<!-- The first touch anywhere starts keep-awake (browsers want a gesture for it). -->+<div class="shell {form}" onpointerdowncapture={keepAwake}>+ <Header {form} />+ <Banner />+ <div class="body">+ {#if rail}+ <nav class="rail" aria-label="Screens">+ {#each SCREENS as s}+ <button class:on={app.screen === s && !app.bigTransport} onclick={() => app.setScreen(s)}>{s}</button>+ {/each}+ </nav>+ {/if}+ <main class:dim aria-busy={dim}>+ {#if noInstrument}+ <Empty />+ {:else if app.screen === 'Pads'}+ <Pads {form} />+ {:else if app.screen === 'Keys'}+ <Keys {form} />+ {:else if app.screen === 'XY'}+ <XY {form} />+ {:else if app.screen === 'Mixer'}+ <Mixer {form} />+ {:else if app.screen === 'Macros'}+ <Macros {form} />+ {:else}+ <Scenes {form} />+ {/if}+ {#if app.bigTransport}+ <BigTransport {form} />+ {/if}+ </main>+ </div>+ {#if !rail}+ <nav class="tabs" aria-label="Screens">+ <div class="seg">+ {#each SCREENS as s}+ <button class:on={app.screen === s && !app.bigTransport} onclick={() => app.setScreen(s)}>{s}</button>+ {/each}+ </div>+ </nav>+ {/if}+ <Sheets {form} />+ <Overlays {form} />+</div>++<style>+ .shell {+ position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--app);+ padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);+ }+ .body { flex: 1; min-height: 0; display: flex; }+ main { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; padding: 12px; transition: opacity 200ms ease-out; }+ .phoneLand main { padding: 8px 10px max(10px, env(safe-area-inset-bottom)) 10px; }+ .tablet main { padding: 18px 18px max(18px, env(safe-area-inset-bottom)); }+ main.dim { opacity: .35; pointer-events: none; }+ .rail { width: 104px; flex: none; display: flex; flex-direction: column; gap: 4px; padding: 8px; border-right: 1px solid var(--hairline); }+ .tablet .rail { padding: 12px 10px; }+ .rail button { height: 44px; border-radius: 5px; font-size: 11px; font-weight: 600; color: var(--ink4); position: relative; transition: background-color 120ms ease-out, color 120ms ease-out; }+ .tablet .rail button { height: 56px; font-size: 13px; }+ .rail button.on { background: var(--raised); color: var(--ink1); }+ .rail button.on::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 1px; background: var(--accent); }+ .tabs { flex: none; padding: 8px 12px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--hairline); }+ .tabs .seg { border-radius: 8px; }+ .tabs .seg button { height: 44px; padding: 0; font-size: 11px; min-width: 0; border-radius: 5px; }+</style>diff --git a/src/web/remote/src/app.css b/src/web/remote/src/app.cssnew file mode 100644index 00000000..4d69060a--- /dev/null+++ b/src/web/remote/src/app.css@@ -0,0 +1,70 @@+/* SPDX-License-Identifier: AGPL-3.0-only */+/* Ember tokens, mirrored from src/managed/Nota.App/Theme/NotaTheme.axaml (Dark / Light).+ The theme file is definitive: change a value there first, then here. */++@font-face { font-family: 'Geist'; font-weight: 400; font-display: swap; src: url('/fonts/Geist-Regular.woff2') format('woff2'); }+@font-face { font-family: 'Geist'; font-weight: 500 700; font-display: swap; src: url('/fonts/Geist-SemiBold.woff2') format('woff2'); }+@font-face { font-family: 'Geist Mono'; font-weight: 400 700; font-display: swap; src: url('/fonts/GeistMono-Medium.woff2') format('woff2'); }++:root, [data-theme='dark'] {+ --abyss: #0A0908; --app: #0B0A09; --gutter: #0C0B09; --well: #100F0D; --panel: #141310;+ --card: #171613; --raised: #1C1A16; --hover: #252219; --track-off: #26231E; --selected: #241F17;+ --hairline: #221F1A; --border: #2C2923; --border-strong: #3A362D; --border-brass: #6B5326;+ --grid: #1E1C18;+ --ink0: #F2EDE1; --ink1: #E9E4D8; --ink2: #C7C0B0; --ink3: #A39D8F; --ink4: #8D8779; --ink5: #6E6A5E; --ink6: #55514A;+ --on-accent: #171613;+ --accent: #D8A03D; --accent-bright: #F0C060; --accent-dim: #8A6B2E; --accent-edge: #5E4A22; --accent-wash: #241F17;+ --record: #C25B44; --record-wash: #2A1A16; --record-ink: #E08A72;+ --danger: #C2554A; --danger-bright: #E08A72; --warning: #D9C34C; --success: #58B368; --success-dim: #7FB069;+ --steel: #6D8FB5;+ --white-key: #D9D3C5; --white-key-ink: #55514A;+ --scrim: rgba(10, 9, 8, 0.6);+ color-scheme: dark;+}+[data-theme='light'] {+ --abyss: #D8D1BE; --app: #DCD6C5; --gutter: #E0DAC9; --well: #E4DFD1; --panel: #EAE5D7;+ --card: #EFEADE; --raised: #F8F5EC; --hover: #E7E1D0; --track-off: #DBD4C0; --selected: #F2E4C4;+ --hairline: #D5CFBE; --border: #D5CEBB; --border-strong: #BDB5A0; --border-brass: #C9A254;+ --grid: #DED8C8;+ --ink0: #1A150E; --ink1: #241F17; --ink2: #3E382C; --ink3: #5E5849; --ink4: #746D5C; --ink5: #8A8474; --ink6: #9E9786;+ --on-accent: #FFFBF2;+ --accent: #A87415; --accent-bright: #744D07; --accent-dim: #9C8034; --accent-edge: #D3B173; --accent-wash: #F2E4C4;+ --record: #B54A32; --record-wash: #F3DDD4; --record-ink: #A3391B;+ --danger: #B13E33; --danger-bright: #A3391B; --warning: #837010; --success: #2C7A3E; --success-dim: #609548;+ --steel: #3E6288;+ --white-key: #FBF9F3; --white-key-ink: #8A8474;+ --scrim: rgba(36, 31, 23, 0.35);+ color-scheme: light;+}++* { box-sizing: border-box; margin: 0; padding: 0; }+html, body {+ height: 100%; overflow: hidden; background: var(--app); color: var(--ink1);+ font-family: Geist, system-ui, -apple-system, sans-serif; font-size: 13px;+ -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;+ user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;+ overscroll-behavior: none; touch-action: none;+}+body { position: fixed; inset: 0; }+#app { position: fixed; inset: 0; }+button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; touch-action: manipulation; }+input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; touch-action: manipulation; }+.mono { font-family: 'Geist Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }+.caps { font-size: 10px; font-weight: 700; letter-spacing: .14em; color: var(--ink5); text-transform: uppercase; }+.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }++/* Shared controls */+.btn {+ height: 42px; padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px;+ border-radius: 5px; background: var(--raised); border: 1px solid var(--border); color: var(--ink2);+ font-size: 12px; font-weight: 600; transition: background-color 120ms ease-out, border-color 120ms ease-out, color 120ms ease-out;+}+.btn.on { background: var(--accent-wash); border-color: var(--border-brass); color: var(--accent-bright); }+.seg { display: flex; gap: 2px; background: var(--well); border: 1px solid var(--hairline); border-radius: 6px; padding: 3px; }+.seg > button { height: 36px; padding: 0 11px; border-radius: 4px; color: var(--ink4); font-size: 12px; font-weight: 600; flex: 1; transition: background-color 120ms ease-out, color 120ms ease-out; }+.seg > button.on { background: var(--raised); color: var(--ink1); }+.switch { width: 18px; height: 10px; border-radius: 5px; background: var(--track-off); position: relative; flex: none; display: block; }+.switch::after { content: ''; position: absolute; top: 1.5px; left: 1.5px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink5); transition: left 120ms ease-out; }+.switch.on { background: var(--accent); }+.switch.on::after { left: 9.5px; background: var(--on-accent); }+.learnable { outline: 1px dashed var(--accent-dim); outline-offset: 2px; }diff --git a/src/web/remote/src/components/Banner.svelte b/src/web/remote/src/components/Banner.sveltenew file mode 100644index 00000000..7236bb22--- /dev/null+++ b/src/web/remote/src/components/Banner.svelte@@ -0,0 +1,43 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- The strip under the header: the link is being rebuilt, or Nota's MIDI Learn is listening. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';++ const b = $derived.by(() => {+ if (app.link === 'lost')+ return { kind: 'quiet', title: `Reconnecting to ${app.host}…`, sub: 'Touches are not sent until the link is back' };+ if (app.learn.on && app.live) {+ if (app.learned) return { kind: 'brass', title: `Mapped ${app.learned}`, sub: 'Click another control in Nota to keep mapping' };+ return {+ kind: 'brass',+ title: app.learn.pend ? `Nota is listening: ${app.learn.pend}` : 'MIDI Learn is on in Nota',+ sub: app.learn.pend+ ? 'Move a macro, an XY axis or tilt the phone. Pads, keys and the mixer can’t be mapped.'+ : 'Click a control in Nota, then move a macro, an XY axis or tilt the phone.',+ };+ }+ return null;+ });+</script>++{#if b}+ <div class="banner {b.kind}" role="status">+ <span class="dot" class:blink={b.kind === 'quiet'}></span>+ <div>+ <div class="t">{b.title}</div>+ <div class="s">{b.sub}</div>+ </div>+ </div>+{/if}++<style>+ .banner { flex: none; display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-bottom: 1px solid var(--border-brass); background: var(--accent-wash); }+ .banner.quiet { background: var(--panel); border-color: var(--border); }+ .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); }+ .quiet .dot { background: var(--ink4); }+ .blink { animation: blink 800ms steps(1) infinite; }+ @keyframes blink { 50% { opacity: .35; } }+ .t { font-size: 12px; font-weight: 600; color: var(--accent-bright); }+ .quiet .t { color: var(--ink1); }+ .s { font-size: 11px; color: var(--ink3); }+</style>diff --git a/src/web/remote/src/components/Header.svelte b/src/web/remote/src/components/Header.sveltenew file mode 100644index 00000000..4354b3af--- /dev/null+++ b/src/web/remote/src/components/Header.svelte@@ -0,0 +1,144 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- The header every screen sits under: the track picker (‹ › step, tap for the list), the+ mini transport, the link indicator and the ⋯ menu. Tapping the position opens the big+ transport. Portrait stacks it in two rows; landscape and tablet keep one. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();++ const t = $derived(app.track);+ const sub = $derived.by(() => {+ if (!t) return app.proj ? 'No track to play' : 'Connecting…';+ const others = (app.who[String(t.id)] ?? []).join(', ');+ return t.dev + (app.proj?.follow ? ' · following Nota' : '') + (others ? ` · with ${others}` : '');+ });++ // The readout animates between Nota's messages (bar.beat), off one rAF loop.+ let pos = $state('1.1');+ $effect(() => {+ let raf = 0;+ const loop = () => {+ const b = Math.max(0, app.position());+ pos = `${Math.floor(b / 4) + 1}.${Math.floor(b % 4) + 1}`;+ raf = requestAnimationFrame(loop);+ };+ loop();+ return () => cancelAnimationFrame(raf);+ });++ const link = $derived.by(() => {+ switch (app.link) {+ case 'ok': return { dot: 'var(--success-dim)', ink: 'var(--ink4)', label: app.rtt >= 0 ? `${app.rtt} ms` : 'Connected' };+ case 'weak': return { dot: 'var(--warning)', ink: 'var(--warning)', label: `Weak · ${app.rtt} ms` };+ case 'lost': case 'connecting': return { dot: 'var(--ink4)', ink: 'var(--ink3)', label: app.link === 'lost' ? 'Reconnecting' : 'Connecting', blink: true };+ case 'down': return { dot: 'var(--danger)', ink: 'var(--danger-bright)', label: 'No connection', blink: true };+ default: return { dot: 'var(--danger)', ink: 'var(--danger-bright)', label: 'Not paired' };+ }+ });++ function linkTip() {+ if (app.link === 'weak') app.showToast(`Latency is ${app.rtt} ms. Move closer to the router or put the phone on 5 GHz Wi-Fi.`);+ else if (app.link === 'ok') app.showToast(`Connected to ${app.host} · ${app.rtt} ms`);+ else if (app.link === 'lost') app.showToast('Touches are not sent until the link is back.');+ }++ function play() {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ app.send({ t: app.tp.play ? 'stop' : 'play' });+ }+ function stop() {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ app.send({ t: 'stop' });+ }+ function rec() {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ app.record();+ }+</script>++<header class={form}>+ <div class="picker">+ <button class="step" aria-label="Previous track" onclick={() => app.stepTrack(-1)}>+ <svg width="10" height="14" viewBox="0 0 10 14"><path d="M7 2 L2 7 L7 12" /></svg>+ </button>+ <button class="track" onclick={() => (app.sheet = 'tracks')} aria-label="Choose the track to play">+ <span class="bar" style:background={t?.color ?? 'var(--border-strong)'}></span>+ <span class="names">+ <span class="name">{t?.name ?? '—'}</span>+ <span class="sub mono">{sub}</span>+ </span>+ <svg width="10" height="10" viewBox="0 0 10 10"><path d="M2 3.5 L5 6.5 L8 3.5" /></svg>+ </button>+ <button class="step" aria-label="Next track" onclick={() => app.stepTrack(1)}>+ <svg width="10" height="14" viewBox="0 0 10 14"><path d="M3 2 L8 7 L3 12" /></svg>+ </button>+ </div>++ <div class="transport">+ <button class="tbtn" aria-label="Stop" onclick={stop}><span class="sq"></span></button>+ <button class="tbtn play" class:on={app.tp.play} aria-label={app.tp.play ? 'Stop playback' : 'Play'} aria-pressed={app.tp.play} onclick={play}><span class="tri"></span></button>+ <button class="tbtn rec" class:on={app.tp.rec} class:count={app.countIn !== null} aria-label="Record" aria-pressed={app.tp.rec} onclick={rec}><span class="dot"></span></button>+ <button class="pos" class:open={app.bigTransport} aria-label="Big transport" onclick={() => (app.bigTransport = !app.bigTransport)}>+ <span class="mono p">{pos}</span>+ <span class="mono bpm">{app.tp.bpm.toFixed(0)}</span>+ <svg width="10" height="10" viewBox="0 0 10 10"><path d="M2 3.5 L5 6.5 L8 3.5" /></svg>+ </button>+ </div>++ <div class="status">+ <button class="link" onclick={linkTip} aria-label="Connection: {link.label}">+ <span class="ldot" class:blink={link.blink} style:background={link.dot}></span>+ <span class="mono" style:color={link.ink}>{link.label}</span>+ </button>+ <button class="menu" class:open={app.sheet === 'menu'} aria-label="Menu" onclick={() => (app.sheet = 'menu')}>+ <span></span><span></span><span></span>+ </button>+ </div>+</header>++<style>+ header { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 6px 10px 10px; border-bottom: 1px solid var(--hairline); background: var(--app); position: relative; z-index: 6; }+ header.phoneLand { flex-wrap: nowrap; padding: 6px 10px; }+ header.tablet { flex-wrap: nowrap; padding: 10px 16px; }+ svg path { fill: none; stroke: var(--ink4); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }++ .picker { order: 1; flex: 1; min-width: 0; display: flex; align-items: center; gap: 4px; }+ .step { width: 36px; height: 44px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 5px; }+ .track { flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; text-align: left; }+ .bar { width: 4px; height: 24px; border-radius: 2px; flex: none; }+ .names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }+ .name { font-size: 14px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .sub { font-size: 10px; color: var(--ink5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }++ .transport { order: 3; flex-basis: 100%; display: flex; align-items: center; gap: 6px; }+ .phoneLand .transport { order: 2; flex: 0 0 330px; }+ .tablet .transport { order: 2; flex: 0 0 460px; }+ .tbtn { width: 44px; height: 40px; border-radius: 5px; background: var(--raised); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; flex: none; transition: background-color 120ms ease-out, border-color 120ms ease-out; }+ .tbtn.play { width: 54px; }+ .sq { width: 11px; height: 11px; border-radius: 1px; background: var(--ink2); }+ .tri { width: 0; height: 0; border-left: 12px solid var(--ink2); border-top: 7px solid transparent; border-bottom: 7px solid transparent; margin-left: 3px; }+ .play.on { background: var(--accent); border-color: var(--accent); }+ .play.on .tri { border-left-color: var(--on-accent); }+ .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ink4); }+ .rec.on, .rec.count { background: var(--record-wash); border-color: var(--record); }+ .rec.on .dot, .rec.count .dot { background: var(--record); }+ .pos { flex: 1; min-width: 0; height: 40px; display: flex; align-items: center; gap: 10px; padding: 0 10px; border-radius: 5px; background: var(--well); border: 1px solid var(--border); box-shadow: inset 0 1px 0 rgba(0,0,0,.5); }+ .pos.open { border-color: var(--border-brass); }+ .pos.open svg { transform: rotate(180deg); }+ .pos svg { margin-left: auto; }+ .p { font-size: 16px; font-weight: 500; color: var(--ink1); }+ .bpm { font-size: 11px; color: var(--ink4); }++ .status { order: 2; display: flex; align-items: center; gap: 4px; }+ .phoneLand .status, .tablet .status { order: 3; }+ .link { height: 44px; display: flex; align-items: center; gap: 6px; padding: 0 8px; border-radius: 5px; }+ .link .mono { font-size: 10px; white-space: nowrap; }+ .ldot { width: 7px; height: 7px; border-radius: 50%; }+ .blink { animation: blink 800ms steps(1) infinite; }+ @keyframes blink { 50% { opacity: .35; } }+ .menu { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; gap: 3px; border-radius: 5px; }+ .menu.open { background: var(--raised); }+ .menu span { width: 4px; height: 4px; border-radius: 50%; background: var(--ink3); }+</style>diff --git a/src/web/remote/src/components/Overlays.svelte b/src/web/remote/src/components/Overlays.sveltenew file mode 100644index 00000000..aa3590a5--- /dev/null+++ b/src/web/remote/src/components/Overlays.svelte@@ -0,0 +1,96 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- States that cover the screen: Nota can't be reached, the phone needs a new code, the phone+ left, the count-in before a take — and the toast. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();+ let digits = $state('');+ let input: HTMLInputElement | undefined = $state();++ $effect(() => {+ if (app.link === 'expired') { digits = ''; setTimeout(() => input?.focus(), 50); }+ });+ $effect(() => {+ if (digits.length === 4 && app.link === 'expired') app.pairWith(digits);+ });++ const why = $derived(+ app.deny === 'code' ? 'That code didn’t match. Codes change every two minutes — check the one Nota shows now.'+ : app.deny === 'locked' ? 'Too many wrong codes. Wait half a minute, then try the code Nota shows.'+ : app.deny === 'version' ? 'This page is older than Nota. Reload it.'+ : app.deny === 'new' ? 'In Nota, click Remote in the top bar and scan the QR code with the camera, or type its four digits here.'+ : 'This phone was removed from trusted devices, or the code has expired. In Nota, click Remote to show a fresh QR, or type its four digits here.');+</script>++{#if app.link === 'down'}+ <div class="cover" role="alert">+ <h1>Nota isn’t responding</h1>+ <ol>+ <li><span class="mono">1</span>Nota is open on {app.host}</li>+ <li><span class="mono">2</span>Remote is on: the Remote button in Nota’s top bar is lit</li>+ <li><span class="mono">3</span>The phone is on the same Wi-Fi. Guest networks often keep devices apart; share the phone’s hotspot with the computer instead.</li>+ </ol>+ <div class="retry"><span class="dot blink"></span>Retrying every few seconds</div>+ </div>+{:else if app.link === 'expired'}+ <div class="cover" role="alert">+ <h1>{app.deny === 'new' ? 'Pair with Nota' : 'Scan a new code in Nota'}</h1>+ <p>{why}</p>+ <label class="code" aria-label="Four-digit code">+ <input bind:this={input} bind:value={digits} inputmode="numeric" pattern="[0-9]*" maxlength="4" autocomplete="one-time-code"+ oninput={() => (digits = digits.replace(/\D/g, '').slice(0, 4))} />+ {#each [0, 1, 2, 3] as i}+ <span class="cell" class:cur={digits.length === i}>+ {#if digits[i]}<span class="mono">{digits[i]}</span>{:else if digits.length === i}<span class="caret"></span>{/if}+ </span>+ {/each}+ </label>+ </div>+{:else if app.link === 'left'}+ <div class="cover" role="alert">+ <h1>Disconnected</h1>+ <p>This phone has left Nota. It is still trusted, so connecting again needs no code.</p>+ <button class="btn on big" onclick={() => app.rejoin()}>Connect again</button>+ </div>+{/if}++{#if app.countIn !== null}+ <button class="count" onclick={() => app.record()} aria-label="Cancel count-in">+ <span class="mono num {form}">{app.countIn}</span>+ <span class="caps rec">Count-in · recording starts on 1</span>+ </button>+{/if}++{#if app.toast}+ <div class="toast" class:low={form === 'phone'} role="status">{app.toast}</div>+{/if}++<style>+ .cover { position: absolute; inset: 0; z-index: 40; background: var(--app); display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 28px; padding-top: calc(env(safe-area-inset-top) + 28px); }+ h1 { font-size: 22px; font-weight: 600; color: var(--ink0); }+ p { font-size: 13px; line-height: 1.6; color: var(--ink3); max-width: 420px; }+ ol { list-style: none; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; max-width: 420px; }+ li { padding: 12px 14px; background: var(--panel); display: flex; gap: 12px; font-size: 12px; line-height: 1.5; color: var(--ink2); }+ li + li { border-top: 1px solid var(--hairline); }+ li .mono { font-size: 11px; color: var(--accent-dim); }+ .retry { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink4); }+ .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ink5); }+ .blink { animation: blink 800ms steps(1) infinite; }+ @keyframes blink { 50% { opacity: .35; } }+ .code { position: relative; display: grid; grid-template-columns: repeat(4, 64px); gap: 10px; }+ .code input { position: absolute; inset: 0; opacity: 0; font-size: 16px; }+ .cell { height: 68px; border-radius: 6px; background: var(--well); border: 1px solid var(--hairline); box-shadow: inset 0 1px 0 rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; pointer-events: none; }+ .cell.cur { border-color: var(--border-brass); }+ .cell .mono { font-size: 28px; color: var(--ink0); }+ .caret { width: 2px; height: 28px; background: var(--accent); animation: blink 1s steps(1) infinite; }+ .big { height: 48px; align-self: flex-start; padding: 0 20px; font-size: 13px; }+ .count { position: absolute; inset: 0; z-index: 35; background: var(--app); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }+ .num { font-size: 200px; font-weight: 500; line-height: 1; color: var(--accent-bright); }+ .num.phoneLand { font-size: 150px; }+ .num.tablet { font-size: 260px; }+ .rec { color: var(--record); font-size: 12px; }+ .toast { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: 86%; padding: 10px 14px; border-radius: 6px; background: var(--raised); border: 1px solid var(--border-strong); font-size: 12px; line-height: 1.45; color: var(--ink1); text-align: center; }+ .toast.low { bottom: calc(env(safe-area-inset-bottom) + 84px); }+</style>diff --git a/src/web/remote/src/components/Sheets.svelte b/src/web/remote/src/components/Sheets.sveltenew file mode 100644index 00000000..cefae672--- /dev/null+++ b/src/web/remote/src/components/Sheets.svelte@@ -0,0 +1,125 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Sheets over the screen: the track list, the ⋯ menu, the key picker and the device list. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';+ import { NN } from '../lib/music';++ let { form }: { form: Form } = $props();+ const portrait = $derived(form === 'phone');+ let nameInput = $state('');+ $effect(() => { if (app.sheet === 'menu') nameInput = app.name; });++ function close() {+ if (app.sheet === 'menu') app.rename(nameInput);+ app.sheet = null;+ }+ const projectKey = $derived(app.proj?.key ?? null);+</script>++{#if app.sheet}+ <button class="scrim" aria-label="Close" onclick={close}></button>+{/if}++{#if app.sheet === 'tracks'}+ <div class="sheet" class:bottom={portrait} role="dialog" aria-label="Play on track">+ <div class="caps head">Play on track</div>+ <div class="list">+ {#each app.playable as t (t.id)}+ {@const others = app.who[String(t.id)] ?? []}+ <button class="row" class:on={t.id === app.proj?.you} onclick={() => app.selectTrack(t.id)}>+ <span class="bar" style:background={t.color}></span>+ <span class="names"><span class="n">{t.name}</span><span class="d mono">{t.dev}</span></span>+ {#if t.id === app.proj?.you}<span class="who">You</span>{/if}+ {#each others as o}<span class="who">{o}</span>{/each}+ </button>+ {/each}+ {#if app.playable.length === 0}<div class="empty">The project has no tracks yet.</div>{/if}+ </div>+ <button class="toggle" onclick={() => app.setFollow(!app.proj?.follow)}>+ <span class="switch" class:on={app.proj?.follow}></span>+ <span><span class="n2">Follow Nota’s selection</span><span class="d2">Off: this phone keeps its own track</span></span>+ </button>+ </div>+{:else if app.sheet === 'menu'}+ <div class="sheet menu" role="dialog" aria-label="Menu">+ <div class="block">+ <label class="caps" for="devname">Device name</label>+ <input id="devname" class="field" bind:value={nameInput} maxlength="40" enterkeyhint="done"+ onkeydown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }}+ onblur={() => app.rename(nameInput)} />+ </div>+ <div class="block">+ <span class="caps">Theme</span>+ <div class="seg">+ <button class:on={app.prefs.theme === 'nota'} onclick={() => (app.prefs.theme = 'nota')}>Follow Nota</button>+ <button class:on={app.prefs.theme === 'phone'} onclick={() => (app.prefs.theme = 'phone')}>Follow phone</button>+ </div>+ </div>+ <button class="toggle" onclick={() => (app.prefs.haptics = !app.prefs.haptics)}>+ <span class="switch" class:on={app.prefs.haptics}></span><span class="n2">Haptics on pads</span>+ </button>+ <button class="toggle" onclick={() => (app.prefs.countIn = !app.prefs.countIn)}>+ <span class="switch" class:on={app.prefs.countIn}></span><span class="n2">Count-in before recording</span>+ </button>+ <button class="disconnect" onclick={() => app.leave()}>Disconnect</button>+ </div>+{:else if app.sheet === 'key'}+ <div class="sheet" class:bottom={portrait} role="dialog" aria-label="Key">+ <div class="caps head">Key on this phone</div>+ <div class="block">+ <button class="row slim" class:on={!app.prefs.key} onclick={() => { app.prefs.key = null; app.sheet = null; }}>+ <span class="names"><span class="n">Project key</span><span class="d mono">{projectKey ? projectKey.name : 'Not set in Nota — C major'}</span></span>+ </button>+ <div class="seg">+ <button class:on={!(app.prefs.key?.minor ?? projectKey?.minor ?? false)} onclick={() => (app.prefs.key = { root: app.prefs.key?.root ?? projectKey?.root ?? 0, minor: false })}>Major</button>+ <button class:on={app.prefs.key?.minor ?? projectKey?.minor ?? false} onclick={() => (app.prefs.key = { root: app.prefs.key?.root ?? projectKey?.root ?? 0, minor: true })}>Minor</button>+ </div>+ <div class="tonics">+ {#each NN as n, i}+ <button class="btn" class:on={app.prefs.key?.root === i} onclick={() => (app.prefs.key = { root: i, minor: app.prefs.key?.minor ?? projectKey?.minor ?? false })}>{n}</button>+ {/each}+ </div>+ </div>+ </div>+{:else if app.sheet === 'devices'}+ <div class="sheet" class:bottom={portrait} role="dialog" aria-label="Device">+ <div class="caps head">Device on {app.track?.name ?? 'this track'}</div>+ <div class="list">+ {#each app.mac?.devs ?? [] as d, i}+ <button class="row" class:on={i === (app.mac?.di ?? 0)} onclick={() => { app.macroDevice = i; app.sub(); app.sheet = null; }}>+ <span class="names"><span class="n">{d}</span></span>+ </button>+ {/each}+ </div>+ </div>+{/if}++<style>+ .scrim { position: absolute; inset: 0; z-index: 20; background: var(--scrim); }+ .sheet { position: absolute; z-index: 21; left: 12px; top: calc(env(safe-area-inset-top) + 64px); width: 360px; max-width: calc(100% - 24px); max-height: calc(100% - 88px); background: var(--panel); border: 1px solid var(--border-strong); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }+ .sheet.bottom { top: auto; right: 12px; width: auto; bottom: max(24px, env(safe-area-inset-bottom)); max-height: 75%; }+ .sheet.menu { left: auto; right: 12px; width: 300px; }+ .head { padding: 14px 16px 8px; }+ .list { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }+ .row { width: 100%; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; border-top: 1px solid var(--hairline); position: relative; text-align: left; }+ .row.slim { border: none; padding: 0; height: 44px; }+ .row.on { background: var(--accent-wash); }+ .row.on::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--accent); }+ .row.slim.on::before { display: none; }+ .bar { width: 4px; height: 22px; border-radius: 2px; flex: none; }+ .names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }+ .n { font-size: 13px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .d { font-size: 10px; color: var(--ink5); }+ .who { height: 20px; display: flex; align-items: center; padding: 0 8px; border-radius: 10px; background: var(--track-off); font-size: 10px; font-weight: 600; color: var(--ink2); }+ .empty { padding: 16px; font-size: 12px; color: var(--ink5); }+ .toggle { width: 100%; min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-top: 1px solid var(--border); text-align: left; }+ .n2 { display: block; font-size: 12px; color: var(--ink1); }+ .d2 { display: block; font-size: 10px; color: var(--ink5); }+ .block { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }+ .field { height: 40px; padding: 0 12px; background: var(--well); border: 1px solid var(--border); border-radius: 4px; box-shadow: inset 0 1px 0 rgba(0,0,0,.5); font-size: 13px; outline: none; }+ .field:focus { border-color: var(--border-brass); }+ .tonics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }+ .tonics .btn { padding: 0; height: 44px; }+ .disconnect { height: 52px; padding: 0 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--danger-bright); text-align: left; }+</style>diff --git a/src/web/remote/src/lib/app.svelte.ts b/src/web/remote/src/lib/app.svelte.tsnew file mode 100644index 00000000..df0e2011--- /dev/null+++ b/src/web/remote/src/lib/app.svelte.ts@@ -0,0 +1,391 @@+// SPDX-License-Identifier: AGPL-3.0-only+// The phone's whole state and its link to Nota. One WebSocket; a hello with the device token+// (or a pairing code from the QR) opens it. The phone pings every second: the round trip is+// the link indicator, and Nota releases a silent phone's notes. On a drop it retries on its+// own — the only state that needs the person is a forgotten device or an expired code.++import type { Project, Transport, Mixer, Xy, Macros, Session, Learn, LinkState, Screen, Track } from './types';++const LS = 'nota-remote:';+const store = {+ get(k: string, d = ''): string { try { return localStorage.getItem(LS + k) ?? d; } catch { return d; } },+ set(k: string, v: string) { try { localStorage.setItem(LS + k, v); } catch { /* private mode */ } },+ del(k: string) { try { localStorage.removeItem(LS + k); } catch { /* */ } },+};++export interface Prefs {+ theme: 'nota' | 'phone';+ haptics: boolean;+ countIn: boolean;+ fullVel: boolean;+ keysMode: 'Keyboard' | 'Scale' | 'Chords';+ octave: number;+ /** Phone-side key override: tonic 0..11 + minor, or null to use the project's. */+ key: { root: number; minor: boolean } | null;+ xyHold: boolean;+ bank: number;+ groupsOpen: number[];+}++const defaultPrefs: Prefs = {+ theme: 'nota', haptics: true, countIn: true, fullVel: false, keysMode: 'Scale', octave: 3, key: null,+ xyHold: true, bank: 0, groupsOpen: [],+};++function guessName(): string {+ const ua = navigator.userAgent;+ if (/iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)) return 'iPad';+ if (/iPhone/.test(ua)) return 'iPhone';+ if (/Android/.test(ua)) return /Mobile/.test(ua) ? 'Android phone' : 'Android tablet';+ return 'Phone';+}++export class App {+ // ---- from Nota ----+ proj = $state<Project | null>(null);+ tp = $state<Transport>({ play: false, rec: false, loop: false, met: false, pos: 0, bpm: 120, ls: 0, le: 16, can: false });+ lit = $state<number[]>([]);+ who = $state<Record<string, string[]>>({});+ mix = $state<Mixer | null>(null);+ xy = $state<Xy | null>(null);+ mac = $state<Macros | null>(null);+ ses = $state<Session | null>(null);+ learn = $state<Learn>({ on: false, pend: null });+ learned = $state<string | null>(null);++ // ---- link ----+ link = $state<LinkState>('connecting');+ rtt = $state(-1);+ /** This phone's connection id (Nota marks faders another phone holds with theirs). */+ conn = $state(0);+ host = $state(store.get('host', 'Nota'));+ deny = $state<string | null>(null);+ everConnected = false;++ // ---- phone ----+ screen = $state<Screen>((store.get('screen', '') as Screen) || 'Pads');+ bigTransport = $state(false);+ sheet = $state<'tracks' | 'menu' | 'key' | 'devices' | null>(null);+ toast = $state<string | null>(null);+ countIn = $state<number | null>(null);+ name = $state(store.get('name', guessName()));+ prefs = $state<Prefs>({ ...defaultPrefs, ...JSON.parse(store.get('prefs', '{}') || '{}') });+ /** Position estimate between transport messages, for a smooth readout. */+ posAt = 0;+ posBase = 0;++ private ws: WebSocket | null = null;+ private pingTimer = 0;+ private retryTimer = 0;+ private lostSince = 0;+ private lastPong = 0;+ private rtts: number[] = [];+ private toastTimer = 0;+ private learnedTimer = 0;+ private pairCode: string | null = null;+ private screenChosen = !!store.get('screen', '');++ constructor() {+ // A QR link carries the pairing code in the fragment (never sent over the network).+ const m = /[#&]p=(\d{4})/.exec(location.hash);+ if (m) {+ this.pairCode = m[1];+ history.replaceState(null, '', location.pathname + location.search);+ }+ $effect.root(() => {+ $effect(() => { store.set('prefs', JSON.stringify(this.prefs)); });+ $effect(() => { store.set('screen', this.screen); });+ });+ }++ get token() { return store.get('token'); }++ get track(): Track | null {+ const p = this.proj;+ if (!p) return null;+ return p.tracks.find((t) => t.id === p.you) ?? null;+ }++ get playable(): Track[] {+ return this.proj?.tracks.filter((t) => t.kind === 'drum' || t.kind === 'inst' || t.kind === 'audio') ?? [];+ }++ get canControl() { return this.proj?.access !== 'play'; }++ get dark(): boolean {+ if (this.prefs.theme === 'phone') return matchMedia('(prefers-color-scheme: dark)').matches;+ return this.proj?.dark ?? true;+ }++ // ---- connection ---------------------------------------------------------------++ connect() {+ clearTimeout(this.retryTimer);+ if (this.ws) { this.ws.onclose = null; this.ws.close(); }+ const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';+ let ws: WebSocket;+ try { ws = new WebSocket(`${proto}//${location.host}/ws`); } catch { this.retry(); return; }+ this.ws = ws;+ const opened = Date.now();+ ws.onopen = () => {+ const base = { v: 1, name: this.name, model: guessName(), track: Number(store.get('track', '0')), screen: this.screen, follow: store.get('follow') === '1' };+ if (this.pairCode) this.raw({ t: 'pair', code: this.pairCode, ...base });+ else if (this.token) this.raw({ t: 'hello', token: this.token, ...base });+ else { this.link = 'expired'; this.deny = 'new'; }+ };+ ws.onmessage = (e) => { try { this.onMessage(JSON.parse(e.data)); } catch { /* ignore */ } };+ ws.onclose = () => {+ this.ws = null;+ clearInterval(this.pingTimer);+ if (this.link === 'left' || this.link === 'expired') return;+ if (this.link === 'ok' || this.link === 'weak') { this.link = 'lost'; this.lostSince = Date.now(); }+ else if (this.link === 'connecting' && Date.now() - opened > 0 && !this.everConnected && Date.now() - this.firstTry > 4000) this.link = 'down';+ else if (this.link === 'lost' && Date.now() - this.lostSince > 10000) this.link = 'down';+ this.retry();+ };+ }++ private firstTry = Date.now();++ private retry() {+ clearTimeout(this.retryTimer);+ const wait = this.link === 'down' ? 3000 : this.link === 'lost' ? 700 : 1200;+ this.retryTimer = window.setTimeout(() => this.connect(), wait);+ }++ /** The phone came back to the foreground (unlock, app switch): reconnect at once. */+ wake() {+ if (this.link === 'left') return;+ if (!this.ws || this.ws.readyState > 1 || Date.now() - this.lastPong > 3000) {+ if (this.link === 'ok' || this.link === 'weak') { this.link = 'lost'; this.lostSince = Date.now(); }+ this.connect();+ }+ }++ private startPing() {+ clearInterval(this.pingTimer);+ this.lastPong = Date.now();+ const tick = () => {+ if (Date.now() - this.lastPong > 3500 && (this.link === 'ok' || this.link === 'weak')) {+ // Silent link (Wi-Fi dropped without a close): treat as lost and redial.+ this.link = 'lost';+ this.lostSince = Date.now();+ this.connect();+ return;+ }+ this.raw({ t: 'ping', c: performance.now(), rtt: this.rtt });+ };+ tick();+ this.pingTimer = window.setInterval(tick, 1000);+ }++ pairWith(code: string) {+ this.pairCode = code;+ this.deny = null;+ this.link = 'connecting';+ this.connect();+ }++ leave() {+ this.raw({ t: 'bye' });+ this.link = 'left';+ this.sheet = null;+ clearInterval(this.pingTimer);+ this.ws?.close();+ }++ rejoin() {+ this.link = 'connecting';+ this.firstTry = Date.now();+ this.connect();+ }++ // ---- messages ----------------------------------------------------------------------++ private onMessage(m: any) {+ switch (m.t) {+ case 'welcome':+ if (m.token) store.set('token', m.token);+ this.pairCode = null;+ this.deny = null;+ this.host = m.host; store.set('host', m.host);+ this.conn = m.conn;+ this.name = m.name; store.set('name', m.name);+ this.link = 'ok';+ this.everConnected = true;+ this.startPing();+ break;+ case 'denied':+ this.deny = m.why;+ if (m.why === 'forgotten') store.del('token');+ this.pairCode = null;+ this.link = 'expired';+ clearInterval(this.pingTimer);+ break;+ case 'kicked':+ this.link = 'left';+ this.showToast('Disconnected in Nota');+ break;+ case 'pong': {+ this.lastPong = Date.now();+ const ms = Math.max(0, Math.round(performance.now() - m.c));+ this.rtts.push(ms);+ if (this.rtts.length > 5) this.rtts.shift();+ const avg = Math.round(this.rtts.reduce((a, b) => a + b, 0) / this.rtts.length);+ this.rtt = avg;+ if (this.link === 'ok' || this.link === 'weak') this.link = avg > 50 ? 'weak' : 'ok';+ break;+ }+ case 'proj': {+ const first = !this.proj;+ const prevTrack = this.proj?.you;+ delete m.t;+ this.proj = m;+ store.set('track', String(m.you));+ store.set('follow', m.follow ? '1' : '0');+ if (first || prevTrack !== m.you) this.onTrackChanged(first);+ break;+ }+ case 'tp':+ delete m.t;+ this.tp = m;+ this.posBase = m.pos;+ this.posAt = performance.now();+ break;+ case 'lit': this.lit = m.n; break;+ case 'who': this.who = m.p; break;+ case 'mix': delete m.t; this.mix = m; break;+ case 'xy': delete m.t; this.xy = m; break;+ case 'mac': delete m.t; this.mac = m; break;+ case 'ses': delete m.t; this.ses = m; break;+ case 'learn':+ this.learn = { on: m.on, pend: m.pend };+ if (!m.on) this.learned = null;+ break;+ case 'learned':+ this.learned = `${m.src} → ${m.dst}`;+ clearTimeout(this.learnedTimer);+ this.learnedTimer = window.setTimeout(() => (this.learned = null), 6000);+ break;+ case 'toast': this.showToast(m.msg); break;+ }+ }++ /** A new track: open the screen that suits it (once, unless the person picked one). */+ private onTrackChanged(first: boolean) {+ const t = this.track;+ if (!t) return;+ if (first && this.screenChosen) {+ this.sub();+ return;+ }+ if (t.kind === 'audio') this.bigTransport = true;+ if (!first || !this.screenChosen) {+ if (t.kind === 'drum' && (this.screen === 'Keys' || this.screen === 'Pads')) this.screen = 'Pads';+ else if (t.kind === 'inst' && (this.screen === 'Pads' || this.screen === 'Keys')) this.screen = 'Keys';+ }+ this.sub();+ }++ setScreen(s: Screen) {+ this.screen = s;+ this.screenChosen = true;+ this.bigTransport = false;+ this.sub();+ }++ sub() {+ this.raw({ t: 'sub', s: this.screen, i: this.macroDevice });+ }++ macroDevice = 0;++ selectTrack(id: number) {+ this.sheet = null;+ if (this.proj && this.proj.you !== id) {+ this.proj = { ...this.proj, you: id, follow: false };+ this.onTrackChanged(false);+ }+ this.send({ t: 'track', id });+ }++ stepTrack(dir: number) {+ const list = this.playable;+ if (list.length === 0) return;+ const i = list.findIndex((t) => t.id === this.proj?.you);+ const n = list[(i + dir + list.length) % list.length];+ this.selectTrack(n.id);+ }++ // ---- sending -------------------------------------------------------------------------++ private raw(m: object) {+ if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(JSON.stringify(m));+ }++ /** Send when the link is up; while it is down nothing is queued (a late note is worse than none). */+ send(m: object) {+ if (this.link === 'ok' || this.link === 'weak') this.raw(m);+ }++ get live() { return this.link === 'ok' || this.link === 'weak'; }++ noteOn(p: number, v: number) {+ if (p < 0 || p > 127) return;+ this.send({ t: 'on', p, v: Math.round(v * 1000) / 1000 });+ if (this.prefs.haptics && navigator.vibrate) { try { navigator.vibrate(8); } catch { /* */ } }+ }++ noteOff(p: number) {+ if (p < 0 || p > 127) return;+ this.send({ t: 'off', p });+ }++ /** The transport position now, interpolated between Nota's messages while playing. */+ position(now = performance.now()): number {+ if (!this.tp.play) return this.tp.pos;+ return this.posBase + ((now - this.posAt) / 60000) * this.tp.bpm;+ }++ record() {+ if (this.tp.rec) { this.send({ t: 'rec', on: false }); return; }+ if (!this.tp.play && this.prefs.countIn) this.runCountIn();+ else this.send({ t: 'rec', on: true });+ }++ private countTimer = 0;+ private runCountIn() {+ if (this.countIn !== null) { clearInterval(this.countTimer); this.countIn = null; return; }+ const beat = 60000 / Math.max(20, this.tp.bpm);+ this.countIn = 4;+ this.countTimer = window.setInterval(() => {+ if (this.countIn === null) return;+ if (this.countIn <= 1) {+ clearInterval(this.countTimer);+ this.countIn = null;+ this.send({ t: 'rec', on: true });+ } else this.countIn = this.countIn - 1;+ }, beat);+ }++ rename(name: string) {+ name = name.trim();+ if (!name || name === this.name) return;+ this.name = name;+ store.set('name', name);+ this.send({ t: 'name', s: name });+ }++ setFollow(on: boolean) {+ this.send({ t: 'follow', on });+ if (this.proj) this.proj = { ...this.proj, follow: on };+ }++ showToast(msg: string) {+ this.toast = msg;+ clearTimeout(this.toastTimer);+ this.toastTimer = window.setTimeout(() => (this.toast = null), 2600);+ }+}++export const app = new App();diff --git a/src/web/remote/src/lib/device.svelte.ts b/src/web/remote/src/lib/device.svelte.tsnew file mode 100644index 00000000..42f0cb7c--- /dev/null+++ b/src/web/remote/src/lib/device.svelte.ts@@ -0,0 +1,88 @@+// SPDX-License-Identifier: AGPL-3.0-only+// What the phone itself offers: its form factor, keeping the screen awake, and tilt.++export type Form = 'phone' | 'phoneLand' | 'tablet';++class Device {+ w = $state(window.innerWidth);+ h = $state(window.innerHeight);++ constructor() {+ const upd = () => { this.w = window.innerWidth; this.h = window.innerHeight; };+ window.addEventListener('resize', upd);+ window.addEventListener('orientationchange', () => setTimeout(upd, 120));+ }++ get form(): Form {+ if (Math.min(this.w, this.h) >= 600) return 'tablet';+ return this.w > this.h ? 'phoneLand' : 'phone';+ }+}++export const device = new Device();++// ---- keep awake ---------------------------------------------------------------------+// The Wake Lock API needs a secure page; over plain LAN HTTP the classic fallback is a tiny+// silent looping video, which mobile browsers treat as playback and so keep the screen on.++let lock: { release(): Promise<void> } | null = null;+let video: HTMLVideoElement | null = null;++export async function keepAwake() {+ const wl = (navigator as any).wakeLock;+ if (wl && window.isSecureContext) {+ try {+ if (!lock) lock = await wl.request('screen');+ (lock as any)?.addEventListener?.('release', () => (lock = null));+ return;+ } catch { /* fall through to the video */ }+ }+ if (!video) {+ video = document.createElement('video');+ video.setAttribute('playsinline', '');+ video.setAttribute('muted', '');+ video.muted = true;+ video.loop = true;+ video.src = './keepawake.mp4';+ video.style.cssText = 'position:fixed;width:1px;height:1px;opacity:0;pointer-events:none;left:-10px;top:-10px';+ document.body.appendChild(video);+ }+ if (video.paused) video.play().catch(() => {});+}++// ---- tilt -----------------------------------------------------------------------------++export type TiltSupport = 'yes' | 'ask' | 'insecure' | 'no';++export function tiltSupport(): TiltSupport {+ if (typeof DeviceOrientationEvent === 'undefined') return 'no';+ if (!window.isSecureContext) return 'insecure';+ return typeof (DeviceOrientationEvent as any).requestPermission === 'function' ? 'ask' : 'yes';+}++/** Ask iOS for motion access (must run inside a tap). True when tilt can be used. */+export async function requestTilt(): Promise<boolean> {+ const s = tiltSupport();+ if (s === 'yes') return true;+ if (s !== 'ask') return false;+ try { return (await (DeviceOrientationEvent as any).requestPermission()) === 'granted'; } catch { return false; }+}++/** Follow the phone's tilt from where it is held now: ±30° left/right → x 0..1, ±25°+ * towards / away → y 0..1. Returns the stop function. */+export function followTilt(cb: (x: number, y: number) => void): () => void {+ let base: { b: number; g: number } | null = null;+ const clamp = (v: number) => Math.min(1, Math.max(0, v));+ const on = (e: DeviceOrientationEvent) => {+ if (e.beta == null || e.gamma == null) return;+ const land = Math.abs((screen.orientation?.angle ?? (window as any).orientation ?? 0) % 180) === 90;+ const angle = screen.orientation?.angle ?? (window as any).orientation ?? 0;+ // In landscape the axes swap: tilting "left/right" on screen is the device's beta.+ let lr = land ? (angle === 90 || angle === -270 ? e.beta : -e.beta) : e.gamma;+ let fb = land ? (angle === 90 || angle === -270 ? -e.gamma : e.gamma) : e.beta;+ if (!base) base = { b: fb, g: lr };+ cb(clamp(0.5 + (lr - base.g) / 60), clamp(0.5 - (fb - base.b) / 50));+ };+ window.addEventListener('deviceorientation', on);+ return () => window.removeEventListener('deviceorientation', on);+}diff --git a/src/web/remote/src/lib/music.ts b/src/web/remote/src/lib/music.tsnew file mode 100644index 00000000..4509f60b--- /dev/null+++ b/src/web/remote/src/lib/music.ts@@ -0,0 +1,41 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Note names (Nota's convention: middle C, MIDI 60, is C4), keys and chords.++export const NN = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];+const FLAT = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'];+const MAJOR = [0, 2, 4, 5, 7, 9, 11];+const MINOR = [0, 2, 3, 5, 7, 8, 10];++export const noteName = (m: number) => NN[((m % 12) + 12) % 12] + (Math.floor(m / 12) - 1);++export interface Key { root: number; minor: boolean }++export const keyName = (k: Key) => (k.minor ? NN : FLAT)[k.root] + (k.minor ? ' minor' : ' major');+export const scaleOf = (k: Key) => (k.minor ? MINOR : MAJOR);++/** The MIDI note of scale degree <paramref name="deg"/> (0 = the tonic at <paramref name="base"/>'s octave). */+export function degreeNote(k: Key, base: number, deg: number): number {+ const iv = scaleOf(k);+ const o = Math.floor(deg / 7), d = ((deg % 7) + 7) % 7;+ return base + k.root + iv[d] + 12 * o;+}++const ROMAN = ['i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii'];++export interface Chord { roman: string; name: string; notes: number[] }++/** The seven diatonic triads of a key, voiced from <paramref name="base"/>. */+export function chords(k: Key, base: number): Chord[] {+ const iv = scaleOf(k);+ return iv.map((_, d) => {+ const a = iv[d], b = iv[(d + 2) % 7] + (d + 2 >= 7 ? 12 : 0), c = iv[(d + 4) % 7] + (d + 4 >= 7 ? 12 : 0);+ const third = b - a, fifth = c - a;+ const q = third === 4 ? '' : fifth === 6 ? '°' : 'm';+ const root = base + k.root + a;+ return {+ roman: (q === '' ? ROMAN[d].toUpperCase() : ROMAN[d]) + (q === '°' ? '°' : ''),+ name: (k.minor ? NN : FLAT)[(k.root + a) % 12] + q,+ notes: [root, base + k.root + b, base + k.root + c],+ };+ });+}diff --git a/src/web/remote/src/lib/types.ts b/src/web/remote/src/lib/types.tsnew file mode 100644index 00000000..2ec2370e--- /dev/null+++ b/src/web/remote/src/lib/types.ts@@ -0,0 +1,103 @@+// SPDX-License-Identifier: AGPL-3.0-only+// The messages Nota sends (see Nota.Remote/RemoteHub.State.cs for the writer side).++export type TrackKind = 'drum' | 'inst' | 'audio' | 'group' | 'return';++export interface Track {+ id: number;+ name: string;+ color: string;+ kind: TrackKind;+ dev: string;+ grp: number;+ /** Drum tracks: [note, name] per pad. */+ pads?: [number, string][];+}++export interface Project {+ host: string;+ dark: boolean;+ tracks: Track[];+ key: { root: number; minor: boolean; name: string } | null;+ scenes: number;+ sections: [string, number][];+ access: 'control' | 'play';+ /** The track Nota has this phone on. */+ you: number;+ follow: boolean;+}++export interface Transport {+ play: boolean;+ rec: boolean;+ loop: boolean;+ met: boolean;+ pos: number;+ bpm: number;+ ls: number;+ le: number;+ can: boolean;+}++/** [id, volume (0..1.5), pan, mute, solo, arm, meterL, meterR, held-by name, held-by connection]. */+export type MixRow = [number, number, number, number, number, number, number, number, string, number];++export interface Mixer {+ ch: MixRow[];+ /** [volume, meterL, meterR, held-by, held-by connection]. */+ m: [number, number, number, string, number];+}++export interface XyAxis {+ n?: string;+ d?: string;+ v?: number;+ txt?: string;+ map: string | null;+ tilt: string | null;+}++export interface Xy {+ id: number;+ ok: boolean;+ auto: boolean;+ x: XyAxis;+ y: XyAxis;+}++export interface MacroKnob {+ n?: string;+ v?: number;+ txt?: string;+ a?: boolean;+ map: string | null;+}++export interface Macros {+ id: number;+ di: number;+ devs: string[];+ k: MacroKnob[];+}++/** Per scene: [state (0 empty, 1 filled, 2 queued, 3 playing, 4 recording), length beats, progress 0..1]. */+export interface SessionTrack {+ id: number;+ c: [number, number, number][];+}++export interface Session {+ n: number;+ tr: SessionTrack[];+}++export interface Learn {+ on: boolean;+ pend: string | null;+}++export type Screen = 'Pads' | 'Keys' | 'XY' | 'Mixer' | 'Macros' | 'Scenes';+export const SCREENS: Screen[] = ['Pads', 'Keys', 'XY', 'Mixer', 'Macros', 'Scenes'];++/** ok · weak (> 50 ms) · lost (was connected, retrying) · down (Nota unreachable) · expired (needs a code). */+export type LinkState = 'connecting' | 'ok' | 'weak' | 'lost' | 'down' | 'expired' | 'left';diff --git a/src/web/remote/src/main.ts b/src/web/remote/src/main.tsnew file mode 100644index 00000000..0ed25f9a--- /dev/null+++ b/src/web/remote/src/main.ts@@ -0,0 +1,20 @@+// SPDX-License-Identifier: AGPL-3.0-only+import { mount } from 'svelte';+import './app.css';+import App from './App.svelte';+import { app } from './lib/app.svelte';++// Browser gestures fight fast playing: no pinch zoom, no long-press menu, no double-tap zoom.+for (const ev of ['gesturestart', 'gesturechange', 'contextmenu', 'dblclick']) {+ document.addEventListener(ev, (e) => e.preventDefault(), { passive: false });+}+document.addEventListener('touchmove', (e) => { if ((e as TouchEvent).touches.length > 1) e.preventDefault(); }, { passive: false });+document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'visible') app.wake(); });+window.addEventListener('online', () => app.wake());++if ('serviceWorker' in navigator && window.isSecureContext) {+ navigator.serviceWorker.register('./sw.js').catch(() => {});+}++mount(App, { target: document.getElementById('app')! });+app.connect();diff --git a/src/web/remote/src/screens/BigTransport.svelte b/src/web/remote/src/screens/BigTransport.sveltenew file mode 100644index 00000000..258881ce--- /dev/null+++ b/src/web/remote/src/screens/BigTransport.svelte@@ -0,0 +1,132 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- The big transport, opened from the header's position: buttons sized for a hand on a+ guitar neck, the position large, sections that jump on tap and loop on hold, tap tempo. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();+ let pos = $state('1.1.1');+ $effect(() => {+ let raf = 0;+ const loop = () => {+ const b = Math.max(0, app.position());+ pos = `${Math.floor(b / 4) + 1}.${Math.floor(b % 4) + 1}.${Math.floor((b * 4) % 4) + 1}`;+ raf = requestAnimationFrame(loop);+ };+ loop();+ return () => cancelAnimationFrame(raf);+ });++ const sections = $derived(app.proj?.sections ?? []);+ const beat = $derived(app.position());+ const current = $derived(sections.reduce((a, s, i) => (beat >= s[1] ? i : a), -1));+ const loopSec = $derived(app.tp.loop ? sections.findIndex((s, i) => Math.abs(s[1] - app.tp.ls) < 0.01 && Math.abs((sections[i + 1]?.[1] ?? s[1] + 16) - app.tp.le) < 0.01) : -1);++ function ctl(m: object) {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ app.send(m);+ }++ let taps: number[] = [];+ function tap() {+ const now = performance.now();+ taps = [...taps.filter((t) => now - t < 2500), now];+ if (taps.length >= 3) {+ const iv = (taps[taps.length - 1] - taps[0]) / (taps.length - 1);+ const bpm = Math.round(Math.min(220, Math.max(50, 60000 / iv)) * 100) / 100;+ ctl({ t: 'bpm', v: bpm });+ }+ }++ let holdTimer = 0;+ let held = false;+ function secDown(i: number) {+ held = false;+ holdTimer = window.setTimeout(() => {+ held = true;+ const s = sections[i], end = sections[i + 1]?.[1] ?? s[1] + 16;+ if (loopSec === i) ctl({ t: 'loop', on: false });+ else ctl({ t: 'loopRange', v: s[1], v2: end, on: true });+ }, 450);+ }+ function secUp(i: number) {+ clearTimeout(holdTimer);+ if (!held) ctl({ t: 'seek', v: sections[i][1] });+ }+ const bpmText = $derived(app.tp.bpm.toFixed(app.tp.bpm % 1 ? 2 : 0));+</script>++<div class="big {form}">+ <div class="top">+ <div class="pblock">+ <span class="caps">Position</span>+ <span class="mono pos" class:rec={app.tp.rec}>{pos}</span>+ </div>+ <button class="tap" onclick={tap}>+ <span class="mono">{bpmText}</span>+ <span class="caps">Tap tempo</span>+ </button>+ </div>+ <div class="btns" style:grid-template-columns="repeat({form === 'phone' ? 3 : 6}, minmax(0, 1fr))">+ <button class="b play" class:on={app.tp.play} aria-pressed={app.tp.play} onclick={() => ctl({ t: app.tp.play ? 'stop' : 'play' })}><span class="tri"></span>Play</button>+ <button class="b" onclick={() => ctl({ t: 'stop' })}><span class="sq"></span>Stop</button>+ <button class="b recb" class:on={app.tp.rec} aria-pressed={app.tp.rec} onclick={() => app.canControl ? app.record() : ctl({})}><span class="dot"></span>Record</button>+ <button class="b" class:on={app.tp.loop} aria-pressed={app.tp.loop} onclick={() => ctl({ t: 'loop', on: !app.tp.loop })}>+ <svg width="30" height="26" viewBox="0 0 30 26"><path d="M7 9 H21 A5 5 0 0 1 21 19 H9 M9 19 L12 16 M9 19 L12 22 M7 9 A5 5 0 0 0 5 14" /></svg>Loop+ </button>+ <button class="b" class:on={app.tp.met} aria-pressed={app.tp.met} onclick={() => ctl({ t: 'met', on: !app.tp.met })}>+ <svg width="26" height="28" viewBox="0 0 26 28"><path d="M8 25 L11 3 H15 L18 25 Z M13 18 L21 8" /></svg>Click+ </button>+ <button class="b" class:dim={!app.tp.can} onclick={() => ctl({ t: 'undo' })}>+ <svg width="28" height="24" viewBox="0 0 28 24"><path d="M9 5 L4 10 L9 15 M4 10 H17 A6 6 0 0 1 17 22 H12" /></svg>Undo+ </button>+ </div>+ {#if sections.length > 0}+ <div class="secs">+ <span class="caps">Sections · tap to jump, hold to loop</span>+ <div class="sgrid">+ {#each sections as s, i}+ <button class="sec" class:cur={current === i} class:looping={loopSec === i} onpointerdown={() => secDown(i)} onpointerup={() => secUp(i)} onpointercancel={() => clearTimeout(holdTimer)}>+ <span class="sn">{s[0]}</span>+ <span class="mono si">{loopSec === i ? 'LOOPING' : `BAR ${Math.floor(s[1] / 4) + 1}`}</span>+ </button>+ {/each}+ </div>+ </div>+ {/if}+</div>++<style>+ .big { position: absolute; inset: 0; z-index: 4; background: var(--app); display: flex; flex-direction: column; gap: 14px; padding: 12px; }+ .phoneLand.big { padding: 8px 10px; gap: 10px; }+ .tablet.big { padding: 18px; }+ .top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }+ .pblock { display: flex; flex-direction: column; gap: 4px; }+ .pos { font-size: 52px; font-weight: 500; line-height: 1; color: var(--ink1); }+ .phoneLand .pos { font-size: 40px; }+ .tablet .pos { font-size: 88px; }+ .pos.rec { color: var(--record-ink); }+ .tap { height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0 16px; border-radius: 6px; background: var(--raised); border: 1px solid var(--border); }+ .tap .mono { font-size: 18px; font-weight: 500; color: var(--ink1); }+ .tap .caps { font-size: 9px; letter-spacing: .1em; }+ .btns { flex: 1; min-height: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 8px; }+ .b { min-height: 0; border-radius: 8px; background: var(--raised); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 14px; font-weight: 600; color: var(--ink2); }+ .b svg path { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }+ .b.on { background: var(--accent-wash); border-color: var(--border-brass); color: var(--accent-bright); }+ .b.dim { color: var(--ink6); }+ .tri { width: 0; height: 0; border-left: 26px solid currentColor; border-top: 16px solid transparent; border-bottom: 16px solid transparent; margin-left: 6px; }+ .sq { width: 26px; height: 26px; border-radius: 3px; background: currentColor; }+ .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--record); }+ .play.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }+ .recb.on { background: var(--record-wash); border-color: var(--record); color: var(--record-ink); }+ .secs { display: flex; flex-direction: column; gap: 6px; }+ .sgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }+ .sec { height: 52px; border-radius: 5px; background: var(--panel); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }+ .sec.cur { background: var(--raised); border-color: var(--border-strong); }+ .sec.looping { background: var(--accent-wash); border-color: var(--border-brass); }+ .sn { font-size: 13px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 92%; }+ .looping .sn { color: var(--accent-bright); }+ .si { font-size: 9px; color: var(--ink5); }+ .looping .si { color: var(--accent); }+</style>diff --git a/src/web/remote/src/screens/Empty.svelte b/src/web/remote/src/screens/Empty.sveltenew file mode 100644index 00000000..e900c322--- /dev/null+++ b/src/web/remote/src/screens/Empty.svelte@@ -0,0 +1,17 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+</script>++<div class="empty">+ <span class="t">{app.track?.name ?? 'This track'} is an audio track</span>+ <span class="s">There is no instrument to play. Pick an instrument track, or use the transport to record.</span>+ <button class="btn" onclick={() => (app.sheet = 'tracks')}>Choose another track</button>+</div>++<style>+ .empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; border: 1px dashed var(--border); border-radius: 6px; }+ .t { font-size: 15px; font-weight: 600; color: var(--ink1); }+ .s { font-size: 12px; line-height: 1.6; color: var(--ink4); max-width: 280px; }+ .btn { height: 44px; padding: 0 18px; font-size: 13px; color: var(--ink1); }+</style>diff --git a/src/web/remote/src/screens/Keys.svelte b/src/web/remote/src/screens/Keys.sveltenew file mode 100644index 00000000..54fa35cb--- /dev/null+++ b/src/web/remote/src/screens/Keys.svelte@@ -0,0 +1,219 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Keys: a keyboard (one octave upright, 1.5 sideways, two on a tablet), a scale grid where+ every cell is a note of the key (rows a fourth apart, tonic cells raised — no wrong notes),+ and Chords (one triad per degree). The key is the project's KEY unless overridden here.+ Fingers can slide across keys and cells: every pointer is tracked over the whole surface. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';+ import { NN, noteName, keyName, degreeNote, chords as chordsOf, type Key } from '../lib/music';++ let { form }: { form: Form } = $props();+ const MODES = ['Keyboard', 'Scale', 'Chords'] as const;+ const WP = [0, 2, 4, 5, 7, 9, 11];++ const key = $derived<Key>(app.prefs.key ?? (app.proj?.key ? { root: app.proj.key.root, minor: app.proj.key.minor } : { root: 0, minor: false }));+ const keySrc = $derived(app.prefs.key ? 'PHONE' : app.proj?.key ? 'PROJECT' : 'DEFAULT');+ const base = $derived(12 * (app.prefs.octave + 1));+ const lit = $derived(new Set(app.lit));+ const color = $derived(app.track?.color ?? 'var(--accent)');+ const mode = $derived(app.prefs.keysMode);++ // ---- keyboard ----+ const whiteCount = $derived(form === 'phone' ? 8 : form === 'phoneLand' ? 11 : 15);+ const whites = $derived(Array.from({ length: whiteCount }, (_, k) => base + WP[k % 7] + 12 * Math.floor(k / 7)));+ const blacks = $derived.by(() => {+ const out: { note: number; left: string; w: string }[] = [];+ for (let k = 0; k < whiteCount - 1; k++)+ if ([0, 1, 3, 4, 5].includes(k % 7))+ out.push({+ note: base + WP[k % 7] + 12 * Math.floor(k / 7) + 1,+ left: `calc(${((k + 1) / whiteCount) * 100}% - ${(0.62 / whiteCount) * 50}%)`,+ w: `${(0.62 / whiteCount) * 100}%`,+ });+ return out;+ });++ // ---- scale grid ----+ const gridCols = $derived(form === 'phone' ? 5 : 8);+ const gridRows = $derived(form === 'phoneLand' ? 4 : 6);+ const cells = $derived.by(() => {+ const out: { note: number; tonic: boolean }[] = [];+ for (let r = gridRows - 1; r >= 0; r--)+ for (let c = 0; c < gridCols; c++) {+ const deg = r * 3 + c;+ out.push({ note: degreeNote(key, base, deg), tonic: deg % 7 === 0 });+ }+ return out;+ });++ // ---- chords ----+ const chordList = $derived(chordsOf(key, base));++ // ---- pointers: each finger plays what is under it, sliding included ----+ const fingers = new Map<number, string>(); // pointer → target id ("n60" / "c3")+ let held = $state<Record<string, boolean>>({});++ function targetAt(x: number, y: number): string | null {+ const el = document.elementFromPoint(x, y)?.closest('[data-t]') as HTMLElement | null;+ return el?.dataset.t ?? null;+ }+ function notesOf(t: string): number[] {+ if (t[0] === 'n') return [Number(t.slice(1))];+ return chordList[Number(t.slice(1))]?.notes ?? [];+ }+ // The notes each held target sounded, so its release ends exactly those (the key may change mid-hold).+ const sounding = new Map<string, number[]>();+ function start(t: string, vel = 0.85) {+ if (sounding.has(t)) return; // a second finger on the same key+ held[t] = true;+ const notes = notesOf(t);+ sounding.set(t, notes);+ for (const n of notes) app.noteOn(n, vel);+ }+ function stop(t: string) {+ if ([...fingers.values()].includes(t)) return;+ held[t] = false;+ for (const n of sounding.get(t) ?? []) app.noteOff(n);+ sounding.delete(t);+ }+ const active = new Set<number>();+ function down(e: PointerEvent) {+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);+ active.add(e.pointerId);+ const t = targetAt(e.clientX, e.clientY);+ if (!t) return;+ fingers.set(e.pointerId, t);+ start(t);+ }+ function move(e: PointerEvent) {+ if (!active.has(e.pointerId)) return;+ const prev = fingers.get(e.pointerId);+ const t = targetAt(e.clientX, e.clientY);+ if (t === prev) return;+ if (prev !== undefined) { fingers.delete(e.pointerId); stop(prev); }+ if (t) { fingers.set(e.pointerId, t); start(t); }+ }+ function up(e: PointerEvent) {+ active.delete(e.pointerId);+ const prev = fingers.get(e.pointerId);+ fingers.delete(e.pointerId);+ if (prev !== undefined) stop(prev);+ }++ // A key changed under held notes (octave, mode): release them.+ $effect(() => {+ void base; void mode; void key;+ return () => {+ for (const notes of sounding.values()) for (const n of notes) app.noteOff(n);+ sounding.clear();+ fingers.clear();+ active.clear();+ held = {};+ };+ });+</script>++<div class="keys">+ <div class="bar">+ <div class="seg modes" role="group" aria-label="Mode">+ {#each MODES as m}+ <button class:on={mode === m} onclick={() => (app.prefs.keysMode = m)}>{m}</button>+ {/each}+ </div>+ <button class="btn keybtn" onclick={() => (app.sheet = 'key')} aria-label="Key: {keyName(key)}">+ <span class="caps k">Key</span>+ <span class="kn">{keyName(key)}</span>+ <span class="mono src">{keySrc}</span>+ </button>+ <div class="oct">+ <button class="btn sq" aria-label="Octave down" onclick={() => (app.prefs.octave = Math.max(0, app.prefs.octave - 1))}>+ <svg width="12" height="12" viewBox="0 0 12 12"><path d="M2 6 H10" /></svg>+ </button>+ <span class="mono">Oct {app.prefs.octave}</span>+ <button class="btn sq" aria-label="Octave up" onclick={() => (app.prefs.octave = Math.min(7, app.prefs.octave + 1))}>+ <svg width="12" height="12" viewBox="0 0 12 12"><path d="M2 6 H10 M6 2 V10" /></svg>+ </button>+ </div>+ </div>++ <div class="surface" style:--tc={color}+ onpointerdown={down} onpointermove={move} onpointerup={up} onpointercancel={up} role="application" aria-label="Keys">+ {#if mode === 'Keyboard'}+ <div class="kb">+ {#each whites as n (n)}+ <div class="white" class:on={held['n' + n]} data-t={'n' + n}>+ {#if n % 12 === 0}<span class="mono lbl">{noteName(n)}</span>{/if}+ {#if lit.has(n)}<span class="band"></span>{/if}+ </div>+ {/each}+ {#each blacks as b (b.note)}+ <div class="black" class:on={held['n' + b.note]} data-t={'n' + b.note} style:left={b.left} style:width={b.w}>+ {#if lit.has(b.note)}<span class="band"></span>{/if}+ </div>+ {/each}+ </div>+ {:else if mode === 'Scale'}+ <div class="grid" style:grid-template-columns="repeat({gridCols}, minmax(0, 1fr))">+ {#each cells as c, i (i)}+ <div class="cell" class:tonic={c.tonic} class:on={held['n' + c.note]} class:lit={lit.has(c.note)} data-t={'n' + c.note}>+ <span class="mono">{NN[c.note % 12]}{c.tonic ? Math.floor(c.note / 12) - 1 : ''}</span>+ </div>+ {/each}+ </div>+ {:else}+ <div class="grid chords" style:grid-template-columns="repeat({form === 'phone' ? 2 : 7}, minmax(0, 1fr))">+ {#each chordList as ch, i (i)}+ <div class="chord" class:on={held['c' + i]} class:lit={ch.notes.every((n) => lit.has(n))} data-t={'c' + i}>+ <span class="mono roman">{ch.roman}</span>+ <span class="cn">{ch.name}</span>+ </div>+ {/each}+ </div>+ {/if}+ </div>+ {#if form === 'phone' && mode === 'Keyboard'}+ <span class="hint">Turn the phone sideways for 1.5 octaves.</span>+ {/if}+</div>++<style>+ .keys { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }+ .bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }+ .modes button { flex: none; }+ .keybtn { gap: 7px; padding: 0 10px; }+ .k { font-size: 9px; letter-spacing: .1em; }+ .kn { font-size: 12px; font-weight: 600; color: var(--ink1); }+ .src { font-size: 9px; color: var(--accent-dim); }+ .oct { display: flex; align-items: center; gap: 2px; margin-left: auto; }+ .oct .mono { width: 46px; text-align: center; font-size: 12px; color: var(--ink1); }+ .sq { width: 42px; padding: 0; }+ .sq path { stroke: var(--ink2); stroke-width: 1.6; stroke-linecap: round; fill: none; }+ .surface { flex: 1; min-height: 0; display: flex; touch-action: none; }+ .kb { flex: 1; min-width: 0; position: relative; display: flex; gap: 3px; }+ .white { flex: 1; min-width: 0; border-radius: 0 0 6px 6px; background: var(--white-key); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 12px; }+ .white.on { background: var(--accent); }+ .lbl { font-size: 10px; color: var(--white-key-ink); }+ .white.on .lbl { color: var(--on-accent); }+ .black { position: absolute; top: 0; height: 58%; border-radius: 0 0 5px 5px; background: var(--raised); border: 1px solid var(--border-strong); border-top: none; overflow: hidden; z-index: 1; }+ .black.on { background: var(--accent); border-color: var(--accent); }+ .band { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--tc); }+ .grid { flex: 1; min-width: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 6px; }+ .cell { border-radius: 5px; background: var(--raised); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; min-height: 0; }+ .cell .mono { font-size: 12px; color: var(--ink3); pointer-events: none; }+ .cell.tonic { background: var(--track-off); border-color: var(--border-strong); }+ .cell.tonic .mono { color: var(--ink0); font-weight: 600; }+ .cell.lit { border-color: var(--tc); }+ .cell.on { background: var(--accent); border-color: var(--accent); }+ .cell.on .mono { color: var(--on-accent); }+ .chords { gap: 8px; }+ .chord { border-radius: 6px; background: var(--raised); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 0; }+ .chord * { pointer-events: none; }+ .roman { font-size: 12px; color: var(--accent-dim); }+ .cn { font-size: 20px; font-weight: 600; color: var(--ink1); }+ .chord.lit { border-color: var(--tc); }+ .chord.on { background: var(--accent); border-color: var(--accent); }+ .chord.on .cn, .chord.on .roman { color: var(--on-accent); }+ .hint { font-size: 11px; color: var(--ink5); }+ .white *, .black * { pointer-events: none; }+</style>diff --git a/src/web/remote/src/screens/Macros.svelte b/src/web/remote/src/screens/Macros.sveltenew file mode 100644index 00000000..53344d9e--- /dev/null+++ b/src/web/remote/src/screens/Macros.svelte@@ -0,0 +1,105 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Macros: eight big knobs for one device of the track's chain — a rack's macros, a built-in+ instrument's or effect's parameters, a plug-in's first eight (paged). A vertical swipe turns+ a knob, as in Nota; a brass dot marks an automated parameter. A knob mapped with MIDI Learn+ shows what it drives instead. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();+ const cols = $derived(form === 'phone' ? 2 : 4);+ const size = $derived(form === 'phone' ? 64 : form === 'phoneLand' ? 52 : 112);+ const m = $derived(app.mac?.id === app.proj?.you ? app.mac : null);+ const devName = $derived(m?.devs[m.di] ?? 'No devices');++ let local = $state<Record<number, number>>({});+ let mappedPos = $state<Record<number, number>>({});+ let drag: { i: number; y: number; v: number } | null = null;+ let active = $state(-1);+ let lastSend = 0;++ function down(e: PointerEvent, i: number, v: number) {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ if (!m) return;+ (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);+ drag = { i, y: e.clientY, v };+ active = i;+ local[i] = v;+ app.send({ t: 'mac', i, v, ph: 1 });+ }+ function move(e: PointerEvent) {+ if (!drag) return;+ const v = Math.min(1, Math.max(0, drag.v + (drag.y - e.clientY) / 200));+ local[drag.i] = v;+ if (m?.k[drag.i]?.map) mappedPos[drag.i] = v;+ const now = performance.now();+ if (now - lastSend > 30) { lastSend = now; app.send({ t: 'mac', i: drag.i, v, ph: 0 }); }+ }+ function up() {+ if (!drag) return;+ const i = drag.i;+ app.send({ t: 'mac', i, v: local[i], ph: 2 });+ drag = null;+ active = -1;+ setTimeout(() => { if (active !== i) delete local[i]; }, 500);+ }+ const ARC = 98.9, CIRC = 131.9;+</script>++<div class="macros" onpointermove={move} onpointerup={up} onpointercancel={up} role="group" aria-label="Macros">+ <button class="dev" onclick={() => m && m.devs.length > 1 && (app.sheet = 'devices')}>+ <span class="caps">Device</span>+ <span class="dn">{devName}</span>+ {#if m && m.devs.length > 1}<span class="mono pos">{m.di + 1}/{m.devs.length}</span>{/if}+ <svg width="10" height="10" viewBox="0 0 10 10"><path d="M2 3.5 L5 6.5 L8 3.5" /></svg>+ </button>+ {#if !m || m.devs.length === 0}+ <div class="empty">{m ? 'This track has no instrument or effects to control.' : 'Loading…'}</div>+ {:else}+ <div class="grid" style:grid-template-columns="repeat({cols}, minmax(0, 1fr))">+ {#each m.k as k, i (i)}+ {@const v = local[i] ?? (k.map ? mappedPos[i] ?? 0.5 : k.v ?? 0)}+ {@const on = active === i}+ {@const empty = k.n === undefined && !k.map}+ <div class="knob" class:on class:empty class:learnable={app.learn.on && !empty}+ onpointerdown={(e) => !empty && down(e, i, v)} role="slider" tabindex="0"+ aria-label={k.map ?? k.n ?? `Macro ${i + 1}`} aria-valuenow={Math.round(v * 100)} aria-valuetext={k.map ? `${Math.round(v * 100)} %` : k.txt}>+ {#if k.a && !k.map}<span class="auto"></span>{/if}+ <svg width={size} height={size} viewBox="0 0 52 52">+ <circle cx="26" cy="26" r="21" class="trk" stroke-dasharray="{ARC} {CIRC}" transform="rotate(135 26 26)" />+ {#if !empty}<circle cx="26" cy="26" r="21" class="arc" stroke-dasharray="{v * ARC} {CIRC}" transform="rotate(135 26 26)" />{/if}+ <circle cx="26" cy="26" r="14" class="capc" />+ {#if !empty}<line x1="26" y1="26" x2="26" y2="14" class="ptr" transform="rotate({-135 + 270 * v} 26 26)" />{/if}+ </svg>+ <span class="kn">{(k.map ?? k.n ?? `Macro ${i + 1}`).toUpperCase()}</span>+ <span class="mono kv">{empty ? '—' : k.map ? `${Math.round(v * 100)} %` : on ? `${Math.round(v * 100)} %` : k.txt}</span>+ </div>+ {/each}+ </div>+ {/if}+</div>++<style>+ .macros { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; touch-action: none; }+ .dev { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--well); border: 1px solid var(--border); border-radius: 5px; box-shadow: inset 0 1px 0 rgba(0,0,0,.5); text-align: left; }+ .dev .caps { font-size: 9px; letter-spacing: .1em; }+ .dn { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .pos { font-size: 10px; color: var(--ink5); }+ .dev path { fill: none; stroke: var(--ink4); stroke-width: 1.4; stroke-linecap: round; }+ .grid { flex: 1; min-height: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 8px; }+ .knob { min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 6px; background: var(--card); border: 1px solid var(--border); touch-action: none; }+ .knob.on { border-color: var(--border-brass); }+ .auto { position: absolute; top: 8px; right: 8px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }+ .trk { fill: none; stroke: var(--well); stroke-width: 5; stroke-linecap: round; }+ .arc { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }+ .on .arc { stroke: var(--accent-bright); }+ .capc { fill: var(--panel); stroke: var(--border-strong); }+ .ptr { stroke: var(--accent-bright); stroke-width: 2.4; stroke-linecap: round; }+ .kn { font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink5); max-width: 92%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .kv { font-size: 12px; color: var(--ink1); }+ .on .kn, .on .kv { color: var(--accent-bright); }+ .empty .kv { color: var(--ink6); }+ .empty { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--ink5); }+ .knob.empty { flex: initial; display: flex; }+</style>diff --git a/src/web/remote/src/screens/Mixer.svelte b/src/web/remote/src/screens/Mixer.sveltenew file mode 100644index 00000000..4f06f028--- /dev/null+++ b/src/web/remote/src/screens/Mixer.svelte@@ -0,0 +1,195 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Mixer: a channel per track, scrolling sideways, the master pinned right. Groups are folded+ until tapped, as in the arrangement. A fader moves relative to the finger (no jump to the+ touch), a double tap resets it to 0 dB; values follow Nota live, and a fader another phone+ is holding carries their name. Mute and Solo read as letters, not colour alone. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';+ import type { Track, MixRow } from '../lib/types';++ let { form }: { form: Form } = $props();+ const MAX = 1.5;++ const rows = $derived(new Map((app.mix?.ch ?? []).map((r) => [r[0], r] as [number, MixRow])));+ const tracks = $derived(app.proj?.tracks ?? []);+ const open = $derived(new Set(app.prefs.groupsOpen));++ // A track shows unless one of its groups is folded.+ const visible = $derived.by(() => {+ const byId = new Map(tracks.map((t) => [t.id, t]));+ return tracks.filter((t) => {+ let g = t.grp, guard = 0;+ while (g > 0 && guard++ < 16) {+ if (!open.has(g)) return false;+ g = byId.get(g)?.grp ?? -1;+ }+ return true;+ });+ });+ const childCount = (id: number) => tracks.filter((t) => t.grp === id).length;++ // Local values while a finger holds a control, so Nota's echo doesn't fight the finger.+ let local = $state<Record<string, number>>({});+ let drag = $state<{ key: string; id: number; kind: "vol" | "pan" | "mvol"; start: number; y: number; x: number; size: number } | null>(null);+ const lastTap = new Map<string, number>();++ function begin(e: PointerEvent, key: string, id: number, kind: 'vol' | 'pan' | 'mvol', value: number) {+ if (!app.canControl) { app.showToast('Nota lets this phone play notes only.'); return; }+ const el = e.currentTarget as HTMLElement;+ el.setPointerCapture(e.pointerId);+ const now = performance.now();+ if (now - (lastTap.get(key) ?? 0) < 300) {+ lastTap.delete(key);+ const reset = kind === 'pan' ? 0 : 1;+ local[key] = reset;+ app.send({ t: kind, id, v: reset, ph: 2 });+ setTimeout(() => delete local[key], 400);+ drag = null;+ return;+ }+ lastTap.set(key, now);+ const r = el.getBoundingClientRect();+ drag = { key, id, kind, start: value, y: e.clientY, x: e.clientX, size: kind === 'pan' ? r.width : r.height };+ local[key] = value;+ app.send({ t: kind, id, v: value, ph: 1 });+ }+ let lastSend = 0;+ function moveDrag(e: PointerEvent) {+ if (!drag) return;+ const v = drag.kind === 'pan'+ ? Math.max(-1, Math.min(1, drag.start + ((e.clientX - drag.x) / drag.size) * 2))+ : Math.max(0, Math.min(MAX, drag.start + ((drag.y - e.clientY) / drag.size) * MAX));+ local[drag.key] = v;+ const now = performance.now();+ if (now - lastSend > 30) { lastSend = now; app.send({ t: drag.kind, id: drag.id, v, ph: 0 }); }+ }+ function end() {+ if (!drag) return;+ const d = drag;+ drag = null;+ app.send({ t: d.kind, id: d.id, v: local[d.key], ph: 2 });+ setTimeout(() => { if (drag?.key !== d.key) delete local[d.key]; }, 400);+ }++ function toggle(kind: 'mute' | 'solo' | 'arm', t: Track, on: boolean) {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ app.send({ t: kind, id: t.id, on });+ }+ function fold(t: Track) {+ const s = new Set(app.prefs.groupsOpen);+ if (s.has(t.id)) s.delete(t.id); else s.add(t.id);+ app.prefs.groupsOpen = [...s];+ }++ const db = (v: number) => {+ if (v < 1e-4) return '−∞';+ const d = 20 * Math.log10(v);+ return (d >= 0.05 ? '+' : d <= -0.05 ? '−' : '') + Math.abs(d).toFixed(1);+ };+ const panText = (p: number) => (Math.abs(p) < 0.01 ? 'C' : (p < 0 ? 'L' : 'R') + Math.round(Math.abs(p) * 50));+ const heldBy = (r: MixRow | undefined) => (r && r[8] && r[9] !== app.conn ? r[8] : '');+ const master = $derived(app.mix?.m);+</script>++<div class="mixer {form}" onpointermove={moveDrag} onpointerup={end} onpointercancel={end} role="group" aria-label="Mixer">+ <div class="strips">+ {#each visible as t (t.id)}+ {@const r = rows.get(t.id)}+ {@const vol = local['v' + t.id] ?? r?.[1] ?? 1}+ {@const pan = local['p' + t.id] ?? r?.[2] ?? 0}+ {@const held = heldBy(r)}+ {@const isGroup = t.kind === 'group'}+ <div class="strip" class:group={isGroup} class:active={drag?.key === 'v' + t.id}>+ <button class="head" onclick={() => isGroup && fold(t)} aria-label={isGroup ? `${t.name}: ${open.has(t.id) ? 'fold' : 'unfold'}` : t.name}>+ <span class="cbar" style:background={t.color}></span>+ <span class="nm">{t.name}</span>+ {#if isGroup}+ <span class="tag mono">+ <svg width="8" height="8" viewBox="0 0 8 8" style:transform={open.has(t.id) ? 'rotate(90deg)' : 'none'}><path d="M2.5 1.5 L5.5 4 L2.5 6.5" /></svg>{childCount(t.id)}+ </span>+ {/if}+ </button>+ <div class="pan" onpointerdown={(e) => begin(e, 'p' + t.id, t.id, 'pan', pan)} role="slider" tabindex="0" aria-label="{t.name} pan" aria-valuetext={panText(pan)} aria-valuenow={pan}>+ <div class="pbar"><span style:left="{50 + pan * 50}%"></span></div>+ <span class="mono pv">{panText(pan)}</span>+ </div>+ <div class="fz">+ {#if held}<span class="held">{held} has it</span>{/if}+ <div class="meters"><div><span style:height="{(r?.[6] ?? 0) * 100}%"></span></div><div><span style:height="{(r?.[7] ?? 0) * 100}%"></span></div></div>+ <div class="fader" onpointerdown={(e) => begin(e, 'v' + t.id, t.id, 'vol', vol)} role="slider" tabindex="0" aria-label="{t.name} volume" aria-valuetext="{db(vol)} dB" aria-valuenow={vol}>+ <div class="slot"></div>+ <div class="travel"><span class="cap" class:held={!!held} style:bottom="{(vol / MAX) * 100}%"><i></i></span></div>+ </div>+ </div>+ <span class="mono dbv" class:act={drag?.key === 'v' + t.id}>{db(vol)}</span>+ <div class="btns">+ <button class="ms" class:mute={r?.[3]} aria-pressed={!!r?.[3]} aria-label="Mute {t.name}" onclick={() => toggle('mute', t, !r?.[3])}>M</button>+ <button class="ms" class:solo={r?.[4]} aria-pressed={!!r?.[4]} aria-label="Solo {t.name}" onclick={() => toggle('solo', t, !r?.[4])}>S</button>+ {#if t.kind !== 'group' && t.kind !== 'return'}+ <button class="arm" class:on={r?.[5]} aria-pressed={!!r?.[5]} aria-label="Arm {t.name}" onclick={() => toggle('arm', t, !r?.[5])}><span></span>ARM</button>+ {/if}+ </div>+ </div>+ {/each}+ </div>+ <div class="rule"></div>+ <div class="strip masterstrip">+ <div class="head mh"><span class="caps">Master</span></div>+ <div class="fz">+ {#if heldBy(master as any)}<span class="held">{master?.[3]} has it</span>{/if}+ <div class="meters wide"><div><span style:height="{(master?.[1] ?? 0) * 100}%"></span></div><div><span style:height="{(master?.[2] ?? 0) * 100}%"></span></div></div>+ <div class="fader" onpointerdown={(e) => begin(e, 'm', 0, 'mvol', local['m'] ?? master?.[0] ?? 1)} role="slider" tabindex="0" aria-label="Master volume" aria-valuenow={local['m'] ?? master?.[0] ?? 1}>+ <div class="slot"></div>+ <div class="travel"><span class="cap" style:bottom="{((local['m'] ?? master?.[0] ?? 1) / MAX) * 100}%"><i></i></span></div>+ </div>+ </div>+ <span class="mono dbv">{db(local['m'] ?? master?.[0] ?? 1)}</span>+ </div>+</div>++<style>+ .mixer { flex: 1; min-height: 0; display: flex; gap: 8px; touch-action: none; }+ .strips { flex: 1; min-width: 0; display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; touch-action: pan-x; overscroll-behavior: contain; }+ .strip { flex: 0 0 88px; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px 6px; border-radius: 6px; background: var(--panel); border: 1px solid var(--border); }+ .phoneLand .strip { flex-basis: 84px; }+ .tablet .strip { flex: 1 1 0; min-width: 84px; }+ .strip.group { background: var(--well); border-color: var(--hairline); }+ .strip.active { border-color: var(--border-brass); }+ .head { display: flex; align-items: center; gap: 6px; min-width: 0; height: 28px; text-align: left; }+ .cbar { width: 3px; height: 16px; border-radius: 2px; flex: none; }+ .nm { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .tag { display: flex; align-items: center; gap: 2px; font-size: 9px; color: var(--ink5); }+ .tag path { fill: none; stroke: var(--ink5); stroke-width: 1.4; stroke-linecap: round; }+ .pan { height: 22px; display: flex; align-items: center; gap: 4px; touch-action: none; }+ .pbar { flex: 1; height: 4px; border-radius: 2px; background: var(--well); position: relative; }+ .pbar span { position: absolute; top: -3px; width: 3px; height: 10px; margin-left: -1.5px; border-radius: 1px; background: var(--ink2); }+ .pv { font-size: 9px; color: var(--ink4); width: 22px; text-align: right; }+ .fz { flex: 1; min-height: 0; display: flex; gap: 6px; justify-content: center; position: relative; }+ .held { position: absolute; left: 50%; top: 0; transform: translateX(-50%); z-index: 2; height: 18px; display: flex; align-items: center; padding: 0 6px; border-radius: 9px; background: var(--track-off); border: 1px solid var(--border-strong); font-size: 9px; font-weight: 600; color: var(--ink1); white-space: nowrap; }+ .meters { display: flex; gap: 2px; padding: 4px 0; }+ .meters div { width: 4px; height: 100%; border-radius: 2px; background: var(--well); position: relative; overflow: hidden; }+ .meters.wide div { width: 5px; }+ .meters span { position: absolute; left: 0; right: 0; bottom: 0; background: var(--success); }+ .fader { width: 40px; position: relative; display: flex; justify-content: center; padding: 10px 0; touch-action: none; }+ .slot { width: 4px; height: 100%; border-radius: 2px; background: var(--well); border: 1px solid var(--hairline); }+ .travel { position: absolute; left: 0; right: 0; top: 10px; bottom: 10px; }+ .cap { position: absolute; left: 4px; right: 4px; height: 20px; margin-bottom: -10px; border-radius: 4px; background: var(--raised); border: 1px solid var(--border-strong); display: flex; align-items: center; justify-content: center; }+ .cap.held { border-color: var(--steel); }+ .cap i { width: 18px; height: 2px; border-radius: 1px; background: var(--ink3); }+ .active .cap i { background: var(--accent-bright); }+ .dbv { font-size: 11px; color: var(--ink2); text-align: center; }+ .dbv.act { color: var(--accent-bright); }+ .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }+ .ms { height: 34px; border-radius: 4px; background: var(--raised); border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--ink4); }+ .ms.mute { background: var(--track-off); border-color: var(--ink5); color: var(--ink0); }+ .ms.solo { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }+ .arm { grid-column: span 2; height: 30px; border-radius: 4px; background: var(--raised); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 10px; font-weight: 700; letter-spacing: .08em; color: var(--ink4); }+ .arm span { width: 8px; height: 8px; border-radius: 50%; background: var(--ink6); }+ .arm.on { background: var(--record-wash); border-color: var(--record); color: var(--record-ink); }+ .arm.on span { background: var(--record); }+ .rule { width: 1px; background: var(--hairline); }+ .masterstrip { flex: 0 0 84px; }+ .tablet .masterstrip { flex-basis: 110px; }+ .mh { justify-content: center; }+</style>diff --git a/src/web/remote/src/screens/Pads.svelte b/src/web/remote/src/screens/Pads.sveltenew file mode 100644index 00000000..30fd2740--- /dev/null+++ b/src/web/remote/src/screens/Pads.svelte@@ -0,0 +1,118 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Pads: a 4×4 grid (8×2 in landscape, 8×4 on a tablet) of 16-note banks from C2, the+ bottom-left pad lowest, as on a hardware pad controller. A drum track names its pads. Velocity+ comes from where the finger lands (higher is louder) unless Full vel. is on. A pad lights+ brass under the finger at once, and in the track colour when the track plays it. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';+ import { noteName } from '../lib/music';++ let { form }: { form: Form } = $props();+ const RATES = [{ n: '1/8', div: 2 }, { n: '1/16', div: 4 }, { n: '1/32', div: 8 }];+ let rate = $state(1);+ let repeat = $state(false);+ let down = $state<Record<number, boolean>>({});+ const timers = new Map<number, number>();+ const pointers = new Map<number, number>(); // pointer → note++ const cols = $derived(form === 'phone' ? 4 : 8);+ const count = $derived(form === 'tablet' ? 32 : 16);+ const base = $derived(36 + Math.min(app.prefs.bank, form === 'tablet' ? 2 : 3) * 16);+ const names = $derived(new Map((app.track?.pads ?? []).map(([n, name]) => [n, name])));+ const lit = $derived(new Set(app.lit));+ const color = $derived(app.track?.color ?? 'var(--accent)');++ // Rows run bottom-up: the first note of the bank sits bottom-left.+ const pads = $derived.by(() => {+ const rows = count / cols, out: number[] = [];+ for (let r = rows - 1; r >= 0; r--) for (let c = 0; c < cols; c++) out.push(base + r * cols + c);+ return out;+ });++ const banks = $derived(Array.from({ length: form === 'tablet' ? 3 : 4 }, (_, i) => ({ i, name: noteName(36 + i * 16) })));++ function press(e: PointerEvent, note: number) {+ e.preventDefault();+ const el = e.currentTarget as HTMLElement;+ const r = el.getBoundingClientRect();+ const vel = app.prefs.fullVel ? 1 : Math.max(0.2, Math.min(1, 1 - (e.clientY - r.top) / r.height + 0.15));+ pointers.set(e.pointerId, note);+ down[note] = true;+ app.noteOn(note, vel);+ if (repeat) {+ const step = () => 60000 / Math.max(20, app.tp.bpm) / RATES[rate].div;+ const tick = () => {+ app.noteOff(note);+ app.noteOn(note, vel);+ timers.set(note, window.setTimeout(tick, step()));+ };+ timers.set(note, window.setTimeout(tick, step()));+ }+ }++ function release(e: PointerEvent) {+ const note = pointers.get(e.pointerId);+ if (note === undefined) return;+ pointers.delete(e.pointerId);+ if ([...pointers.values()].includes(note)) return; // another finger still holds it+ clearTimeout(timers.get(note));+ timers.delete(note);+ down[note] = false;+ app.noteOff(note);+ }++ $effect(() => () => { for (const t of timers.values()) clearTimeout(t); });+</script>++<div class="pads">+ <div class="bar">+ <div class="seg banks" role="group" aria-label="Bank">+ {#each banks as b}+ <button class="mono" class:on={app.prefs.bank === b.i} onclick={() => (app.prefs.bank = b.i)}>{b.name}</button>+ {/each}+ </div>+ <button class="btn" class:on={app.prefs.fullVel} aria-pressed={app.prefs.fullVel} onclick={() => (app.prefs.fullVel = !app.prefs.fullVel)}>Full vel.</button>+ <button class="btn rep" class:on={repeat} aria-pressed={repeat} onclick={() => (repeat = !repeat)}>+ Repeat+ <span class="rate mono" role="button" tabindex="0" aria-label="Repeat rate"+ onclick={(e) => { e.stopPropagation(); rate = (rate + 1) % RATES.length; }}+ onkeydown={() => {}}>{RATES[rate].n}</span>+ </button>+ </div>+ <div class="grid" style:grid-template-columns="repeat({cols}, minmax(0, 1fr))">+ {#each pads as note (note)}+ {@const on = down[note]}+ {@const playing = !on && lit.has(note)}+ <button class="pad" class:on class:playing style:--tc={color}+ onpointerdown={(e) => press(e, note)} onpointerup={release} onpointercancel={release} onpointerleave={release}+ aria-label={names.get(note) ?? noteName(note)}>+ <span class="num mono">{note - 35}</span>+ <span class="label">+ <span class="name">{names.get(note) ?? noteName(note)}</span>+ <span class="note mono">{noteName(note)}</span>+ </span>+ </button>+ {/each}+ </div>+</div>++<style>+ .pads { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }+ .bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }+ .banks button { min-width: 42px; flex: none; font-size: 11px; font-weight: 500; }+ .rep { padding: 0 6px 0 10px; gap: 8px; }+ .rate { height: 30px; display: flex; align-items: center; padding: 0 7px; border-radius: 3px; background: var(--well); font-size: 11px; color: var(--ink3); }+ .rep.on .rate { color: var(--accent-bright); }+ .grid { flex: 1; min-height: 0; display: grid; grid-auto-rows: minmax(0, 1fr); gap: 8px; }+ .pad { border-radius: 6px; background: var(--raised); border: 1px solid var(--border); box-shadow: inset 0 1px 0 rgba(255,255,255,.03); display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; padding: 8px; min-height: 0; min-width: 0; overflow: hidden; text-align: left; touch-action: none; }+ .num, .note { font-size: 10px; color: var(--ink5); }+ .note { font-size: 9px; }+ .label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }+ .name { font-size: 12px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ :global(.tablet) .name { font-size: 14px; }+ .pad.playing { background: var(--tc); border-color: var(--tc); }+ .pad.on { background: var(--accent); border-color: var(--accent); }+ .pad.on *, .pad.playing * { color: var(--on-accent); }+ .pad.playing * { color: #171613; }+</style>diff --git a/src/web/remote/src/screens/Scenes.svelte b/src/web/remote/src/screens/Scenes.sveltenew file mode 100644index 00000000..26d20004--- /dev/null+++ b/src/web/remote/src/screens/Scenes.svelte@@ -0,0 +1,87 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- Scenes: the Session grid, tracks across and scenes down, in the project's colours. Tap a clip+ to launch it, a scene name to launch the row, Stop to stop a track. A queued clip blinks+ until the launch point; a playing one shows a play mark and a progress line — readable at+ arm's length. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import type { Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();+ const s = $derived(app.ses);+ const tracks = $derived(new Map((app.proj?.tracks ?? []).map((t) => [t.id, t])));+ const cols = $derived(s?.tr ?? []);+ const colMin = $derived(form === 'phone' ? 96 : form === 'phoneLand' ? 104 : 132);+ const rowH = $derived(form === 'phone' ? 58 : form === 'phoneLand' ? 50 : 84);+ const bars = (beats: number) => { const b = beats / 4; return b === Math.round(b) ? `${b} bar${b === 1 ? '' : 's'}` : `${beats} beats`; };++ function guard(): boolean {+ if (!app.canControl) { app.showToast('Nota lets this phone play notes only.'); return false; }+ return true;+ }+</script>++<div class="scroll">+ {#if !s}+ <div class="empty">Loading…</div>+ {:else}+ <div class="grid" style:grid-template-columns="{form === 'phone' ? 92 : 110}px repeat({cols.length}, minmax({colMin}px, 1fr))">+ <div class="caps corner">Scene</div>+ {#each cols as c (c.id)}+ {@const t = tracks.get(c.id)}+ <div class="th"><span style:background={t?.color}></span><b>{t?.name ?? ''}</b></div>+ {/each}+ {#each Array.from({ length: s.n }, (_, i) => i) as si (si)}+ <button class="scene" style:height="{rowH}px" onclick={() => guard() && app.send({ t: 'scene', i: si })} aria-label="Launch scene {si + 1}">+ <span class="tri"></span>Scene {si + 1}+ </button>+ {#each cols as c (c.id)}+ {@const t = tracks.get(c.id)}+ {@const [st, len, prog] = c.c[si] ?? [0, 0, 0]}+ {#if st === 0}+ <div class="clip empty" style:height="{rowH}px"></div>+ {:else}+ <button class="clip" class:playing={st === 3} class:queued={st === 2} class:rec={st === 4} style:height="{rowH}px" style:--tc={t?.color}+ onclick={() => guard() && app.send({ t: 'launch', id: c.id, i: si })}+ aria-label="{t?.name} scene {si + 1}: {st === 3 ? 'playing' : st === 2 ? 'queued' : st === 4 ? 'recording' : 'stopped'}">+ <span class="cn">{#if st === 3}<span class="ptri"></span>{/if}{bars(len)}</span>+ <span class="mono cs">{st === 3 ? 'PLAYING' : st === 2 ? 'QUEUED' : st === 4 ? 'RECORDING' : ''}</span>+ {#if st === 3}<span class="prog" style:width="{prog * 100}%"></span>{/if}+ </button>+ {/if}+ {/each}+ {/each}+ <button class="stopall" onclick={() => guard() && app.send({ t: 'stopAll' })}><span class="sq"></span>All</button>+ {#each cols as c (c.id)}+ <button class="stop" onclick={() => guard() && app.send({ t: 'stopSlot', id: c.id })} aria-label="Stop {tracks.get(c.id)?.name}"><span class="sq"></span>Stop</button>+ {/each}+ </div>+ {/if}+</div>++<style>+ .scroll { flex: 1; min-height: 0; overflow: auto; touch-action: pan-x pan-y; overscroll-behavior: contain; }+ .grid { display: grid; gap: 6px; min-width: min-content; }+ .corner { height: 36px; display: flex; align-items: center; padding-left: 4px; font-size: 9px; }+ .th { height: 36px; display: flex; align-items: center; gap: 6px; padding: 0 6px; min-width: 0; }+ .th span { width: 3px; height: 14px; border-radius: 2px; flex: none; }+ .th b { font-size: 12px; font-weight: 600; color: var(--ink2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .scene { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 5px; background: var(--raised); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--ink1); }+ .tri { width: 0; height: 0; border-left: 9px solid var(--ink3); border-top: 6px solid transparent; border-bottom: 6px solid transparent; }+ .clip { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 3px; padding: 0 10px; border-radius: 5px; background: var(--raised); border: 1px solid var(--border); overflow: hidden; min-width: 0; text-align: left; }+ .clip.empty { background: var(--well); border: 1px dashed var(--hairline); }+ .cn { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink2); white-space: nowrap; }+ .cs { font-size: 9px; opacity: .8; }+ .clip.playing, .clip.queued { background: var(--tc); border-color: var(--tc); }+ .clip.playing { border-color: var(--ink0); }+ .clip.playing *, .clip.queued * { color: #171613; }+ .clip.queued { animation: blink 800ms steps(1) infinite; }+ .clip.rec { border-color: var(--record); }+ .clip.rec .cs { color: var(--record-ink); }+ @keyframes blink { 50% { opacity: .35; } }+ .ptri { width: 0; height: 0; border-left: 8px solid #171613; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }+ .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: #F2EDE1; opacity: .75; }+ .stop, .stopall { height: 44px; border-radius: 5px; background: var(--raised); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 11px; font-weight: 600; color: var(--ink3); }+ .sq { width: 9px; height: 9px; border-radius: 1px; background: var(--ink3); }+ .empty { padding: 20px; font-size: 12px; color: var(--ink5); }+</style>diff --git a/src/web/remote/src/screens/XY.svelte b/src/web/remote/src/screens/XY.sveltenew file mode 100644index 00000000..715ed121--- /dev/null+++ b/src/web/remote/src/screens/XY.svelte@@ -0,0 +1,201 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+<!-- XY: a full field whose axes drive two parameters — Nota Flux's vector, else Cutoff ×+ Resonance of the track's first Auto Filter, or whatever MIDI Learn mapped them to. On+ release the point stays (Hold) or glides back (Return). Tilt hands the point to the phone's+ gyroscope. With Record on, moves write latch automation in Nota. -->+<script lang="ts">+ import { app } from '../lib/app.svelte';+ import { tiltSupport, requestTilt, followTilt, type Form } from '../lib/device.svelte';++ let { form }: { form: Form } = $props();+ const portrait = $derived(form === 'phone');++ let x = $state(0.5), y = $state(0.5);+ let dragging = $state(false);+ let tilt = $state(false);+ let gliding = false;+ let home = { x: 0.5, y: 0.5 };+ let startPt = { x: 0, y: 0 };+ let axisLock = 0; // learn mode: 1 = X only, 2 = Y only+ let lastSend = 0;+ let stopTilt: (() => void) | null = null;+ const support = tiltSupport();++ // Follow Nota's values while the finger is off (automation, the mouse, another phone).+ $effect(() => {+ const s = app.xy;+ if (!s || dragging || tilt || gliding) return;+ if (s.x.v !== undefined && !s.x.map) x = s.x.v;+ if (s.y.v !== undefined && !s.y.map) y = s.y.v;+ });++ function send(ph: number, src = 'xy') {+ const now = performance.now();+ if (ph === 0 && now - lastSend < 30) return;+ lastSend = now;+ app.send({ t: 'xy', v: x, v2: y, ph, s: src, i: app.learn.on ? axisLock : 0 });+ }++ function at(e: PointerEvent, el: HTMLElement) {+ const r = el.getBoundingClientRect();+ x = Math.min(1, Math.max(0, (e.clientX - r.left) / r.width));+ y = Math.min(1, Math.max(0, 1 - (e.clientY - r.top) / r.height));+ }++ function down(e: PointerEvent) {+ if (tilt || !app.canControl) { if (!app.canControl) app.showToast('Nota lets this phone play notes only.'); return; }+ const el = e.currentTarget as HTMLElement;+ el.setPointerCapture(e.pointerId);+ gliding = false;+ home = { x, y };+ startPt = { x: e.clientX, y: e.clientY };+ axisLock = 0;+ dragging = true;+ at(e, el);+ if (!app.learn.on) send(1);+ }+ function move(e: PointerEvent) {+ if (!dragging) return;+ if (app.learn.on && axisLock === 0) {+ const dx = Math.abs(e.clientX - startPt.x), dy = Math.abs(e.clientY - startPt.y);+ if (Math.max(dx, dy) < 14) return;+ axisLock = dx >= dy ? 1 : 2;+ }+ at(e, e.currentTarget as HTMLElement);+ send(0);+ }+ function up() {+ if (!dragging) return;+ dragging = false;+ send(2);+ if (!app.prefs.xyHold) glideHome();+ }++ function glideHome() {+ gliding = true;+ const step = () => {+ if (!gliding || dragging) return;+ x += (home.x - x) * 0.2;+ y += (home.y - y) * 0.2;+ const done = Math.abs(home.x - x) + Math.abs(home.y - y) < 0.003;+ if (done) { x = home.x; y = home.y; gliding = false; send(2); return; }+ send(0);+ requestAnimationFrame(step);+ };+ requestAnimationFrame(step);+ }++ async function toggleTilt() {+ if (!app.canControl) return app.showToast('Nota lets this phone play notes only.');+ if (tilt) { tilt = false; stopTilt?.(); stopTilt = null; send(2, 'tilt'); return; }+ if (!(await requestTilt())) {+ app.showToast('Motion access was refused. Allow it in Settings → Safari → Motion & Orientation Access, then reload.');+ return;+ }+ tilt = true;+ stopTilt = followTilt((tx, ty) => { x = tx; y = ty; send(0, 'tilt'); });+ }+ $effect(() => () => stopTilt?.());++ const label = (a: 'x' | 'y') => {+ const s = app.xy?.[a];+ if (!s) return a === 'x' ? 'X' : 'Y';+ if (tilt && s.tilt) return s.tilt;+ return s.map ?? s.n ?? (a === 'x' ? 'X' : 'Y');+ };+ const sub = (a: 'x' | 'y') => {+ const s = app.xy?.[a];+ if (!s) return '';+ if ((tilt && s.tilt) || s.map) return 'Mapped in Nota';+ return s.d ?? 'Not assigned';+ };+ const value = (a: 'x' | 'y') => {+ const s = app.xy?.[a];+ const v = a === 'x' ? x : y;+ if (s && !s.map && !(tilt && s.tilt) && s.txt && !dragging && !tilt) return s.txt;+ return Math.round(v * 100) + ' %';+ };+ const note = $derived(+ tilt ? 'Tilt the phone to move the point. Tap Tilt again to use your finger.'+ : !app.xy?.ok && !app.xy?.x.map && !app.xy?.y.map ? 'This track has no Auto Filter or Nota Flux. Add one in Nota, or map the axes with MIDI Learn.'+ : app.prefs.xyHold ? 'The point stays where you lift your finger.' : 'On release the point glides back to where it started.');+</script>++<div class="xy" class:col={portrait}>+ <div class="field" class:learnable={app.learn.on} role="slider" tabindex="0" aria-label="XY pad" aria-valuenow={Math.round(x * 100)}+ onpointerdown={down} onpointermove={move} onpointerup={up} onpointercancel={up}>+ <div class="gridlines"></div>+ <div class="fill" style:width="{x * 100}%" style:height="{y * 100}%" style:background={app.track?.color ?? 'var(--accent)'}></div>+ <div class="vl" style:left="{x * 100}%"></div>+ <div class="hl" style:top="{(1 - y) * 100}%"></div>+ <div class="pt" style:left="{x * 100}%" style:top="{(1 - y) * 100}%"><span></span></div>+ <span class="ax ax-x mono">{label('x')} →</span>+ <span class="ax ax-y mono">↑ {label('y')}</span>+ {#if tilt}<span class="pill">Tilt is moving the point</span>{/if}+ </div>+ <div class="panel">+ <div class="axes">+ {#each ['x', 'y'] as const as a}+ <div class="axis" class:learnable={app.learn.on}>+ <span class="mono an">{a.toUpperCase()}</span>+ <span class="names"><span class="pn">{label(a)}</span><span class="pd">{sub(a)}</span></span>+ <span class="mono av">{value(a)}</span>+ </div>+ {/each}+ </div>+ <div class="row">+ <div class="seg">+ <button class:on={app.prefs.xyHold} onclick={() => (app.prefs.xyHold = true)}>Hold</button>+ <button class:on={!app.prefs.xyHold} onclick={() => (app.prefs.xyHold = false)}>Return</button>+ </div>+ {#if support === 'yes' || support === 'ask'}+ <button class="btn tilt" class:on={tilt} class:learnable={app.learn.on} aria-pressed={tilt} onclick={toggleTilt}>+ <span class="ph"></span>Tilt+ </button>+ {/if}+ </div>+ <span class="note">{note}</span>+ {#if support === 'insecure'}+ <span class="note dim">Tilt needs a secure (HTTPS) page, which a local Nota can’t offer yet.</span>+ {/if}+ {#if app.xy?.auto}+ <div class="auto"><span class="rd"></span>Writing automation · latch</div>+ {/if}+ </div>+</div>++<style>+ .xy { flex: 1; min-height: 0; display: flex; gap: 12px; }+ .xy.col { flex-direction: column; }+ .field { flex: 1; min-height: 0; min-width: 0; position: relative; border-radius: 6px; background: var(--well); border: 1px solid var(--hairline); box-shadow: inset 0 1px 0 rgba(0,0,0,.5); overflow: hidden; touch-action: none; }+ .gridlines { position: absolute; inset: 0; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 25% 25%; background-position: -1px -1px; }+ .fill { position: absolute; left: 0; bottom: 0; opacity: .08; }+ .vl { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--accent-edge); }+ .hl { position: absolute; left: 0; right: 0; height: 1px; background: var(--accent-edge); }+ .pt { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 2px solid var(--accent); background: var(--accent-wash); display: flex; align-items: center; justify-content: center; }+ .pt span { width: 10px; height: 10px; border-radius: 50%; background: var(--accent-bright); }+ .ax { position: absolute; font-size: 10px; color: var(--ink5); pointer-events: none; }+ .ax-x { right: 10px; bottom: 8px; }+ .ax-y { left: 10px; top: 8px; }+ .pill { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); height: 24px; display: flex; align-items: center; padding: 0 10px; border-radius: 12px; background: var(--accent-wash); border: 1px solid var(--border-brass); font-size: 11px; font-weight: 600; color: var(--accent-bright); white-space: nowrap; }+ .panel { width: 290px; flex: none; display: flex; flex-direction: column; gap: 10px; }+ :global(.tablet) .panel { width: 340px; }+ .col .panel { width: auto; }+ .axes { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }+ .axis { height: 50px; display: flex; align-items: center; gap: 12px; padding: 0 12px; background: var(--panel); outline-offset: -3px; }+ .axis + .axis { border-top: 1px solid var(--hairline); }+ .an { font-size: 13px; color: var(--accent-dim); width: 12px; }+ .names { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }+ .pn { font-size: 12px; font-weight: 600; color: var(--ink1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .pd { font-size: 10px; color: var(--ink5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }+ .av { font-size: 13px; color: var(--ink1); white-space: nowrap; }+ .row { display: flex; gap: 8px; }+ .row .seg { flex: 1; }+ .row .seg button { height: 38px; }+ .tilt { height: 46px; padding: 0 14px; }+ .ph { width: 10px; height: 14px; border-radius: 2px; border: 1.5px solid currentColor; transform: rotate(-18deg); }+ .note { font-size: 11px; line-height: 1.5; color: var(--ink4); }+ .note.dim { color: var(--ink5); }+ .auto { height: 30px; align-self: flex-start; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 4px; background: var(--raised); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--ink1); }+ .rd { width: 7px; height: 7px; border-radius: 50%; background: var(--record); }+</style>diff --git a/src/web/remote/src/vite-env.d.ts b/src/web/remote/src/vite-env.d.tsnew file mode 100644index 00000000..11f02fe2--- /dev/null+++ b/src/web/remote/src/vite-env.d.ts@@ -0,0 +1 @@+/// <reference types="vite/client" />diff --git a/src/web/remote/svelte.config.js b/src/web/remote/svelte.config.jsnew file mode 100644index 00000000..c415fee3--- /dev/null+++ b/src/web/remote/svelte.config.js@@ -0,0 +1,3 @@+// SPDX-License-Identifier: AGPL-3.0-only+import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';+export default { preprocess: vitePreprocess() };diff --git a/src/web/remote/tsconfig.json b/src/web/remote/tsconfig.jsonnew file mode 100644index 00000000..edfaf6a2--- /dev/null+++ b/src/web/remote/tsconfig.json@@ -0,0 +1,15 @@+{+ "compilerOptions": {+ "target": "ES2022",+ "module": "ESNext",+ "moduleResolution": "bundler",+ "lib": ["ES2022", "DOM", "DOM.Iterable"],+ "strict": true,+ "noEmit": true,+ "verbatimModuleSyntax": true,+ "isolatedModules": true,+ "skipLibCheck": true,+ "types": ["svelte"]+ },+ "include": ["src/**/*.ts", "src/**/*.svelte"]+}diff --git a/src/web/remote/vite.config.ts b/src/web/remote/vite.config.tsnew file mode 100644index 00000000..d45f4e35--- /dev/null+++ b/src/web/remote/vite.config.ts@@ -0,0 +1,23 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Builds the phone app into Nota.Remote/wwwroot, which Nota embeds and serves. `npm run dev`+// proxies /ws to a running Nota (NOTA_REMOTE=http://192.168.1.5:7788 to pick another one).+import { defineConfig } from 'vite';+import { svelte } from '@sveltejs/vite-plugin-svelte';++const nota = process.env.NOTA_REMOTE ?? 'http://127.0.0.1:7788';++export default defineConfig({+ plugins: [svelte()],+ base: './',+ build: {+ outDir: '../../managed/Nota.Remote/wwwroot',+ emptyOutDir: true,+ target: ['safari16', 'chrome100'],+ assetsInlineLimit: 0,+ reportCompressedSize: true,+ },+ server: {+ host: true,+ proxy: { '/ws': { target: nota, ws: true } },+ },+});diff --git a/tests/Nota.SmokeTest/Nota.SmokeTest.csproj b/tests/Nota.SmokeTest/Nota.SmokeTest.csprojindex 82181acd..98a785bd 100644--- a/tests/Nota.SmokeTest/Nota.SmokeTest.csproj+++ b/tests/Nota.SmokeTest/Nota.SmokeTest.csproj@@ -32,6 +32,7 @@assembly (Phase 0.7); Presentation is not in Infrastructure's closure. --><ProjectReference Include="..\..\src\managed\Nota.Presentation\Nota.Presentation.csproj" /><ProjectReference Include="..\..\src\managed\Nota.Mcp\Nota.Mcp.csproj" />+ <ProjectReference Include="..\..\src\managed\Nota.Remote\Nota.Remote.csproj" /></ItemGroup><!-- Engine contract types + ports live in the Application namespace. -->diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 28a10428..ddce709d 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -190,6 +190,15 @@ if (args.Length >= 1 && args[0] == "--bundle")return failures == 0 ? 0 : 1;}+// Nota Remote alone (fast iteration): `--remote`. Also part of the full run.+if (args.Length >= 1 && args[0] == "--remote")+{+ Console.WriteLine("-- nota remote --");+ foreach (var (ok, label) in RemoteTests.Run()) Check(ok, label);+ Console.WriteLine(failures == 0 ? "REMOTE PASSED" : $"REMOTE FAILED ({failures})");+ return failures == 0 ? 0 : 1;+}+// Project version history alone (fast iteration): `--history`. Also part of the full run.if (args.Length >= 1 && args[0] == "--history"){@@ -13660,6 +13669,10 @@ foreach (var (ok, label) in HistoryTests.RunSummary()) Check(ok, label);foreach (var (ok, label) in HistoryTests.RunCleanup()) Check(ok, label);foreach (var (ok, label) in HistoryTests.RunMcp()) Check(ok, label);+// --- nota remote: track-addressed notes, pairing, a phone session over a real socket ---+Console.WriteLine("-- nota remote --");+foreach (var (ok, label) in RemoteTests.Run()) Check(ok, label);+// --- get plug-ins: registry index, install/uninstall from local archives ---Console.WriteLine("-- get plug-ins: registry store --");foreach (var (ok, label) in PluginStoreTests.Run()) Check(ok, label);diff --git a/tests/Nota.SmokeTest/RemoteTests.cs b/tests/Nota.SmokeTest/RemoteTests.csnew file mode 100644index 00000000..9bbf30ce--- /dev/null+++ b/tests/Nota.SmokeTest/RemoteTests.cs@@ -0,0 +1,322 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Nota Remote: the engine's track-addressed notes (a phone plays its own track, armed or not,+// and never leaks into other tracks), pairing (codes rotate, wrong guesses lock out, tokens+// survive a restart, forgetting revokes), and a phone session over a real WebSocket against+// a running server — pair, receive the project, play a note, change the mixer, respect the+// play-only access level, release held notes when the phone drops.++using System.Net;+using System.Net.Sockets;+using System.Net.WebSockets;+using System.Text;+using System.Text.Json;+using Nota.Infrastructure;+using Nota.Remote;++namespace Nota.SmokeTest;++internal static class RemoteTests+{+ private static float Rms(float[] buf, int frames)+ {+ double sum = 0;+ for (int i = 0; i < frames * 2; i++) sum += buf[i] * (double)buf[i];+ return (float)Math.Sqrt(sum / (frames * 2));+ }++ // Render a few blocks and return the loudest.+ private static float Loudest(NotaEngine e, int blocks = 8)+ {+ var b = new float[512 * 2];+ float max = 0;+ for (int i = 0; i < blocks; i++) { e.RenderOffline(b, 512); max = Math.Max(max, Rms(b, 512)); }+ return max;+ }++ public static IEnumerable<(bool, string)> Run()+ {+ foreach (var r in Engine()) yield return r;+ foreach (var r in Pairing()) yield return r;+ foreach (var r in Session()) yield return r;+ }++ private static IEnumerable<(bool, string)> Engine()+ {+ using var e = new NotaEngine();+ e.SetBpm(120);+ int a = e.AddInstrumentTrack();+ int b = e.AddInstrumentTrack();+ e.SetTrackMute(b, false);+ Loudest(e, 2);++ e.TrackNoteOn(a, 60, 0.9f);+ float on = Loudest(e);+ yield return (on > 0.005f, $"a track-addressed note plays its unarmed track (rms={on:F4})");+ e.TrackNoteOff(a, 60);+ Loudest(e, 40);+ float off = Loudest(e, 4);+ yield return (off < 1e-3f, $"its note-off releases it (rms={off:F5})");++ // The same note on the other track only, then mute that track: silence proves it went+ // nowhere else.+ e.SetTrackMute(b, true);+ e.TrackNoteOn(b, 64, 0.9f);+ float leak = Loudest(e);+ yield return (leak < 1e-4f, $"an addressed note plays only its own track (rms={leak:F5} with that track muted)");+ e.TrackNoteOff(b, 64);+ Loudest(e, 40);++ // Ordinary live input keeps its rule: nothing armed, nothing plays.+ e.NoteOn(67, 0.9f);+ float live = Loudest(e);+ yield return (live < 1e-4f, $"ordinary live notes still need an armed track (rms={live:F5})");+ e.NoteOff(67);++ // Recording: a phone note on the take's track is captured; on another track it is not.+ using var r = new NotaEngine();+ r.SetBpm(120);+ int rec = r.AddInstrumentTrack();+ int other = r.AddInstrumentTrack();+ r.SetTrackArmed(rec, true);+ r.SetRecording(true);+ Loudest(r, 4);+ r.TrackNoteOn(rec, 60, 0.8f);+ r.TrackNoteOn(other, 72, 0.8f);+ Loudest(r, 20);+ r.TrackNoteOff(rec, 60);+ r.TrackNoteOff(other, 72);+ Loudest(r, 4);+ r.SetRecording(false);+ r.Poll();+ var notes = new List<int>();+ if (r.TryGetTrackInfo(0, out var ti))+ for (int c = 0; c < ti.ClipCount; c++) notes.AddRange(r.GetClipNotes(rec, c).Select(n => n.Pitch));+ yield return (notes.Contains(60), "a phone note on the armed track is recorded into the take");+ yield return (!notes.Contains(72), "a phone note on another track is not recorded into it");+ }++ private static IEnumerable<(bool, string)> Pairing()+ {+ string dir = Path.Combine(Path.GetTempPath(), "nota-remote-test-" + Guid.NewGuid().ToString("N"));+ string store = Path.Combine(dir, "trusted.json");+ var p = new RemotePairing(store);+ string code = p.Code;+ yield return (code.Length == 4 && code.All(char.IsDigit), "the code is four digits");++ var wrong = code == "0000" ? "0001" : "0000";+ yield return (p.Pair(wrong, "x", "1.2.3.4", out var err1) is null && err1 == "code", "a wrong code is refused");+ var ok = p.Pair(code, "Egor's iPhone", "1.2.3.4", out _);+ yield return (ok is not null && ok.Value.Device.Name == "Egor's iPhone", "the right code pairs and names the phone");+ yield return (p.Code != code, "the code changes after a pairing");+ yield return (p.Pair(code, "again", "1.2.3.5", out _) is null, "a used code can't pair a second phone");++ // Five wrong codes from one address lock it out, even for the right code.+ string sender = "10.0.0.9";+ string? last = null;+ for (int i = 0; i < 5; i++) p.Pair(p.Code == "1111" ? "2222" : "1111", "y", sender, out last);+ yield return (last == "locked" && p.Pair(p.Code, "y", sender, out var e2) is null && e2 == "locked", "five wrong codes lock the sender out");++ var token = ok!.Value.Token;+ var reload = new RemotePairing(store);+ yield return (reload.Authenticate(token)?.Name == "Egor's iPhone", "a token survives a restart");+ yield return (reload.Authenticate(token + "x") is null, "a wrong token is refused");+ yield return (!File.ReadAllText(store).Contains(token), "the token itself is never stored");+ reload.Forget(ok.Value.Device.Id);+ yield return (reload.Authenticate(token) is null, "a forgotten phone's token stops working");+ try { Directory.Delete(dir, true); } catch { }+ }++ private sealed class FakeHost : IRemoteHost+ {+ public string HostName => "Test Mac";+ public bool DarkTheme => true;+ public string TrackColor(int trackId) => "#58B368";+ public int SelectedTrackId { get; set; }+ public int ProjectKeyCode => -1;+ public IReadOnlyList<(string Name, double StartBeat)> Sections => new[] { ("Intro", 0.0), ("Drop", 16.0) };+ public bool Recording { get; set; }+ public bool LoopOn { get; set; }+ public bool MetronomeOn { get; set; }+ public int Plays;+ public void Play() => Plays++;+ public void Stop() { }+ public void SetRecord(bool on) => Recording = on;+ public void SetLoop(bool on) => LoopOn = on;+ public void SetLoopRange(double s, double e) { }+ public void SetMetronome(bool on) => MetronomeOn = on;+ public void SetBpm(double bpm) { }+ public double MasterVolume { get; set; } = 1;+ public bool Undo() => false;+ public int Refreshes;+ public void Refresh() => Refreshes++;+ public bool LearnArmed => false;+ public string? LearnPendingName => null;+ public PhoneControlResult PhoneControl(int controlId, double norm) => PhoneControlResult.None;+ public string? PhoneMappingName(int controlId) => null;+ public void DevicesChanged() { }+ public void Activity() { }+ }++ private static int FreePort()+ {+ var l = new TcpListener(IPAddress.Loopback, 0);+ l.Start();+ int port = ((IPEndPoint)l.LocalEndpoint).Port;+ l.Stop();+ return port;+ }++ private static IEnumerable<(bool, string)> Session()+ {+ using var e = new NotaEngine();+ e.SetBpm(120);+ int inst = e.AddInstrumentTrack();+ var pairing = new RemotePairing(null);+ var access = RemoteAccess.Control;+ var host = new FakeHost();+ var hub = new RemoteHub(e, pairing) { Host = host, Access = () => access, HostName = "Test Mac" };+ var server = new RemoteServer();+ int port = FreePort();+ bool started = true;+ try { server.StartAsync(hub, port).GetAwaiter().GetResult(); }+ catch { started = false; }+ yield return (started, $"the server starts on port {port}");+ if (!started) yield break;++ var http = new HttpClient();+ string page = "";+ try { page = http.GetStringAsync($"http://127.0.0.1:{port}/").GetAwaiter().GetResult(); } catch { }+ yield return (page.Contains("id=\"app\"") && page.Contains("manifest.webmanifest"), "the built phone app is served at / (not the not-built placeholder)");+ int status = 0;+ try { status = (int)http.GetAsync($"http://127.0.0.1:{port}/../../etc/passwd").GetAwaiter().GetResult().StatusCode; } catch { }+ yield return (status is 400 or 404, $"nothing outside the app is served (status {status})");++ var ws = new ClientWebSocket();+ ws.ConnectAsync(new Uri($"ws://127.0.0.1:{port}/ws"), CancellationToken.None).GetAwaiter().GetResult();+ var inbox = new List<JsonElement>();+ var cts = new CancellationTokenSource();+ var reader = Task.Run(async () =>+ {+ var buf = new byte[1 << 16];+ while (ws.State == WebSocketState.Open && !cts.IsCancellationRequested)+ {+ int len = 0;+ WebSocketReceiveResult r;+ try+ {+ do { r = await ws.ReceiveAsync(new ArraySegment<byte>(buf, len, buf.Length - len), cts.Token); len += r.Count; }+ while (!r.EndOfMessage);+ }+ catch { break; }+ if (r.MessageType == WebSocketMessageType.Close) break;+ var doc = JsonDocument.Parse(buf.AsMemory(0, len));+ lock (inbox) inbox.Add(doc.RootElement.Clone());+ }+ });+ void Send(object m) => ws.SendAsync(Encoding.UTF8.GetBytes(JsonSerializer.Serialize(m)), WebSocketMessageType.Text, true, CancellationToken.None).GetAwaiter().GetResult();+ JsonElement? Wait(string t, int ms = 2000, Func<JsonElement, bool>? where = null)+ {+ var until = DateTime.UtcNow.AddMilliseconds(ms);+ while (DateTime.UtcNow < until)+ {+ hub.Tick();+ lock (inbox)+ {+ var hit = inbox.FirstOrDefault(m => m.GetProperty("t").GetString() == t && (where is null || where(m)));+ if (hit.ValueKind != JsonValueKind.Undefined) { inbox.Remove(hit); return hit; }+ }+ Thread.Sleep(20);+ }+ return null;+ }++ Send(new { t = "hello", token = "nope", name = "x" });+ var denied = Wait("denied");+ yield return (denied?.GetProperty("why").GetString() == "forgotten", "an unknown token is turned away");+ Send(new { t = "mute", id = inst, on = true });+ Thread.Sleep(80); hub.Tick();+ yield return (e.TryGetTrackInfo(0, out var t0) && t0.Muted == 0, "nothing is accepted before pairing");++ Send(new { t = "pair", code = pairing.Code, name = "Anna's iPhone", screen = "Mixer" });+ var welcome = Wait("welcome");+ yield return (welcome?.GetProperty("token").GetString()?.Length > 20 && welcome?.GetProperty("host").GetString() == "Test Mac",+ "the code pairs: welcome with a token and the host's name");+ var proj = Wait("proj");+ yield return (proj is { } pj && pj.GetProperty("tracks").GetArrayLength() == 1 && pj.GetProperty("you").GetInt32() == inst,+ "the phone gets the project and is put on the instrument track");+ yield return (hub.Devices.Count == 1 && hub.Devices[0].Name == "Anna's iPhone", "Nota lists the phone");++ Send(new { t = "ping", c = 1 });+ yield return (Wait("pong") is not null, "a ping is answered");++ Loudest(e, 2);+ Send(new { t = "on", p = 60, v = 0.9 });+ Thread.Sleep(60);+ float note = Loudest(e);+ yield return (note > 0.005f, $"a pad hit from the phone sounds on its track (rms={note:F4})");++ // Dropping the link releases the held note (as when a gamepad is unplugged).+ ws.Abort();+ cts.Cancel();+ Thread.Sleep(200);+ hub.Tick();+ Loudest(e, 60);+ float after = Loudest(e, 4);+ yield return (after < 1e-3f, $"a phone that drops has its held notes released (rms={after:F5})");+ yield return (hub.Devices.Count == 0, "the dropped phone leaves the list");++ // Reconnect with the token, then the mixer.+ string token = welcome!.Value.GetProperty("token").GetString()!;+ ws = new ClientWebSocket();+ ws.ConnectAsync(new Uri($"ws://127.0.0.1:{port}/ws"), CancellationToken.None).GetAwaiter().GetResult();+ cts = new CancellationTokenSource();+ lock (inbox) inbox.Clear();+ reader = Task.Run(async () =>+ {+ var buf = new byte[1 << 16];+ while (ws.State == WebSocketState.Open && !cts.IsCancellationRequested)+ {+ int len = 0;+ WebSocketReceiveResult r;+ try+ {+ do { r = await ws.ReceiveAsync(new ArraySegment<byte>(buf, len, buf.Length - len), cts.Token); len += r.Count; }+ while (!r.EndOfMessage);+ }+ catch { break; }+ if (r.MessageType == WebSocketMessageType.Close) break;+ var doc = JsonDocument.Parse(buf.AsMemory(0, len));+ lock (inbox) inbox.Add(doc.RootElement.Clone());+ }+ });+ Send(new { t = "hello", token, name = "Anna's iPhone", screen = "Mixer" });+ yield return (Wait("welcome") is not null && !Wait("welcome", 200).HasValue, "the token reconnects without a code");+ var mix = Wait("mix");+ yield return (mix is { } mx && mx.GetProperty("ch").GetArrayLength() == 1, "the Mixer screen gets channel state");++ Send(new { t = "vol", id = inst, v = 0.5, ph = 2 });+ Send(new { t = "mute", id = inst, on = true });+ Wait("none", 150);+ yield return (e.TryGetTrackInfo(0, out var t1) && Math.Abs(t1.Volume - 0.5f) < 1e-3 && t1.Muted == 1, "fader and mute from the phone reach the track");+ yield return (host.Refreshes > 0, "Nota redraws after a phone edit");+ Send(new { t = "play" });+ Wait("none", 120);+ yield return (host.Plays == 1, "transport goes through Nota's transport");++ access = RemoteAccess.PlayNotes;+ Send(new { t = "mute", id = inst, on = false });+ var toast = Wait("toast");+ yield return (toast is not null && e.TryGetTrackInfo(0, out var t2) && t2.Muted == 1, "a play-only phone can't change the mixer, and is told why");++ // Forgetting in Nota drops the phone and its token.+ hub.Forget(hub.Devices[0].DeviceId);+ yield return (Wait("denied")?.GetProperty("why").GetString() == "forgotten", "forgetting the phone in Nota tells it to pair again");+ yield return (pairing.Authenticate(token) is null, "the forgotten token no longer works");++ cts.Cancel();+ try { ws.Abort(); } catch { }+ server.StopAsync().GetAwaiter().GetResult();+ }+}