@skillre/dsh-plugin-sticky-wall 0.2.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -62,6 +62,7 @@ window.__ModuleLoader__.load({
62
62
  md: 222,
63
63
  lg: 276
64
64
  });
65
+ var CENTRE_RADIUS = 300;
65
66
  var LAYOUT_LIMITS = Object.freeze({
66
67
  /** Absolute value of x and y, in world pixels. */
67
68
  coord: 2e4,
@@ -195,7 +196,14 @@ window.__ModuleLoader__.load({
195
196
  "zoomOut": "\u7F29\u5C0F",
196
197
  "zoomReset": "\u91CD\u7F6E\u89C6\u56FE",
197
198
  "dragHint": "\u62D6\u52A8\u5361\u7247\u6446\u653E\u4F4D\u7F6E\uFF0C\u2318/Ctrl + \u6EDA\u8F6E\u7F29\u653E",
198
- "markdownHint": "\u6B63\u6587\u652F\u6301 Markdown\uFF1A\u6807\u9898\u3001\u5217\u8868\u3001\u7C97\u4F53\u3001\u4EE3\u7801\u5757\u3001\u94FE\u63A5\u3001\u8868\u683C"
199
+ "markdownHint": "\u6B63\u6587\u652F\u6301 Markdown\uFF1A\u6807\u9898\u3001\u5217\u8868\u3001\u7C97\u4F53\u3001\u4EE3\u7801\u5757\u3001\u94FE\u63A5\u3001\u8868\u683C",
200
+ "greetMorning": "\u65E9\u4E0A\u597D\uFF0C\u4ECA\u5929\u60F3\u8BB0\u70B9\u4EC0\u4E48\uFF1F",
201
+ "greetAfternoon": "\u4E0B\u5348\u597D\uFF0C\u6709\u4EC0\u4E48\u60F3\u7559\u4E0B\u6765\u7684\uFF1F",
202
+ "greetEvening": "\u665A\u4E0A\u597D\uFF0C\u6536\u4E00\u4E0B\u4ECA\u5929\u7684\u788E\u7247\u3002",
203
+ "greetNight": "\u591C\u6DF1\u4E86\uFF0C\u60F3\u5230\u4EC0\u4E48\u5C31\u5148\u8BB0\u4E0B\u6765\u3002",
204
+ "centreTally": "{count} \u5F20\u4FBF\u7B7E \xB7 {archived} \u5F20\u5DF2\u5F52\u6863",
205
+ "capturePlaceholder": "\u8BB0\u4E0B\u4E00\u4E2A\u7075\u611F\uFF0C\u6216\u7C98\u8D34\u4E00\u4E2A\u94FE\u63A5",
206
+ "captureGo": "\u8BB0\u4E0B"
199
207
  };
200
208
  var en = {
201
209
  "nav": "Notes",
@@ -260,16 +268,23 @@ window.__ModuleLoader__.load({
260
268
  "zoomOut": "Zoom out",
261
269
  "zoomReset": "Reset view",
262
270
  "dragHint": "Drag a card to place it \xB7 \u2318/Ctrl + wheel to zoom",
263
- "markdownHint": "The body renders Markdown: headings, lists, bold, code blocks, links, tables"
271
+ "markdownHint": "The body renders Markdown: headings, lists, bold, code blocks, links, tables",
272
+ "greetMorning": "Good morning \u2014 what is worth keeping today?",
273
+ "greetAfternoon": "Good afternoon \u2014 anything to jot down?",
274
+ "greetEvening": "Good evening \u2014 collect the loose pieces.",
275
+ "greetNight": "Late night \u2014 capture it before it goes.",
276
+ "centreTally": "{count} notes \xB7 {archived} archived",
277
+ "capturePlaceholder": "Jot an idea, or paste a link",
278
+ "captureGo": "Capture"
264
279
  };
265
280
 
266
281
  // src/client/view.tsx
267
282
  var import_react = require("react");
268
283
 
269
284
  // src/layout.ts
270
- var PREVIEW_CELL_W = 300;
271
- var PREVIEW_CELL_H = 232;
272
- var PREVIEW_COLUMNS = 4;
285
+ var GOLDEN_ANGLE = Math.PI * (3 - Math.sqrt(5));
286
+ var PREVIEW_STEP = 196;
287
+ var PREVIEW_NOMINAL_HEIGHT = 200;
273
288
  var PREVIEW_TILT = 4;
274
289
  function hash(text) {
275
290
  let value = 2166136261;
@@ -306,20 +321,60 @@ window.__ModuleLoader__.load({
306
321
  md: 288,
307
322
  lg: 336
308
323
  });
324
+ function columns(text) {
325
+ let total = 0;
326
+ for (const char of text) {
327
+ const code = char.codePointAt(0) ?? 0;
328
+ total += code >= 4352 && (code <= 4447 || code >= 11904 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65376 || code >= 65504 && code <= 65510) ? 2 : 1;
329
+ }
330
+ return total;
331
+ }
332
+ function estimateHeight(note, width) {
333
+ const columnsPerLine = columnsPerLineFor(width);
334
+ let lines = 0;
335
+ for (const paragraph of note.body.split("\n")) {
336
+ if (paragraph.trim() === "") {
337
+ lines += 0.4;
338
+ continue;
339
+ }
340
+ lines += Math.max(1, Math.ceil(columns(paragraph.replace(/^[#>*\-+\d. ]+/u, "")) / columnsPerLine));
341
+ }
342
+ if (note.title !== "") {
343
+ const titleColumns = columnsPerLineFor(width, 0.92);
344
+ lines += Math.max(1, Math.ceil(columns(note.title) / titleColumns));
345
+ }
346
+ if (note.tags.length > 0) {
347
+ let pillColumns = 0;
348
+ for (const tag of note.tags) pillColumns += columns(tag) + 4;
349
+ lines += Math.max(1, Math.ceil(pillColumns / columnsPerLine));
350
+ }
351
+ const clamped = Math.min(16, Math.max(2, lines));
352
+ const estimated = Math.round(58 + clamped * 19);
353
+ return Math.min(estimated, MAX_CARD_HEIGHT[width]);
354
+ }
355
+ function columnsPerLineFor(width, density = 1) {
356
+ return Math.max(8, Math.floor((WIDTH_PX[width] - 26) / 7.1 * density));
357
+ }
309
358
  function layoutOf(note, index) {
310
359
  return note.layout ?? previewLayout(note, index);
311
360
  }
312
361
  function previewLayout(note, index) {
313
- const column = index % PREVIEW_COLUMNS;
314
- const row = Math.floor(index / PREVIEW_COLUMNS);
315
362
  const width = previewWidth(note.id);
363
+ const radius = PREVIEW_STEP * Math.sqrt(Math.max(0, index) + (CENTRE_RADIUS / PREVIEW_STEP) ** 2);
364
+ const theta = index * GOLDEN_ANGLE + (unit(`${note.id}:pa`) - 0.5) * 0.55;
316
365
  return clampLayout({
317
- x: column * PREVIEW_CELL_W + unit(`${note.id}:px`) * 42,
318
- y: row * PREVIEW_CELL_H + unit(`${note.id}:py`) * 34,
366
+ x: Math.cos(theta) * radius - WIDTH_PX[width] / 2,
367
+ y: Math.sin(theta) * radius - PREVIEW_NOMINAL_HEIGHT / 2,
319
368
  rotate: (unit(`${note.id}:pr`) - 0.5) * 2 * PREVIEW_TILT,
320
369
  width
321
370
  });
322
371
  }
372
+ function rotatedExtent(width, height, rotate) {
373
+ const radians = Math.abs(rotate) * Math.PI / 180;
374
+ const cos = Math.cos(radians);
375
+ const sin = Math.sin(radians);
376
+ return { width: width * cos + height * sin, height: height * cos + width * sin };
377
+ }
323
378
 
324
379
  // src/client/markdown.tsx
325
380
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -522,22 +577,11 @@ window.__ModuleLoader__.load({
522
577
  .skw-page {
523
578
  position: relative; height: 100%; display: flex; flex-direction: column;
524
579
  background-color: var(--dsw-alias-bg-base);
525
- /* A barely-there dot grid reads as paper without competing with the notes. */
526
- background-image: radial-gradient(circle at 1px 1px, var(--dsw-alias-border-l1) 1px, transparent 0);
527
- background-size: 18px 18px;
528
580
  color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px;
529
581
  overflow: hidden; -webkit-font-smoothing: antialiased;
530
582
  }
531
583
  .skw-page *, .skw-page *::before, .skw-page *::after { box-sizing: border-box; }
532
584
  .skw-page button { font: inherit; }
533
- .skw-head { flex: 0 0 auto; display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px 14px; }
534
- .skw-head-text { min-width: 0; flex: 1; }
535
- .skw-title { margin: 0; font-size: 19px; line-height: 27px; font-weight: 650; letter-spacing: -.2px; display: flex; align-items: center; gap: 9px; }
536
- /* The title mark echoes the sidebar glyph in the brand color, so the page and
537
- the sidebar entry read as the same object. */
538
- .skw-title-mark { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex: none; border-radius: 8px; background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-primary-foreground); }
539
- .skw-subtitle { margin: 3px 0 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }
540
- .skw-actions { display: flex; align-items: center; gap: 6px; flex: none; }
541
585
  .skw-btn { height: 28px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 7px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-secondary); cursor: pointer; white-space: nowrap; }
542
586
  .skw-btn:hover { background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
543
587
  .skw-btn:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
@@ -548,28 +592,34 @@ window.__ModuleLoader__.load({
548
592
  .skw-btn-danger { color: var(--dsw-alias-state-error-primary); border-color: transparent; background: transparent; }
549
593
  .skw-btn-danger:hover { background: var(--dsw-alias-state-error-secondary); color: var(--dsw-alias-label-primary-foreground); }
550
594
 
551
- .skw-toolbar { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 0 22px 14px; flex-wrap: wrap; }
552
- .skw-search-wrap { position: relative; flex: 1 1 240px; min-width: 160px; display: flex; align-items: center; }
553
- .skw-search-icon { position: absolute; left: 10px; display: flex; color: var(--dsw-alias-label-tertiary); pointer-events: none; }
554
- .skw-search { width: 100%; height: 32px; padding: 0 11px 0 31px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 9px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); transition: border-color .12s ease, box-shadow .12s ease; }
595
+ .skw-dock .skw-search-wrap { position: relative; flex: 0 1 190px; min-width: 96px; display: flex; align-items: center; }
596
+ .skw-search-icon { position: absolute; left: 9px; display: flex; color: var(--dsw-alias-label-tertiary); pointer-events: none; }
597
+ .skw-search { width: 100%; height: 30px; padding: 0 10px 0 29px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 9px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); transition: border-color .12s ease, box-shadow .12s ease; }
555
598
  .skw-search::placeholder { color: var(--dsw-alias-label-tertiary); }
556
599
  .skw-search:focus-visible { outline: none; border-color: var(--dsw-alias-brand-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 18%, transparent); }
557
600
  /* Chips: one row of quiet pills, the active one filled. No boxed segments, so
558
601
  filters, sorting and the archive toggle stop reading as three boxes. */
559
602
  .skw-seg { display: inline-flex; gap: 4px; }
560
- .skw-seg button { height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; font-size: 12.5px; transition: background .12s ease, color .12s ease; }
603
+ .skw-seg button { height: 28px; padding: 0 9px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; font-size: 12.5px; transition: background .12s ease, color .12s ease; }
561
604
  .skw-seg button:hover { background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
562
605
  .skw-seg button[data-on="true"] { background: var(--dsw-alias-label-primary); color: var(--dsw-alias-bg-base); font-weight: 550; }
606
+ @media (max-width: 1180px) {
607
+ /* Narrow window: keep the row, drop the least-used groups' labels down a step. */
608
+ .skw-dock { gap: 6px; padding: 5px 6px; }
609
+ .skw-seg button { padding: 0 7px; font-size: 11.5px; }
610
+ }
563
611
  .skw-seg button:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
564
- .skw-toolbar-sep { width: 1px; height: 18px; background: var(--dsw-alias-border-l2); flex: none; }
565
- .skw-toggle { height: 30px; padding: 0 11px; display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--dsw-alias-border-l2); border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; font-size: 12.5px; transition: background .12s ease, color .12s ease, border-color .12s ease; }
612
+ .skw-toggle { height: 28px; padding: 0 9px; display: inline-flex; align-items: center; gap: 6px; border: 1px dashed var(--dsw-alias-border-l2); border-radius: 999px; background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; font-size: 12.5px; transition: background .12s ease, color .12s ease, border-color .12s ease; }
566
613
  .skw-toggle:hover { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l4); }
567
614
  .skw-toggle[data-on="true"] { border-style: solid; border-color: var(--dsw-alias-border-l3); background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
568
615
  .skw-toggle:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
569
- .skw-count { margin-left: auto; font-size: 12px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; }
616
+ .skw-count { font-size: 11.5px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; padding: 0 4px; }
570
617
 
571
- .skw-body { flex: 1 1 auto; overflow: auto; overscroll-behavior: contain; padding: 4px 22px 40px; }
572
- .skw-body[data-view="canvas"] { padding: 0; overflow: hidden; }
618
+ .skw-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 18px 22px 118px; }
619
+ .skw-body[data-view="canvas"] { padding: 0; overflow: hidden; position: relative; }
620
+ /* The grid and the list are scrolled under the floating dock, so their bottom
621
+ padding clears it instead of hiding the last row behind it. */
622
+ .skw-list-empty { margin: 40px auto; text-align: center; color: var(--dsw-alias-label-secondary); font-size: 13px; }
573
623
  /* Masonry-style columns, not a row grid: cards keep their natural height and
574
624
  short notes no longer sit in a tall row with dead space underneath. */
575
625
  .skw-grid { column-count: 5; column-gap: 14px; }
@@ -579,29 +629,44 @@ window.__ModuleLoader__.load({
579
629
  @media (max-width: 560px) { .skw-grid { column-count: 1; } }
580
630
 
581
631
  /* The free canvas.
582
- A scroll container holding a world-sized surface; every card is absolutely
583
- positioned in world coordinates. Scrolling pans, and \u2318/Ctrl + wheel scales
584
- the world around its origin, so a wall keeps its spatial memory instead of
585
- being re-flowed by the window width. */
586
- .skw-canvas-scroll { width: 100%; height: 100%; overflow: auto; overscroll-behavior: contain; }
632
+ One clipping viewport holding one transformed world. The camera is
633
+ translate3d(pan) scale(zoom) on .skw-world, written imperatively, so a pan or
634
+ a zoom never re-renders React and never triggers layout. Cards keep left/top
635
+ in world coordinates and a rotate(); the drag is the only thing that writes
636
+ their transform, and it is removed on drop. */
587
637
  .skw-canvas {
588
- position: relative; min-width: 100%; min-height: 100%;
589
- /* The same dot grid as the page, so the canvas reads as the paper itself. */
638
+ position: relative; width: 100%; height: 100%; overflow: hidden;
639
+ /* The dot grid lives on the viewport and is shifted/scaled with the camera, so
640
+ the paper moves under the cards instead of staying a screen texture. */
590
641
  background-image: radial-gradient(circle at 1px 1px, var(--dsw-alias-border-l1) 1px, transparent 0);
591
642
  background-size: 22px 22px;
643
+ cursor: grab; touch-action: none;
644
+ user-select: none; -webkit-user-select: none;
645
+ }
646
+ .skw-canvas[data-panning="true"] { cursor: grabbing; }
647
+ .skw-canvas[data-panning="true"] .skw-note { cursor: grabbing; }
648
+ .skw-world {
649
+ position: absolute; left: 0; top: 0; width: 0; height: 0;
650
+ transform-origin: 0 0;
651
+ /* The world wrapper is a zero-sized origin marker; cards position themselves
652
+ from it. Promoting it once keeps pan/zoom on the compositor. */
653
+ will-change: transform;
654
+ }
655
+ /* A soft halo at the wall's middle. Decorative only: it marks where the camera
656
+ opens, and it is drawn under the cards so it never intercepts a pointer. */
657
+ .skw-origin-glow {
658
+ position: absolute; width: 620px; height: 620px; margin: -310px 0 0 -310px;
659
+ border-radius: 50%; pointer-events: none;
660
+ background: radial-gradient(circle, color-mix(in srgb, var(--dsw-alias-brand-primary) 9%, transparent) 0%, transparent 68%);
592
661
  }
593
- .skw-world { position: absolute; inset: 0; }
594
- .skw-note-slot { position: absolute; inset: 0; pointer-events: none; }
595
- /* Cards inside the canvas are absolutely placed by their stored layout, and
596
- only the card itself takes pointer events, so empty paper stays scrollable. */
597
662
  /* The canvas card.
598
663
  Performance note: transform must NEVER be transitioned here. The drag writes
599
664
  a new transform on every animation frame, and an active transition makes each
600
665
  write an animation target \u2014 the browser then interpolates toward it, so the
601
- card visibly lags the pointer by ~160ms and reads as sticky. Only the
602
- shadow is animated. */
666
+ card visibly lags the pointer by ~160ms and reads as sticky. Only the shadow
667
+ and the drop shadow animate. */
603
668
  .skw-canvas .skw-note {
604
- position: absolute; pointer-events: auto; margin: 0;
669
+ position: absolute; margin: 0; pointer-events: auto;
605
670
  cursor: grab; touch-action: none;
606
671
  /* One layer per card, promoted once. Toggling will-change on drag would
607
672
  itself cost a style recalculation on the press. */
@@ -609,20 +674,28 @@ window.__ModuleLoader__.load({
609
674
  transition: box-shadow .18s ease;
610
675
  /* The Host's tidy pass estimates card heights from text columns, so the
611
676
  rendered box has to honour the same budget: without a cap a long note grows
612
- past its estimate and the shelf packing underneath it overlaps. The value
613
- mirrors MAX_CARD_HEIGHT in src/layout.ts. */
677
+ past its estimate and the packing underneath it overlaps. The value mirrors
678
+ MAX_CARD_HEIGHT in src/layout.ts. */
614
679
  overflow: hidden;
615
680
  }
681
+ /* The card's height is written inline from the Host's own estimate, so the
682
+ rendered box IS the box the packer collision-checked. These are only the
683
+ fallback for a card rendered without that inline height. */
616
684
  .skw-canvas .skw-note[data-width="sm"] { max-height: 236px; }
617
685
  .skw-canvas .skw-note[data-width="md"] { max-height: 288px; }
618
686
  .skw-canvas .skw-note[data-width="lg"] { max-height: 336px; }
687
+ /* With a fixed height the body must absorb the remainder and clip, rather than
688
+ pushing the footer out of the card. */
689
+ .skw-canvas .skw-note .skw-note-body { min-height: 0; overflow: hidden; }
619
690
  /* While dragging: no hover lift, no text selection, a lifted shadow, and no
620
691
  pointer events on the card's own children so the drag cannot be interrupted
621
- by a child capturing the pointer. */
692
+ by a child capturing the pointer. Containment keeps the lifted card's paint
693
+ out of the rest of the wall. */
622
694
  .skw-canvas .skw-note[data-dragging="true"] {
623
695
  cursor: grabbing; z-index: 20;
624
- box-shadow: 0 4px 10px var(--dsw-alias-bg-mask-2), 0 26px 46px -14px var(--skw-note-glow);
696
+ box-shadow: 0 6px 14px var(--dsw-alias-bg-mask-2), 0 34px 60px -16px var(--skw-note-glow);
625
697
  user-select: none; -webkit-user-select: none;
698
+ contain: layout paint;
626
699
  }
627
700
  .skw-canvas .skw-note[data-dragging="true"] * { pointer-events: none; }
628
701
  /* The hover lift belongs to the grid view only. On the canvas the card already
@@ -653,22 +726,98 @@ window.__ModuleLoader__.load({
653
726
  .skw-row[data-color="purple"] { --skw-note-accent: #9b81e0; }
654
727
  .skw-row[data-color="orange"] { --skw-note-accent: #e79a4e; }
655
728
 
656
- /* Floating camera control, bottom-left: it belongs to the canvas, not to the
657
- toolbar, so the toolbar stays about filtering and the view switch. */
658
- .skw-cameras {
659
- position: absolute; left: 22px; bottom: 18px; z-index: 12;
660
- display: inline-flex; align-items: center; gap: 2px;
661
- padding: 3px; border-radius: 999px; border: 1px solid var(--dsw-alias-border-l2);
662
- background: var(--dsw-alias-bg-layer-1); box-shadow: 0 4px 14px var(--dsw-alias-bg-mask-2);
729
+ /* The floating dock.
730
+ One row of quiet pills across the bottom of the canvas. The wall gets the whole
731
+ window, and the controls sit where the pointer already is after a drag. */
732
+ .skw-dock {
733
+ position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 14;
734
+ max-width: calc(100% - 32px); white-space: nowrap;
735
+ display: flex; align-items: center; gap: 8px;
736
+ padding: 6px 8px 6px 10px; border-radius: 16px;
737
+ border: 1px solid var(--dsw-alias-border-l2);
738
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-1) 88%, transparent);
739
+ backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
740
+ box-shadow: 0 8px 28px var(--dsw-alias-bg-mask-2), 0 1px 0 color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent) inset;
741
+ /* One row, never a wrapped stack: the dock is a floating control strip, and a
742
+ two-line block over the canvas eats the wall it is floating above. */
743
+ flex-wrap: nowrap; justify-content: center;
744
+ }
745
+ .skw-dock-group { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
746
+ .skw-dock-group + .skw-dock-group { padding-left: 8px; border-left: 1px solid var(--dsw-alias-border-l1); }
747
+ .skw-dock-zoom { gap: 1px; }
748
+ .skw-dock-quiet {
749
+ height: 28px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent;
750
+ color: var(--dsw-alias-label-tertiary); cursor: pointer; font-size: 11.5px; white-space: nowrap;
663
751
  }
752
+ .skw-dock-quiet:hover { background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
753
+ .skw-dock-quiet[disabled] { opacity: .45; cursor: default; }
754
+ /* The one filled control: creating a note is the primary action. */
755
+ .skw-dock-new {
756
+ width: 32px; height: 32px; flex: none; display: inline-flex; align-items: center; justify-content: center;
757
+ border: 0; border-radius: 50%; background: var(--dsw-alias-brand-primary);
758
+ color: var(--dsw-alias-label-primary-foreground); cursor: pointer;
759
+ font-size: 19px; line-height: 1; font-weight: 400; padding: 0 0 2px;
760
+ transition: transform .12s ease, filter .12s ease;
761
+ }
762
+ .skw-dock-new:hover { filter: brightness(1.08); transform: scale(1.06); }
763
+ .skw-dock-new:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
764
+ .skw-dock-new[disabled] { opacity: .5; cursor: default; transform: none; }
664
765
  .skw-camera-btn {
665
766
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
666
767
  border: 0; border-radius: 50%; background: transparent; color: var(--dsw-alias-label-secondary);
667
768
  cursor: pointer; font-size: 13px; line-height: 1;
668
769
  }
669
770
  .skw-camera-btn:hover { background: var(--dsw-alias-bg-layer-2); color: var(--dsw-alias-label-primary); }
771
+ .skw-camera-btn[disabled] { opacity: .4; cursor: default; background: transparent; }
670
772
  .skw-camera-btn:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; }
671
- .skw-camera-value { min-width: 38px; text-align: center; font-size: 11px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
773
+ .skw-camera-value { min-width: 36px; text-align: center; font-size: 11px; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
774
+
775
+ /* The wall's centrepiece: greeting, tally and quick capture.
776
+ Screen space, not world space, so it stays put when the wall pans or zooms.
777
+ The wrapper ignores the pointer (the paper behind it stays draggable) and only
778
+ the field itself takes input. */
779
+ .skw-centre {
780
+ position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
781
+ width: min(560px, calc(100% - 48px)); z-index: 10;
782
+ display: flex; flex-direction: column; align-items: center; gap: 8px;
783
+ pointer-events: none; text-align: center;
784
+ }
785
+ .skw-centre-hello {
786
+ margin: 0; font-size: 21px; line-height: 30px; font-weight: 650; letter-spacing: -.3px;
787
+ color: var(--dsw-alias-label-primary);
788
+ }
789
+ .skw-centre-tally {
790
+ margin: 0 0 6px; font-size: 12.5px; line-height: 19px; color: var(--dsw-alias-label-tertiary);
791
+ font-variant-numeric: tabular-nums;
792
+ }
793
+ .skw-capture {
794
+ pointer-events: auto; width: 100%; display: flex; align-items: center; gap: 8px;
795
+ padding: 8px 8px 8px 14px; border-radius: 14px;
796
+ border: 1px solid var(--dsw-alias-border-l2);
797
+ background: color-mix(in srgb, var(--dsw-alias-bg-layer-1) 92%, transparent);
798
+ backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
799
+ box-shadow: 0 8px 24px var(--dsw-alias-bg-mask-2);
800
+ transition: border-color .14s ease, box-shadow .14s ease;
801
+ }
802
+ .skw-capture:focus-within {
803
+ border-color: color-mix(in srgb, var(--dsw-alias-brand-primary) 55%, var(--dsw-alias-border-l2));
804
+ box-shadow: 0 8px 24px var(--dsw-alias-bg-mask-2), 0 0 0 3px color-mix(in srgb, var(--dsw-alias-brand-primary) 14%, transparent);
805
+ }
806
+ .skw-capture-icon { flex: none; color: var(--dsw-alias-label-tertiary); font-size: 13px; line-height: 1; }
807
+ .skw-capture-input {
808
+ flex: 1; min-width: 0; height: 26px; border: 0; background: transparent;
809
+ color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 26px;
810
+ }
811
+ .skw-capture-input:focus-visible { outline: none; }
812
+ .skw-capture-input::placeholder { color: var(--dsw-alias-label-tertiary); }
813
+ .skw-capture-go {
814
+ width: 30px; height: 30px; flex: none; display: inline-flex; align-items: center; justify-content: center;
815
+ border: 0; border-radius: 9px; background: var(--dsw-alias-brand-primary);
816
+ color: var(--dsw-alias-label-primary-foreground); cursor: pointer; font-size: 13px; line-height: 1;
817
+ }
818
+ .skw-capture-go[disabled] { opacity: .35; cursor: default; }
819
+ .skw-capture-go:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
820
+
672
821
  .skw-empty { margin: 64px auto 0; max-width: 380px; text-align: center; color: var(--dsw-alias-label-secondary); }
673
822
  .skw-empty p { margin: 0 0 14px; font-size: 13px; }
674
823
  .skw-empty-icon { font-size: 30px; line-height: 1; display: block; margin-bottom: 12px; opacity: .65; }
@@ -685,7 +834,7 @@ window.__ModuleLoader__.load({
685
834
  makes the wall read as paper rather than as flat rectangles. */
686
835
  box-shadow: 0 1px 2px var(--dsw-alias-bg-mask-2), 0 6px 16px -8px var(--skw-note-glow);
687
836
  cursor: default;
688
- transition: box-shadow .18s ease, transform .18s ease;
837
+ transition: box-shadow .18s ease, transform .18s ease, opacity .18s ease;
689
838
  break-inside: avoid; -webkit-column-break-inside: avoid;
690
839
  margin: 0 0 14px;
691
840
  }
@@ -711,7 +860,13 @@ window.__ModuleLoader__.load({
711
860
  .skw-note-body { margin: 0; overflow-wrap: anywhere; font-size: 13px; line-height: 20px; flex: 1; color: var(--skw-note-ink); opacity: .92; }
712
861
  /* Clamp the rendered Markdown block, not a plain string: display:-webkit-box
713
862
  on the wrapper clips every child, so a long note stays a card and not a page. */
714
- .skw-note-body.is-clamped { display: -webkit-box; -webkit-line-clamp: 12; -webkit-box-orient: vertical; overflow: hidden; }
863
+ .skw-note-body.is-clamped { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; -webkit-line-clamp: 12; }
864
+ /* Clamp per width preset so the body ends on a whole line instead of being cut
865
+ mid-glyph by the card's own max-height. The numbers are what fits under the
866
+ budget once the action bar, title, tags and footer have taken their share. */
867
+ .skw-note[data-width="sm"] .skw-note-body.is-clamped { -webkit-line-clamp: 5; }
868
+ .skw-note[data-width="md"] .skw-note-body.is-clamped { -webkit-line-clamp: 8; }
869
+ .skw-note[data-width="lg"] .skw-note-body.is-clamped { -webkit-line-clamp: 11; }
715
870
  .skw-note-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 1px; }
716
871
  /* Tags read as real labels: a tinted pill with the note's accent, not a grey
717
872
  block. */
@@ -895,10 +1050,12 @@ window.__ModuleLoader__.load({
895
1050
 
896
1051
  // src/client/view.tsx
897
1052
  var import_jsx_runtime2 = require("react/jsx-runtime");
898
- var ZOOM_MIN = 0.4;
1053
+ var ZOOM_MIN = 0.35;
899
1054
  var ZOOM_MAX = 2;
900
1055
  var DRAG_THRESHOLD = 3;
901
1056
  var WIDTH_CYCLE = ["sm", "md", "lg"];
1057
+ var DOT_PITCH = 22;
1058
+ var WHEEL_PAN = 1;
902
1059
  function SidebarGlyph({ size = 18 }) {
903
1060
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { className: "skw-glyph", width: size, height: size, viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
904
1061
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "4", y: "7.5", width: "11.5", height: "11.5", rx: "2", stroke: "currentColor", strokeWidth: "1.6" }),
@@ -923,6 +1080,28 @@ window.__ModuleLoader__.load({
923
1080
  function parseTags(raw) {
924
1081
  return raw.split(/[,,\s]+/).map((tag) => tag.trim()).filter((tag) => tag !== "");
925
1082
  }
1083
+ function clampZoom(value) {
1084
+ return Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, value));
1085
+ }
1086
+ function sameNote(left, right) {
1087
+ if (left.title !== right.title || left.body !== right.body || left.color !== right.color || left.pinned !== right.pinned || left.archived !== right.archived || left.createdAt !== right.createdAt || left.updatedAt !== right.updatedAt || left.tags.length !== right.tags.length || left.tags.some((tag, index) => tag !== right.tags[index])) {
1088
+ return false;
1089
+ }
1090
+ if (left.layout === right.layout) return true;
1091
+ if (left.layout === null || right.layout === null) return false;
1092
+ return left.layout.x === right.layout.x && left.layout.y === right.layout.y && left.layout.rotate === right.layout.rotate && left.layout.width === right.layout.width;
1093
+ }
1094
+ function reconcileNotes(previous, next) {
1095
+ const byId = new Map(previous.map((note) => [note.id, note]));
1096
+ let changed = previous.length !== next.length;
1097
+ const merged = next.map((note) => {
1098
+ const old = byId.get(note.id);
1099
+ if (old !== void 0 && sameNote(old, note)) return old;
1100
+ changed = true;
1101
+ return note;
1102
+ });
1103
+ return changed ? merged : previous;
1104
+ }
926
1105
  function Composer({
927
1106
  draft,
928
1107
  t,
@@ -1098,28 +1277,34 @@ window.__ModuleLoader__.load({
1098
1277
  }
1099
1278
  );
1100
1279
  }
1101
- function NoteCard({
1280
+ var NoteCard = (0, import_react.memo)(function NoteCard2({
1102
1281
  note,
1103
1282
  index,
1283
+ surface,
1104
1284
  t,
1105
1285
  locale,
1106
- onEdit,
1107
- onPatch,
1108
- onRemove,
1109
- onResize,
1110
- onDragStart
1286
+ actions
1111
1287
  }) {
1112
1288
  const layout = layoutOf(note, index);
1113
- const style = {
1289
+ const style = surface === "canvas" ? {
1114
1290
  left: `${layout.x}px`,
1115
1291
  top: `${layout.y}px`,
1116
1292
  width: `${WIDTH_PX[layout.width]}px`,
1293
+ // The HEIGHT is the Host's own estimate, not a CSS max-height.
1294
+ //
1295
+ // This is what makes the packer's geometry exact: the collision check runs
1296
+ // on `estimateHeight`, so unless the rendered box is that same height, a
1297
+ // card whose content renders taller than its estimate overlaps its
1298
+ // neighbour — which is precisely the residual overlap this fixes (a code
1299
+ // block's padding and border are not something a line count can see).
1300
+ height: `${estimateHeight(note, layout.width)}px`,
1117
1301
  transform: `rotate(${layout.rotate}deg)`
1118
- };
1302
+ } : {};
1119
1303
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1120
1304
  "article",
1121
1305
  {
1122
1306
  className: "skw-note",
1307
+ "data-note-id": note.id,
1123
1308
  "data-color": note.color,
1124
1309
  "data-pinned": note.pinned,
1125
1310
  "data-archived": note.archived,
@@ -1127,12 +1312,12 @@ window.__ModuleLoader__.load({
1127
1312
  style,
1128
1313
  "aria-label": note.title || note.body.slice(0, 40),
1129
1314
  tabIndex: 0,
1130
- onPointerDown: (event) => onDragStart(note, event),
1131
- onDoubleClick: () => onEdit(note),
1315
+ onPointerDown: (event) => actions.drag(note, event),
1316
+ onDoubleClick: () => actions.edit(note),
1132
1317
  onKeyDown: (event) => {
1133
1318
  if (event.key === "Enter" && !event.metaKey && !event.ctrlKey) {
1134
1319
  event.preventDefault();
1135
- onEdit(note);
1320
+ actions.edit(note);
1136
1321
  }
1137
1322
  },
1138
1323
  children: [
@@ -1149,7 +1334,7 @@ window.__ModuleLoader__.load({
1149
1334
  "data-on": note.pinned,
1150
1335
  "aria-label": note.pinned ? t("unpin") : t("pin"),
1151
1336
  onPointerDown: (event) => event.stopPropagation(),
1152
- onClick: () => onPatch(note, { pinned: !note.pinned }),
1337
+ onClick: () => actions.patch(note, { pinned: !note.pinned }),
1153
1338
  children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-pin", "aria-hidden": "true", children: note.pinned ? "\u2605" : "\u2606" })
1154
1339
  }
1155
1340
  ),
@@ -1161,7 +1346,7 @@ window.__ModuleLoader__.load({
1161
1346
  title: t("resize"),
1162
1347
  "aria-label": t("resize"),
1163
1348
  onPointerDown: (event) => event.stopPropagation(),
1164
- onClick: () => onResize(note, WIDTH_CYCLE[(WIDTH_CYCLE.indexOf(layout.width) + 1) % WIDTH_CYCLE.length] ?? "md"),
1349
+ onClick: () => actions.resize(note, WIDTH_CYCLE[(WIDTH_CYCLE.indexOf(layout.width) + 1) % WIDTH_CYCLE.length] ?? "md"),
1165
1350
  children: "\u2922"
1166
1351
  }
1167
1352
  ),
@@ -1173,7 +1358,7 @@ window.__ModuleLoader__.load({
1173
1358
  title: t("edit"),
1174
1359
  "aria-label": t("edit"),
1175
1360
  onPointerDown: (event) => event.stopPropagation(),
1176
- onClick: () => onEdit(note),
1361
+ onClick: () => actions.edit(note),
1177
1362
  children: "\u270E"
1178
1363
  }
1179
1364
  ),
@@ -1185,7 +1370,7 @@ window.__ModuleLoader__.load({
1185
1370
  title: note.archived ? t("restore") : t("archive"),
1186
1371
  "aria-label": note.archived ? t("restore") : t("archive"),
1187
1372
  onPointerDown: (event) => event.stopPropagation(),
1188
- onClick: () => onPatch(note, { archived: !note.archived }),
1373
+ onClick: () => actions.patch(note, { archived: !note.archived }),
1189
1374
  children: note.archived ? "\u21A9" : "\u25A4"
1190
1375
  }
1191
1376
  ),
@@ -1197,7 +1382,7 @@ window.__ModuleLoader__.load({
1197
1382
  title: t("delete"),
1198
1383
  "aria-label": t("delete"),
1199
1384
  onPointerDown: (event) => event.stopPropagation(),
1200
- onClick: () => onRemove(note),
1385
+ onClick: () => actions.remove(note),
1201
1386
  children: "\u2715"
1202
1387
  }
1203
1388
  )
@@ -1221,7 +1406,7 @@ window.__ModuleLoader__.load({
1221
1406
  ]
1222
1407
  }
1223
1408
  );
1224
- }
1409
+ });
1225
1410
  function NoteRow({ note, t, locale, onEdit }) {
1226
1411
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "skw-row", type: "button", "data-color": note.color, "data-archived": note.archived, onClick: () => onEdit(note), children: [
1227
1412
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-row-dot", "aria-hidden": "true" }),
@@ -1245,14 +1430,26 @@ window.__ModuleLoader__.load({
1245
1430
  const [draft, setDraft] = (0, import_react.useState)(null);
1246
1431
  const [draftError, setDraftError] = (0, import_react.useState)("");
1247
1432
  const [confirming, setConfirming] = (0, import_react.useState)(null);
1248
- const [camera, setCamera] = (0, import_react.useState)({ zoom: 1 });
1433
+ const [zoom, setZoom] = (0, import_react.useState)(1);
1434
+ const [viewportTick, setViewportTick] = (0, import_react.useState)(0);
1435
+ const [capture, setCapture] = (0, import_react.useState)("");
1249
1436
  const [, setLocaleRevision] = (0, import_react.useState)(0);
1250
1437
  const alive = (0, import_react.useRef)(true);
1251
1438
  const life = (0, import_react.useRef)(new AbortController());
1252
1439
  const sequence = (0, import_react.useRef)(0);
1253
1440
  const inFlight = (0, import_react.useRef)(false);
1441
+ const viewportRefCurrent = (0, import_react.useRef)(null);
1442
+ const worldRef = (0, import_react.useRef)(null);
1443
+ const detachWheel = (0, import_react.useRef)(null);
1444
+ const camera = (0, import_react.useRef)({ zoom: 1, panX: 0, panY: 0 });
1445
+ const centreRequest = (0, import_react.useRef)(true);
1254
1446
  const drag = (0, import_react.useRef)(null);
1255
- const canvasRef = (0, import_react.useRef)(null);
1447
+ const pan = (0, import_react.useRef)(null);
1448
+ const live = (0, import_react.useRef)({ mutate: (_run) => {
1449
+ } });
1450
+ live.current.mutate = (run) => {
1451
+ void mutate(run);
1452
+ };
1256
1453
  const activeLocale = locale.getSnapshot().active;
1257
1454
  const stableIndex = (0, import_react.useMemo)(() => {
1258
1455
  const map = /* @__PURE__ */ new Map();
@@ -1272,7 +1469,7 @@ window.__ModuleLoader__.load({
1272
1469
  try {
1273
1470
  const next = await api.list(options.includeArchived, options.sort, life.current.signal);
1274
1471
  if (alive.current && seq === sequence.current) {
1275
- setNotes(next);
1472
+ setNotes((previous) => reconcileNotes(previous, next));
1276
1473
  if (options.clearError !== false) setError("");
1277
1474
  }
1278
1475
  } catch (cause) {
@@ -1293,7 +1490,7 @@ window.__ModuleLoader__.load({
1293
1490
  };
1294
1491
  }, [reload, includeArchived, sort]);
1295
1492
  async function mutate(run) {
1296
- if (inFlight.current) return;
1493
+ if (inFlight.current) return false;
1297
1494
  inFlight.current = true;
1298
1495
  setBusy(true);
1299
1496
  setError("");
@@ -1309,6 +1506,19 @@ window.__ModuleLoader__.load({
1309
1506
  }
1310
1507
  inFlight.current = false;
1311
1508
  }
1509
+ return true;
1510
+ }
1511
+ async function tidyWall() {
1512
+ const ran = await mutate(async () => {
1513
+ await api.arrange(life.current.signal);
1514
+ });
1515
+ if (!ran) return;
1516
+ await new Promise((resolve) => {
1517
+ requestAnimationFrame(() => resolve());
1518
+ });
1519
+ if (!alive.current) return;
1520
+ centreRequest.current = true;
1521
+ setViewportTick((value) => value + 1);
1312
1522
  }
1313
1523
  function openComposer(note) {
1314
1524
  setDraftError("");
@@ -1348,16 +1558,184 @@ window.__ModuleLoader__.load({
1348
1558
  });
1349
1559
  }, [notes, filter, query, showArchived]);
1350
1560
  const archivedCount = notes.filter((note) => note.archived).length;
1351
- const extent = (0, import_react.useMemo)(() => {
1352
- let maxX = 0;
1353
- let maxY = 0;
1354
- for (const [index, note] of visible.entries()) {
1355
- const layout = layoutOf(note, index);
1356
- maxX = Math.max(maxX, layout.x + WIDTH_PX[layout.width]);
1357
- maxY = Math.max(maxY, layout.y + 220);
1561
+ const greeting = (0, import_react.useMemo)(() => {
1562
+ const hour = (/* @__PURE__ */ new Date()).getHours();
1563
+ const key = hour < 5 ? "greetNight" : hour < 12 ? "greetMorning" : hour < 18 ? "greetAfternoon" : "greetEvening";
1564
+ return t(key);
1565
+ }, [t, activeLocale]);
1566
+ const emptyCopy = filter === "archived" ? t("emptyArchived") : query.trim() !== "" ? t("noResults") : t("empty");
1567
+ const wallBounds = (0, import_react.useMemo)(() => {
1568
+ let minX = Number.POSITIVE_INFINITY;
1569
+ let minY = Number.POSITIVE_INFINITY;
1570
+ let maxX = Number.NEGATIVE_INFINITY;
1571
+ let maxY = Number.NEGATIVE_INFINITY;
1572
+ let sumX = 0;
1573
+ let sumY = 0;
1574
+ let count = 0;
1575
+ for (const note of visible) {
1576
+ const layout = layoutOf(note, indexOf(note));
1577
+ const width = WIDTH_PX[layout.width];
1578
+ const height = estimateHeight(note, layout.width);
1579
+ const box = rotatedExtent(width, height, layout.rotate);
1580
+ const centreX = layout.x + width / 2;
1581
+ const centreY = layout.y + height / 2;
1582
+ minX = Math.min(minX, centreX - box.width / 2);
1583
+ maxX = Math.max(maxX, centreX + box.width / 2);
1584
+ minY = Math.min(minY, centreY - box.height / 2);
1585
+ maxY = Math.max(maxY, centreY + box.height / 2);
1586
+ sumX += centreX;
1587
+ sumY += centreY;
1588
+ count += 1;
1589
+ }
1590
+ if (count === 0) return { centre: { x: 0, y: 0 }, width: 0, height: 0 };
1591
+ return {
1592
+ // The bounding box's middle, not the centroid: "frame the whole wall" means
1593
+ // the wall's outer edges are equidistant from the viewport edges, and only
1594
+ // the box middle guarantees that. A lopsided two-card wall has a centroid
1595
+ // far from its visual middle, which left one card half off screen.
1596
+ centre: { x: (minX + maxX) / 2, y: (minY + maxY) / 2 },
1597
+ width: maxX - minX,
1598
+ height: maxY - minY
1599
+ };
1600
+ }, [visible, stableIndex]);
1601
+ const wallCentre = wallBounds.centre;
1602
+ const boundsRef = (0, import_react.useRef)(wallBounds);
1603
+ boundsRef.current = wallBounds;
1604
+ const hasNotes = visible.length > 0;
1605
+ const applyCamera = (0, import_react.useCallback)(() => {
1606
+ const current = camera.current;
1607
+ const world = worldRef.current;
1608
+ const viewport = viewportRefCurrent.current;
1609
+ if (world !== null) world.style.transform = `translate3d(${current.panX}px, ${current.panY}px, 0) scale(${current.zoom})`;
1610
+ if (viewport !== null) {
1611
+ viewport.style.backgroundSize = `${DOT_PITCH * current.zoom}px ${DOT_PITCH * current.zoom}px`;
1612
+ viewport.style.backgroundPosition = `${current.panX}px ${current.panY}px`;
1613
+ }
1614
+ }, []);
1615
+ const centreOn = (0, import_react.useCallback)((worldX, worldY) => {
1616
+ const viewport = viewportRefCurrent.current;
1617
+ const current = camera.current;
1618
+ if (viewport !== null) {
1619
+ current.panX = viewport.clientWidth / 2 - worldX * current.zoom;
1620
+ current.panY = viewport.clientHeight / 2 - worldY * current.zoom;
1358
1621
  }
1359
- return { width: maxX + 420, height: maxY + 320 };
1360
- }, [visible]);
1622
+ applyCamera();
1623
+ }, [applyCamera]);
1624
+ (0, import_react.useEffect)(() => {
1625
+ if (hasNotes) centreRequest.current = true;
1626
+ setViewportTick((value) => value + 1);
1627
+ }, [hasNotes, view]);
1628
+ const zoomTo = (0, import_react.useCallback)((next, anchor) => {
1629
+ const viewport = viewportRefCurrent.current;
1630
+ const current = camera.current;
1631
+ const target = clampZoom(next);
1632
+ if (viewport === null) {
1633
+ current.zoom = target;
1634
+ setZoom(target);
1635
+ return;
1636
+ }
1637
+ const ax = anchor?.x ?? viewport.clientWidth / 2;
1638
+ const ay = anchor?.y ?? viewport.clientHeight / 2;
1639
+ const worldX = (ax - current.panX) / current.zoom;
1640
+ const worldY = (ay - current.panY) / current.zoom;
1641
+ current.zoom = target;
1642
+ current.panX = ax - worldX * target;
1643
+ current.panY = ay - worldY * target;
1644
+ setZoom(target);
1645
+ applyCamera();
1646
+ }, [applyCamera]);
1647
+ const fitWall = (0, import_react.useCallback)(() => {
1648
+ const viewport = viewportRefCurrent.current;
1649
+ if (viewport === null) return;
1650
+ const availableWidth = viewport.clientWidth || 960;
1651
+ const availableHeight = viewport.clientHeight || 640;
1652
+ const world = worldRef.current;
1653
+ let minX = Number.POSITIVE_INFINITY;
1654
+ let minY = Number.POSITIVE_INFINITY;
1655
+ let maxX = Number.NEGATIVE_INFINITY;
1656
+ let maxY = Number.NEGATIVE_INFINITY;
1657
+ if (world !== null) {
1658
+ for (const node of world.querySelectorAll(".skw-note")) {
1659
+ const x = node.offsetLeft;
1660
+ const y = node.offsetTop;
1661
+ const width = node.offsetWidth;
1662
+ const height = node.offsetHeight;
1663
+ if (width === 0 || height === 0) continue;
1664
+ minX = Math.min(minX, x);
1665
+ minY = Math.min(minY, y);
1666
+ maxX = Math.max(maxX, x + width);
1667
+ maxY = Math.max(maxY, y + height);
1668
+ }
1669
+ }
1670
+ const measured = Number.isFinite(minX) && Number.isFinite(minY) && maxX > minX;
1671
+ const bounds = boundsRef.current;
1672
+ const boxWidth = measured ? maxX - minX : bounds.width;
1673
+ const boxHeight = measured ? maxY - minY : bounds.height;
1674
+ const centreX = measured ? (minX + maxX) / 2 : bounds.centre.x;
1675
+ const centreY = measured ? (minY + maxY) / 2 : bounds.centre.y;
1676
+ const margin = 48;
1677
+ const fit = Math.min(
1678
+ (availableWidth - margin * 2) / Math.max(1, boxWidth),
1679
+ (availableHeight - margin * 2) / Math.max(1, boxHeight)
1680
+ );
1681
+ const FIT_FLOOR = 0.5;
1682
+ const target = clampZoom(Math.min(1, Math.max(FIT_FLOOR, fit)));
1683
+ camera.current.zoom = target;
1684
+ setZoom(target);
1685
+ centreOn(centreX, centreY);
1686
+ }, [centreOn]);
1687
+ const resetView = (0, import_react.useCallback)(() => {
1688
+ fitWall();
1689
+ }, [fitWall]);
1690
+ const onWheel = (0, import_react.useCallback)((event) => {
1691
+ const node = viewportRefCurrent.current;
1692
+ if (node === null) return;
1693
+ if (event.ctrlKey || event.metaKey) {
1694
+ event.preventDefault();
1695
+ const rect = node.getBoundingClientRect();
1696
+ zoomTo(camera.current.zoom - event.deltaY * 22e-4, { x: event.clientX - rect.left, y: event.clientY - rect.top });
1697
+ return;
1698
+ }
1699
+ event.preventDefault();
1700
+ camera.current.panX -= event.deltaX * WHEEL_PAN;
1701
+ camera.current.panY -= event.deltaY * WHEEL_PAN;
1702
+ applyCamera();
1703
+ }, [applyCamera, zoomTo]);
1704
+ const bindViewport = (0, import_react.useCallback)((node) => {
1705
+ viewportRefCurrent.current = node;
1706
+ detachWheel.current?.();
1707
+ detachWheel.current = null;
1708
+ if (node === null) return;
1709
+ node.addEventListener("wheel", onWheel, { passive: false });
1710
+ detachWheel.current = () => node.removeEventListener("wheel", onWheel);
1711
+ }, [onWheel]);
1712
+ (0, import_react.useEffect)(() => {
1713
+ const node = viewportRefCurrent.current;
1714
+ if (node === null) return;
1715
+ detachWheel.current?.();
1716
+ node.addEventListener("wheel", onWheel, { passive: false });
1717
+ detachWheel.current = () => node.removeEventListener("wheel", onWheel);
1718
+ }, [onWheel]);
1719
+ (0, import_react.useEffect)(() => {
1720
+ const node = viewportRefCurrent.current;
1721
+ if (node === null || typeof ResizeObserver === "undefined") return;
1722
+ const observer = new ResizeObserver(() => {
1723
+ if (drag.current !== null || pan.current !== null) return;
1724
+ centreRequest.current = true;
1725
+ setViewportTick((value) => value + 1);
1726
+ });
1727
+ observer.observe(node);
1728
+ return () => observer.disconnect();
1729
+ }, [view]);
1730
+ (0, import_react.useLayoutEffect)(() => {
1731
+ if (view !== "canvas") return;
1732
+ if (centreRequest.current) {
1733
+ centreRequest.current = false;
1734
+ fitWall();
1735
+ return;
1736
+ }
1737
+ applyCamera();
1738
+ }, [applyCamera, fitWall, view, viewportTick]);
1361
1739
  function startDrag(note, event) {
1362
1740
  if (event.button !== 0 || event.isPrimary === false) return;
1363
1741
  const layout = layoutOf(note, indexOf(note));
@@ -1375,8 +1753,6 @@ window.__ModuleLoader__.load({
1375
1753
  width: layout.width,
1376
1754
  moved: false,
1377
1755
  captured: false,
1378
- x: layout.x,
1379
- y: layout.y,
1380
1756
  frame: 0,
1381
1757
  lastX: event.clientX,
1382
1758
  lastY: event.clientY
@@ -1387,52 +1763,105 @@ window.__ModuleLoader__.load({
1387
1763
  } catch {
1388
1764
  }
1389
1765
  }
1766
+ function startPan(event) {
1767
+ if (event.button !== 0 || event.isPrimary === false) return;
1768
+ const target = event.target;
1769
+ if (target !== null && target.closest(".skw-note") !== null) return;
1770
+ const node = viewportRefCurrent.current;
1771
+ if (node === null) return;
1772
+ node.setAttribute("data-panning", "true");
1773
+ pan.current = {
1774
+ pointerId: event.pointerId,
1775
+ startX: event.clientX,
1776
+ startY: event.clientY,
1777
+ originX: camera.current.panX,
1778
+ originY: camera.current.panY,
1779
+ node,
1780
+ frame: 0,
1781
+ lastX: event.clientX,
1782
+ lastY: event.clientY
1783
+ };
1784
+ }
1390
1785
  (0, import_react.useEffect)(() => {
1391
- const paint = (current) => {
1786
+ const paintDrag = (current) => {
1392
1787
  current.frame = 0;
1393
1788
  const node = current.node;
1394
1789
  if (node === null) return;
1395
- const dx = (current.lastX - current.startX) / camera.zoom;
1396
- const dy = (current.lastY - current.startY) / camera.zoom;
1790
+ const zoomNow = camera.current.zoom;
1791
+ const dx = (current.lastX - current.startX) / zoomNow;
1792
+ const dy = (current.lastY - current.startY) / zoomNow;
1397
1793
  node.style.transform = `translate3d(${dx}px, ${dy}px, 0) rotate(${current.rotate}deg)`;
1398
1794
  };
1795
+ const paintPan = (current) => {
1796
+ current.frame = 0;
1797
+ camera.current.panX = current.originX + (current.lastX - current.startX);
1798
+ camera.current.panY = current.originY + (current.lastY - current.startY);
1799
+ applyCamera();
1800
+ };
1399
1801
  const move = (event) => {
1400
1802
  const current = drag.current;
1401
- if (current === null || event.pointerId !== current.pointerId) return;
1402
- current.lastX = event.clientX;
1403
- current.lastY = event.clientY;
1404
- if (!current.moved) {
1405
- if (Math.hypot(event.clientX - current.startX, event.clientY - current.startY) < DRAG_THRESHOLD) return;
1406
- current.moved = true;
1803
+ if (current !== null && event.pointerId === current.pointerId) {
1804
+ current.lastX = event.clientX;
1805
+ current.lastY = event.clientY;
1806
+ if (!current.moved) {
1807
+ if (Math.hypot(event.clientX - current.startX, event.clientY - current.startY) < DRAG_THRESHOLD) return;
1808
+ current.moved = true;
1809
+ }
1810
+ if (current.frame === 0) current.frame = requestAnimationFrame(() => paintDrag(current));
1811
+ return;
1812
+ }
1813
+ const panning = pan.current;
1814
+ if (panning !== null && event.pointerId === panning.pointerId) {
1815
+ panning.lastX = event.clientX;
1816
+ panning.lastY = event.clientY;
1817
+ if (panning.frame === 0) panning.frame = requestAnimationFrame(() => paintPan(panning));
1407
1818
  }
1408
- if (current.frame === 0) current.frame = requestAnimationFrame(() => paint(current));
1409
1819
  };
1410
1820
  const finish = (event) => {
1821
+ const panning = pan.current;
1822
+ if (panning !== null && event.pointerId === panning.pointerId) {
1823
+ pan.current = null;
1824
+ if (panning.frame !== 0) {
1825
+ cancelAnimationFrame(panning.frame);
1826
+ panning.frame = 0;
1827
+ camera.current.panX = panning.originX + (panning.lastX - panning.startX);
1828
+ camera.current.panY = panning.originY + (panning.lastY - panning.startY);
1829
+ applyCamera();
1830
+ }
1831
+ panning.node?.removeAttribute("data-panning");
1832
+ }
1411
1833
  const current = drag.current;
1412
1834
  if (current === null || event.pointerId !== current.pointerId) return;
1413
1835
  drag.current = null;
1414
1836
  if (current.frame !== 0) cancelAnimationFrame(current.frame);
1415
1837
  const node = current.node;
1416
- if (node !== null) {
1417
- node.removeAttribute("data-dragging");
1418
- node.style.transform = `translate3d(0, 0, 0) rotate(${current.rotate}deg)`;
1838
+ const zoomNow = camera.current.zoom;
1839
+ const release = () => {
1419
1840
  if (current.captured) {
1420
1841
  try {
1421
- node.releasePointerCapture?.(event.pointerId);
1842
+ node?.releasePointerCapture?.(event.pointerId);
1422
1843
  } catch {
1423
1844
  }
1424
1845
  }
1425
- }
1426
- if (!current.moved) return;
1427
- const dx = (current.lastX - current.startX) / camera.zoom;
1428
- const dy = (current.lastY - current.startY) / camera.zoom;
1429
- const layout = {
1430
- x: current.originX + dx,
1431
- y: current.originY + dy,
1432
- rotate: current.rotate,
1433
- width: current.width
1434
1846
  };
1435
- void mutate(async () => {
1847
+ if (!current.moved) {
1848
+ node?.removeAttribute("data-dragging");
1849
+ if (node !== null) node.style.transform = `rotate(${current.rotate}deg)`;
1850
+ release();
1851
+ return;
1852
+ }
1853
+ const dx = (current.lastX - current.startX) / zoomNow;
1854
+ const dy = (current.lastY - current.startY) / zoomNow;
1855
+ const layout = clampLayout({ x: current.originX + dx, y: current.originY + dy, rotate: current.rotate, width: current.width });
1856
+ if (node !== null) {
1857
+ node.removeAttribute("data-dragging");
1858
+ node.style.transform = `rotate(${current.rotate}deg)`;
1859
+ node.style.left = `${layout.x}px`;
1860
+ node.style.top = `${layout.y}px`;
1861
+ release();
1862
+ }
1863
+ setNotes((previous) => previous.map((note) => note.id === current.id ? { ...note, layout } : note));
1864
+ live.current.mutate(async () => {
1436
1865
  await api.move(current.id, layout, life.current.signal);
1437
1866
  });
1438
1867
  };
@@ -1445,50 +1874,90 @@ window.__ModuleLoader__.load({
1445
1874
  window.removeEventListener("pointercancel", finish);
1446
1875
  const pending = drag.current;
1447
1876
  if (pending !== null && pending.frame !== 0) cancelAnimationFrame(pending.frame);
1877
+ const pendingPan = pan.current;
1878
+ if (pendingPan !== null && pendingPan.frame !== 0) cancelAnimationFrame(pendingPan.frame);
1879
+ pan.current?.node?.removeAttribute("data-panning");
1448
1880
  };
1449
- }, [camera.zoom, api, mutate]);
1450
- function onWheel(event) {
1451
- if (!event.ctrlKey && !event.metaKey) return;
1452
- event.preventDefault();
1453
- const next = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, camera.zoom - event.deltaY * 2e-3));
1454
- setCamera((current) => ({ ...current, zoom: next }));
1455
- }
1456
- const zoomBy = (delta) => {
1457
- setCamera((current) => ({ ...current, zoom: Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, current.zoom + delta)) }));
1881
+ }, [api, applyCamera]);
1882
+ const latestActions = (0, import_react.useRef)(null);
1883
+ latestActions.current = {
1884
+ edit: openComposer,
1885
+ patch: (note, patch) => {
1886
+ void mutate(async () => {
1887
+ await api.update(note.id, patch, life.current.signal);
1888
+ });
1889
+ },
1890
+ remove: (note) => setConfirming(note),
1891
+ resize: (note, width) => {
1892
+ void mutate(async () => {
1893
+ const current = notes.find((candidate) => candidate.id === note.id);
1894
+ if (current !== void 0) await api.move(note.id, { ...layoutOf(current, stableIndex.get(current.id) ?? 0), width }, life.current.signal);
1895
+ });
1896
+ },
1897
+ drag: startDrag
1458
1898
  };
1899
+ const actions = (0, import_react.useMemo)(() => ({
1900
+ edit: (note) => latestActions.current?.edit(note),
1901
+ patch: (note, patch) => latestActions.current?.patch(note, patch),
1902
+ remove: (note) => latestActions.current?.remove(note),
1903
+ resize: (note, width) => latestActions.current?.resize(note, width),
1904
+ drag: (note, event) => latestActions.current?.drag(note, event)
1905
+ }), []);
1459
1906
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("section", { className: "skw-page", "aria-label": t("title"), children: [
1460
1907
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("style", { children: WALL_CSS }),
1461
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("header", { className: "skw-head", children: [
1462
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-head-text", children: [
1463
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("h1", { className: "skw-title", children: [
1464
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-title-mark", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarGlyph, { size: 15 }) }),
1465
- t("title")
1466
- ] }),
1467
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-subtitle", children: t("subtitle") })
1908
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-body", "data-view": view, children: [
1909
+ error !== "" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "skw-error", role: "alert", children: [
1910
+ error,
1911
+ " ",
1912
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-btn skw-btn-quiet", type: "button", onClick: () => void reload({ includeArchived, sort }), children: t("retry") })
1468
1913
  ] }),
1469
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-actions", children: [
1470
- archivedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-btn skw-btn-quiet", type: "button", onClick: () => setConfirming("clear"), disabled: busy, children: t("clearArchived") }),
1471
- view === "canvas" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1472
- "button",
1473
- {
1474
- className: "skw-btn skw-btn-quiet",
1475
- type: "button",
1476
- disabled: busy || visible.length === 0,
1477
- onClick: () => void mutate(async () => {
1478
- await api.arrange(life.current.signal);
1479
- }),
1480
- children: t("arrange")
1481
- }
1482
- ),
1483
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("button", { className: "skw-btn skw-btn-primary", type: "button", onClick: () => openComposer(), disabled: busy, children: [
1484
- "+ ",
1485
- t("new")
1914
+ loading && notes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-empty", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: t("loading") }) }) : view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-list", children: [
1915
+ visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NoteRow, { note, t, locale: activeLocale, onEdit: openComposer }, note.id)),
1916
+ visible.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-list-empty", children: emptyCopy })
1917
+ ] }) : view === "grid" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-grid", children: [
1918
+ visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NoteCard, { note, index: indexOf(note), surface: "grid", t, locale: activeLocale, actions }, note.id)),
1919
+ visible.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-list-empty", children: emptyCopy })
1920
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { ref: bindViewport, className: "skw-canvas", "data-zoomed": zoom !== 1, onPointerDown: startPan, children: [
1921
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: worldRef, className: "skw-world", children: visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NoteCard, { note, index: indexOf(note), surface: "canvas", t, locale: activeLocale, actions }, note.id)) }),
1922
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-centre", "aria-hidden": false, children: [
1923
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-centre-hello", children: greeting }),
1924
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "skw-centre-tally", "data-empty": visible.length === 0, children: visible.length === 0 ? emptyCopy : t("centreTally", { count: visible.length, archived: archivedCount }) }),
1925
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1926
+ "form",
1927
+ {
1928
+ className: "skw-capture",
1929
+ onSubmit: (event) => {
1930
+ event.preventDefault();
1931
+ const body = capture.trim();
1932
+ if (body === "" || busy) return;
1933
+ void mutate(async () => {
1934
+ await api.create({ body }, life.current.signal);
1935
+ setCapture("");
1936
+ });
1937
+ },
1938
+ children: [
1939
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-capture-icon", "aria-hidden": "true", children: "\u270E" }),
1940
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1941
+ "input",
1942
+ {
1943
+ className: "skw-capture-input",
1944
+ value: capture,
1945
+ placeholder: t("capturePlaceholder"),
1946
+ "aria-label": t("capturePlaceholder"),
1947
+ maxLength: LIMITS.body,
1948
+ onChange: (event) => setCapture(event.target.value)
1949
+ }
1950
+ ),
1951
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-capture-go", type: "submit", disabled: busy || capture.trim() === "", "aria-label": t("captureGo"), children: "\u21B5" })
1952
+ ]
1953
+ }
1954
+ )
1486
1955
  ] })
1487
1956
  ] })
1488
1957
  ] }),
1489
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-toolbar", children: [
1490
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-search-wrap", children: [
1491
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-search-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", children: [
1958
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-dock", role: "toolbar", "aria-label": t("title"), children: [
1959
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-dock-group", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-search-wrap", children: [
1960
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-search-icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "13", height: "13", viewBox: "0 0 24 24", fill: "none", children: [
1492
1961
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "10.5", cy: "10.5", r: "6.2", stroke: "currentColor", strokeWidth: "1.8" }),
1493
1962
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M15.4 15.4L20 20", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })
1494
1963
  ] }) }),
@@ -1503,100 +1972,49 @@ window.__ModuleLoader__.load({
1503
1972
  onChange: (event) => setQuery(event.target.value)
1504
1973
  }
1505
1974
  )
1975
+ ] }) }),
1976
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-dock-group", children: [
1977
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("filters"), children: ["all", "pinned", "archived"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": filter === key, onClick: () => setFilter(key), children: key === "all" ? t("all") : key === "pinned" ? t("pin") : t("archive") }, key)) }),
1978
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1979
+ "button",
1980
+ {
1981
+ className: "skw-toggle",
1982
+ type: "button",
1983
+ "data-on": showArchived,
1984
+ "aria-pressed": showArchived,
1985
+ onClick: () => setShowArchived((value) => !value),
1986
+ children: showArchived ? t("hideArchived") : t("showArchived")
1987
+ }
1988
+ )
1506
1989
  ] }),
1507
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("filters"), children: ["all", "pinned", "archived"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": filter === key, onClick: () => setFilter(key), children: key === "all" ? t("all") : key === "pinned" ? t("pin") : t("archive") }, key)) }),
1508
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1509
- "button",
1510
- {
1511
- className: "skw-toggle",
1512
- type: "button",
1513
- "data-on": showArchived,
1514
- "aria-pressed": showArchived,
1515
- onClick: () => setShowArchived((value) => !value),
1516
- children: showArchived ? t("hideArchived") : t("showArchived")
1517
- }
1518
- ),
1519
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("sortPinned"), children: ["pinned", "created", "updated"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": sort === key, onClick: () => setSort(key), children: key === "pinned" ? t("sortPinned") : key === "created" ? t("sortCreated") : t("sortUpdated") }, key)) }),
1520
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg skw-view-seg", role: "group", "aria-label": t("viewLabel"), children: ["canvas", "grid", "list"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": view === mode, onClick: () => setView(mode), "aria-label": t(`view_${mode}`), children: t(`view_${mode}`) }, mode)) }),
1521
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-count", children: t("count", { count: visible.length }) })
1522
- ] }),
1523
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-body", "data-view": view, children: [
1524
- error !== "" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: "skw-error", role: "alert", children: [
1525
- error,
1526
- " ",
1527
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-btn skw-btn-quiet", type: "button", onClick: () => void reload({ includeArchived, sort }), children: t("retry") })
1990
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-dock-group", children: [
1991
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("viewLabel"), children: ["canvas", "grid", "list"].map((mode) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": view === mode, onClick: () => setView(mode), "aria-label": t(`view_${mode}`), children: t(`view_${mode}`) }, mode)) }),
1992
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-seg", role: "group", "aria-label": t("sortPinned"), children: ["pinned", "created", "updated"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { type: "button", "data-on": sort === key, onClick: () => setSort(key), children: key === "pinned" ? t("sortPinned") : key === "created" ? t("sortCreated") : t("sortUpdated") }, key)) })
1528
1993
  ] }),
1529
- loading && notes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-empty", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: t("loading") }) }) : visible.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-empty", children: [
1530
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-empty-icon", "aria-hidden": "true", children: "\u{1F5D2}\uFE0F" }),
1531
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: filter === "archived" ? t("emptyArchived") : query.trim() !== "" ? t("noResults") : t("empty") }),
1532
- filter !== "archived" && query.trim() === "" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-btn", type: "button", onClick: () => openComposer(), children: t("new") })
1533
- ] }) : view === "list" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-list", children: visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NoteRow, { note, t, locale: activeLocale, onEdit: openComposer }, note.id)) }) : view === "grid" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-grid", children: visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1534
- NoteCard,
1535
- {
1536
- note,
1537
- index: indexOf(note),
1538
- t,
1539
- locale: activeLocale,
1540
- onEdit: openComposer,
1541
- onPatch: (target, patch) => void mutate(async () => {
1542
- await api.update(target.id, patch, life.current.signal);
1543
- }),
1544
- onRemove: (target) => setConfirming(target),
1545
- onResize: (target, width) => void mutate(async () => {
1546
- const current = notes.find((candidate) => candidate.id === target.id);
1547
- if (current !== void 0) await api.move(target.id, { ...layoutOf(current, stableIndex.get(current.id) ?? 0), width }, life.current.signal);
1548
- }),
1549
- onDragStart: () => {
1994
+ view === "canvas" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-dock-group skw-dock-zoom", role: "group", "aria-label": t("zoomLabel"), children: [
1995
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-camera-btn", type: "button", "aria-label": t("zoomOut"), onClick: () => zoomTo(zoom - 0.15), children: "\u2212" }),
1996
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "skw-camera-value", children: [
1997
+ Math.round(zoom * 100),
1998
+ "%"
1999
+ ] }),
2000
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-camera-btn", type: "button", "aria-label": t("zoomIn"), onClick: () => zoomTo(zoom + 0.15), children: "+" }),
2001
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-camera-btn", type: "button", "aria-label": t("zoomReset"), onClick: resetView, children: "\u2316" }),
2002
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2003
+ "button",
2004
+ {
2005
+ className: "skw-camera-btn",
2006
+ type: "button",
2007
+ "aria-label": t("arrange"),
2008
+ title: t("arrange"),
2009
+ disabled: busy || visible.length === 0,
2010
+ onClick: () => void tidyWall(),
2011
+ children: "\u2727"
1550
2012
  }
