@n-uf/placement 26.11.24 → 26.11.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/README.md +143 -41
  3. package/dist/{chunk-LPMZ2FFR.js → chunk-3P6VOXA6.js} +2 -2
  4. package/dist/chunk-3P6VOXA6.js.map +1 -0
  5. package/dist/{chunk-CJA6LRHN.js → chunk-7ASCUAGV.js} +5 -7
  6. package/dist/chunk-7ASCUAGV.js.map +1 -0
  7. package/dist/chunk-CIGRI35P.js +1999 -0
  8. package/dist/chunk-CIGRI35P.js.map +1 -0
  9. package/dist/{chunk-RL3QB5SM.js → chunk-IHU6IOZH.js} +135 -19
  10. package/dist/chunk-IHU6IOZH.js.map +1 -0
  11. package/dist/{chunk-2H3CSPEH.js → chunk-OYGOJWAX.js} +2 -2
  12. package/dist/chunk-WM5FJ3IS.js +47 -0
  13. package/dist/chunk-WM5FJ3IS.js.map +1 -0
  14. package/dist/{constructions-VDK_mwmz.d.ts → constructions-DSEjvWMP.d.ts} +1 -1
  15. package/dist/desk.d.ts +3 -3
  16. package/dist/desk.js +3 -3
  17. package/dist/dock.d.ts +3 -3
  18. package/dist/dock.js +2 -2
  19. package/dist/float-fit-DRSOU_2y.d.ts +37 -0
  20. package/dist/geometry-CkZ6Fcfb.d.ts +48 -0
  21. package/dist/index.d.ts +3 -2
  22. package/dist/index.js +21 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/{model-DPTu2EtG.d.ts → model-Bd0oELzF.d.ts} +9 -1
  25. package/dist/{targets-DwwIWPpN.d.ts → model-Dz4R5ydE.d.ts} +36 -116
  26. package/dist/panels.d.ts +5 -4
  27. package/dist/panels.js +6 -5
  28. package/dist/scene-cases.d.ts +9 -5
  29. package/dist/scene-cases.js +18 -17
  30. package/dist/scene-cases.js.map +1 -1
  31. package/dist/scene.d.ts +69 -37
  32. package/dist/scene.js +6 -3
  33. package/dist/stack.d.ts +53 -33
  34. package/dist/stack.js +4 -98
  35. package/dist/stack.js.map +1 -1
  36. package/dist/{target-D3PiLg44.d.ts → target-CEVCfJd-.d.ts} +4 -2
  37. package/dist/{targets-B6eLC-52.d.ts → targets-BPG7Kf02.d.ts} +4 -6
  38. package/dist/targets.d.ts +4 -4
  39. package/dist/targets.js +6 -7
  40. package/dist/targets.js.map +1 -1
  41. package/dist/toolbar.d.ts +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-CJA6LRHN.js.map +0 -1
  44. package/dist/chunk-LPMZ2FFR.js.map +0 -1
  45. package/dist/chunk-QMTNB2C3.js +0 -17
  46. package/dist/chunk-QMTNB2C3.js.map +0 -1
  47. package/dist/chunk-RL3QB5SM.js.map +0 -1
  48. package/dist/chunk-XUC5BU4N.js +0 -1669
  49. package/dist/chunk-XUC5BU4N.js.map +0 -1
  50. package/dist/geometry-mL-GTRti.d.ts +0 -28
  51. /package/dist/{chunk-2H3CSPEH.js.map → chunk-OYGOJWAX.js.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,140 @@
3
3
  Versions are calendar versions, `YY.M.R` (year, month of the release, counter within the month), shared with
4
4
  `@n-uf/motion`: both packages carry the same version, and a release bumps both.
5
5
 
6
+ ## 26.11.26
7
+
8
+ - Notes for hosts: every `SceneItemLayout` now carries `hidden` (an empty array when nothing is hidden), so a host that
9
+ compares layouts as JSON sees every item change once. A column whose items are all closed keeps its give-way notes
10
+ (e.g. `column-folded`) in `layout.notes` while nothing of it is drawn; read notes for the edges you draw.
11
+
12
+ - `@n-uf/placement/stack` and `/scene`, **forms carry what they hide** (additive). A toolbar's compact variants are
13
+ more row forms between its full row and its next form, each at its own size (its "+N" cell counted) with
14
+ **`StackForm.hides`**, the control ids it leaves out against the item's first form (any form may set it). The ladder
15
+ is unchanged: variants are taken in order, give way by priority then age and come back in the exact reverse.
16
+ **`SceneItemLayout.hidden`** is the chosen form's `hides` on every item (empty when none, or in a » menu); `form`
17
+ already names the variant, so there is no separate field. `after()` previews the variant a drop lands in. A drop onto
18
+ a title bar lands in a form of its first form's kind (the full row or a variant), read from the forms rather than
19
+ from index 0. **Typing:** code that builds a `SceneItemLayout` itself needs `hidden`.
20
+
21
+ - `@n-uf/placement/stack`, **Changed: a growing fixed item (a title) holds its natural length first.** While the other
22
+ items of its stack can still step to a form of the kind they are in (a toolbar's compact variants) or shrink toward
23
+ their least, they do so before the title gives up any of its natural width; then the title shrinks, and after it come
24
+ the steps that change a form's kind (icons, fold, the » menu), by priority then age. Room coming back is the exact
25
+ reverse. In a title bar a narrowing window now steps toolbar variants (and shrinks toolbars) before the title, and a
26
+ toolbar dropped onto a crowded title bar lands in its compact variant. `StackFit.need` is the forms' least with every
27
+ growing fixed item at its minimum.
28
+
29
+ - `@n-uf/placement/scene`, **Fixed: a closed item is not a removed one.** A column whose items are all closed keeps its
30
+ fold history (`column-folded` / `kept-folded` notes, at their place in the order) while they are closed, and when its
31
+ items open again (`previous` being the layout with them closed) they come back with their ages and that history
32
+ applies again: closing whole columns and opening them at the same width gives the layout from before the close.
33
+ Items opened together keep their order among themselves. An item opened beside items that stayed open in its edge is
34
+ still a request to show it (the newest there, its column weighed anew). A shrink isn't kept: a reopened column
35
+ shrinks again by the usual order.
36
+
37
+ - `@n-uf/placement/scene` and `/stack`, **the Scene owns the whole window**. Nothing published is removed.
38
+ - **What moved:** `fitFloat` and `FloatFit` are exported by `./scene` (the Scene fits its floats with it). `./scene`
39
+ no longer reaches into `./stack`'s files: it uses `./stack` only as the edge solver, through its entry.
40
+ `solve` and `targets` are split by phase into smaller modules; their results are unchanged.
41
+ - **Deprecated in `./stack`**, each with its Scene replacement, until the next breaking release:
42
+ `stackTargets`, `StackTarget`, `StackPlace`, `StackTargetOptions` → `targets(scene, id)` (`SceneTarget`,
43
+ `ScenePlace`, `SceneTargetOptions`); `createStack`, `storeStack`, `readStack`, `StackState`, `StoredStack`,
44
+ `StackRead` → `storeScene` / `readScene`; `stackFloatTarget`, `FloatTarget`, `FloatDrop`, `StackFloatTargetInput`
45
+ → the `float:<id>` target of `targets()`; `storeFloats`, `readFloats`, `StoredFloats`, `FloatsRead`, `StackFloat`
46
+ → the stored scene's floats (`Scene.floats`); `fitFloat`, `FloatFit` → the same names from `./scene`.
47
+ - **Stays in `./stack`:** the edge solver, `fitStack` with `StackInput`, `StackItem`, `StackFit`, and the form
48
+ vocabulary (`StackForm`, `CrossLimits` and the form helpers).
49
+
50
+ - `@n-uf/placement/scene`, **Changed: space ownership, refined** (the 26.11.25 target model's rules):
51
+ - A refused place owns nothing against other edges: an edge owns its band only along the stretches its surviving
52
+ slots tile (home's place aside), and a refusal takes only what every surviving target's tile and every other
53
+ edge's drawn rect leave (within its own edge a refusal keeps its tile). So a panel
54
+ can always become its own column beside the others: in a window with no inset and a side bar, an empty rail that
55
+ would refuse the drop no longer hides the new-column target just inside the bar (`column:<side>:<ring>`); and an
56
+ empty top bar whose zone holds only the dragged item's place no longer covers a column's top band.
57
+ - A stretch is owned by what the user sees there; if the owner has no slot there, it refuses. Until a target shows,
58
+ the host draws the layout as it is now, so an edge that moves when the dragged item lifts (a side bar pushed inward
59
+ by a rail that empties) still owns where it is seen, unless another edge lies there once the item has lifted; what
60
+ its own tiles don't cover there is its refusal, with its zone's reason. No stretch under an edge as it is now is
61
+ left to the float.
62
+ - Clipping changes a slot's shape, never who owns it: whatever is left of a slot's tile is the slot's. A target left
63
+ in pieces has **`hits`** (every piece; additive, optional on `Target`), `hit` the largest piece for hosts that
64
+ read one rect. `pickTarget` (`./scene/cases`) tests every piece. Nothing of a slot's own room is refused any more.
65
+
66
+ ## 26.11.25
67
+
68
+ - `@n-uf/placement` (root), **one geometry** (additive): the rect math every entry shares is the root's: `EPS`,
69
+ `PLANE`, `area`, `overlaps`, `contains`, `clamp`, `subtract` (a rect less another, as disjoint rects), and the hit
70
+ sizes `COLUMN_REACH` and `RAIL_EDGE`, next to `rect`, `overlap`, `clampInto` and `centre`. The **`Target`** type
71
+ (a drop target's shape) is the root's too. **What moved:** `Target` from `./targets` (which still exports it) to
72
+ the root; `COLUMN_REACH` and `RAIL_EDGE` from `./panels` (which still exports them) to the root; the private copies
73
+ in `./scene`, `./stack`, `./panels` and `./targets` are gone. Nothing else changes.
74
+
75
+ - `@n-uf/placement/scene`, **Changed: one target model**. `targets` and `refusals` come from one
76
+ generation: edge → zones → slots → tiles, then one ordered filter (accepts and zones, fit, clipping, `blocked`). Every
77
+ point of an edge that takes the dragged kind is one target or one refusal of its own zone (a property check over
78
+ generated windows: no hole, no overlap, no other zone, the item's own rect only home, every slot its landing).
79
+ `targets`, `after`, `refusals`, `stops`, `SceneTarget` and the priorities keep their shape. Some ids change, as
80
+ listed below; no id is given twice by one call. What changes:
81
+ - A zone's extent is where its items lie: the thirds of a bar, a compact rail or a side toolbar bar (compact bars and
82
+ rails too, now); the solver's spans where items fill the edge (a plain panel column is one zone, its whole length;
83
+ a tray column its panels' span and its tray's).
84
+ - Home's tile is the item's own interval: no ±12 px band, no 16 px kept per gap. A stretch with no slot of its own
85
+ is refused, never home's and never another zone's: beside an item alone in its zone with the new reason
86
+ **`own-place`** (there is room, but the zone's only place is the item's own), elsewhere `no-room`.
87
+ - A refused slot is refused over its own tile; a zone may have more than one refusal: `refuse:<edge>:<zone>`, then
88
+ `refuse:<edge>:<zone>:<n>`, numbered by where they lie along the edge (then across it), so an id holds from one
89
+ frame to the next.
90
+ - `strip:<edge>:<zone>` names a slot only on an edge with no members at all. On an edge that draws nothing but holds
91
+ closed members (or the dragged item's own place), every slot keeps its `gap:<edge>:<zone>:<at>` id.
92
+ - A place that would move a fixed item of its edge (before a title, after the window controls) is no slot.
93
+ - With no rail shown, the `rail:` strip is `RAIL_EDGE` px of `SceneLayout.railPlaces` (where the rail lands).
94
+ - The column lines and the rail are edges like the others, tiled by the same rule: two column lines nearer than
95
+ `2 × COLUMN_REACH` meet halfway; a column line or rail stop whose drop wouldn't land or fit, and any piece clipping
96
+ cuts off its tile, is refused (`refuse:column:<side>:start`, `refuse:rail:<side>:start`, `no-room`) instead of
97
+ being left to the float.
98
+ - **Space ownership** decides where tiles meet: owned, then virtual, then overreach.
99
+ - A drawn edge owns its rect. An empty edge owns only a thin band of its place, half the hit band (12 px), at the
100
+ boundary where it would appear; so does the side's rail where none shows. The item's own place (home's tile) is
101
+ owned before everything.
102
+ - Owned rects rank in the order the layout lays edges out: an edge laid first, whose filling pushes the other, wins
103
+ (outer before inner on one side, full bars before the sides, the rail before its side's columns). Between edges
104
+ laid independently, a drawn rect wins over an empty edge's band.
105
+ - A zone loses what an edge ranked before it owns, its panel bodies and its reserved rects before it is tiled; a
106
+ zone left with no room offers no slot. Every slot that is offered keeps a hit.
107
+ - A column line is where a new column would appear, so it owns a place band like an empty edge: half the hit band
108
+ (12 px) in all, centred on its line, ranked where that new column would be laid (it wins over the inner column it
109
+ would push, not over the outer one). Past that band its tile takes only space no edge owns. Two columns that
110
+ touch keep the line at their seam; a narrow column keeps its gaps in the rest of its own rect.
111
+ - Overreach, the part of a tile past what its edge owns (the depth a column will have after the drop, an empty
112
+ strip past its band, a compact rail's inward reach), comes last: it yields to the column lines and to every other
113
+ edge's owned rect, and it stays a tile's only where it meets the owned part along its whole length. A compact
114
+ rail's reach no longer covers the next column's rect.
115
+ - Slots that are the same move (one line and one landing, or both putting the item back) are one slot, the lowest
116
+ `at` keeping its id.
117
+ - An overlay column is drawn on top, and what shows on top wins: an empty rail's place under an overlay column
118
+ offers no `rail:` stop there, and a column line beside an overlay column yields to it.
119
+
120
+ - Typing: `SceneRefusal["reason"]` gains `own-place`; an exhaustive `switch` over it needs the case.
121
+
122
+ **Migration:** match refusals by `refuse:<edge>:<zone>` prefix and read `own-place` as "back to its place"; read
123
+ `home:<id>` (unchanged, over the own rect) for "back to its place"; expect no target over a stretch beside a lone
124
+ item, a refusal there instead; match `gap:<edge>:<zone>:<at>` for an edge that holds only closed members.
125
+
126
+ - `@n-uf/placement/scene`, **`SceneLayout.railPlaces`** (additive): where each side's rail lies, or would lie were one
127
+ shown, for every side with a rail (`Scene.rails`): the shown rail's rect, else where a drop into the rail lands.
128
+ `targets` reads it. Hosts draw `rails` (only shown rails, unchanged), never `railPlaces`.
129
+
130
+ - `@n-uf/placement/scene`, **Changed:** every empty edge's strip is by zone, as an empty bar's has been since
131
+ 26.11.19: `strip:<edge>:start|center|end`, by thirds along the edge (a side edge's or a compact rail's height), the
132
+ item docking aligned in that third (top, middle or bottom of a side). It used to be one `strip:<edge>` landing at the
133
+ start, so an empty rail took every drop at its top. Affected: left and right edges (static columns, column trays,
134
+ side toolbar bars) and compact rails on any side. Only the thirds whose zone takes the kind (`Edge.zoneAccepts`) are
135
+ strips; the others are refusals (`refusals()`). A kind still never opens an empty side column its start zone doesn't
136
+ take (a group gets the rail, never a column of one toolbar). The strips keep every strip rule
137
+ (clipped, clear of home, no sliver, preview = landing). **Migration:** match `strip:<edge>:<zone>` where a host
138
+ matched `strip:<edge>`.
139
+
6
140
  ## 26.11.24
7
141
 
8
142
  - `@n-uf/placement/scene`, **fixed:** `columnRoom` counts a side toolbar bar. A left or right bar that lays out an item
package/README.md CHANGED
@@ -22,8 +22,13 @@ Its sibling [`@n-uf/motion`](https://www.npmjs.com/package/@n-uf/motion) owns ho
22
22
  without importing each other: a target list from `@n-uf/placement/targets` is exactly what
23
23
  `@n-uf/motion/drag`'s drag intent takes, and a rect from any layout here is what `@n-uf/motion/layout` glides to.
24
24
 
25
- - **`@n-uf/placement`**: the shapes (`Rect`, `Size`, `Point`) and a popup positioner, as Wayland's xdg-positioner: an anchor
26
- point, gravity and offset, then flip, slide and resize, each only when the rule allows it.
25
+ - **`@n-uf/placement`**: the shapes (`Rect`, `Size`, `Point`), the geometry every entry shares, and a popup positioner,
26
+ as Wayland's xdg-positioner: an anchor point, gravity and offset, then flip, slide and resize, each only when the
27
+ rule allows it. The geometry is `rect`, `overlap`, `clampInto`, `centre`, `EPS`, `PLANE`, `area`, `overlaps`,
28
+ `contains`, `clamp` and `subtract` (a rect less another, as disjoint rects), with the hit sizes `COLUMN_REACH` (22 px,
29
+ each way of a column line) and `RAIL_EDGE` (10 px). The `Target` type (a drop target's shape, as
30
+ `@n-uf/motion/drag` takes it) is exported here too, with its optional `hits` (every piece of a zone that isn't one
31
+ rect; `hit` is the largest); `./targets` and `./panels` still export it and the hit sizes.
27
32
  - **`/dock`**: a desk of documents and tool panels. Side docks and a bottom dock (between the side docks or across
28
33
  the full width), rails, natural-height sections whose last one takes the rest, fold and unfold, the give-way
29
34
  rules (sections fold least recently used first, docks fold to their rails), floating palettes with corner stacks,
@@ -43,13 +48,14 @@ without importing each other: a target list from `@n-uf/placement/targets` is ex
43
48
  - **`/stack`**: the items along one edge, a column or a bar, each a panel or a control group with forms from largest to
44
49
  smallest (open, header, rail icon, » menu; row, stacked, icons, fold, » menu): one form and rect per item, giving
45
50
  way by age and `rank`, only to a form that is shorter, spare room to the panels that grow, a rail when nothing open
46
- sets the width, `gap` and `pad` in the length; a drop target for every gap, each with the exact solve a drop makes; a
47
- stored form; and floats (an item above the pages, in the stage's own px, kept inside the stage and clear of the docked
48
- items, with its drop target and stored form). Not tied to `/panels`.
49
- - **`/scene`**: one model of a whole window on `/stack`: edges cut ring by ring along the stage's sides (full and
50
- between bars, columns, overlay edges), each a stack with start, center and end zones, fixed items (a title, window
51
- controls), floats clear of every bar and chrome, one `solve` for every rect, one `targets` for every drop target
52
- of one item (each carrying the layout a release makes, so the preview is the result), pure changes and a stored form.
51
+ sets the width, `gap` and `pad` in the length. It is the edge solver `/scene` lays each edge with. Its window-level
52
+ parts (a drop target for every gap, a stored form, floats with their drop target and stored form) are
53
+ **deprecated**: `/scene` owns the window and replaces each of them (see Edge stacks). Not tied to `/panels`.
54
+ - **`/scene`**: one model of a whole window, each edge laid with `/stack`: edges cut ring by ring along the stage's
55
+ sides (full and between bars, columns, overlay edges), each a stack with start, center and end zones, fixed items (a
56
+ title, window controls), floats clear of every bar and chrome (`fitFloat`), one `solve` for every rect, one
57
+ `targets` for every drop target of one item (each carrying the layout a release makes, so the preview is the
58
+ result), pure changes and a stored form.
53
59
  - **`/scene/cases`**: the Scene's behaviour as data: conformance rows (a scene, what a user does, the layout and DOM
54
60
  expected after) and `runCase`, which plays one on a host, so a UI kit's suite and the lab run the same rows.
55
61
 
@@ -434,6 +440,11 @@ places them; it is not tied to `./panels` columns, and nothing in it is a word.
434
440
  can't go in alone: the items stuck that way go in together, in give-way order, as few as shorten the stack (two
435
441
  icons, 48 px, for one entry, 28 px); each item after that saves its whole size. If all of them together don't beat
436
442
  the entry, they stay.
443
+ - A growing fixed item (a title: `fixed`, with a form that `grows`) holds its natural length first. While the other
444
+ items can still step to a form of the kind they are in (a toolbar's compact variants, a row to a smaller row) or shrink
445
+ toward their least, they do so before the title gives up any of its natural length; then the title shrinks toward its
446
+ `main.min`, and after it come the steps that change a form's kind (icons, fold, the » menu), by rank, then age. Room
447
+ coming back is the exact reverse. `StackFit.need` is the forms' least with every growing fixed item at its minimum.
437
448
  - `StackForm.rank` (default 0) orders the steps: the lowest rank of the form an item would step into goes first, then
438
449
  unkept before kept, then the oldest, then the later in the stack. Give a pinned primary's last forms a higher rank
439
450
  and every other group gives way before it does.
@@ -468,6 +479,8 @@ places them; it is not tied to `./panels` columns, and nothing in it is a word.
468
479
  A word 1 px wider moves nothing else while the rows don't change.
469
480
  - `StackForm.grip` (px): a grip at the form's start along the stack, this long (an icons strip's horizontal grip on
470
481
  top); `./scene` reports its rect as the item's `grip`. A `wrap` form's grip is its lead cell instead.
482
+ - `StackForm.hides` (control ids): what the form leaves out against the item's first form, for a toolbar's compact
483
+ variants (see Compact variants under Scenes). The stack never reads it; `./scene` reports it as the item's `hidden`.
471
484
  - `fitStack(input, { previous })` keeps the forms of the fit the stack had before, while they still fit: a change of
472
485
  `used` ages alone (a press on a header) reshapes nothing. Ages decide only who gives way anew (the length shrank, an
473
486
  item was added, or a panel opened: its `from` went down, so it starts over). Growing never re-ranks. When the stack got
@@ -529,6 +542,12 @@ menu has the entry's rect; `menu.items` are exactly the items whose kind is `men
529
542
  into its forms), `to-menu` (`id`), `too-wide` (`id`), `no-forms` (`id`) and `overflow` (`over` px: no item can give
530
543
  more way and the stack is still too long; forms that don't end in a `menu` form can't give more).
531
544
 
545
+ > **Deprecated:** `stackTargets`, `createStack`, `storeStack`, `readStack` and the floats below (`fitFloat`,
546
+ > `stackFloatTarget`, `storeFloats`, `readFloats`) belong to the window, which `@n-uf/placement/scene` owns:
547
+ > `targets(scene, id)` replaces `stackTargets` and `stackFloatTarget` (its `float:<id>` target), `storeScene` /
548
+ > `readScene` replace the stack's and the floats' stored forms, and `fitFloat` is exported by `./scene`. They stay
549
+ > until the next breaking release. `fitStack` and the forms are the edge solver and stay.
550
+
532
551
  `stackTargets(input, dragged)` takes the stack (an item of it with the dragged id is lifted out first, so a reorder
533
552
  within a stack works) and gives a target for every gap, before each item and after the last, in the shape
534
553
  `@n-uf/motion/drag` takes: `id` `gap:<k>`, priority 2, `place` `{ kind: "gap", at: k }`, `hit` (the stack split at
@@ -796,7 +815,8 @@ is over the leading zone (`start`), in the middle third over the center zone, in
796
815
  (`end`), and within the zone the nearest of its gaps wins, each zone's gaps splitting only that zone's third. A zone whose
797
816
  toolbars run past its third spreads its gap lines inside the third, so its last gap keeps a slice of it. An empty bar's
798
817
  strip is three targets, `strip:<bar>:start`, `strip:<bar>:center` and `strip:<bar>:end` (it was one `strip:<bar>`), one
799
- per third. Columns keep their one `strip:<column>`.
818
+ per third. Every empty edge does the same along its own axis: a side edge or a compact rail by thirds of its height
819
+ (`strip:<edge>:start|center|end`, top, middle, bottom).
800
820
 
801
821
  A **title bar**, a bar with a fixed item that grows (the window title), is a constrained host: a toolbar dropped there
802
822
  must land in its first form, nothing else in the bar may change form for it, and the title keeps its natural width (it may
@@ -811,7 +831,9 @@ takes no drop in that zone. The zones are then laid with the title at its natura
811
831
  separated from it by a stretch of title.
812
832
 
813
833
  **Fixed items** (a title, window controls, a page readout) never change form, are never reordered, never dragged, and
814
- no hit covers them. Their length shrinks toward `main.min` and grows with spare room when the form `grows`; window
834
+ no hit covers them. Their length shrinks toward `main.min` and grows with spare room when the form `grows` (a title
835
+ holds its natural length while the toolbars of its bar can still step to a compact variant or shrink, and shrinks before
836
+ any step that changes a form's kind); window
815
837
  controls have `min` equal to `natural`. A stage too short for them overflows instead of folding them. A `kept` item with
816
838
  no smaller form never folds either: it reports `overflow` or `too-wide`.
817
839
 
@@ -836,6 +858,30 @@ with `orient: "column"`, a group skips its `wrap` forms and shows its next form
836
858
  whatever its `from`. An item with only `wrap` forms left has no form there: it is left out with a `no-vertical-form` note,
837
859
  so give a word group an `icons` form. A drop's `after()` gives the wrapped rect as the slot.
838
860
 
861
+ **Compact variants.** A toolbar that can drop controls before it wraps declares them as more row forms between its full
862
+ row and its next form, largest first, each at its own measured size with its "+N" cell counted, and each naming the
863
+ control ids it leaves out (`StackForm.hides`, against the item's first form; any form may set it). Variants are forms
864
+ like any other: taken in declared order, giving way by priority then age, coming back in the exact reverse. The layout
865
+ reports the chosen form's ids as `hidden` on every item (empty when it hides none or sits in a » menu), and `form`
866
+ names the variant; a host draws the kept controls and a "+N" control that lists exactly `hidden`. A drop's `after()`
867
+ previews the variant the drop lands in. A drop onto a title bar lands in a form of its first form's kind (the full row
868
+ or a variant), read from the forms.
869
+
870
+ ```ts
871
+ const zoom: SceneItem = {
872
+ id: "zoom", kind: "group", used: 3,
873
+ forms: {
874
+ row: [
875
+ f("row", 150, 150, 28), // − 86% + FIT
876
+ { ...f("row", 118, 118, 28), hides: ["fit"] }, // − 86% + "+1"
877
+ { ...f("row", 70, 70, 28), hides: ["-", "+", "fit"] }, // 86% "+3"
878
+ f("fold", 30, 30, 28),
879
+ f("menu", 0, 0, 0),
880
+ ],
881
+ },
882
+ };
883
+ ```
884
+
839
885
  **Compact edges.** `Edge.compact: true` makes a thin rail of vertical toolbars along a window side: its items take only
840
886
  their `icons` form (and the » menu after it), stacked, each item's grip the divider. An item with no `icons` form is left
841
887
  out of it with a `no-icons-form` note.
@@ -844,9 +890,11 @@ out of it with a `no-icons-form` note.
844
890
  the kinds each zone takes, and a zone not listed takes nothing. A panel column with `{ start: ["panel"], end: ["group"] }`
845
891
  has its panels at the top and a tray of toolbars at its foot (the end zone, one toolbar per row): a toolbar in the tray
846
892
  takes only its `wrap` or `icons` form, never the menu, and the panels give way first. Gaps are offered only in the zones
847
- that take the dragged kind, `moveTo` puts an item in the zone asked for, else in its own zone if that takes its kind, else in the first that does, and a group never opens such a
848
- column on its own: an empty edge offers its strip only to the kinds its start zone takes, so a group's drag gets the compact
849
- rail's strip but none for an empty panel column.
893
+ that take the dragged kind, `moveTo` puts an item in the zone asked for, else in its own zone if that takes its kind, else in the first that does. An empty edge offers
894
+ each third of its strip only to the kinds that third's zone takes (the other thirds are refusals), and a group never
895
+ opens such a column on its own: an empty side column offers its strip only to the kinds its start zone takes, so a
896
+ group's drag gets the compact rail's strips but none for an empty panel column, and a panel's gets the column's top
897
+ third.
850
898
 
851
899
  **Columns and rails.** A left or right edge with `column: true` is a dynamic column: drops make it (a `column` place, from
852
900
  `scene.columns[side]`: `accepts`, `cross`, `gap`, `pad`, `menu`), and it is deleted, its side's rings closed up, when it
@@ -908,7 +956,7 @@ none lays out as before.
908
956
  lie (by ring, then by order, no ties), and `homeFor` gives a start column's ring that way.
909
957
 
910
958
  **Floats** lie above the content in stage px, last on top. Each is moved inside the stage and clear of every docked
911
- item, every bar and every `chrome` rect (`fitFloat`), with `float-clamped`, `float-moved` or `float-covers` notes. With
959
+ item, every bar and every `chrome` rect (`fitFloat`, which `./scene` exports with `FloatFit`), with `float-clamped`, `float-moved` or `float-covers` notes. With
912
960
  `anchor` (such as `"content-top-right"`) it sits flush with that side or corner of the content and follows it until a
913
961
  drop gives it a real rect. `orient` picks the forms it uses; folded by hand (`from` over 0) it is its
914
962
  bar: that form's natural length along its orient, its other size kept.
@@ -934,10 +982,21 @@ and one whose kind changed starts over. Whenever `content` isn't the rect `previ
934
982
  refits it. Columns that gave way stay folded, in the order they folded (the fold notes' order), while the content still
935
983
  fits; room that comes back unfolds them in the reverse of that order, never by age, so a press unfolds nothing, and
936
984
  solving again from a layout changes nothing. An item docked now that was closed or absent in `previous` has just
937
- opened: it counts as the newest and takes its largest form that fits its edge as laid out. The columns' fold and shrink
938
- state still follows `previous` (only a column folded by give-way that holds the opened item is weighed again), so to
939
- reweigh a column fully, pass `fresh: [columnId]`. `fresh` (edge or item ids, on `solve` and `targets`) solves those
940
- edges without `previous`.
985
+ opened. Opened beside items that stayed open in its edge, it counts as the newest and takes its largest form that fits
986
+ its edge as laid out, and its column is weighed again. A closed item is not a removed one: opened into an edge whose
987
+ items were all closed, it comes back with its age, and the column's folds, kept while it was closed, apply again. The
988
+ columns' fold and shrink state otherwise follows `previous`, so to reweigh a column fully, pass `fresh: [columnId]`.
989
+ `fresh` (edge or item ids, on `solve` and `targets`) solves those edges without `previous`.
990
+
991
+ `use` alone never reshapes anything: ages decide only who gives way anew. A user's explicit request to show an item
992
+ is passed as `fresh`:
993
+
994
+ | Action | What to pass |
995
+ |---|---|
996
+ | focus (a press on a header) | `use` only |
997
+ | expand a folded or railed item | `use` + `fresh: [id]` |
998
+ | Keep open | `keep` + `fresh: [id]` |
999
+ | open a closed item | `open`: it counts as fresh by itself beside items that stayed open in its edge. Into an edge whose items were all closed it comes back as it was (its column may stay folded by give-way); to show it regardless, `open` + `use` + `fresh: [id]`, as for expanding |
941
1000
 
942
1001
  **Targets.** `targets(scene, id, { previous, endReach, floatSize, floatOrient })` gives, in the `@n-uf/motion/drag` shape:
943
1002
 
@@ -962,14 +1021,15 @@ edges without `previous`.
962
1021
  by is spare room: the drop shrinks it toward its natural size (to its `min` if the room needs it), so a group moved
963
1022
  out of a title bar can always go back while the room allows. No slot lies over a fixed item's reserved rect. `slot`
964
1023
  is the item's rect after the drop and `marker` the insertion line across the edge.
965
- - `strip:<edge>` (2; for an empty horizontal bar three, `strip:<bar>:start`, `:center` and `:end`, one per third, see
966
- Bar alignment zones): an empty accepting edge, a strip `Edge.strip` px deep (default 24) along its side, inside the
1024
+ - `strip:<edge>:<zone>` (2; three per empty edge, `:start`, `:center` and `:end`, one per third along the edge: a bar's
1025
+ width, a side edge's height, see Bar alignment zones): an accepting edge with no members at all (one that holds only
1026
+ closed members keeps its `gap:` ids), a strip `Edge.strip` px deep (default 24) along its side, inside the
967
1027
  content and clear of the other edges (overlay ones included), so never over a docked edge or a panel's body: a
968
1028
  full-width empty bar's strip covers only the content between the columns. A compact rail's strip alone stays at the
969
1029
  window edge, its own place. A gap hit that spans it across trims its start or end (a bar's strip along the top never
970
1030
  covers the columns' first gaps); one across its middle is left to the smaller-hit tie-break. With nothing left (an
971
- empty outer bar on a non-empty inner one, a bar's strip all under an overlay column) it has no target. Only for a
972
- kind its start zone takes (`Edge.zoneAccepts`).
1031
+ empty outer bar on a non-empty inner one, a bar's strip all under an overlay column) it has no target. A third is
1032
+ offered only for a kind its zone takes (`Edge.zoneAccepts`); the others are refusals.
973
1033
  - `float:<id>` (3, free) when `floatKinds` lists the kind: the whole plane, landing with the pointer holding the float
974
1034
  at `grab`, clamped and moved clear. It has no fixed `slot`: the slot to draw is
975
1035
  `after(point, grab).layout.items[id].rect`, for the pointer at the time.
@@ -983,24 +1043,66 @@ edges without `previous`.
983
1043
  too: no slot, nothing committed. Every rail target on the side whose rail already holds the item is a home: a segment
984
1044
  dropped on its own rail, even below the last segment, never splits or reorders it (P9).
985
1045
 
986
- **Local targets.** A target wins only where its own hit is. Home's hit is the item's own rect and half a band
987
- (`DEFAULT_HIT_BAND / 2`, 12 px) each way along its edge, across the edge's full hit thickness, cut out of every other gap
988
- hit there, so home is offered only over the item's own place, and it always covers the item's whole own rect: across
989
- it no point picks a target that moves the item. An empty bar's or edge's strip (and the `rail:` strip while no rail
990
- shows) keeps only what lies outside the item's own rect; the strip of the item's own edge, which the item alone fills,
991
- means home there, and what is left of a strip under 1 px has no target. The rest of its gaps' slices goes
992
- only to the gap beside it in the same zone; with none there, that stretch has no target (the pointer shows nothing, and a
993
- release goes home), never a "back to its place" preview far away and never a gap of another zone. Affected: the drag of
994
- an item in a bar whose zone held only its own gap (that zone's whole third used to preview home), and items whose own
995
- rect lay outside their gap's slice (home now always covers them).
996
-
997
- **Refusals.** `refusals(scene, dragged, options?)` gives the places a drop is refused, as `{ id: "refuse:<edge>:<zone>",
998
- edge, zone, hit, reason }[]` (type `SceneRefusal`): the bar zones, by thirds, that have no target (`reason: "no-room"`
999
- when the zone takes the kind but no gap of it fits, a title bar at the title's natural width say; `"not-accepted"` when
1000
- the zone or the bar doesn't take the kind), and the side edges that don't take the kind (as a whole, zone `start`). Each
1001
- hit is cut clear of every target's hit, so a pointer over one has no target there but the float. A host shows "no room
1002
- here" at the pointer over one, with no slot anywhere; a release there commits nothing, the item goes home. It takes the
1003
- same `previous` and `fresh` as `targets`.
1046
+ **The target model.** `targets` and `refusals` come from one generation: edge, then zones, then slots, then tiles, then
1047
+ one ordered filter (accepts and zones, fit, clipping, `blocked`). A target wins only where its own hit is, and every point
1048
+ of an edge that takes the dragged kind is one target or one refusal of its own zone, never a hole, an overlap or another
1049
+ zone's.
1050
+
1051
+ - **Zones.** A zone's extent is where its items lie: the thirds of a bar, of a compact rail or of a side toolbar bar;
1052
+ the solver's spans where items fill the edge (a plain panel column is one zone, its whole length; a tray column its
1053
+ panels' span and its tray's). An **empty zone is one slot**, a single place that takes the drop.
1054
+ - **Slots and tiles.** A zone's slots are the places a drop can land (before each item, after the last); the zone's
1055
+ extent is cut into one tile per slot, each tile meeting its neighbour halfway. Slots that are the same move (one line
1056
+ and one landing, or both putting the item back) are one slot, the lowest `at` keeping its id. A place that would move a
1057
+ fixed item of its edge (before a title, after the window controls) is no slot.
1058
+ - **Home.** Home's tile is the item's own interval, with no band around it: a stretch with no slot of its own is refused,
1059
+ never home's and never another zone's. Beside an item alone in its zone it is refused as `own-place`.
1060
+ - **Space ownership** decides where tiles of different edges meet: owned, then virtual, then overreach.
1061
+ - A drawn edge owns its rect. An empty edge owns only a thin place band of 12 px (half the hit band) at the boundary
1062
+ where it would appear; so does the side's rail where none shows. The item's own place is owned before everything.
1063
+ - A column line is where a new column would appear, so it owns a 12 px place band too, centred on its line. Owned rects
1064
+ are ranked by the order the layout lays edges out: an edge laid first, whose filling pushes the other, wins (outer
1065
+ before inner on one side, full bars before the sides, the rail before its side's columns, a column line over the
1066
+ inner column it would push but not the outer one). Between edges laid independently a drawn rect wins over an empty
1067
+ edge's band. Two columns that touch keep the line at their seam.
1068
+ - A zone loses what an edge ranked before it owns, and its panel bodies and reserved rects before it is tiled; a zone
1069
+ left with no room offers no slot.
1070
+ - Overreach, the part of a tile past what its edge owns (the depth a column will have after the drop, an empty
1071
+ strip past its band, a compact rail's inward reach), comes last: it yields to the column lines and to every other
1072
+ edge's owned rect.
1073
+ - An overlay column is drawn on top, and what shows on top wins: an empty rail's place under it offers no `rail:` stop
1074
+ there, and a column line beside it yields to it.
1075
+ - A refused place owns nothing against other edges, zone by zone: an edge owns its band only along the zones with a
1076
+ slot the filter keeps (home's place aside), and a refusal of a zone with none takes only what every surviving target's
1077
+ tile and every other edge's owned rect leave (within its own edge a refusal keeps its tile). So a panel can always
1078
+ become its own column beside the others: an empty rail that would refuse the drop doesn't hide the new-column target
1079
+ just inside a side bar, and an empty top bar whose zone holds only the dragged item's place doesn't cover a column's
1080
+ top band.
1081
+ - An edge that only moves when the dragged item lifts (a side bar pushed inward by a rail that empties) owns where it
1082
+ lies after the lift, where its tiles are, never its old place.
1083
+ - Clipping changes a slot's shape, never who owns it: whatever is left of a slot's tile is the slot's. A target left in
1084
+ pieces has **`hits`**, every piece (optional on `Target`), and `hit` is the largest piece, for hosts that read one
1085
+ rect; `pickTarget` (`./scene/cases`) tests every piece, as `@n-uf/motion/drag` does. Nothing of a slot's own room is
1086
+ refused.
1087
+ - **The column lines and the rail are edges like the others**, tiled by the same rule. A column line or rail stop whose
1088
+ drop wouldn't land or fit, and any piece clipping cuts off its tile, is refused (`refuse:column:<side>:start`,
1089
+ `refuse:rail:<side>:start`, `no-room`) rather than left to the float.
1090
+ - **Strips.** `strip:<edge>:<zone>` names a slot only on an edge with no members at all. On an edge that draws nothing
1091
+ but holds closed members (or the dragged item's own place), every slot keeps its `gap:<edge>:<zone>:<at>` id.
1092
+ - **`SceneLayout.railPlaces`:** where each side's rail lies, or would lie were one shown, for every side with a rail
1093
+ (`Scene.rails`): the shown rail's rect, else where a drop into the rail lands. With no rail shown, the `rail:` strip is
1094
+ `RAIL_EDGE` px of it. Targets read it; a host draws `rails` (the shown rails), never `railPlaces`.
1095
+
1096
+ **Refusals.** `refusals(scene, dragged, options?)` gives the places a drop is refused, as `{ id, edge, zone, hit,
1097
+ reason }[]` (type `SceneRefusal`): the stretches of a zone with no slot of their own, and the side edges that don't take
1098
+ the kind (as a whole, zone `start`). `reason` is `"no-room"` when the zone takes the kind but no place of it fits (a
1099
+ title bar at the title's natural width say), `"not-accepted"` when the zone or the edge doesn't take the kind, and
1100
+ **`"own-place"`** for the stretch beside an item alone in its zone: there is room, but the zone's only place is the item's
1101
+ own. An exhaustive `switch` over `SceneRefusal["reason"]` needs the `own-place` case. Ids are `refuse:<edge>:<zone>` and,
1102
+ when a zone has more than one refusal, `refuse:<edge>:<zone>:<n>`, numbered by where they lie along the edge (then
1103
+ across it), so an id holds from one frame to the next; no id is given twice by one call. A refused slot is refused over
1104
+ its own tile. A host shows "no room here" at the pointer over one, with no slot anywhere; a release there commits
1105
+ nothing, the item goes home. It takes the same `previous` and `fresh` as `targets`.
1004
1106
 
1005
1107
  A gap, column or rail target exists only where the drop keeps the whole scene sound (C29): it adds no `overflow` or
1006
1108
  `too-wide` note to any edge, changes no fixed item's form, squeezes none under its `main.min` anywhere (a between bar
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  clampInto,
3
3
  rect
4
- } from "./chunk-QMTNB2C3.js";
4
+ } from "./chunk-WM5FJ3IS.js";
5
5
 
6
6
  // src/dock/model.ts
7
7
  var G = 6;
@@ -466,4 +466,4 @@ export {
466
466
  pillBetween,
467
467
  aroundDocs
468
468
  };
469
- //# sourceMappingURL=chunk-LPMZ2FFR.js.map
469
+ //# sourceMappingURL=chunk-3P6VOXA6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dock/model.ts","../src/dock/arrange.ts","../src/dock/parts.ts"],"sourcesContent":["/**\n * The desk's model: panels and documents, the options, the state every construction keeps, and what a layout\n * returns (a placed rect per item). The panels themselves (their titles and natural heights) come from the\n * consumer as a catalog; see `createDesk`.\n */\nimport type { Rect, Size } from \"../geometry\";\n\nexport type Side = \"left\" | \"right\";\n\n/** Gaps and sizes, in stage px. */\nexport const G = 6;\n/** A toolbar bar's height (the pill is 4 px thinner). */\nexport const BAR = 34;\n/** A rail's width. */\nexport const RAIL = 34;\n/** A folded section's (or a shaded palette's) height: its title bar. */\nexport const TITLE = 22;\n/** A tab row's height (navigator sides and drawers). */\nexport const TABS = 28;\n/** The smallest a tiled document may be where a construction promises it (the tiling tree, the strip). */\nexport const DOC_MIN: Size = { width: 240, height: 160 };\n\n/** Items are keyed \"panel:<id>\" and \"doc:<id>\". */\nexport const panelKey = (id: number): string => `panel:${id}`;\nexport const docKey = (id: number): string => `doc:${id}`;\nexport const isPanelKey = (key: string): boolean => key.startsWith(\"panel:\");\nexport const isDocKey = (key: string): boolean => key.startsWith(\"doc:\");\nexport const idOf = (key: string): number => Number(key.slice(key.indexOf(\":\") + 1));\n\n/** A tool panel: its title and the height its content needs (its natural height, title bar included). */\nexport interface PanelSpec {\n readonly id: number;\n readonly title: string;\n readonly natural: number;\n}\n\n/** Where the panels start. Unset parts follow from the sides (see `createDesk`). */\nexport interface DeskStart {\n readonly left: readonly number[];\n readonly right: readonly number[];\n readonly bottom: readonly number[];\n readonly active?: { readonly left: number | null; readonly right: number | null };\n readonly tree?: DeskState[\"tree\"];\n readonly cols?: DeskState[\"cols\"];\n readonly stacks?: DeskState[\"stacks\"];\n}\n\n/** What a desk is made of: its panels, its documents' titles and where the panels start. */\nexport interface DeskSpec {\n readonly panels: readonly PanelSpec[];\n /** A document's title (default \"Document <id>\"). */\n readonly docTitle?: (id: number) => string;\n readonly start: DeskStart;\n /** The panels in the order they were opened (default: as listed); the tiling tree floats the newest first. */\n readonly opened?: readonly number[];\n}\n\n/** The catalog every part reads: a panel's natural height, an item's title and age. */\nexport interface Catalog {\n readonly panelIds: readonly number[];\n readonly natural: (id: number) => number;\n /** An item's title by key (\"panel:<id>\", \"doc:<id>\"); any other key is its own title. */\n readonly title: (key: string) => string;\n /** An item's age: higher is newer (panels in the order they were opened, then the documents). */\n readonly born: (key: string) => number;\n readonly start: Required<DeskStart>;\n}\n\n/** The catalog for a spec (unset start parts filled in). */\nexport function catalogOf(spec: DeskSpec): Catalog {\n const byId = new Map(spec.panels.map((p) => [p.id, p]));\n const opened = spec.opened ?? spec.panels.map((p) => p.id);\n const docTitle = spec.docTitle ?? ((id: number) => `Document ${id}`);\n const { left, right, bottom } = spec.start;\n const rest = [...right, ...bottom];\n const start: Required<DeskStart> = {\n left,\n right,\n bottom,\n active: spec.start.active ?? { left: left[0] ?? null, right: right.at(-1) ?? null },\n tree: spec.start.tree ?? { L: left.map(panelKey), R: rest.map(panelKey), C: [] },\n cols: spec.start.cols ?? [left.map(panelKey), rest.map(panelKey)].filter((c) => c.length > 0),\n stacks: spec.start.stacks ?? { left, right: rest },\n };\n return {\n panelIds: spec.panels.map((p) => p.id),\n natural: (id) => byId.get(id)?.natural ?? TITLE,\n title: (key) => (isPanelKey(key) ? (byId.get(idOf(key))?.title ?? key) : isDocKey(key) ? docTitle(idOf(key)) : key),\n born: (key) => (isDocKey(key) ? 1000 + idOf(key) : opened.indexOf(idOf(key)) + 1),\n start,\n };\n}\n\n/** Where the toolbar floats (top or bottom) and whether the documents keep a band clear for it; the bottom dock's mode. */\nexport interface Options {\n readonly toolbar: \"top\" | \"bottom\";\n readonly toolbarSpace: \"reserved\" | \"overlay\";\n readonly bottom: \"reserved\" | \"overlay\" | \"off\";\n /** The pill's width when its contents need more than the default; unset: the default. */\n readonly toolbarWidth?: number;\n /** The pill holds nothing: it takes no space and isn't shown. */\n readonly toolbarHidden?: boolean;\n}\nexport const DEFAULT_OPTIONS: Options = { toolbar: \"top\", toolbarSpace: \"reserved\", bottom: \"reserved\" };\n\n/** A panel placed freely (torn off, or a palette out of its stack): its top-left corner, null for the default spot. */\nexport interface Free {\n readonly id: number;\n readonly at: { readonly x: number; readonly y: number } | null;\n}\n\n/**\n * Everything any construction keeps. Each construction has its own copy (its own arrangement) and reads only what\n * it uses; the open documents are the same in all of them.\n */\nexport interface DeskState {\n /** Open document ids, in open order. */\n readonly docs: readonly number[];\n readonly focus: number | null;\n /** Panel ids, least recently used first: what folds or shades first when height runs out. */\n readonly recent: readonly number[];\n /** Sections folded (palettes shaded) by hand. */\n readonly folded: readonly number[];\n /** Docks, navigator sides and drawers: the panels on each side, top to bottom (tabs: left to right). */\n readonly left: readonly number[];\n readonly right: readonly number[];\n /** The bottom dock's panels (edge docks only). */\n readonly bottom: readonly number[];\n /** Docks or drawers folded to their rail by hand. */\n readonly closed: readonly Side[];\n /** The side opened last by hand: when width runs out it folds last. */\n readonly opened: Side | null;\n /** The panel showing on each side (navigator, drawers). */\n readonly active: { readonly left: number | null; readonly right: number | null };\n /** Panels torn off a dock, floating (edge docks + tear-off). */\n readonly torn: readonly Free[];\n /** The tiling tree: item keys in the left column, the right column and the centre (dwindle order). */\n readonly tree: { readonly L: readonly string[]; readonly R: readonly string[]; readonly C: readonly string[] };\n /** The scrolling strip: its columns, left to right, each a list of item keys top to bottom. */\n readonly cols: readonly (readonly string[])[];\n /** The strip scrolled by hand, or null: it scrolls to the focus. */\n readonly stripScroll: number | null;\n /** Palettes: the corner stacks, top to bottom, and the ones placed anywhere. */\n readonly stacks: { readonly left: readonly number[]; readonly right: readonly number[] };\n readonly free: readonly Free[];\n}\n\n/** How an item is drawn. */\nexport type Look =\n | \"pill\" // the toolbar floating as a rounded pill\n | \"bar\" // the toolbar as a bar across the top\n | \"section\" // a panel open in a dock\n | \"header\" // a section folded (or a palette shaded) to its title bar\n | \"float\" // a panel floating over the documents\n | \"palette\" // a floating panel that reserves its footprint\n | \"tile\" // a panel tiled like a document\n | \"bare\" // a panel under a tab row: no title bar of its own\n | \"doc\"\n | \"rail\"\n | \"tabs\"\n | \"track\"\n | \"thumb\";\n\n/** Stacking layers, bottom to top. */\nexport const LAYER = { doc: 1, dock: 2, palette: 3, overlay: 4, float: 5, toolbar: 6 } as const;\n\n/** One item as a layout places it. */\nexport interface Placed {\n readonly rect: Rect;\n readonly look: Look;\n readonly layer: number;\n /** Folded away (into a rail, behind a tab): it goes to `rect`, hidden. */\n readonly hidden?: boolean;\n /** Never laid out below this (where the construction promises it). */\n readonly min?: Partial<Size>;\n /** It may lie outside the stage (the strip scrolls). */\n readonly offStage?: boolean;\n /** A rail's icons or a tab row's tabs (panel ids), and the active tab. */\n readonly icons?: readonly number[];\n readonly tabs?: readonly number[];\n readonly active?: number | null;\n /** Drawn with an accent outline (the bottom dock). */\n readonly accent?: boolean;\n /** Drawn with a shadow (it floats over something). */\n readonly shadow?: boolean;\n}\n\n/**\n * How a layout gave way (or what it is worth knowing about it):\n *\n * - `bottom-folded`: the bottom dock folded to its header; `dock-folded`: a side dock folded to its rail (`side`);\n * - `sections-folded`: sections folded to their headers by themselves, least recently used first;\n * - `torn-floating`: panels torn off a dock float (`items`); `torn-shaded`: some shade because they don't fit;\n * - `columns-railed`: the tiling tree's side columns are folded to rails (`side` when only one);\n * - `tiles-float`: tiles that broke a minimum float, newest first (`items`);\n * - `tabs-folded`: a tabbed side folded to icon tabs (`side`); `drawer-over`: a drawer slides over the\n * documents (`side`);\n * - `column-split`: a strip column split in two (`items`); `strip-scrolls`: the strip is wider than the stage;\n * - `stacks-merged`: both palette stacks share one corner; `palettes-shaded`: palettes shaded to title bars;\n * - `palettes-cover`, `docs-room`: how much of the documents palettes cover, and how much room they leave.\n */\nexport type NoteCode =\n | \"bottom-folded\"\n | \"dock-folded\"\n | \"sections-folded\"\n | \"torn-floating\"\n | \"torn-shaded\"\n | \"columns-railed\"\n | \"tiles-float\"\n | \"tabs-folded\"\n | \"drawer-over\"\n | \"column-split\"\n | \"strip-scrolls\"\n | \"stacks-merged\"\n | \"palettes-shaded\"\n | \"palettes-cover\"\n | \"docs-room\";\n\n/**\n * One note on a layout. `code` (and `side`, `items` where they apply) is the contract; `text` says it in English for\n * people, and its wording may change in any release.\n */\nexport interface Note {\n readonly code: NoteCode;\n readonly text: string;\n readonly side?: Side;\n /** The item keys it is about. */\n readonly items?: readonly string[];\n}\n\n/** Where everything is (\"toolbar\", \"panel:<id>\", \"doc:<id>\", \"rail:<side>\", \"tabs:<side>\", \"track\", \"thumb\"), and how it gave way. */\nexport interface Layout {\n readonly items: ReadonlyMap<string, Placed>;\n readonly notes: readonly Note[];\n}\n\n// --- state changes -------------------------------------------------------------------------------------------------\n\n/** The arrangement a catalog starts from, with these documents open (none by default). */\nexport function startState(cat: Catalog, docs: readonly number[] = []): DeskState {\n const st = cat.start;\n const base: DeskState = {\n docs: [],\n focus: null,\n recent: [...cat.panelIds],\n folded: [],\n left: [...st.left],\n right: [...st.right],\n bottom: [...st.bottom],\n closed: [],\n opened: null,\n active: st.active,\n torn: [],\n tree: st.tree,\n cols: st.cols,\n stripScroll: null,\n stacks: st.stacks,\n free: [],\n };\n return withDocs(base, docs, docs.at(-1) ?? null);\n}\n\n/**\n * The same state with these documents open: new ones join the tiling tree's centre (the first one at its front)\n * and get a strip column of their own after the last document column; closed ones leave both.\n */\nexport function withDocs(s: DeskState, docs: readonly number[], focus: number | null): DeskState {\n const keys = docs.map(docKey);\n const gone = (k: string): boolean => isDocKey(k) && !keys.includes(k);\n let C = s.tree.C.filter((k) => !gone(k));\n let cols = s.cols.map((c) => c.filter((k) => !gone(k))).filter((c) => c.length > 0);\n const has = (k: string): boolean => [...s.tree.L, ...s.tree.R, ...C].includes(k);\n for (const k of keys) {\n if (!has(k)) C = C.some(isDocKey) || C.length === 0 ? [...C, k] : [k, ...C];\n if (!cols.some((c) => c.includes(k))) {\n const lastDoc = cols.map((c) => c.some(isDocKey)).lastIndexOf(true);\n const at = lastDoc >= 0 ? lastDoc + 1 : Math.min(1, cols.length);\n cols = [...cols.slice(0, at), [k], ...cols.slice(at)];\n }\n }\n const L = s.tree.L.filter((k) => !gone(k));\n const R = s.tree.R.filter((k) => !gone(k));\n const f = focus !== null && docs.includes(focus) ? focus : (docs.at(-1) ?? null);\n // A new focus: the strip scrolls to it again.\n return { ...s, docs: [...docs], focus: f, tree: { L, R, C }, cols, stripScroll: f === s.focus ? s.stripScroll : null };\n}\n\n/** Panel `id` was used: it is the last to fold when height runs out. */\nexport const touch = (s: DeskState, id: number): DeskState => ({ ...s, recent: [...s.recent.filter((x) => x !== id), id] });\n\n/** Fold or unfold a section (shade or unshade a palette) by hand; unfolding is a use. */\nexport function toggleFold(s: DeskState, id: number): DeskState {\n const folded = s.folded.includes(id);\n const next = { ...s, folded: folded ? s.folded.filter((x) => x !== id) : [...s.folded, id] };\n return folded ? touch(next, id) : next;\n}\n\n/** Fold a dock (or drawer) to its rail by hand, or open it again (then it folds last when width runs out). */\nexport function toggleClosed(s: DeskState, side: Side): DeskState {\n const closed = s.closed.includes(side);\n return closed ? { ...s, closed: s.closed.filter((x) => x !== side), opened: side } : { ...s, closed: [...s.closed, side] };\n}\n\n/** Show panel `id` on its side (navigator, drawers). */\nexport const withActive = (s: DeskState, side: Side, id: number): DeskState => touch({ ...s, active: { ...s.active, [side]: id } }, id);\n\n/** The state with `key` lifted out of wherever it is (before a drop puts it somewhere). */\nexport function liftOut(s: DeskState, key: string): DeskState {\n const dropK = (l: readonly string[]): string[] => l.filter((k) => k !== key);\n const base: DeskState = { ...s, tree: { L: dropK(s.tree.L), R: dropK(s.tree.R), C: dropK(s.tree.C) }, cols: s.cols.map(dropK).filter((c) => c.length > 0) };\n if (!isPanelKey(key)) return base;\n const id = idOf(key);\n const drop = (l: readonly number[]): number[] => l.filter((x) => x !== id);\n return {\n ...base,\n left: drop(s.left),\n right: drop(s.right),\n bottom: drop(s.bottom),\n torn: s.torn.filter((f) => f.id !== id),\n free: s.free.filter((f) => f.id !== id),\n stacks: { left: drop(s.stacks.left), right: drop(s.stacks.right) },\n active: { left: s.active.left === id ? null : s.active.left, right: s.active.right === id ? null : s.active.right },\n };\n}\n","/**\n * The arrangers the desk constructions build on, internal to `./dock`: master and stack for the documents, dwindle\n * for the tiling tree's centre, stacked columns at natural heights, and the minimum-size give-way (the newest tile\n * that breaks a minimum floats). A public `./tiling` will come from a merge with a full split-tree model; these stay\n * the dock's own until then.\n */\nimport type { Rect, Size } from \"../geometry\";\n\n/**\n * Master and stack: the first id takes the left part (`ratio` of the width less the gap), the rest stack on the\n * right in equal rows. One id takes the whole area.\n */\nexport function masterStack<K>(ids: readonly K[], area: Rect, gap: number, ratio = 0.5): Map<K, Rect> {\n const out = new Map<K, Rect>();\n if (ids.length === 0) return out;\n if (ids.length === 1) {\n out.set(ids[0]!, { ...area });\n return out;\n }\n const mw = (area.width - gap) * ratio;\n out.set(ids[0]!, { x: area.x, y: area.y, width: mw, height: area.height });\n const k = ids.length - 1;\n const sh = (area.height - gap * (k - 1)) / k;\n ids.slice(1).forEach((id, i) => out.set(id, { x: area.x + mw + gap, y: area.y + i * (sh + gap), width: area.width - mw - gap, height: sh }));\n return out;\n}\n\n/** Dwindle over an order: each tile but the last splits the space left in two along its longer side. */\nexport function dwindle(area: Rect, n: number, gap: number): Rect[] {\n const out: Rect[] = [];\n let cur = { ...area };\n for (let i = 0; i < n; i++) {\n if (i === n - 1) {\n out.push(cur);\n break;\n }\n if (cur.width >= cur.height) {\n const w = (cur.width - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: w, height: cur.height });\n cur = { x: cur.x + w + gap, y: cur.y, width: w, height: cur.height };\n } else {\n const h = (cur.height - gap) / 2;\n out.push({ x: cur.x, y: cur.y, width: cur.width, height: h });\n cur = { x: cur.x, y: cur.y + h + gap, width: cur.width, height: h };\n }\n }\n return out;\n}\n\n/**\n * Heights for a column of items stacked in `avail` with gaps: each at its minimum (its natural height), the last\n * taking the rest. When the minimums don't fit, an even share instead, so the ones that break their minimum show.\n */\nexport function columnHeights(avail: number, mins: readonly number[], gap: number): number[] {\n const room = avail - gap * (mins.length - 1);\n const need = mins.reduce((a, b) => a + b, 0);\n if (need > room) return mins.map(() => room / mins.length);\n return mins.map((m, i) => (i === mins.length - 1 ? room - need + m : m));\n}\n\n/**\n * Lengths for items sharing `avail`: each gets at least its minimum, the rest of the room is shared in proportion\n * to the minimums (when the minimums don't fit, each gets its minimum).\n */\nexport function share(avail: number, mins: readonly number[]): number[] {\n const need = mins.reduce((a, b) => a + b, 0);\n const spare = Math.max(0, avail - need);\n return mins.map((m) => m + (need > 0 ? (spare * m) / need : spare / mins.length));\n}\n\n/**\n * The minimum-size give-way: while a tile is laid out below its minimum, the newest tile (highest `age`) floats and\n * the rest are laid out again. Stops when every tile keeps its minimum or one tile is left. `layout` lays out the\n * kept keys; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(keys: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (key: K) => Size, age: (key: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...keys];\n const floats: K[] = [];\n for (;;) {\n const res = layout(kept);\n const broken = [...res].some(([k, r]) => r.width < min(k).width - 0.5 || r.height < min(k).height - 0.5);\n if (!broken || kept.length <= 1) return { kept, floats };\n const newest = kept.reduce((a, b) => (age(b) > age(a) ? b : a));\n kept = kept.filter((k) => k !== newest);\n floats.push(newest);\n }\n}\n","/**\n * The parts the desk constructions are built from, each pure: the toolbar pill, the documents' tiles, natural-height\n * sections (the last open one takes the rest; the least recently used fold to headers), rails, the edge docks'\n * geometry, the tiling tree's columns, the scrolling strip, tabbed sides and floating palettes.\n */\nimport { clampInto, rect, type Rect, type Size } from \"../geometry\";\nimport { columnHeights, dwindle, giveWay, masterStack } from \"./arrange\";\nimport { BAR, DOC_MIN, G, LAYER, RAIL, TABS, TITLE, docKey, idOf, isDocKey, panelKey, type Catalog, type DeskState, type Note, type Options, type Placed, type Side } from \"./model\";\n\nexport type Out = Map<string, Placed>;\n\nexport const plural = (n: number, one: string, many: string): string => `${n} ${n > 1 ? many : one}`;\n\n// --- the toolbar pill and the documents ----------------------------------------------------------------------------\n\n/** The shortest a pill gets (unless there is less room than that). */\nexport const PILL_MIN = 60;\n\n/**\n * The toolbar pill, floating at the top or the bottom of the band [y0, y1] above a region `cx`..`cx + cw`; returns\n * the pill and the band left for the documents (reserved: they keep clear of it; overlay: it floats over them).\n */\nexport function pill(opt: Options, cx: number, cw: number, y0: number, y1: number): { placed: Placed; top: number; bottom: number } {\n const pw = Math.max(PILL_MIN, Math.min(opt.toolbarWidth ?? 320, cw - 24));\n const ph = BAR - 4;\n const atTop = opt.toolbar === \"top\";\n // A hidden pill keeps no band clear, as if it floated.\n const overlay = opt.toolbarSpace === \"overlay\" || !!opt.toolbarHidden;\n return {\n placed: { rect: rect(cx + cw / 2 - pw / 2, atTop ? y0 + G : y1 - G - ph, pw, ph), look: \"pill\", layer: LAYER.toolbar, shadow: overlay, ...(opt.toolbarHidden ? { hidden: true } : {}) },\n top: atTop && !overlay ? y0 + BAR + 2 * G : y0 + G,\n bottom: !atTop && !overlay ? y1 - BAR - 2 * G : y1 - G,\n };\n}\n\n/** The toolbar as a bar across the top of the stage. */\nexport const bar = (W: number): Placed => ({ rect: rect(0, 0, W, BAR), look: \"bar\", layer: LAYER.toolbar });\n\n/** The documents in `r`, master and stack: the first takes 56 % of the width, the rest stack on the right. */\nexport function tiles(out: Out, r: Rect, ids: readonly number[], min?: Size): void {\n for (const [id, rr] of masterStack(ids, r, G, 0.56)) out.set(docKey(id), { rect: rr, look: \"doc\", layer: LAYER.doc, ...(min ? { min } : {}) });\n}\n\n// --- sections and rails --------------------------------------------------------------------------------------------\n\n/**\n * The ones of `ids` to fold, least recently used first, until what stays open fits `avail`. An accordion keeps one\n * section open whatever (`keepOne`); a palette stack shades even its last palette rather than run off the stage.\n */\nfunction lruFold(s: DeskState, ids: readonly number[], avail: number, open: (id: number) => number, closed: number, keepOne = true): number[] {\n const byHand = ids.filter((id) => s.folded.includes(id));\n const auto: number[] = [];\n const isOpen = (id: number): boolean => !byHand.includes(id) && !auto.includes(id);\n const need = (): number => ids.reduce((sum, id) => sum + (isOpen(id) ? open(id) : closed), 0) + G * (ids.length - 1);\n const order = [...s.recent].filter((id) => ids.includes(id));\n for (const id of order) {\n if (need() <= avail || (keepOne && ids.filter(isOpen).length <= 1)) break;\n if (isOpen(id)) auto.push(id);\n }\n return [...byHand, ...auto];\n}\n\n/**\n * Natural-height sections in x, y, w, h: each open section takes its natural height and the last open one takes\n * the rest; the least recently used fold to headers until the open ones fit. Returns how many folded by themselves.\n */\nexport function accordion(cat: Catalog, out: Out, s: DeskState, x: number, y: number, w: number, h: number, ids: readonly number[]): number {\n const folded = lruFold(s, ids, h, cat.natural, TITLE);\n const open = ids.filter((id) => !folded.includes(id));\n const room = h - G * (ids.length - 1) - TITLE * (ids.length - open.length);\n const last = open.at(-1);\n const rest = room - open.reduce((sum, id) => sum + (id === last ? 0 : cat.natural(id)), 0);\n let cy = y;\n for (const id of ids) {\n const i = open.indexOf(id);\n const n = cat.natural(id);\n const hh = i < 0 ? TITLE : id === last ? Math.max(n, rest) : n;\n out.set(panelKey(id), { rect: rect(x, cy, w, hh), look: i >= 0 ? \"section\" : \"header\", layer: LAYER.dock, ...(i >= 0 ? { min: { height: n } } : {}) });\n cy += hh + G;\n }\n return folded.filter((id) => !s.folded.includes(id)).length;\n}\n\n/** A rail of icons at x, y; the rect of its icon `i`. */\nconst railIcon =(x: number, y: number, i: number): Rect => rect(x + 6, y + 10 + i * 32, RAIL - 12, 24);\n\n/** A rail (a column whose panels are all folded) at x, y, h: one icon per panel. */\nexport function rail(out: Out, side: Side, x: number, y: number, h: number, ids: readonly number[], hidden = false): void {\n out.set(`rail:${side}`, { rect: rect(x, y, RAIL, h), look: \"rail\", layer: LAYER.dock, icons: ids, ...(hidden ? { hidden } : {}) });\n}\n\n/** Panels folded into a rail: hidden, each at its icon at `w` × its natural height. */\nexport function intoRail(cat: Catalog, out: Out, x: number, y: number, w: number, ids: readonly number[], side: Side): void {\n ids.forEach((id, i) => {\n const icon = railIcon(x, y, i);\n out.set(panelKey(id), { rect: rect(side === \"left\" ? icon.x : icon.x + icon.width - w, icon.y, w, cat.natural(id)), look: \"section\", layer: LAYER.dock, hidden: true });\n });\n}\n\n// --- edge docks ----------------------------------------------------------------------------------------------------\n\n/**\n * The dock width (rail excluded, its sections 240 px wide after the gap) and the narrowest the documents may get\n * before a dock folds.\n */\nexport const DOCK = 246;\nconst WORK_MIN = 380;\n/** The bottom dock's height when open, and the most of the stage's height it takes. */\nconst BOTTOM = 190;\nconst BOTTOM_SHARE = 0.36;\n\n/** What the edge docks put where: shared by their layouts and their drop targets. */\nexport interface DockGeometry {\n /** The side docks' height (less the bottom dock's in full-width mode). */\n readonly h: number;\n /** The bottom dock's height (its header's when folded; 0 when off). */\n readonly bh: number;\n readonly lOpen: boolean;\n readonly rOpen: boolean;\n /** The right dock's panels (the bottom dock's join them when it is off). */\n readonly right: readonly number[];\n readonly bottomOn: boolean;\n readonly bottomRect: Rect | null;\n /** The documents' band, left to right. */\n readonly x0: number;\n readonly x1: number;\n}\n\n/**\n * The edge docks' give-way: the bottom dock folds to its header when the stage is short, and a whole side dock\n * folds to its rail when the documents would get narrower than WORK_MIN (the right one first, unless it was opened\n * last by hand). `mode`: the bottom dock between the side docks, or across the full width under them.\n */\nexport function dockGeometry(cat: Catalog, s: DeskState, size: Size, opt: Options, mode: \"between\" | \"full\", notes: Note[] = []): DockGeometry {\n const { width: W, height: H } = size;\n const bottomOn = opt.bottom !== \"off\" && s.bottom.length > 0;\n const right = bottomOn ? s.right : [...s.right, ...s.bottom];\n const bottomFolded = bottomOn && (H < 480 || s.bottom.every((id) => s.folded.includes(id)));\n // Open, it is BOTTOM tall, never more than BOTTOM_SHARE of the stage (but never below what its panels need).\n const bh = !bottomOn ? 0 : bottomFolded ? TITLE : Math.max(...s.bottom.map(cat.natural), Math.min(BOTTOM, BOTTOM_SHARE * H));\n if (bottomOn && H < 480) notes.push({ code: \"bottom-folded\", text: \"bottom dock folded to its header\" });\n const full = mode === \"full\";\n const h = full && bottomOn ? H - bh - G : H;\n let lOpen = s.left.length > 0 && !s.closed.includes(\"left\");\n let rOpen = right.length > 0 && !s.closed.includes(\"right\");\n const work = (): number => W - 2 * RAIL - (lOpen ? DOCK : 0) - (rOpen ? DOCK : 0) - 2 * G;\n for (const side of s.opened === \"right\" ? ([\"left\", \"right\"] as const) : ([\"right\", \"left\"] as const)) {\n if (work() >= WORK_MIN) break;\n if (side === \"right\" && rOpen) {\n rOpen = false;\n notes.push({ code: \"dock-folded\", side: \"right\", text: \"right dock folded to its rail\" });\n } else if (side === \"left\" && lOpen) {\n lOpen = false;\n notes.push({ code: \"dock-folded\", side: \"left\", text: \"left dock folded to its rail\" });\n }\n }\n const x0 = RAIL + (lOpen ? DOCK : 0) + G;\n const x1 = W - RAIL - (rOpen ? DOCK : 0) - G;\n const bottomRect = bottomOn ? (full ? rect(G, H - G - bh, W - 2 * G, bh) : rect(x0, H - G - bh, x1 - x0, bh)) : null;\n return { h, bh, lOpen, rOpen, right, bottomOn, bottomRect, x0, x1 };\n}\n\n/** The width of a torn-off panel (its height is its natural height). */\nexport const TORN_W = 200;\n\n// --- the tiling tree -----------------------------------------------------------------------------------------------\n\n/** The smallest a tile may be: a document's minimum, or a panel at its natural height. */\nexport const tileMin = (cat: Catalog, key: string): Size => (isDocKey(key) ? DOC_MIN : { width: 150, height: cat.natural(idOf(key)) });\n/** A side column's width. */\nexport const TREE_COLUMN = 180;\n\n/** The tree's tiles laid out (no floating): the left and right columns, the centre by dwindle. */\nexport function treeTiles(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): Map<string, Rect> {\n const res = new Map<string, Rect>();\n let x0 = area.x;\n let x1 = area.x + area.width;\n // A side column's tiles take their natural height, the last one the rest.\n const column = (list: readonly string[], x: number): void => {\n const heights = columnHeights(area.height, list.map((k) => tileMin(cat, k).height), G);\n let y = area.y;\n list.forEach((k, i) => {\n res.set(k, rect(x, y, TREE_COLUMN, heights[i]!));\n y += heights[i]! + G;\n });\n };\n if (tree.L.length) {\n column(tree.L, x0);\n x0 += TREE_COLUMN + G;\n }\n if (tree.R.length) {\n column(tree.R, x1 - TREE_COLUMN);\n x1 -= TREE_COLUMN + G;\n }\n dwindle(rect(x0, area.y, x1 - x0, area.height), tree.C.length, G).forEach((r, i) => res.set(tree.C[i]!, r));\n return res;\n}\n\n/** The sides of the tree whose column is folded to a rail at the stage's edge (closed by hand, or at a narrow start). */\nexport const treeRails = (s: DeskState): { readonly left: boolean; readonly right: boolean } => ({\n left: s.closed.includes(\"left\") && s.tree.L.length > 0,\n right: s.closed.includes(\"right\") && s.tree.R.length > 0,\n});\n\n/** The area the tree tiles: the stage under the bar, less the rails of folded columns. */\nexport const treeArea = (size: Size, s?: DeskState): Rect => {\n const r = s ? treeRails(s) : { left: false, right: false };\n const x0 = r.left ? RAIL + G : G;\n const x1 = size.width - (r.right ? RAIL + G : G);\n return rect(x0, BAR + G, x1 - x0, size.height - BAR - 2 * G);\n};\n\n/** The tree as tiled: a column folded to its rail tiles nothing. */\nexport const treeShown = (s: DeskState): DeskState[\"tree\"] => {\n const r = treeRails(s);\n return { L: r.left ? [] : s.tree.L, R: r.right ? [] : s.tree.R, C: s.tree.C };\n};\n\n/** Which tiles float: the newest tile that breaks a minimum floats, then the tree is laid out again. */\nexport function treeFloats(cat: Catalog, tree: DeskState[\"tree\"], area: Rect): { tree: DeskState[\"tree\"]; floats: string[] } {\n const only = (kept: readonly string[]): DeskState[\"tree\"] => ({ L: tree.L.filter((k) => kept.includes(k)), R: tree.R.filter((k) => kept.includes(k)), C: tree.C.filter((k) => kept.includes(k)) });\n const { kept, floats } = giveWay(\n [...tree.L, ...tree.R, ...tree.C],\n (k) => treeTiles(cat, only(k), area),\n (k) => tileMin(cat, k),\n cat.born,\n );\n return { tree: only(kept), floats };\n}\n\n// --- tabbed sides --------------------------------------------------------------------------------------------------\n\n/**\n * One side with tabs: the tab row on top, the active panel under it, the others hidden behind it. `float` puts\n * them over the documents (a drawer that slides over).\n */\nexport function tabbed(out: Out, side: Side, ids: readonly number[], active: number | null, x: number, y: number, w: number, h: number, float: boolean): void {\n const shown = active !== null && ids.includes(active) ? active : (ids[0] ?? null);\n out.set(`tabs:${side}`, { rect: rect(x, y, w, TABS), look: \"tabs\", layer: float ? LAYER.float : LAYER.dock, tabs: ids, active: shown, ...(float ? { shadow: true } : {}) });\n for (const id of ids) {\n const r = rect(x, y + TABS, w, h - TABS);\n out.set(panelKey(id), { rect: r, look: \"bare\", layer: float ? LAYER.float : LAYER.dock, ...(id === shown ? {} : { hidden: true }), ...(float ? { shadow: true } : {}) });\n }\n}\n\n/** A side folded to its rail: the tab row and the panels hidden into it. */\nexport function tabbedIntoRail(cat: Catalog, out: Out, side: Side, ids: readonly number[], x: number, y: number, w: number): void {\n out.set(`tabs:${side}`, { rect: rect(side === \"left\" ? x : x + RAIL - w, y, w, TABS), look: \"tabs\", layer: LAYER.dock, tabs: ids, active: null, hidden: true });\n intoRail(cat, out, x, y, w, ids, side);\n}\n\n/** Below these widths a drawer slides over the documents instead of pushing them. */\nexport const DRAWER_DOCK = { left: 760, right: 1040 } as const;\n\n// --- the scrolling strip -------------------------------------------------------------------------------------------\n\nconst STRIP_PANEL_W = 180;\nconst stripDocW =(W: number): number => Math.max(360, Math.min(520, W * 0.5));\nexport const stripMin = (cat: Catalog, k: string): number => (isDocKey(k) ? DOC_MIN.height : cat.natural(idOf(k)));\n\n/** The strip's columns as laid out: a column whose minimums don't fit the height splits in two, recursively. */\nexport function stripColumns(cat: Catalog, cols: readonly (readonly string[])[], h: number, notes: Note[] = []): string[][] {\n const split = (keys: readonly string[]): string[][] => {\n const need = keys.reduce((sum, k) => sum + stripMin(cat, k), 0) + G * (keys.length - 1);\n if (need <= h || keys.length === 1) return [[...keys]];\n const half = Math.ceil(keys.length / 2);\n notes.push({ code: \"column-split\", items: [...keys], text: `${keys.map(cat.title).join(\" + \")} split into two columns` });\n return [...split(keys.slice(0, half)), ...split(keys.slice(half))];\n };\n return cols.flatMap(split);\n}\n\nexport interface StripGeometry {\n readonly cols: string[][];\n /** Each column's left edge on the stage (scroll applied) and width. */\n readonly xs: number[];\n readonly widths: number[];\n readonly y: number;\n readonly h: number;\n /** The whole strip's width, and how far it is scrolled. */\n readonly total: number;\n readonly scroll: number;\n}\n\n/** The strip's columns and scroll: scrolled by hand, else to centre the focused document's column. */\nexport function stripGeometry(cat: Catalog, s: DeskState, size: Size, notes: Note[] = []): StripGeometry {\n const { width: W, height: H } = size;\n const y = BAR + G;\n const h = H - BAR - 2 * G;\n const cols = stripColumns(cat, s.cols, h, notes);\n const widths = cols.map((c) => (c.some(isDocKey) ? stripDocW(W) : STRIP_PANEL_W));\n const total = widths.reduce((a, b) => a + b, 0) + G * (cols.length + 1);\n const want = s.focus !== null ? docKey(s.focus) : null;\n let fi = cols.findIndex((c) => want !== null && c.includes(want));\n if (fi < 0) fi = cols.findIndex((c) => c.some(isDocKey));\n const xsAbs: number[] = [];\n let x = G;\n for (const w of widths) {\n xsAbs.push(x);\n x += w + G;\n }\n const focusX = fi >= 0 ? xsAbs[fi]! + widths[fi]! / 2 : 0;\n const scroll = Math.max(0, Math.min(total - W, s.stripScroll ?? focusX - W / 2));\n return { cols, xs: xsAbs.map((v) => v - scroll), widths, y, h, total, scroll };\n}\n\n// --- floating palettes ---------------------------------------------------------------------------------------------\n\nexport const paletteWidth = (W: number): number => Math.min(200, Math.max(140, W * 0.22));\n/** Narrower than this, both stacks share the right corner. */\nexport const PALETTE_NARROW = 640;\n/** The margin palettes keep from the area's edges when they float over the documents. */\nexport const OVER_MARGIN = 14;\n\n/**\n * Palettes at their natural size, stacked in the top corners of `area` (`m` in from its edges), and the free ones\n * where they were put; a stack too tall for the area shades its least recently used palettes to their title bars.\n */\nexport function palettes(cat: Catalog, s: DeskState, area: Rect, W: number, m: number, notes: Note[] = []): Map<number, { rect: Rect; shaded: boolean }> {\n const pw = paletteWidth(W);\n const avail = area.height - 2 * m;\n const narrow = W < PALETTE_NARROW;\n const stacks = narrow ? [[...s.stacks.left, ...s.stacks.right]] : [s.stacks.left, s.stacks.right];\n if (narrow && s.stacks.left.length && s.stacks.right.length) notes.push({ code: \"stacks-merged\", text: \"both stacks share the right corner\" });\n const out = new Map<number, { rect: Rect; shaded: boolean }>();\n let shaded = 0;\n stacks.forEach((ids, si) => {\n const folded = lruFold(s, ids, avail, cat.natural, TITLE, false);\n shaded += folded.filter((id) => !s.folded.includes(id)).length;\n const x = narrow || si === 1 ? area.x + area.width - m - pw : area.x + m;\n let y = area.y + m;\n for (const id of ids) {\n const h = folded.includes(id) ? TITLE : cat.natural(id);\n out.set(id, { rect: rect(x, y, pw, h), shaded: folded.includes(id) });\n y += h + G;\n }\n });\n for (const f of s.free) {\n const shade = s.folded.includes(f.id);\n const at = f.at ?? { x: area.x + m, y: area.y + m };\n out.set(f.id, { rect: clampInto(rect(at.x, at.y, pw, shade ? TITLE : cat.natural(f.id)), area), shaded: shade });\n }\n if (shaded) notes.push({ code: \"palettes-shaded\", text: `${plural(shaded, \"palette\", \"palettes\")} shaded to ${shaded > 1 ? \"title bars\" : \"a title bar\"}` });\n return out;\n}\n\n/** The stage area palettes and documents share (below or above the pill when it keeps its band). */\nexport function paletteArea(size: Size, opt: Options): { area: Rect } {\n const p = pill(opt, G, size.width - 2 * G, 0, size.height);\n return { area: rect(G, p.top, size.width - 2 * G, p.bottom - p.top) };\n}\n\n/**\n * A floating pill among palettes: in a stretch of its band that no palette crosses, so it never covers one. Of the\n * stretches wide enough for a full-width pill (its minimum plus margins), the one nearest the centre; with none, the\n * widest, the pill shrunk to fit it.\n */\nexport function pillBetween(opt: Options, size: Size, blocks: readonly Rect[]): Placed {\n const band = pill(opt, G, size.width - 2 * G, 0, size.height).placed.rect;\n const spans = blocks\n .filter((r) => r.y < band.y + band.height && r.y + r.height > band.y)\n .map((r) => [r.x - G, r.x + r.width + G] as const)\n .sort((a, b) => a[0] - b[0]);\n const stretches: [number, number][] = [];\n let x = G;\n for (const [b0, b1] of spans) {\n if (b0 > x) stretches.push([x, b0]);\n x = Math.max(x, b1);\n }\n if (size.width - G > x) stretches.push([x, size.width - G]);\n const roomy = stretches.filter(([a, b]) => b - a >= PILL_MIN + 24);\n const mid = size.width / 2;\n const pick =\n roomy.sort((p, q) => Math.abs((p[0] + p[1]) / 2 - mid) - Math.abs((q[0] + q[1]) / 2 - mid))[0] ??\n stretches.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))[0] ??\n ([G, G] as [number, number]);\n const placed = pill(opt, pick[0], pick[1] - pick[0], 0, size.height).placed;\n const room = pick[1] - pick[0];\n // Too little room for even the shortest pill: it shrinks to the room rather than cover a palette.\n return placed.rect.width <= room ? placed : { ...placed, rect: { ...placed.rect, x: pick[0], width: Math.max(0, room) } };\n}\n\n/** The documents' band between the palettes on the left half and those on the right half. */\nexport function aroundDocs(pals: ReadonlyMap<number, { rect: Rect }>, area: Rect): Rect {\n const mid = area.x + area.width / 2;\n const rects = [...pals.values()].map((p) => p.rect);\n const left = rects.filter((r) => r.x + r.width / 2 < mid);\n const right = rects.filter((r) => r.x + r.width / 2 >= mid);\n const x0 = left.length ? Math.max(...left.map((r) => r.x + r.width)) + G : area.x;\n const x1 = right.length ? Math.min(...right.map((r) => r.x)) - G : area.x + area.width;\n return rect(x0, area.y, Math.max(0, x1 - x0), area.height);\n}\n"],"mappings":";;;;;;AAUO,IAAM,IAAI;AAEV,IAAM,MAAM;AAEZ,IAAM,OAAO;AAEb,IAAM,QAAQ;AAEd,IAAM,OAAO;AAEb,IAAM,UAAgB,EAAE,OAAO,KAAK,QAAQ,IAAI;AAGhD,IAAM,WAAW,CAAC,OAAuB,SAAS,EAAE;AACpD,IAAM,SAAS,CAAC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