1551
- },
1552
- note.id
1553
- )) }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-canvas-scroll", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1554
- "div",
1555
- {
1556
- ref: canvasRef,
1557
- className: "skw-canvas",
1558
- "data-zoomed": camera.zoom !== 1,
1559
- style: { width: `${extent.width}px`, height: `${extent.height}px` },
1560
- onWheel,
1561
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-world", style: { transform: `scale(${camera.zoom})`, transformOrigin: "0 0" }, children: visible.map((note) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "skw-note-slot", "data-note-id": note.id, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1562
- NoteCard,
1563
- {
1564
- note,
1565
- index: indexOf(note),
1566
- t,
1567
- locale: activeLocale,
1568
- onEdit: openComposer,
1569
- onPatch: (target, patch) => void mutate(async () => {
1570
- await api.update(target.id, patch, life.current.signal);
1571
- }),
1572
- onRemove: (target) => setConfirming(target),
1573
- onResize: (target, width) => void mutate(async () => {
1574
- const current = notes.find((candidate) => candidate.id === target.id);
1575
- if (current !== void 0) await api.move(target.id, { ...layoutOf(current, stableIndex.get(current.id) ?? 0), width }, life.current.signal);
1576
- }),
1577
- onDragStart: startDrag
1578
- }
1579
- ) }, note.id)) })
1580
- }
1581
- ) })
1582
- ] }),
1583
- view === "canvas" && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "skw-cameras", role: "group", "aria-label": t("zoomLabel"), children: [
1584
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-camera-btn", type: "button", "aria-label": t("zoomOut"), onClick: () => zoomBy(-0.15), children: "\u2212" }),
1585
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "skw-camera-value", children: [
1586
- Math.round(camera.zoom * 100),
1587
- "%"
2013
+ )
1588
2014
  ] }),
1589
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-camera-btn", type: "button", "aria-label": t("zoomIn"), onClick: () => zoomBy(0.15), children: "+" }),
1590
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1591
- "button",
1592
- {
1593
- className: "skw-camera-btn",
1594
- type: "button",
1595
- "aria-label": t("zoomReset"),
1596
- onClick: () => setCamera({ zoom: 1 }),
1597
- children: "\u2316"
1598
- }
1599
- )
2015
+ archivedCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-dock-quiet", type: "button", onClick: () => setConfirming("clear"), disabled: busy, children: t("clearArchived") }),
2016
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "skw-count", children: t("count", { count: visible.length }) }),
2017
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { className: "skw-dock-new", type: "button", onClick: () => openComposer(), disabled: busy, "aria-label": t("new"), children: "+" })
1600
2018
  ] }),
1601
2019
  draft && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1602
2020
  Composer,