@n-uf/placement 26.11.56 → 26.11.58

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/tiling/order.ts","../src/tiling/split.ts","../src/tiling/layout.ts","../src/tiling/drop.ts","../src/tiling/regions.ts","../src/tiling/targets.ts","../src/tiling/give-way.ts","../src/tiling/neighbor.ts"],"sourcesContent":["/**\n * The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders\n * (the dragged pane inserted at an index, see `orderTargets`).\n */\nimport type { Rect } from \"../geometry\";\nimport type { PaneSide } from \"./regions\";\n\n/**\n * How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),\n * `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).\n */\nexport interface TileOptions {\n readonly gap?: number;\n readonly ratio?: number;\n readonly handle?: number;\n}\n\n/**\n * The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `\"left\"`). Left and right\n * make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the\n * concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its\n * `master` field.\n */\nexport interface MasterOptions {\n readonly count?: number;\n readonly side?: PaneSide;\n}\n\n/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */\nexport type OrderOptions = TileOptions & MasterOptions;\n\n/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */\nexport type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;\n\n/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */\nexport const masterRatio = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(0.95, Math.max(0.05, v)));\n\n/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */\nexport function masterCount(count: number | undefined, n: number): number {\n const c = Math.round(count ?? 1);\n return Math.min(Math.max(Number.isNaN(c) ? 1 : c, 1), Math.max(n, 1));\n}\n\n/** `items` side by side or one above the other in equal shares of the box, `gap` between them. */\nfunction divide<K>(items: readonly K[], x: number, y: number, width: number, height: number, vertical: boolean, gap: number, out: Map<K, Rect>): void {\n const n = items.length;\n const total = gap * (n - 1);\n if (vertical) {\n const each = Math.max(0, (height - total) / n);\n items.forEach((pane, i) => out.set(pane, { x, y: y + i * (each + gap), width, height: each }));\n } else {\n const each = Math.max(0, (width - total) / n);\n items.forEach((pane, i) => out.set(pane, { x: x + i * (each + gap), y, width: each, height }));\n }\n}\n\n/**\n * Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the\n * gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make\n * each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put\n * the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's\n * cross axis. Each area divides its length equally between its panes, the gap between them.\n */\nexport function masterStack<K>(panes: readonly K[], area: Rect, options: OrderOptions = {}): Map<K, Rect> {\n const gap = options.gap !== undefined && Number.isFinite(options.gap) && options.gap > 0 ? options.gap : 0;\n const out = new Map<K, Rect>();\n if (panes.length === 0) return out;\n const side = options.side ?? \"left\";\n const ratio = masterRatio(options.ratio);\n const count = masterCount(options.count, panes.length);\n const masters = panes.slice(0, count);\n const stack = panes.slice(count);\n const column = side === \"left\" || side === \"right\";\n if (stack.length === 0) {\n divide(masters, area.x, area.y, area.width, area.height, column, gap, out);\n } else if (column) {\n const room = Math.max(0, area.width - gap);\n const masterWidth = room * ratio;\n const stackWidth = room * (1 - ratio);\n const masterX = side === \"left\" ? area.x : area.x + stackWidth + gap;\n const stackX = side === \"left\" ? area.x + masterWidth + gap : area.x;\n divide(masters, masterX, area.y, masterWidth, area.height, true, gap, out);\n divide(stack, stackX, area.y, stackWidth, area.height, true, gap, out);\n } else {\n const room = Math.max(0, area.height - gap);\n const masterHeight = room * ratio;\n const stackHeight = room * (1 - ratio);\n const masterY = side === \"top\" ? area.y : area.y + stackHeight + gap;\n const stackY = side === \"top\" ? area.y + masterHeight + gap : area.y;\n divide(masters, area.x, masterY, area.width, masterHeight, false, gap, out);\n divide(stack, area.x, stackY, area.width, stackHeight, false, gap, out);\n }\n return out;\n}\n\n/** Equal columns, full height. */\nexport function columns<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n const w = (area.width - gap * (n - 1)) / Math.max(1, n);\n panes.forEach((id, i) => out.set(id, { x: area.x + i * (w + gap), y: area.y, width: w, height: area.height }));\n return out;\n}\n\n/** A grid as square as the count allows; the last row's cells widen to fill it. */\nexport function grid<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n if (n === 0) return out;\n const cols = Math.ceil(Math.sqrt(n));\n const rows = Math.ceil(n / cols);\n const h = (area.height - gap * (rows - 1)) / rows;\n panes.forEach((id, i) => {\n const row = Math.floor(i / cols);\n const inRow = row === rows - 1 ? n - cols * (rows - 1) : cols;\n const col = i - row * cols;\n const w = (area.width - gap * (inRow - 1)) / inRow;\n out.set(id, { x: area.x + col * (w + gap), y: area.y + row * (h + gap), width: w, height: h });\n });\n return out;\n}\n","/**\n * The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split\n * with an `axis` divides along it (`\"x\"`: `a` left of `b`; `\"y\"`: `a` above `b`) at `ratio`; one without divides\n * along the rect's longer side in halves, which is dwindle (split along the longer side). Pure: trees in, trees out.\n */\nimport type { MasterOptions } from \"./order\";\nimport type { PaneRegion, PaneSide } from \"./regions\";\n\n/**\n * A pane, or a split of its rect in two, `a` then `b`. A split takes its `axis` and its `ratio` (the first side's\n * share); `gap` replaces the layout's gap for this split (the handle stays global); `id` names the split so\n * `layoutSplitTree` reports its geometry. With `master`, the split lays its subtree out flat: its panes, in order,\n * as master and stack (`masterStack`) in its rect, by its `ratio` and gap; the splits under it are not laid out.\n */\nexport type Split<K> =\n | { readonly pane: K }\n | {\n readonly a: Split<K>;\n readonly b: Split<K>;\n readonly axis?: \"x\" | \"y\";\n readonly ratio?: number;\n readonly gap?: number;\n readonly id?: string;\n readonly master?: MasterOptions;\n };\n\n/** The panes of `tree` in order (`a` before `b`). */\nexport const panesOf = <K>(tree: Split<K> | null): K[] => (!tree ? [] : \"pane\" in tree ? [tree.pane] : [...panesOf(tree.a), ...panesOf(tree.b)]);\n\nconst has = <K>(tree: Split<K> | null, pane: K): boolean => panesOf(tree).includes(pane);\n\n/** `tree` with each pane node `fn` gives a replacement for replaced. */\nfunction mapPanes<K>(tree: Split<K>, fn: (pane: K) => Split<K>): Split<K> {\n if (\"pane\" in tree) return fn(tree.pane);\n return { ...tree, a: mapPanes(tree.a, fn), b: mapPanes(tree.b, fn) };\n}\n\n/**\n * `tree` with pane `at` split in two, `pane` on its `side`. A side writes an explicit axis and ratio 0.5, so the side\n * means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty\n * tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.\n */\nexport function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: PaneSide): Split<K> {\n const fresh: Split<K> = { pane };\n const split = (node: Split<K>): Split<K> => {\n if (!side) return { a: node, b: fresh };\n const axis = side === \"left\" || side === \"right\" ? \"x\" : \"y\";\n const first = side === \"left\" || side === \"top\";\n return first ? { a: fresh, b: node, axis, ratio: 0.5 } : { a: node, b: fresh, axis, ratio: 0.5 };\n };\n if (!tree) return fresh;\n if (at === null || !has(tree, at)) return split(tree);\n return mapPanes(tree, (p) => (p === at ? split({ pane: p }) : { pane: p }));\n}\n\n/** `tree` without `pane`: its sibling takes their parent's place. */\nexport function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null {\n if (!tree) return null;\n if (\"pane\" in tree) return tree.pane === pane ? null : tree;\n const a = removePane(tree.a, pane);\n const b = removePane(tree.b, pane);\n return a && b ? { ...tree, a, b } : (a ?? b);\n}\n\n/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */\nexport function swapPanes<K>(tree: Split<K> | null, x: K, y: K): Split<K> | null {\n if (!tree || !has(tree, x) || !has(tree, y)) return tree;\n return mapPanes(tree, (p) => ({ pane: p === x ? y : p === y ? x : p }));\n}\n\n/** A dwindle tree for `panes`: each one splits the one before it along the longer side. */\nexport function splitFromOrder<K>(panes: readonly K[]): Split<K> | null {\n let t: Split<K> | null = null;\n panes.forEach((id, i) => {\n t = splitPane(t, i > 0 ? panes[i - 1]! : null, id);\n });\n return t;\n}\n\n/**\n * A drop of `dragged` on pane `at`'s `region`. A side splits `at` on that side (`dragged` taken out of its old place\n * first). The center swaps the two when `dragged` is in the tree; a pane from outside takes `at`'s place, with `at`\n * split off after it along the longer side. An `at` that isn't in the tree (or is `dragged` itself) changes nothing\n * but adding `dragged` when it is missing, as `splitPane` does. The set of panes is kept: the tree's, plus `dragged`.\n */\nexport function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K> {\n if (!tree) return { pane: dragged };\n if (dragged === at || !has(tree, at)) return has(tree, dragged) ? tree : splitPane(tree, null, dragged);\n if (region !== \"center\") return splitPane(removePane(tree, dragged), at, dragged, region);\n if (has(tree, dragged)) return swapPanes(tree, dragged, at)!;\n return mapPanes(tree, (p) => (p === at ? { a: { pane: dragged }, b: { pane: p } } : { pane: p }));\n}\n","/**\n * The split tree laid out: the rect of every pane of a `Split` tree in an area, and the geometry of the splits that\n * have an id. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport { masterCount, masterRatio, masterStack, type MasterOptions, type TileOptions } from \"./order\";\nimport { panesOf, type Split } from \"./split\";\n\n/** A px option: a finite number, never below 0 (anything else is 0). */\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/** A ratio: clamped to 0..1; one that is not finite is 0.5. */\nconst unit = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(1, Math.max(0, v)));\n\n/** A usable length: finite and above 0. */\nconst usable = (v: number | undefined): v is number => v !== undefined && Number.isFinite(v) && v > 0;\n\n/** The least a ratio may be in a split with a floor: within 5 and 95 % unless a side takes the net off. */\nconst NET: readonly [number, number] = [0.05, 0.95];\n\n/** A split child's fixed length along its split. `keep` marks one that holds its length even beside another. */\nexport interface FixedLength {\n readonly length: number;\n readonly keep?: boolean;\n}\n\n/** A split child's least length along its split. `net` (default true) keeps the split's ratio within 5..95 %. */\nexport interface MinLength {\n readonly min: number;\n readonly net?: boolean;\n}\n\n/**\n * What a split tree's layout reads of its host, each per split, of the split's two direct children.\n *\n * - `fixed(child, axis)`: the child's fixed length along the split, if it has one. The first child that reports one\n * decides: it takes its length when the length is above 0 and, with the gutter, less than the extent, and the other\n * side fills the rest (the gutter between). Otherwise, or with a length that does not fit, the split falls back to\n * its ratio, and the other child's length is not read. When both report a length with `keep`, each keeps its own,\n * in order, and the room left over stays empty; if the two (and the gutter) do not fit the extent, the second runs\n * past the end. A split a fixed length decides has no divider and no floor.\n * - `fixedAcross(child, axis)`: the child's fixed length across the split; the child takes it, when positive and\n * finite, from the start of the cross axis instead of the whole cross extent. It is not checked against the cross\n * extent: a length larger than the cross extent makes a pane larger than the split's box.\n * - `floor(child, axis, split)`: the child's least length along the split. The ratio is clamped so each side keeps\n * its floor of the room less the gutter, within the net (5..95 %) unless either side says `net: false`; where the\n * two floors cannot both fit, the ratio is 0.5. With no `floor`, the ratio is only clamped to 0..1. `giveWay` is\n * the other policy of the same minimum: it floats the newest pane instead of squeezing the ratio, and a host\n * chooses one for a pane.\n */\nexport interface SplitOptions<K> extends TileOptions {\n readonly fixed?: (child: Split<K>, axis: \"x\" | \"y\") => FixedLength | undefined;\n readonly fixedAcross?: (child: Split<K>, axis: \"x\" | \"y\") => number | undefined;\n readonly floor?: (child: Split<K>, axis: \"x\" | \"y\", split: Split<K>) => MinLength;\n}\n\n/** A laid-out split: the box it divides, its axis and ratio in effect, and the strip between its two sides. */\nexport interface SplitGeometry {\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n /**\n * The first side's share in effect: the middle of the gutter lies at the box's start plus its extent times this\n * (for a fixed-length child, the middle of the gutter after the first side over the extent). For a master split\n * it is the master area's share (clamped to 0.05..0.95) of the room less the gap, measured from the master's own\n * side: with the master on the right, ratio 0.3 in 1000 with a gap of 10, the divider lies at 693..703.\n */\n readonly ratio: number;\n /** The gutter between the two sides, as a rect inside `rect`; null where the split has none. */\n readonly divider: Rect | null;\n}\n\n/** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */\nexport interface SplitLayout<K> {\n readonly panes: Map<K, Rect>;\n readonly splits: Map<string, SplitGeometry>;\n}\n\ninterface Ctx<K> {\n readonly options: SplitOptions<K>;\n readonly gap: number;\n readonly handle: number;\n readonly panes: Map<K, Rect>;\n /** Where the geometry of the named splits goes; null for `layoutSplit`, which reports panes only and builds none. */\n readonly splits: Map<string, SplitGeometry> | null;\n}\n\n/**\n * The rect of every pane of `tree` in `area`. Each split's gutter is its gap (its own `gap`, else `options.gap`) plus\n * `options.handle`. A split's `ratio` is clamped to 0..1 (one that is not finite is 0.5), and the middle of the gutter\n * sits at `extent * ratio`: the first side is `extent * ratio` less half the gutter, the second starts half a gutter\n * past it and is the rest less half the gutter. No size is ever negative: a side too short for half the gutter is 0\n * along the axis, and the second side of a split with no room may then start up to half a gutter past the rect's end.\n * At ratio 0.5 both sides are equal. `options.floor`, `fixed` and `fixedAcross` (see `SplitOptions`) read the host's\n * minimums and fixed lengths per split. A negative or non-finite `gap` or `handle` is 0. The area is taken as given:\n * with a negative width or height every length along that axis is 0 and a pane's size across it is copied as it\n * is, so pass an area with no negative side.\n */\nexport function layoutSplit<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): Map<K, Rect> {\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits: null };\n lay(tree, area, ctx, false);\n return ctx.panes;\n}\n\n/**\n * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split under another, or a later one beside it): the box it divides,\n * its axis and ratio in effect (after the floors), and its divider, the gutter strip between its two sides. A split\n * that lays out as master and stack is reported too, its nested splits are not.\n */\nexport function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): SplitLayout<K> {\n const splits = new Map<string, SplitGeometry>();\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits };\n lay(tree, area, ctx, false);\n return { panes: ctx.panes, splits };\n}\n\n/** The strip `gutter` wide centered on `mid` across `box`, clipped to it. */\nfunction strip(box: Rect, x: boolean, mid: number, gutter: number): Rect {\n const lo = Math.max(x ? box.x : box.y, mid - gutter / 2);\n const hi = Math.min(x ? box.x + box.width : box.y + box.height, mid + gutter / 2);\n const length = Math.max(0, hi - lo);\n return x ? { x: lo, y: box.y, width: length, height: box.height } : { x: box.x, y: lo, width: box.width, height: length };\n}\n\n/**\n * `ratio` kept so the first side has `minA` and the second `minB` of the room less the gutter (at least 1 px of room),\n * within `net`; 0.5 where the two cannot both fit.\n */\nfunction clampByMin(ratio: number, extent: number, gutter: number, minA: number, minB: number, net: readonly [number, number]): number {\n const room = Math.max(extent - gutter, 1);\n const boundedMin = Math.min(Math.max(minA / room, net[0]), net[1]);\n const boundedMax = Math.max(Math.min(1 - minB / room, net[1]), net[0]);\n return boundedMin > boundedMax ? 0.5 : Math.min(Math.max(ratio, boundedMin), boundedMax);\n}\n\n/** A split that lays its panes out flat as master and stack: the gap only, never the handle. */\nfunction layMaster<K>(tree: Extract<Split<K>, { a: unknown }>, master: MasterOptions, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n const gap = tree.gap === undefined ? ctx.gap : px(tree.gap);\n const panes = panesOf(tree);\n const ratio = masterRatio(tree.ratio);\n const side = master.side ?? \"left\";\n // Only the count and side come from `master`: the ratio and gap are the split's own.\n for (const [pane, r] of masterStack(panes, area, { gap, ratio, count: master.count, side })) ctx.panes.set(pane, r);\n if (tree.id === undefined || ctx.splits === null) return;\n const x = side === \"left\" || side === \"right\";\n const stacked = panes.length > masterCount(master.count, panes.length);\n const room = Math.max(0, (x ? area.width : area.height) - gap);\n const first = side === \"left\" || side === \"top\" ? room * ratio : room * (1 - ratio);\n const mid = (x ? area.x : area.y) + first + gap / 2;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis: x ? \"x\" : \"y\", ratio, divider: stacked ? strip(area, x, mid, gap) : null });\n}\n\n/**\n * Lays `tree` out in `area`. `owned` says `area` is a rect this layout made itself (a split's child), so a pane or a\n * split may keep it as its own; the caller's rect (the root) is copied, never kept.\n */\nfunction lay<K>(tree: Split<K> | null, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n if (!tree) return;\n if (\"pane\" in tree) {\n ctx.panes.set(tree.pane, owned ? area : { ...area });\n return;\n }\n if (tree.master) {\n layMaster(tree, tree.master, area, ctx, owned);\n return;\n }\n const axis = tree.axis ?? (area.width >= area.height ? \"x\" : \"y\");\n const x = axis === \"x\";\n const extent = x ? area.width : area.height;\n const origin = x ? area.x : area.y;\n const cross = x ? area.height : area.width;\n const gutter = (tree.gap === undefined ? ctx.gap : px(tree.gap)) + ctx.handle;\n const { fixed, fixedAcross, floor } = ctx.options;\n // Across the split a child with a fixed length takes it from the start; the others take the whole cross extent.\n const lenA = fixedAcross?.(tree.a, axis);\n const lenB = fixedAcross?.(tree.b, axis);\n const acrossA = usable(lenA) ? lenA : cross;\n const acrossB = usable(lenB) ? lenB : cross;\n const fixedA = fixed?.(tree.a, axis);\n const fixedB = fixed?.(tree.b, axis);\n\n // The lengths of the two sides along the split, where the second starts, the ratio in effect and the divider.\n let lengthA: number;\n let lengthB: number;\n let startB: number;\n let ratio = unit(tree.ratio);\n let ruled = false; // the divider is the gutter strip at the ratio (a split no fixed length decides)\n const lead = fixedA ?? fixedB;\n if (fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length)) {\n lengthA = fixedA.length;\n lengthB = fixedB.length;\n startB = origin + lengthA + gutter;\n ratio = extent > 0 ? (lengthA + gutter / 2) / extent : ratio;\n } else if (lead && usable(lead.length) && lead.length + gutter < extent) {\n const rest = Math.max(0, extent - lead.length - gutter);\n lengthA = lead === fixedA ? lead.length : rest;\n lengthB = lead === fixedA ? rest : lead.length;\n startB = origin + lengthA + gutter;\n ratio = (lengthA + gutter / 2) / extent;\n } else {\n if (floor) {\n const a = floor(tree.a, axis, tree);\n const b = floor(tree.b, axis, tree);\n const net = a.net === false || b.net === false ? ([0, 1] as const) : NET;\n ratio = clampByMin(Number.isFinite(tree.ratio ?? 0.5) ? (tree.ratio ?? 0.5) : 0.5, extent, gutter, px(a.min), px(b.min), net);\n }\n lengthA = Math.max(0, extent * ratio - gutter / 2);\n lengthB = Math.max(0, extent * (1 - ratio) - gutter / 2);\n startB = origin + extent * ratio + gutter / 2;\n ruled = true;\n }\n // The geometry is built only for a named split and only when the caller asked for it (`layoutSplitTree`).\n if (tree.id !== undefined && ctx.splits !== null) {\n const divider = ruled ? strip(area, x, origin + extent * ratio, gutter) : null;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis, ratio, divider });\n }\n if (x) {\n lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx, true);\n lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx, true);\n } else {\n lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx, true);\n lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx, true);\n }\n}\n","/**\n * Whether a drop on a pane leaves room: the rule a host asks before it offers a side of a pane as a drop place. See\n * docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport { layoutSplit, type SplitOptions } from \"./layout\";\nimport type { PaneRegion, PaneSide } from \"./regions\";\nimport { dropOnPane, panesOf, removePane, type Split } from \"./split\";\n\n/** The layout options a drop is judged under, and `min`: the least width and height, px, a pane must keep. */\nexport interface DropOptions<K> extends SplitOptions<K> {\n readonly min: number;\n}\n\n/** A drop's verdict: `ok`, or not, with its `reason`. */\nexport interface DropVerdict {\n readonly ok: boolean;\n readonly reason?: string;\n}\n\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/**\n * Whether dropping `dragged` on pane `at`'s `region` leaves both at least `options.min` wide and high.\n *\n * - The center is fine unless `dragged` is `at`, or `at` is not in the tree (nothing to swap with).\n * - A side needs, in the layout of the tree without `dragged` (so `at` is measured where it will be when `dragged` is\n * lifted out), a span of `at` along the split of at least `2 * min` plus the gutter (the options' gap plus handle)\n * and across it of at least `min`; and in the layout of `dropOnPane(tree, dragged, at, region)` both `dragged` and\n * `at` at least `min` wide and high. That check is skipped when `area` has no width or no height. A pane that is\n * not in the tree counts as one being added; an `at` that is not in it (or is `dragged`) has no place to split.\n */\nexport function canDropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion, area: Rect, options: DropOptions<K>): DropVerdict {\n if (region === \"center\") {\n if (dragged === at) return { ok: false, reason: \"center swap blocked: a pane dropped on itself\" };\n return panesOf(tree).includes(at) ? { ok: true } : { ok: false, reason: \"center rejected: no pane to swap\" };\n }\n const target = layoutSplit(removePane(tree, dragged), area, options).get(at);\n if (!target) return { ok: false, reason: `${region} rejected: no pane to split` };\n const room = canSplitPane(target, region, options);\n if (!room.ok) return room;\n return dropFits(layoutSplit(dropOnPane(tree, dragged, at, region), area, options), dragged, at, area, { min: options.min, side: region });\n}\n\n/** What `canSplitPane` reads: `min` (as in `DropOptions`) and the gutter's parts, `gap` and `handle`, px. */\nexport interface SplitRoomOptions {\n readonly min: number;\n readonly gap?: number;\n readonly handle?: number;\n}\n\n/**\n * The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and\n * high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the\n * gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be\n * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.\n */\nexport function canSplitPane(target: Rect, side: PaneSide, options: SplitRoomOptions): DropVerdict {\n const min = px(options.min);\n const gutter = px(options.gap) + px(options.handle);\n const horizontal = side === \"left\" || side === \"right\";\n const along = horizontal ? target.width : target.height;\n const across = horizontal ? target.height : target.width;\n const need = min * 2 + gutter;\n if (along < need) return { ok: false, reason: `${side} rejected: axis span ${along.toFixed(1)}px < min ${need.toFixed(1)}px (2 panes + gutter ${gutter}px)` };\n if (across < min) return { ok: false, reason: `${side} rejected: cross span ${across.toFixed(1)}px < min ${min.toFixed(1)}px` };\n return { ok: true };\n}\n\n/** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */\nexport interface DropFitsOptions {\n readonly min: number;\n readonly side: PaneSide;\n}\n\n/**\n * The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of\n * `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and high. Fine\n * when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule.\n */\nexport function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict {\n if (!(area.width > 0 && area.height > 0)) return { ok: true };\n const min = px(options.min);\n const fits = (r: Rect | undefined): boolean => !!r && r.width >= min && r.height >= min;\n return fits(projected.get(dragged)) && fits(projected.get(at)) ? { ok: true } : { ok: false, reason: `${options.side} rejected: projected footprint of the two panes violates min ${min}px` };\n}\n","/**\n * A pane's drop regions: a center rectangle (a drop there swaps with the pane) and four side trapezoids (a drop there\n * splits the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the center.\n * The five regions cover the pane with no gaps and no overlaps.\n *\n * Meant for `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane (`paneTargets`), its place\n * the region under the pointer, the previous region held for `hysteresis` px past its boundary so a pointer resting on\n * a boundary doesn't flicker. A region that takes no drop is the consumer's to answer with a null place.\n */\nimport { clamp, type Point, type Rect, type Size } from \"../geometry\";\n\nexport type PaneSide = \"top\" | \"right\" | \"bottom\" | \"left\";\nexport type PaneRegion = \"center\" | PaneSide;\n\n/** The sides in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */\nexport const PANE_SIDES: readonly PaneSide[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface PaneRegionOptions {\n /** The center rectangle's share of each pane axis (0.05 to 0.95); `centerX` / `centerY` override one axis. */\n readonly center?: number;\n readonly centerX?: number;\n readonly centerY?: number;\n /** The least the center spans on either axis, px (a small pane keeps a usable center). */\n readonly centerMin?: number;\n /** How far past its boundary the previous region holds, px. */\n readonly hysteresis?: number;\n /** Device pixels per px: the center's edges snap to that grid, as the browser draws them. */\n readonly pixelRatio?: number;\n /**\n * The pane's center rectangle as the host already has it (pane-local px, as `paneCenter` gives), used as it is in\n * place of measuring: `center`, `centerX`, `centerY`, `centerMin` and `pixelRatio` are not read. Only `paneRegion`\n * reads it; its `width` and `height` are the pane's own size for the hold toward the middle.\n */\n readonly paneCenter?: PaneCenter;\n}\n\nexport const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, \"centerX\" | \"centerY\" | \"paneCenter\">> = { center: 0.34, centerMin: 24, hysteresis: 6, pixelRatio: 1 };\n\n/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */\nexport interface PaneCenter {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nconst snap = (v: number, ratio: number): number => Math.round(v * ratio) / ratio;\n\n/** Where the center rectangle of a pane of `size` lies, by these options. */\nexport function paneCenter(size: Size, options: PaneRegionOptions = {}): PaneCenter {\n const o = { ...PANE_REGION_DEFAULTS, ...options };\n const width = Math.max(0, size.width);\n const height = Math.max(0, size.height);\n const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;\n const rx = clamp(o.centerX ?? o.center, 0.05, 0.95);\n const ry = clamp(o.centerY ?? o.center, 0.05, 0.95);\n const cw = Math.min(width, Math.max(width * rx, Math.min(o.centerMin, width)));\n const ch = Math.min(height, Math.max(height * ry, Math.min(o.centerMin, height)));\n return { width, height, left: snap((width - cw) / 2, ratio), top: snap((height - ch) / 2, ratio), right: snap((width + cw) / 2, ratio), bottom: snap((height + ch) / 2, ratio) };\n}\n\n/** How deep past the center a point is toward each side, as a share of that side's band (positive: in that band). */\nfunction depths(p: Point, c: PaneCenter): { side: PaneSide; depth: number }[] {\n return [\n { side: \"top\", depth: (c.top - p.y) / Math.max(c.top, 1) },\n { side: \"right\", depth: (p.x - c.right) / Math.max(c.width - c.right, 1) },\n { side: \"bottom\", depth: (p.y - c.bottom) / Math.max(c.height - c.bottom, 1) },\n { side: \"left\", depth: (c.left - p.x) / Math.max(c.left, 1) },\n ];\n}\n\n/** The region a pane-local point is in, by position alone. */\nfunction rawRegion(p: Point, c: PaneCenter): PaneRegion {\n if (p.x >= c.left && p.x <= c.right && p.y >= c.top && p.y <= c.bottom) return \"center\";\n let best: PaneRegion = \"center\";\n let deepest = 0;\n for (const d of depths(p, c)) {\n if (d.depth > deepest) {\n deepest = d.depth;\n best = d.side;\n }\n }\n return best;\n}\n\n/** `p` moved `by` px into `region` (toward the pane's middle for the center). */\nfunction toward(p: Point, region: PaneRegion, by: number, c: PaneCenter): Point {\n if (region === \"left\") return { x: p.x - by, y: p.y };\n if (region === \"right\") return { x: p.x + by, y: p.y };\n if (region === \"top\") return { x: p.x, y: p.y - by };\n if (region === \"bottom\") return { x: p.x, y: p.y + by };\n const dx = c.width / 2 - p.x;\n const dy = c.height / 2 - p.y;\n const len = Math.hypot(dx, dy);\n if (len <= by || len === 0) return { x: c.width / 2, y: c.height / 2 };\n return { x: p.x + (dx / len) * by, y: p.y + (dy / len) * by };\n}\n\n/**\n * The drop region of `pane` (in the same coordinates as `point`) the point is in. With a `previous` region, the point\n * has to be `hysteresis` px past that region's boundary before the region changes: no time-based debounce, only\n * geometry. A host that has measured the center itself passes it as `options.paneCenter`; the same center gives the\n * same region as the one measured here.\n */\nexport function paneRegion(pane: Rect, point: Point, previous: PaneRegion | null = null, options: PaneRegionOptions = {}): PaneRegion {\n const c = options.paneCenter ?? paneCenter(pane, options);\n const p = { x: point.x - pane.x, y: point.y - pane.y };\n const raw = rawRegion(p, c);\n const by = Math.max(0, options.hysteresis ?? PANE_REGION_DEFAULTS.hysteresis);\n if (previous === null || by === 0 || previous === raw) return raw;\n return rawRegion(toward(p, previous, by, c), c) === previous ? previous : raw;\n}\n","/**\n * Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one\n * helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an\n * insertion target (`at:<index>`, its hit and slot the dragged pane's rect with it inserted there) for an order layout.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport type { OrderLayout, OrderOptions } from \"./order\";\n\n/** A split tree's target: drop on pane `pane` (the region under the pointer says how). */\nexport interface PaneTarget<K> extends Target {\n readonly pane: K;\n}\n\n/** An order layout's target: insert the dragged pane at `index`; `layout` is every pane's rect with it there. */\nexport interface OrderTarget<K> extends Target {\n readonly index: number;\n readonly layout: ReadonlyMap<K, Rect>;\n}\n\n/** The one shape both kinds share: a slot-sized drop with no precedence over any other. */\nconst tilingTarget = (id: string, hit: Rect, slot?: Rect): Target => ({ id, priority: 2, hit, ...(slot ? { slot } : {}) });\n\nexport interface PaneTargetsOptions<K> {\n /** A pane left out: the dragged one, when it is still laid out. */\n readonly except?: K;\n /**\n * A pane's key in its target's id (`pane:<key>`); default `String`. Keys must be unique across the panes: a drag\n * intent follows its targets by id, so two panes with one key would be one target.\n */\n readonly key?: (pane: K) => string;\n}\n\n/** One target per pane of `layout`, its id `pane:<key>`. */\nexport function paneTargets<K>(layout: ReadonlyMap<K, Rect>, options: PaneTargetsOptions<K> = {}): PaneTarget<K>[] {\n const key = options.key ?? String;\n return [...layout].filter(([k]) => k !== options.except).map(([pane, r]) => ({ ...tilingTarget(`pane:${key(pane)}`, r), pane }));\n}\n\n/**\n * One target per index `dragged` could be inserted at among `panes` (which don't hold it), laid out by `arrange` in\n * `area`. Each target's hit and slot is `dragged`'s rect with it there, so the targets cover the area as the layout\n * does. Ids are `at:<index>`, unique whatever the panes are.\n */\nexport function orderTargets<K>(arrange: OrderLayout, panes: readonly K[], dragged: K, area: Rect, options?: OrderOptions): OrderTarget<K>[] {\n return Array.from({ length: panes.length + 1 }, (_, index) => {\n const layout = arrange([...panes.slice(0, index), dragged, ...panes.slice(index)], area, options);\n const slot = layout.get(dragged)!;\n return { ...tilingTarget(`at:${index}`, slot, slot), index, layout };\n });\n}\n","import type { Rect, Size } from \"../geometry\";\n\n/**\n * The minimum-size give-way: while a pane is laid out below its minimum, the newest pane (highest `age`) floats and\n * the rest are laid out again. Stops when every pane keeps its minimum or one pane is left. `layout` lays out the\n * kept panes; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (pane: K) => Size, age: (pane: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...panes];\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 nearest pane in a direction: the rule a host moves focus by. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\n\n/** A direction on the plane: `\"up\"` is toward smaller y. */\nexport type Direction = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * The pane nearest `from` in `direction`, or null when none lies that way. A candidate's center has to be strictly on\n * that side of `from`'s center. Its score is the center distance along the direction, plus a quarter of the center\n * distance across it, plus 100 when it does not overlap `from` across the direction (the overlap strictly above 0);\n * the lowest score wins, ties to the first in the map's order. A pane that is not in `rects` has no neighbor.\n *\n * The host chooses which rects to pass. One option: lay the tree out in a unit square (`{ x: 0, y: 0, width: 1,\n * height: 1 }`) with the host's px floors. A floor of tens of px cannot fit in a unit square, so a split's two floors\n * cannot both fit and it lays out at 0.5 whatever its ratio; fixed lengths in px along a split do not fit either, and\n * the area's size and the gap drop out. Fixed lengths across a split are not checked against the cross extent, so\n * they still apply in a unit square, and a host leaves `fixedAcross` out there. The rects of the real layout work too.\n */\nexport function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null {\n const origin = rects.get(from);\n if (!origin) return null;\n const horizontal = direction === \"left\" || direction === \"right\";\n // Centers and ends as sums of edges (right = x + width), so a host that keeps edge rects gets the same bits.\n const center = (r: Rect, x: boolean): number => (x ? (r.x + (r.x + r.width)) / 2 : (r.y + (r.y + r.height)) / 2);\n const reach = (r: Rect, x: boolean): [number, number] => (x ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const fromAlong = center(origin, horizontal);\n const fromAcross = center(origin, !horizontal);\n const [originStart, originEnd] = reach(origin, !horizontal);\n const sign = direction === \"left\" || direction === \"up\" ? -1 : 1;\n let best: K | null = null;\n let bestScore = Number.POSITIVE_INFINITY;\n for (const [key, r] of rects) {\n if (key === from) continue;\n const along = center(r, horizontal);\n if (sign < 0 ? along >= fromAlong : along <= fromAlong) continue;\n const [start, end] = reach(r, !horizontal);\n const overlap = Math.max(0, Math.min(originEnd, end) - Math.max(originStart, start));\n const score = Math.abs(along - fromAlong) + Math.abs(center(r, !horizontal) - fromAcross) * 0.25 + (overlap > 0 ? 0 : 100);\n if (score < bestScore) {\n bestScore = score;\n best = key;\n }\n }\n return best;\n}\n"],"mappings":";;;;;AAmCO,IAAM,cAAc,CAAC,MAAmC,MAAM,UAAa,CAAC,O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AAE,KAAK,EAAE,IAAI,EAAE,WAAW;AAC9G,QAAM,QAAQ,CAAC,GAAS,MAAkC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM;AACzG,QAAM,YAAY,OAAO,QAAQ,UAAU;AAC3C,QAAM,aAAa,OAAO,QAAQ,CAAC,UAAU;AAC7C,QAAM,CAAC,aAAa,SAAS,IAAI,MAAM,QAAQ,CAAC,UAAU;AAC1D,QAAM,OAAO,cAAc,UAAU,cAAc,OAAO,KAAK;AAC/D,MAAI,OAAiB;AACrB,MAAI,YAAY,OAAO;AACvB,aAAW,CAAC,KAAK,CAAC,KAAK,OAAO;AAC5B,QAAI,QAAQ,KAAM;AAClB,UAAM,QAAQ,OAAO,GAAG,UAAU;AAClC,QAAI,OAAO,IAAI,SAAS,YAAY,SAAS,UAAW;AACxD,UAAM,CAAC,OAAO,GAAG,IAAI,MAAM,GAAG,CAAC,UAAU;AACzC,UAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,GAAG,IAAI,KAAK,IAAI,aAAa,KAAK,CAAC;AACnF,UAAM,QAAQ,KAAK,IAAI,QAAQ,SAAS,IAAI,KAAK,IAAI,OAAO,GAAG,CAAC,UAAU,IAAI,UAAU,IAAI,QAAQ,UAAU,IAAI,IAAI;AACtH,QAAI,QAAQ,WAAW;AACrB,kBAAY;AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["px"]}
1
+ {"version":3,"sources":["../src/tiling/order.ts","../src/tiling/split.ts","../src/tiling/layout.ts","../src/tiling/drop.ts","../src/tiling/regions.ts","../src/tiling/targets.ts","../src/tiling/give-way.ts","../src/tiling/drag.ts","../src/tiling/reference.ts","../src/tiling/conformance.ts","../src/tiling/neighbor.ts"],"sourcesContent":["/**\n * The order layouts: panes in order and an area in, a rect per pane out. Pure rect functions; a drop on one reorders\n * (the dragged pane inserted at an index, see `orderTargets`).\n */\nimport type { Rect } from \"../geometry\";\nimport type { Side } from \"../side\";\n\n/**\n * How a layout spaces its panes: `gap` px between neighbors (default 0), `ratio` the master's share (default 0.5),\n * `handle` px a split's divider takes beside the gap (default 0; only a split tree reads it).\n */\nexport interface TileOptions {\n readonly gap?: number;\n readonly ratio?: number;\n readonly handle?: number;\n}\n\n/**\n * The master area: `count` panes (rounded, kept within 1..n; default 1) on `side` (default `\"left\"`). Left and right\n * make it a column of panes stacked vertically; top and bottom a row of panes side by side. The one home of the\n * concept: `masterStack` takes it in its options (`OrderOptions`), a split that lays out as master and stack in its\n * `master` field.\n */\nexport interface MasterOptions {\n readonly count?: number;\n readonly side?: Side;\n}\n\n/** What the order layouts take: `TileOptions` and the master area's `count` and `side` (`columns` and `grid` ignore them). */\nexport type OrderOptions = TileOptions & MasterOptions;\n\n/** An order layout: `masterStack`, `columns`, `grid`, or the app's own of the same shape. */\nexport type OrderLayout = <K>(panes: readonly K[], area: Rect, options?: OrderOptions) => Map<K, Rect>;\n\n/** The master's share in effect: clamped to 0.05..0.95; one that is not finite is 0.5. */\nexport const masterRatio = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(0.95, Math.max(0.05, v)));\n\n/** How many of `n` panes are masters for a requested `count`: rounded, within 1..n; NaN is 1. */\nexport function masterCount(count: number | undefined, n: number): number {\n const c = Math.round(count ?? 1);\n return Math.min(Math.max(Number.isNaN(c) ? 1 : c, 1), Math.max(n, 1));\n}\n\n/** `items` side by side or one above the other in equal shares of the box, `gap` between them. */\nfunction divide<K>(items: readonly K[], x: number, y: number, width: number, height: number, vertical: boolean, gap: number, out: Map<K, Rect>): void {\n const n = items.length;\n const total = gap * (n - 1);\n if (vertical) {\n const each = Math.max(0, (height - total) / n);\n items.forEach((pane, i) => out.set(pane, { x, y: y + i * (each + gap), width, height: each }));\n } else {\n const each = Math.max(0, (width - total) / n);\n items.forEach((pane, i) => out.set(pane, { x: x + i * (each + gap), y, width: each, height }));\n }\n}\n\n/**\n * Master and stack: the first `count` panes are the masters, in an area on `side` that takes `ratio` of the room the\n * gap leaves (clamped to 0.05..0.95; default 0.5); the rest are the stack, in the other area. Left and right make\n * each area a column of panes stacked vertically; top and bottom a row of panes side by side. Right and bottom put\n * the stack first in space. With no stack (n at most `count`) all the panes fill the area, stacked along the side's\n * cross axis. Each area divides its length equally between its panes, the gap between them.\n */\nexport function masterStack<K>(panes: readonly K[], area: Rect, options: OrderOptions = {}): Map<K, Rect> {\n const gap = options.gap !== undefined && Number.isFinite(options.gap) && options.gap > 0 ? options.gap : 0;\n const out = new Map<K, Rect>();\n if (panes.length === 0) return out;\n const side = options.side ?? \"left\";\n const ratio = masterRatio(options.ratio);\n const count = masterCount(options.count, panes.length);\n const masters = panes.slice(0, count);\n const stack = panes.slice(count);\n const column = side === \"left\" || side === \"right\";\n if (stack.length === 0) {\n divide(masters, area.x, area.y, area.width, area.height, column, gap, out);\n } else if (column) {\n const room = Math.max(0, area.width - gap);\n const masterWidth = room * ratio;\n const stackWidth = room * (1 - ratio);\n const masterX = side === \"left\" ? area.x : area.x + stackWidth + gap;\n const stackX = side === \"left\" ? area.x + masterWidth + gap : area.x;\n divide(masters, masterX, area.y, masterWidth, area.height, true, gap, out);\n divide(stack, stackX, area.y, stackWidth, area.height, true, gap, out);\n } else {\n const room = Math.max(0, area.height - gap);\n const masterHeight = room * ratio;\n const stackHeight = room * (1 - ratio);\n const masterY = side === \"top\" ? area.y : area.y + stackHeight + gap;\n const stackY = side === \"top\" ? area.y + masterHeight + gap : area.y;\n divide(masters, area.x, masterY, area.width, masterHeight, false, gap, out);\n divide(stack, area.x, stackY, area.width, stackHeight, false, gap, out);\n }\n return out;\n}\n\n/** Equal columns, full height. */\nexport function columns<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n const w = (area.width - gap * (n - 1)) / Math.max(1, n);\n panes.forEach((id, i) => out.set(id, { x: area.x + i * (w + gap), y: area.y, width: w, height: area.height }));\n return out;\n}\n\n/** A grid as square as the count allows; the last row's cells widen to fill it. */\nexport function grid<K>(panes: readonly K[], area: Rect, options: TileOptions = {}): Map<K, Rect> {\n const gap = options.gap ?? 0;\n const out = new Map<K, Rect>();\n const n = panes.length;\n if (n === 0) return out;\n const cols = Math.ceil(Math.sqrt(n));\n const rows = Math.ceil(n / cols);\n const h = (area.height - gap * (rows - 1)) / rows;\n panes.forEach((id, i) => {\n const row = Math.floor(i / cols);\n const inRow = row === rows - 1 ? n - cols * (rows - 1) : cols;\n const col = i - row * cols;\n const w = (area.width - gap * (inRow - 1)) / inRow;\n out.set(id, { x: area.x + col * (w + gap), y: area.y + row * (h + gap), width: w, height: h });\n });\n return out;\n}\n","/**\n * The split tree: how panes divide an area. A node is a pane, or a split of its rect in two (`a` then `b`). A split\n * with an `axis` divides along it (`\"x\"`: `a` left of `b`; `\"y\"`: `a` above `b`) at `ratio`; one without divides\n * along the rect's longer side in halves, which is dwindle (split along the longer side). Pure: trees in, trees out.\n */\nimport type { Axis, Side } from \"../side\";\nimport type { MasterOptions } from \"./order\";\nimport type { PaneRegion } from \"./regions\";\n\n/**\n * A pane, or a split of its rect in two, `a` then `b`. A split takes its `axis` and its `ratio` (the first side's\n * share); `gap` replaces the layout's gap for this split (the handle stays global); `id` names the split so\n * `layoutSplitTree` reports its geometry. With `master`, the split lays its subtree out flat: its panes, in order,\n * as master and stack (`masterStack`) in its rect, by its `ratio` and gap; the splits under it are not laid out.\n */\nexport type Split<K> =\n | { readonly pane: K }\n | {\n readonly a: Split<K>;\n readonly b: Split<K>;\n readonly axis?: Axis;\n readonly ratio?: number;\n readonly gap?: number;\n readonly id?: string;\n readonly master?: MasterOptions;\n };\n\n/** The panes of `tree` in order (`a` before `b`). */\nexport const panesOf = <K>(tree: Split<K> | null): K[] => (!tree ? [] : \"pane\" in tree ? [tree.pane] : [...panesOf(tree.a), ...panesOf(tree.b)]);\n\nconst has = <K>(tree: Split<K> | null, pane: K): boolean => panesOf(tree).includes(pane);\n\n/** `tree` with each pane node `fn` gives a replacement for replaced. */\nfunction mapPanes<K>(tree: Split<K>, fn: (pane: K) => Split<K>): Split<K> {\n if (\"pane\" in tree) return fn(tree.pane);\n return { ...tree, a: mapPanes(tree.a, fn), b: mapPanes(tree.b, fn) };\n}\n\n/**\n * `tree` with pane `at` split in two, `pane` on its `side`. A side writes an explicit axis and ratio 0.5, so the side\n * means the same whatever the pane's shape; no side splits along the longer side, `pane` second (dwindle). An empty\n * tree becomes `pane` alone; an `at` that isn't in the tree (or null) splits the whole tree, so no pane is lost.\n */\nexport function splitPane<K>(tree: Split<K> | null, at: K | null, pane: K, side?: Side): Split<K> {\n const fresh: Split<K> = { pane };\n const split = (node: Split<K>): Split<K> => {\n if (!side) return { a: node, b: fresh };\n const axis = side === \"left\" || side === \"right\" ? \"x\" : \"y\";\n const first = side === \"left\" || side === \"top\";\n return first ? { a: fresh, b: node, axis, ratio: 0.5 } : { a: node, b: fresh, axis, ratio: 0.5 };\n };\n if (!tree) return fresh;\n if (at === null || !has(tree, at)) return split(tree);\n return mapPanes(tree, (p) => (p === at ? split({ pane: p }) : { pane: p }));\n}\n\n/** `tree` without `pane`: its sibling takes their parent's place. */\nexport function removePane<K>(tree: Split<K> | null, pane: K): Split<K> | null {\n if (!tree) return null;\n if (\"pane\" in tree) return tree.pane === pane ? null : tree;\n const a = removePane(tree.a, pane);\n const b = removePane(tree.b, pane);\n return a && b ? { ...tree, a, b } : (a ?? b);\n}\n\n/** `tree` with panes `x` and `y` in each other's place; unchanged unless both are in it. */\nexport function swapPanes<K>(tree: Split<K> | null, x: K, y: K): Split<K> | null {\n if (!tree || !has(tree, x) || !has(tree, y)) return tree;\n return mapPanes(tree, (p) => ({ pane: p === x ? y : p === y ? x : p }));\n}\n\n/** A dwindle tree for `panes`: each one splits the one before it along the longer side. */\nexport function splitFromOrder<K>(panes: readonly K[]): Split<K> | null {\n let t: Split<K> | null = null;\n panes.forEach((id, i) => {\n t = splitPane(t, i > 0 ? panes[i - 1]! : null, id);\n });\n return t;\n}\n\n/**\n * A drop of `dragged` on pane `at`'s `region`. A side splits `at` on that side (`dragged` taken out of its old place\n * first). The center swaps the two when `dragged` is in the tree; a pane from outside takes `at`'s place, with `at`\n * split off after it along the longer side. An `at` that isn't in the tree (or is `dragged` itself) changes nothing\n * but adding `dragged` when it is missing, as `splitPane` does. The set of panes is kept: the tree's, plus `dragged`.\n */\nexport function dropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion): Split<K> {\n if (!tree) return { pane: dragged };\n if (dragged === at || !has(tree, at)) return has(tree, dragged) ? tree : splitPane(tree, null, dragged);\n if (region !== \"center\") return splitPane(removePane(tree, dragged), at, dragged, region);\n if (has(tree, dragged)) return swapPanes(tree, dragged, at)!;\n return mapPanes(tree, (p) => (p === at ? { a: { pane: dragged }, b: { pane: p } } : { pane: p }));\n}\n","/**\n * The split tree laid out: the rect of every pane of a `Split` tree in an area, and the geometry of the splits that\n * have an id. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Axis } from \"../side\";\nimport { masterCount, masterRatio, masterStack, type MasterOptions, type TileOptions } from \"./order\";\nimport { panesOf, type Split } from \"./split\";\n\n/** A px option: a finite number, never below 0 (anything else is 0). */\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/** A ratio: clamped to 0..1; one that is not finite is 0.5. */\nconst unit = (v: number | undefined): number => (v === undefined || !Number.isFinite(v) ? 0.5 : Math.min(1, Math.max(0, v)));\n\n/** A usable length: finite and above 0. */\nconst usable = (v: number | undefined): v is number => v !== undefined && Number.isFinite(v) && v > 0;\n\n/** The least a ratio may be in a split with a floor: within 5 and 95 % unless a side takes the net off. */\nconst NET: readonly [number, number] = [0.05, 0.95];\n\n/** A split child's fixed length along its split. `keep` marks one that holds its length even beside another. */\nexport interface FixedLength {\n readonly length: number;\n readonly keep?: boolean;\n}\n\n/** A split child's least length along its split. `net` (default true) keeps the split's ratio within 5..95 %. */\nexport interface MinLength {\n readonly min: number;\n readonly net?: boolean;\n}\n\n/**\n * What a split tree's layout reads of its host, each per split, of the split's two direct children.\n *\n * - `fixed(child, axis)`: the child's fixed length along the split, if it has one. The first child that reports one\n * decides: it takes its length when the length is above 0 and, with the gutter, less than the extent, and the other\n * side fills the rest (the gutter between). Otherwise, or with a length that does not fit, the split falls back to\n * its ratio, and the other child's length is not read. When both report a length with `keep`, each keeps its own,\n * in order, and the room left over stays empty; if the two (and the gutter) do not fit the extent, the second runs\n * past the end. A split a fixed length decides has no divider and no floor.\n * - `fixedAcross(child, axis)`: the child's fixed length across the split; the child takes it, when positive and\n * finite, from the start of the cross axis instead of the whole cross extent. It is not checked against the cross\n * extent: a length larger than the cross extent makes a pane larger than the split's box.\n * - `floor(child, axis, split)`: the child's least length along the split. The ratio is clamped so each side keeps\n * its floor of the room less the gutter, within the net (5..95 %) unless either side says `net: false`; where the\n * two floors cannot both fit, the ratio is 0.5. With no `floor`, the ratio is only clamped to 0..1. `giveWay` is\n * the other policy of the same minimum: it floats the newest pane instead of squeezing the ratio, and a host\n * chooses one for a pane.\n */\nexport interface SplitOptions<K> extends TileOptions {\n readonly fixed?: (child: Split<K>, axis: Axis) => FixedLength | undefined;\n readonly fixedAcross?: (child: Split<K>, axis: Axis) => number | undefined;\n readonly floor?: (child: Split<K>, axis: Axis, split: Split<K>) => MinLength;\n}\n\n/** A laid-out split: the box it divides, its axis and ratio in effect, and the strip between its two sides. */\nexport interface SplitGeometry {\n readonly rect: Rect;\n readonly axis: \"x\" | \"y\";\n /**\n * The first side's share in effect: the middle of the gutter lies at the box's start plus its extent times this\n * (for a fixed-length child, the middle of the gutter after the first side over the extent). For a master split\n * it is the master area's share (clamped to 0.05..0.95) of the room less the gap, measured from the master's own\n * side: with the master on the right, ratio 0.3 in 1000 with a gap of 10, the divider lies at 693..703.\n */\n readonly ratio: number;\n /** The gutter between the two sides, as a rect inside `rect`; null where the split has none. */\n readonly divider: Rect | null;\n}\n\n/** A tree laid out: every pane's rect, and the geometry of each split that has an `id`. */\nexport interface SplitLayout<K> {\n readonly panes: Map<K, Rect>;\n readonly splits: Map<string, SplitGeometry>;\n}\n\ninterface Ctx<K> {\n readonly options: SplitOptions<K>;\n readonly gap: number;\n readonly handle: number;\n readonly panes: Map<K, Rect>;\n /** Where the geometry of the named splits goes; null for `layoutSplit`, which reports panes only and builds none. */\n readonly splits: Map<string, SplitGeometry> | null;\n}\n\n/**\n * The rect of every pane of `tree` in `area`. Each split's gutter is its gap (its own `gap`, else `options.gap`) plus\n * `options.handle`. A split's `ratio` is clamped to 0..1 (one that is not finite is 0.5), and the middle of the gutter\n * sits at `extent * ratio`: the first side is `extent * ratio` less half the gutter, the second starts half a gutter\n * past it and is the rest less half the gutter. No size is ever negative: a side too short for half the gutter is 0\n * along the axis, and the second side of a split with no room may then start up to half a gutter past the rect's end.\n * At ratio 0.5 both sides are equal. `options.floor`, `fixed` and `fixedAcross` (see `SplitOptions`) read the host's\n * minimums and fixed lengths per split. A negative or non-finite `gap` or `handle` is 0. The area is taken as given:\n * with a negative width or height every length along that axis is 0 and a pane's size across it is copied as it\n * is, so pass an area with no negative side.\n */\nexport function layoutSplit<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): Map<K, Rect> {\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits: null };\n lay(tree, area, ctx, false);\n return ctx.panes;\n}\n\n/**\n * `layoutSplit` and the geometry of every split that has an `id` (a repeated id keeps the one laid out last: a split under another, or a later one beside it): the box it divides,\n * its axis and ratio in effect (after the floors), and its divider, the gutter strip between its two sides. A split\n * that lays out as master and stack is reported too, its nested splits are not.\n */\nexport function layoutSplitTree<K>(tree: Split<K> | null, area: Rect, options: SplitOptions<K> = {}): SplitLayout<K> {\n const splits = new Map<string, SplitGeometry>();\n const ctx: Ctx<K> = { options, gap: px(options.gap), handle: px(options.handle), panes: new Map(), splits };\n lay(tree, area, ctx, false);\n return { panes: ctx.panes, splits };\n}\n\n/** The strip `gutter` wide centered on `mid` across `box`, clipped to it. */\nfunction strip(box: Rect, x: boolean, mid: number, gutter: number): Rect {\n const lo = Math.max(x ? box.x : box.y, mid - gutter / 2);\n const hi = Math.min(x ? box.x + box.width : box.y + box.height, mid + gutter / 2);\n const length = Math.max(0, hi - lo);\n return x ? { x: lo, y: box.y, width: length, height: box.height } : { x: box.x, y: lo, width: box.width, height: length };\n}\n\n/**\n * `ratio` kept so the first side has `minA` and the second `minB` of the room less the gutter (at least 1 px of room),\n * within `net`; 0.5 where the two cannot both fit.\n */\nfunction clampByMin(ratio: number, extent: number, gutter: number, minA: number, minB: number, net: readonly [number, number]): number {\n const room = Math.max(extent - gutter, 1);\n const boundedMin = Math.min(Math.max(minA / room, net[0]), net[1]);\n const boundedMax = Math.max(Math.min(1 - minB / room, net[1]), net[0]);\n return boundedMin > boundedMax ? 0.5 : Math.min(Math.max(ratio, boundedMin), boundedMax);\n}\n\n/** A split that lays its panes out flat as master and stack: the gap only, never the handle. */\nfunction layMaster<K>(tree: Extract<Split<K>, { a: unknown }>, master: MasterOptions, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n const gap = tree.gap === undefined ? ctx.gap : px(tree.gap);\n const panes = panesOf(tree);\n const ratio = masterRatio(tree.ratio);\n const side = master.side ?? \"left\";\n // Only the count and side come from `master`: the ratio and gap are the split's own.\n for (const [pane, r] of masterStack(panes, area, { gap, ratio, count: master.count, side })) ctx.panes.set(pane, r);\n if (tree.id === undefined || ctx.splits === null) return;\n const x = side === \"left\" || side === \"right\";\n const stacked = panes.length > masterCount(master.count, panes.length);\n const room = Math.max(0, (x ? area.width : area.height) - gap);\n const first = side === \"left\" || side === \"top\" ? room * ratio : room * (1 - ratio);\n const mid = (x ? area.x : area.y) + first + gap / 2;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis: x ? \"x\" : \"y\", ratio, divider: stacked ? strip(area, x, mid, gap) : null });\n}\n\n/**\n * Lays `tree` out in `area`. `owned` says `area` is a rect this layout made itself (a split's child), so a pane or a\n * split may keep it as its own; the caller's rect (the root) is copied, never kept.\n */\nfunction lay<K>(tree: Split<K> | null, area: Rect, ctx: Ctx<K>, owned: boolean): void {\n if (!tree) return;\n if (\"pane\" in tree) {\n ctx.panes.set(tree.pane, owned ? area : { ...area });\n return;\n }\n if (tree.master) {\n layMaster(tree, tree.master, area, ctx, owned);\n return;\n }\n const axis = tree.axis ?? (area.width >= area.height ? \"x\" : \"y\");\n const x = axis === \"x\";\n const extent = x ? area.width : area.height;\n const origin = x ? area.x : area.y;\n const cross = x ? area.height : area.width;\n const gutter = (tree.gap === undefined ? ctx.gap : px(tree.gap)) + ctx.handle;\n const { fixed, fixedAcross, floor } = ctx.options;\n // Across the split a child with a fixed length takes it from the start; the others take the whole cross extent.\n const lenA = fixedAcross?.(tree.a, axis);\n const lenB = fixedAcross?.(tree.b, axis);\n const acrossA = usable(lenA) ? lenA : cross;\n const acrossB = usable(lenB) ? lenB : cross;\n const fixedA = fixed?.(tree.a, axis);\n const fixedB = fixed?.(tree.b, axis);\n\n // The lengths of the two sides along the split, where the second starts, the ratio in effect and the divider.\n let lengthA: number;\n let lengthB: number;\n let startB: number;\n let ratio = unit(tree.ratio);\n let ruled = false; // the divider is the gutter strip at the ratio (a split no fixed length decides)\n const lead = fixedA ?? fixedB;\n if (fixedA && fixedB && fixedA.keep && fixedB.keep && usable(fixedA.length) && usable(fixedB.length)) {\n lengthA = fixedA.length;\n lengthB = fixedB.length;\n startB = origin + lengthA + gutter;\n ratio = extent > 0 ? (lengthA + gutter / 2) / extent : ratio;\n } else if (lead && usable(lead.length) && lead.length + gutter < extent) {\n const rest = Math.max(0, extent - lead.length - gutter);\n lengthA = lead === fixedA ? lead.length : rest;\n lengthB = lead === fixedA ? rest : lead.length;\n startB = origin + lengthA + gutter;\n ratio = (lengthA + gutter / 2) / extent;\n } else {\n if (floor) {\n const a = floor(tree.a, axis, tree);\n const b = floor(tree.b, axis, tree);\n const net = a.net === false || b.net === false ? ([0, 1] as const) : NET;\n ratio = clampByMin(Number.isFinite(tree.ratio ?? 0.5) ? (tree.ratio ?? 0.5) : 0.5, extent, gutter, px(a.min), px(b.min), net);\n }\n lengthA = Math.max(0, extent * ratio - gutter / 2);\n lengthB = Math.max(0, extent * (1 - ratio) - gutter / 2);\n startB = origin + extent * ratio + gutter / 2;\n ruled = true;\n }\n // The geometry is built only for a named split and only when the caller asked for it (`layoutSplitTree`).\n if (tree.id !== undefined && ctx.splits !== null) {\n const divider = ruled ? strip(area, x, origin + extent * ratio, gutter) : null;\n ctx.splits.set(tree.id, { rect: owned ? area : { ...area }, axis, ratio, divider });\n }\n if (x) {\n lay(tree.a, { x: area.x, y: area.y, width: lengthA, height: acrossA }, ctx, true);\n lay(tree.b, { x: startB, y: area.y, width: lengthB, height: acrossB }, ctx, true);\n } else {\n lay(tree.a, { x: area.x, y: area.y, width: acrossA, height: lengthA }, ctx, true);\n lay(tree.b, { x: area.x, y: startB, width: acrossB, height: lengthB }, ctx, true);\n }\n}\n","/**\n * Whether a drop on a pane leaves room: the rule a host asks before it offers a side of a pane as a drop place. See\n * docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Side } from \"../side\";\nimport { layoutSplit, type SplitOptions } from \"./layout\";\nimport type { PaneRegion } from \"./regions\";\nimport { dropOnPane, panesOf, removePane, type Split } from \"./split\";\n\n/** The layout options a drop is judged under, and `min`: the least width and height, px, a pane must keep. */\nexport interface DropOptions<K> extends SplitOptions<K> {\n readonly min: number;\n}\n\n/** A drop's verdict: `ok`, or not, with its `reason`. */\nexport interface DropVerdict {\n readonly ok: boolean;\n readonly reason?: string;\n}\n\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/**\n * Whether dropping `dragged` on pane `at`'s `region` leaves both at least `options.min` wide and high.\n *\n * - The center is fine unless `dragged` is `at`, or `at` is not in the tree (nothing to swap with).\n * - A side needs, in the layout of the tree without `dragged` (so `at` is measured where it will be when `dragged` is\n * lifted out), a span of `at` along the split of at least `2 * min` plus the gutter (the options' gap plus handle)\n * and across it of at least `min`; and in the layout of `dropOnPane(tree, dragged, at, region)` both `dragged` and\n * `at` at least `min` wide and high. That check is skipped when `area` has no width or no height. A pane that is\n * not in the tree counts as one being added; an `at` that is not in it (or is `dragged`) has no place to split.\n */\nexport function canDropOnPane<K>(tree: Split<K> | null, dragged: K, at: K, region: PaneRegion, area: Rect, options: DropOptions<K>): DropVerdict {\n if (region === \"center\") {\n if (dragged === at) return { ok: false, reason: \"center swap blocked: a pane dropped on itself\" };\n return panesOf(tree).includes(at) ? { ok: true } : { ok: false, reason: \"center rejected: no pane to swap\" };\n }\n const target = layoutSplit(removePane(tree, dragged), area, options).get(at);\n if (!target) return { ok: false, reason: `${region} rejected: no pane to split` };\n const room = canSplitPane(target, region, options);\n if (!room.ok) return room;\n return dropFits(layoutSplit(dropOnPane(tree, dragged, at, region), area, options), dragged, at, area, { min: options.min, side: region });\n}\n\n/** What `canSplitPane` reads: `min` (as in `DropOptions`) and the gutter's parts, `gap` and `handle`, px. */\nexport interface SplitRoomOptions {\n readonly min: number;\n readonly gap?: number;\n readonly handle?: number;\n}\n\n/**\n * The room rule: whether a pane of rect `target` can take another on `side`, both at least `options.min` wide and\n * high. Along the split (width for left and right, height for top and bottom) the pane needs `2 * min` plus the\n * gutter (`gap` plus `handle`), across it `min`. The rect is the pane's as the host measures it, where it will be\n * when the dragged pane is lifted out. `canDropOnPane`'s first rule, for a side.\n */\nexport function canSplitPane(target: Rect, side: Side, options: SplitRoomOptions): DropVerdict {\n const min = px(options.min);\n const gutter = px(options.gap) + px(options.handle);\n const horizontal = side === \"left\" || side === \"right\";\n const along = horizontal ? target.width : target.height;\n const across = horizontal ? target.height : target.width;\n const need = min * 2 + gutter;\n if (along < need) return { ok: false, reason: `${side} rejected: axis span ${along.toFixed(1)}px < min ${need.toFixed(1)}px (2 panes + gutter ${gutter}px)` };\n if (across < min) return { ok: false, reason: `${side} rejected: cross span ${across.toFixed(1)}px < min ${min.toFixed(1)}px` };\n return { ok: true };\n}\n\n/** What `dropFits` reads: the `min` (as in `DropOptions`) and the `side` of `at` the drop is on, for the reason. */\nexport interface DropFitsOptions {\n readonly min: number;\n readonly side: Side;\n}\n\n/**\n * The fit rule: in `projected`, the rect of every pane in the layout the drop makes (the host's own projection of\n * `dropOnPane`'s tree), whether `dragged` and `at` are both there and at least `options.min` wide and high. Fine\n * when `area` has no width or no height (there is nothing to measure). `canDropOnPane`'s last rule.\n */\nexport function dropFits<K>(projected: ReadonlyMap<K, Rect>, dragged: K, at: K, area: Rect, options: DropFitsOptions): DropVerdict {\n if (!(area.width > 0 && area.height > 0)) return { ok: true };\n const min = px(options.min);\n const fits = (r: Rect | undefined): boolean => !!r && r.width >= min && r.height >= min;\n return fits(projected.get(dragged)) && fits(projected.get(at)) ? { ok: true } : { ok: false, reason: `${options.side} rejected: projected footprint of the two panes violates min ${min}px` };\n}\n","/**\n * A pane's drop regions: a center rectangle (a drop there swaps with the pane) and four side trapezoids (a drop there\n * splits the pane on that side), formed by the diagonals from each pane corner to the nearest corner of the center.\n * The five regions cover the pane with no gaps and no overlaps.\n *\n * Meant for `@n-uf/motion/drag`'s `placeOf(target, point, previous)`: one target per pane (`paneTargets`), its place\n * the region under the pointer, the previous region held for `hysteresis` px past its boundary so a pointer resting on\n * a boundary doesn't flicker. A region that takes no drop is the consumer's to answer with a null place.\n */\nimport { clamp, type Point, type Rect, type Size } from \"../geometry\";\nimport type { Side } from \"../side\";\n\nexport type PaneRegion = \"center\" | Side;\n\n/** The sides in their tie-break order: at an exact diagonal the first wins (a corner resolves to `top`). */\nexport const PANE_SIDES: readonly Side[] = [\"top\", \"right\", \"bottom\", \"left\"];\n\nexport interface PaneRegionOptions {\n /** The center rectangle's share of each pane axis (0.05 to 0.95); `centerX` / `centerY` override one axis. */\n readonly center?: number;\n readonly centerX?: number;\n readonly centerY?: number;\n /** The least the center spans on either axis, px (a small pane keeps a usable center). */\n readonly centerMin?: number;\n /** How far past its boundary the previous region holds, px. */\n readonly hysteresis?: number;\n /** Device pixels per px: the center's edges snap to that grid, as the browser draws them. */\n readonly pixelRatio?: number;\n /**\n * The pane's center rectangle as the host already has it (pane-local px, as `paneCenter` gives), used as it is in\n * place of measuring: `center`, `centerX`, `centerY`, `centerMin` and `pixelRatio` are not read. Only `paneRegion`\n * reads it; its `width` and `height` are the pane's own size for the hold toward the middle.\n */\n readonly paneCenter?: PaneCenter;\n}\n\nexport const PANE_REGION_DEFAULTS: Required<Omit<PaneRegionOptions, \"centerX\" | \"centerY\" | \"paneCenter\">> = { center: 0.34, centerMin: 24, hysteresis: 6, pixelRatio: 1 };\n\n/** The center rectangle of a pane of `size`, in pane-local px (origin at the pane's top-left corner). */\nexport interface PaneCenter {\n readonly width: number;\n readonly height: number;\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nconst snap = (v: number, ratio: number): number => Math.round(v * ratio) / ratio;\n\n/** Where the center rectangle of a pane of `size` lies, by these options. */\nexport function paneCenter(size: Size, options: PaneRegionOptions = {}): PaneCenter {\n const o = { ...PANE_REGION_DEFAULTS, ...options };\n const width = Math.max(0, size.width);\n const height = Math.max(0, size.height);\n const ratio = o.pixelRatio > 0 ? o.pixelRatio : 1;\n const rx = clamp(o.centerX ?? o.center, 0.05, 0.95);\n const ry = clamp(o.centerY ?? o.center, 0.05, 0.95);\n const cw = Math.min(width, Math.max(width * rx, Math.min(o.centerMin, width)));\n const ch = Math.min(height, Math.max(height * ry, Math.min(o.centerMin, height)));\n return { width, height, left: snap((width - cw) / 2, ratio), top: snap((height - ch) / 2, ratio), right: snap((width + cw) / 2, ratio), bottom: snap((height + ch) / 2, ratio) };\n}\n\n/** How deep past the center a point is toward each side, as a share of that side's band (positive: in that band). */\nfunction depths(p: Point, c: PaneCenter): { side: Side; depth: number }[] {\n return [\n { side: \"top\", depth: (c.top - p.y) / Math.max(c.top, 1) },\n { side: \"right\", depth: (p.x - c.right) / Math.max(c.width - c.right, 1) },\n { side: \"bottom\", depth: (p.y - c.bottom) / Math.max(c.height - c.bottom, 1) },\n { side: \"left\", depth: (c.left - p.x) / Math.max(c.left, 1) },\n ];\n}\n\n/** The region a pane-local point is in, by position alone. */\nfunction rawRegion(p: Point, c: PaneCenter): PaneRegion {\n if (p.x >= c.left && p.x <= c.right && p.y >= c.top && p.y <= c.bottom) return \"center\";\n let best: PaneRegion = \"center\";\n let deepest = 0;\n for (const d of depths(p, c)) {\n if (d.depth > deepest) {\n deepest = d.depth;\n best = d.side;\n }\n }\n return best;\n}\n\n/** `p` moved `by` px into `region` (toward the pane's middle for the center). */\nfunction toward(p: Point, region: PaneRegion, by: number, c: PaneCenter): Point {\n if (region === \"left\") return { x: p.x - by, y: p.y };\n if (region === \"right\") return { x: p.x + by, y: p.y };\n if (region === \"top\") return { x: p.x, y: p.y - by };\n if (region === \"bottom\") return { x: p.x, y: p.y + by };\n const dx = c.width / 2 - p.x;\n const dy = c.height / 2 - p.y;\n const len = Math.hypot(dx, dy);\n if (len <= by || len === 0) return { x: c.width / 2, y: c.height / 2 };\n return { x: p.x + (dx / len) * by, y: p.y + (dy / len) * by };\n}\n\n/**\n * The drop region of `pane` (in the same coordinates as `point`) the point is in. With a `previous` region, the point\n * has to be `hysteresis` px past that region's boundary before the region changes: no time-based debounce, only\n * geometry. A host that has measured the center itself passes it as `options.paneCenter`; the same center gives the\n * same region as the one measured here.\n */\nexport function paneRegion(pane: Rect, point: Point, previous: PaneRegion | null = null, options: PaneRegionOptions = {}): PaneRegion {\n const c = options.paneCenter ?? paneCenter(pane, options);\n const p = { x: point.x - pane.x, y: point.y - pane.y };\n const raw = rawRegion(p, c);\n const by = Math.max(0, options.hysteresis ?? PANE_REGION_DEFAULTS.hysteresis);\n if (previous === null || by === 0 || previous === raw) return raw;\n return rawRegion(toward(p, previous, by, c), c) === previous ? previous : raw;\n}\n","/**\n * Drop targets for tiling, in the root `Target` shape (what `@n-uf/motion/drag` takes). Both kinds come from one\n * helper: a pane target (`pane:<id>`, its hit the pane, the place in it its drop region) for the split tree, and an\n * insertion target (`at:<index>`, its hit and slot the dragged pane's rect with it inserted there) for an order layout.\n */\nimport type { Rect } from \"../geometry\";\nimport type { Target } from \"../target\";\nimport type { OrderLayout, OrderOptions } from \"./order\";\n\n/** A split tree's target: drop on pane `pane` (the region under the pointer says how). */\nexport interface PaneTarget<K> extends Target {\n readonly pane: K;\n}\n\n/** An order layout's target: insert the dragged pane at `index`; `layout` is every pane's rect with it there. */\nexport interface OrderTarget<K> extends Target {\n readonly index: number;\n readonly layout: ReadonlyMap<K, Rect>;\n}\n\n/** The one shape both kinds share: a slot-sized drop with no precedence over any other. */\nconst tilingTarget = (id: string, hit: Rect, slot?: Rect): Target => ({ id, priority: 2, hit, ...(slot ? { slot } : {}) });\n\nexport interface PaneTargetsOptions<K> {\n /** A pane left out: the dragged one, when it is still laid out. */\n readonly except?: K;\n /**\n * A pane's key in its target's id (`pane:<key>`); default `String`. Keys must be unique across the panes: a drag\n * intent follows its targets by id, so two panes with one key would be one target.\n */\n readonly key?: (pane: K) => string;\n}\n\n/** One target per pane of `layout`, its id `pane:<key>`. */\nexport function paneTargets<K>(layout: ReadonlyMap<K, Rect>, options: PaneTargetsOptions<K> = {}): PaneTarget<K>[] {\n const key = options.key ?? String;\n return [...layout].filter(([k]) => k !== options.except).map(([pane, r]) => ({ ...tilingTarget(`pane:${key(pane)}`, r), pane }));\n}\n\n/**\n * One target per index `dragged` could be inserted at among `panes` (which don't hold it), laid out by `arrange` in\n * `area`. Each target's hit and slot is `dragged`'s rect with it there, so the targets cover the area as the layout\n * does. Ids are `at:<index>`, unique whatever the panes are.\n */\nexport function orderTargets<K>(arrange: OrderLayout, panes: readonly K[], dragged: K, area: Rect, options?: OrderOptions): OrderTarget<K>[] {\n return Array.from({ length: panes.length + 1 }, (_, index) => {\n const layout = arrange([...panes.slice(0, index), dragged, ...panes.slice(index)], area, options);\n const slot = layout.get(dragged)!;\n return { ...tilingTarget(`at:${index}`, slot, slot), index, layout };\n });\n}\n","import type { Rect, Size } from \"../geometry\";\n\n/**\n * The minimum-size give-way: while a pane is laid out below its minimum, the newest pane (highest `age`) floats and\n * the rest are laid out again. Stops when every pane keeps its minimum or one pane is left. `layout` lays out the\n * kept panes; the result says which are kept (in their order) and which float (newest first).\n */\nexport function giveWay<K>(panes: readonly K[], layout: (kept: readonly K[]) => ReadonlyMap<K, Rect>, min: (pane: K) => Size, age: (pane: K) => number): { kept: K[]; floats: K[] } {\n let kept = [...panes];\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 * One layout for a tiling drag's held frame and its commit, the layout half: `tilingDrag(tree, subject, options)` gives\n * the drag's base (the tree with the subject released, laid out), its home (the gap the release leaves) and\n * `after(held)`, THE layout of each held place: what a release there commits, and what a frame holding it draws.\n *\n * The host keeps its own tree type and its own changes; it hands them over as a `TilingTree` adapter. The library owns\n * the rules: what is released and when, which tree each change takes, home, the refusals, and the one layout per held\n * place. Geometry has one source: the adapter gives the tree as a `Split` (`split`), and the library lays it out with\n * `layoutSplitTree` under the drag's options (`SplitOptions` plus `min`, as `canDropOnPane` takes them).\n *\n * The hit half (targets, a pane's parts, `placeOf`) is not here yet. See docs/placement.md, Entry: tiling.\n */\nimport { EPS, type Rect } from \"../geometry\";\nimport type { Side } from \"../side\";\nimport { canSplitPane, dropFits, type DropOptions } from \"./drop\";\nimport { layoutSplitTree, type SplitGeometry } from \"./layout\";\nimport { panesOf, type Split } from \"./split\";\n\n/** A stack as the adapter reports it: its id, its members in order, and the member it is drawn as. */\nexport interface TilingStack<K> {\n readonly id: string;\n readonly members: readonly K[];\n readonly active: K;\n}\n\n/**\n * What a drag moves: one pane (a member of a stack is torn out of it), or a whole stack, every member as one. A stack\n * subject carries the stack as the adapter reported it at the lift (`stackOf`), so the changes that place it after its\n * release (`beside`, `join`) have its members.\n */\nexport type TilingSubject<K> = { readonly kind: \"pane\"; readonly pane: K } | { readonly kind: \"stack\"; readonly stack: TilingStack<K> };\n\n/**\n * How a side drop sizes the split it makes. One kind today: the two panes take half each (the split `splitPane`\n * writes). A later rule may size the subject by its own length; it will be a new kind here, never an option.\n */\nexport type TilingSize = { readonly kind: \"half\" };\n\n/**\n * The host's tree, as a drag reads and changes it. Every function is pure: it never changes the tree it is given, and\n * returns a new tree (or the same one when nothing changes).\n *\n * Which tree each change takes, and why:\n * - `beside` and `join` take the **released** tree (`release`'s result): the subject leaves its old place first, so the\n * place it lands in is measured, and changed, without it. A pane beside its own old sibling then lands as if it were\n * new there, and a stack never holds the subject twice.\n * - `swap` takes the tree **with the subject still in it**: a swap exchanges two places, and the subject's old place is\n * exactly where the partner goes. With the subject released there would be no old place to give the partner.\n */\nexport interface TilingTree<T, K> {\n /** The tree as panes divide the area: a `Split` of the drawn panes (a stack stands in it as its active member's key). */\n split(tree: T): Split<K> | null;\n /** The stack `pane` is a member of, or null; leave it out when the tree has no stacks. */\n stackOf?(tree: T, pane: K): TilingStack<K> | null;\n /** `tree` without the subject: a pane leaves its place (or its stack), a stack leaves with every member. */\n release(tree: T, subject: TilingSubject<K>): T;\n /** The released tree with the subject placed on `side` of the drawn pane `at`, sized by `size`. */\n beside(released: T, subject: TilingSubject<K>, at: K, side: Side, size: TilingSize): T;\n /**\n * `tree` (the subject still in it) with the subject and the drawn pane `at` in each other's place.\n * - A pane subject and `at` each take the other's slot, in the split or in a stack. The swap moves `at` alone, never\n * the stack it stands for: when `at` is a stack's drawn member, the subject takes its place in that stack (drawn,\n * as `at` was) and the stack's other members stay; `at` goes to the subject's old slot (alone, or in the subject's\n * stack, at its index, when the subject is a member torn out of one).\n * - A whole stack subject trades its drawn slot in the split with `at`'s; when `at` is a stack's drawn member, the\n * two stacks trade places, each whole.\n */\n swap(tree: T, subject: TilingSubject<K>, at: K): T;\n /** The released tree with the subject joined to the drawn pane `at`'s stack (made one when `at` is alone), at `index` (default: last). Leave it out when the tree has no stacks: every join is refused `\"join\"`. */\n join?(released: T, subject: TilingSubject<K>, at: K, index?: number): T;\n /** Commit-time reconciliation: part of every `after` but home's, so what a frame draws is what a release stores. Default: none. */\n normalize?(tree: T): T;\n}\n\n/** What `tilingDrag` reads: the adapter, the stage, and the layout options (`SplitOptions` plus `min`, the least pane width and height a drop keeps). */\nexport interface TilingDragOptions<T, K> extends DropOptions<K> {\n readonly ops: TilingTree<T, K>;\n /** The stage the tree is laid out in, px. */\n readonly area: Rect;\n /** Panes that take no drop (a swap, a side or a join on one is refused `\"still\"`). Default: none. */\n readonly still?: (pane: K) => boolean;\n}\n\n/** A held place of a drag: where a release now lands. `at` is always a pane drawn in the base. */\nexport type TilingHeld<K> =\n | { readonly kind: \"home\" }\n | { readonly kind: \"swap\"; readonly at: K }\n | { readonly kind: \"beside\"; readonly at: K; readonly side: Side }\n | { readonly kind: \"join\"; readonly at: K; readonly index?: number };\n\n/**\n * Why a held place takes no release, as a code:\n * - `self`: the place is the subject's own (a swap or side of the subject itself, a swap with its own stack, a whole\n * stack joined to itself);\n * - `still`: `at` is a still pane;\n * - `missing`: `at` is not a pane drawn in the base;\n * - `join`: the adapter has no `join`;\n * - `room-along`, `room-across`: `at` is too short for two panes along the split, or too narrow across it, in the base\n * (`canSplitPane`): `need` and `have` px;\n * - `fit`: in the layout the release makes (a side, a swap or a join), `pane` (the subject's drawn key or `at`'s) is\n * below `min` wide or high, the fit rule of `dropFits`. A swap hands each pane the other's rect, so either may fall\n * below it; a join is judged on the stack's rect.\n */\nexport type TilingRefusal<K> =\n | { readonly code: \"self\" | \"still\" | \"missing\" | \"join\" }\n | { readonly code: \"room-along\" | \"room-across\"; readonly need: number; readonly have: number }\n | { readonly code: \"fit\"; readonly pane: K };\n\n/** A tree laid out: every drawn pane's rect, and the geometry of each split that has an id. */\nexport interface TilingLaidOut<T, K> {\n readonly tree: T;\n readonly layout: ReadonlyMap<K, Rect>;\n readonly splits: ReadonlyMap<string, SplitGeometry>;\n}\n\n/** A pane a commit moves, from where it was drawn at the lift to where the commit puts it. */\nexport interface TilingMove<K> {\n readonly pane: K;\n readonly from: Rect;\n readonly to: Rect;\n}\n\n/** THE layout of a held place: what a release commits, and what a frame holding it draws. */\nexport interface TilingAfter<T, K> extends TilingLaidOut<T, K> {\n readonly held: TilingHeld<K>;\n /**\n * Why a release here commits nothing, or null. A refused place's tree and layout are the lift's (what its release\n * keeps), its landing null and nothing moved; a frame holding it draws rest (the base).\n */\n readonly refusal: TilingRefusal<K> | null;\n /** The subject's rect in `layout`: its own when it is drawn, else its stack's. Null when refused. */\n readonly landing: Rect | null;\n /** Every other drawn pane whose rect differs from the lift's (the swap partner, the panes that give room), in `layout`'s order. */\n readonly moved: readonly TilingMove<K>[];\n}\n\n/** A drag of one subject: its base, its home, and the one layout of each held place. */\nexport interface TilingDrag<T, K> {\n readonly subject: TilingSubject<K>;\n /** The tree at the lift, laid out: what is drawn before the drag, and what a release on home commits. */\n readonly lift: TilingLaidOut<T, K>;\n /** The hit basis, fixed for the drag: the tree with the subject released, laid out. What a frame draws at rest (nothing held, or a refused place). */\n readonly base: TilingLaidOut<T, K>;\n /**\n * The gap the release leaves: the subject's lift rect when releasing it takes a drawn pane away (a pane alone, a\n * whole stack), null when it takes none (a member torn out of a stack that stays drawn).\n */\n readonly home: Rect | null;\n /** THE layout of `held`. Remembered per held place: the same place gives the same object. */\n after(held: TilingHeld<K>): TilingAfter<T, K>;\n}\n\nconst sameRect = (a: Rect, b: Rect): boolean => Math.abs(a.x - b.x) <= EPS && Math.abs(a.y - b.y) <= EPS && Math.abs(a.width - b.width) <= EPS && Math.abs(a.height - b.height) <= EPS;\n\n/** A px option as the drop rules read it: finite and above 0, else 0. */\nconst px = (v: number | undefined): number => (v !== undefined && Number.isFinite(v) && v > 0 ? v : 0);\n\n/**\n * The drag of `subject` in `tree`: its lift and base layouts, its home, and `after(held)`, the one layout of each held\n * place. `tree` is never changed; `after({ kind: \"home\" }).tree` is `tree` itself.\n *\n * - **`after(held).tree`** is what a release commits: `normalize(change)`, where the change is `beside` or `join` on\n * the released tree, or `swap` on the lift tree (see `TilingTree` for why). Home's is the lift tree, never normalized.\n * - **`layout`** is that tree laid out, so a frame that draws it draws exactly what the release stores.\n * - **Refusals** are judged on the base (room) and on the change's own layout (fit), never on another tree.\n *\n * Throws when the subject is not in `tree` (neither drawn nor a member of a drawn stack): a drag has nothing to lift.\n */\nexport function tilingDrag<T, K>(tree: T, subject: TilingSubject<K>, options: TilingDragOptions<T, K>): TilingDrag<T, K> {\n const { ops, area } = options;\n const normalize = (t: T): T => (ops.normalize ? ops.normalize(t) : t);\n const lay = (t: T): TilingLaidOut<T, K> => {\n const { panes, splits } = layoutSplitTree(ops.split(t), area, options);\n return { tree: t, layout: panes, splits };\n };\n const stackOf = (t: T, pane: K): TilingStack<K> | null => ops.stackOf?.(t, pane) ?? null;\n /** The key `pane` is drawn as in `t`: its stack's active member, or itself. */\n const drawnAs = (t: T, pane: K): K => stackOf(t, pane)?.active ?? pane;\n const subjectKey = subject.kind === \"pane\" ? subject.pane : subject.stack.active;\n\n const lift = lay(tree);\n const liftRect = lift.layout.get(drawnAs(tree, subjectKey));\n if (!liftRect) {\n const what = subject.kind === \"pane\" ? `pane ${String(subject.pane)}` : `stack ${subject.stack.id}`;\n throw new Error(`tilingDrag: the subject (${what}) is not in the tree: it is neither drawn nor a member of a drawn stack`);\n }\n const base = lay(ops.release(tree, subject));\n const takesPane = panesOf(ops.split(base.tree)).length < panesOf(ops.split(tree)).length;\n const home = takesPane ? { ...liftRect } : null;\n\n /** Every drawn pane of `laid` but the subject's whose rect differs from where it was drawn at the lift. */\n const movedIn = (laid: TilingLaidOut<T, K>): TilingMove<K>[] => {\n const own = drawnAs(laid.tree, subjectKey);\n const out: TilingMove<K>[] = [];\n for (const [pane, to] of laid.layout) {\n if (pane === own) continue;\n const from = lift.layout.get(lift.layout.has(pane) ? pane : drawnAs(tree, pane));\n if (from && !sameRect(from, to)) out.push({ pane, from, to });\n }\n return out;\n };\n\n const inSubject = (pane: K): boolean => (subject.kind === \"pane\" ? pane === subject.pane : subject.stack.members.includes(pane));\n\n /** The refusal a held place has before any change is made: whose `at` it names, and whether the adapter can make it. */\n const refusalBefore = (held: Exclude<TilingHeld<K>, { kind: \"home\" }>): TilingRefusal<K> | null => {\n const at = held.at;\n if (inSubject(at)) return { code: \"self\" };\n if (held.kind === \"swap\") {\n // A swap with the stack the subject is torn from: the subject's own place.\n const own = stackOf(tree, subjectKey);\n if (own && stackOf(tree, at)?.id === own.id) return { code: \"self\" };\n }\n if (!base.layout.has(at)) return { code: \"missing\" };\n if (options.still?.(at)) return { code: \"still\" };\n if (held.kind === \"join\" && !ops.join) return { code: \"join\" };\n return null;\n };\n\n /** A refused place: the release commits nothing, so its layout is the lift's. */\n const refused = (held: TilingHeld<K>, refusal: TilingRefusal<K>): TilingAfter<T, K> => ({ ...lift, held, refusal, landing: null, moved: [] });\n\n /** The room rule on `at`'s base rect (`canSplitPane`), as a code with the numbers. */\n const roomFor = (at: K, side: Side): TilingRefusal<K> | null => {\n const r = base.layout.get(at)!;\n if (canSplitPane(r, side, options).ok) return null;\n const along = side === \"left\" || side === \"right\";\n const gutter = px(options.gap) + px(options.handle);\n const min = px(options.min);\n const span = along ? r.width : r.height;\n return span < min * 2 + gutter ? { code: \"room-along\", need: min * 2 + gutter, have: span } : { code: \"room-across\", need: min, have: along ? r.height : r.width };\n };\n\n const make = (held: TilingHeld<K>): TilingAfter<T, K> => {\n if (held.kind === \"home\") return { ...lift, held, refusal: null, landing: liftRect, moved: [] };\n const before = refusalBefore(held) ?? (held.kind === \"beside\" ? roomFor(held.at, held.side) : null);\n if (before) return refused(held, before);\n const changed =\n held.kind === \"swap\"\n ? ops.swap(tree, subject, held.at)\n : held.kind === \"beside\"\n ? ops.beside(base.tree, subject, held.at, held.side, { kind: \"half\" })\n : ops.join!(base.tree, subject, held.at, held.index);\n const laid = lay(normalize(changed));\n const own = drawnAs(laid.tree, subjectKey);\n // The fit rule, on every change: in the layout it makes, the subject and `at` (each as it is drawn there) keep `min`.\n // `side` only words `dropFits`' reason, which is not read here.\n const partner = drawnAs(laid.tree, held.at);\n if (!dropFits(laid.layout, own, partner, area, { min: options.min, side: held.kind === \"beside\" ? held.side : \"left\" }).ok) {\n const small = (r: Rect | undefined): boolean => !r || r.width < px(options.min) || r.height < px(options.min);\n return refused(held, { code: \"fit\", pane: small(laid.layout.get(own)) ? own : partner });\n }\n return { ...laid, held, refusal: null, landing: laid.layout.get(own) ?? null, moved: movedIn(laid) };\n };\n\n // Remembered per held place: by kind (and side or index), then by `at`, so keys need no string form.\n const homeAfter = make({ kind: \"home\" });\n const memo = new Map<string, Map<K, TilingAfter<T, K>>>();\n const after = (held: TilingHeld<K>): TilingAfter<T, K> => {\n if (held.kind === \"home\") return homeAfter;\n const k = held.kind === \"beside\" ? `beside:${held.side}` : held.kind === \"join\" ? `join:${held.index ?? \"\"}` : \"swap\";\n let byAt = memo.get(k);\n if (!byAt) memo.set(k, (byAt = new Map()));\n let a = byAt.get(held.at);\n if (!a) byAt.set(held.at, (a = make(held)));\n return a;\n };\n\n return { subject, lift, base, home, after };\n}\n","/**\n * The reference `TilingTree` adapter: placement's own `Split`, with optional stacks beside it. Tests, labs and hosts\n * whose tree is a `Split` use it as it is; a host with its own tree reads it as the worked example of each change.\n * See docs/placement.md, Entry: tiling.\n */\nimport type { TilingStack, TilingSubject, TilingTree } from \"./drag\";\nimport { removePane, splitPane, type Split } from \"./split\";\n\n/**\n * A split tree with stacks: `split` divides the area among the drawn panes, and each stack stands in it as its\n * `active` member's key. A pane in no stack is drawn alone. A stack of one is kept until `normalize` makes it a pane.\n */\nexport interface StackedSplit<K> {\n readonly split: Split<K> | null;\n readonly stacks?: readonly TilingStack<K>[];\n}\n\n/** `split` with every pane key mapped by `fn` (the same object where nothing changes). */\nfunction mapKeys<K>(split: Split<K> | null, fn: (k: K) => K): Split<K> | null {\n if (!split) return split;\n if (\"pane\" in split) {\n const k = fn(split.pane);\n return k === split.pane ? split : { pane: k };\n }\n const a = mapKeys(split.a, fn)!;\n const b = mapKeys(split.b, fn)!;\n return a === split.a && b === split.b ? split : { ...split, a, b };\n}\n\nconst stacksOf = <K>(t: StackedSplit<K>): readonly TilingStack<K>[] => t.stacks ?? [];\nconst of = <K>(split: Split<K> | null, stacks: readonly TilingStack<K>[]): StackedSplit<K> => (stacks.length ? { split, stacks } : { split });\nconst membersOf = <K>(s: TilingSubject<K>): readonly K[] => (s.kind === \"pane\" ? [s.pane] : s.stack.members);\nconst drawnOf = <K>(s: TilingSubject<K>): K => (s.kind === \"pane\" ? s.pane : s.stack.active);\n\n/**\n * The reference adapter over `StackedSplit<K>`:\n * - `release`: a whole stack leaves the split (its drawn key, `removePane`) and the stack list; a pane in a stack leaves\n * its members (the next member, else the one before, is drawn when it was the active one); a pane alone leaves the split;\n * - `beside`: `splitPane` on `at`'s side (a half split), a whole stack drawn as its active member and kept whole;\n * - `swap`: a pane trades keys with `at` wherever each is (the split, a stack's members), so each takes the other's\n * place; a whole stack trades its drawn place in the split with `at`'s;\n * - `join`: the subject's members go into `at`'s stack at `index` (default last; clamped), the first of them drawn; a\n * pane `at` alone becomes a stack, its id `stack:<at>` (made unique);\n * - `normalize`: a stack of fewer than two members becomes its pane; the same object when there is none.\n */\nexport function splitTreeOps<K>(): TilingTree<StackedSplit<K>, K> {\n return {\n split: (t) => t.split,\n stackOf: (t, pane) => stacksOf(t).find((s) => s.members.includes(pane)) ?? null,\n release(t, s) {\n if (s.kind === \"stack\") {\n const stack = stacksOf(t).find((x) => x.id === s.stack.id);\n return of(removePane(t.split, stack?.active ?? s.stack.active), stacksOf(t).filter((x) => x !== stack));\n }\n const stack = stacksOf(t).find((x) => x.members.includes(s.pane));\n if (!stack) return of(removePane(t.split, s.pane), stacksOf(t));\n const i = stack.members.indexOf(s.pane);\n const members = stack.members.filter((m) => m !== s.pane);\n if (members.length === 0) return of(removePane(t.split, s.pane), stacksOf(t).filter((x) => x !== stack));\n const active = stack.active === s.pane ? (members[i] ?? members[i - 1]!) : stack.active;\n const was = stack.active;\n return of(\n mapKeys(t.split, (k) => (k === was ? active : k)),\n stacksOf(t).map((x) => (x === stack ? { id: stack.id, members, active } : x)),\n );\n },\n beside(released, s, at, side) {\n const split = splitPane(released.split, at, drawnOf(s), side);\n return of(split, s.kind === \"pane\" ? stacksOf(released) : [...stacksOf(released), s.stack]);\n },\n swap(t, s, at) {\n if (s.kind === \"stack\") {\n const x = stacksOf(t).find((st) => st.id === s.stack.id)?.active ?? s.stack.active;\n return of(mapKeys(t.split, (k) => (k === x ? at : k === at ? x : k)), stacksOf(t));\n }\n const x = s.pane;\n const trade = (k: K): K => (k === x ? at : k === at ? x : k);\n return of(\n mapKeys(t.split, trade),\n stacksOf(t).map((st) => ({ id: st.id, members: st.members.map(trade), active: trade(st.active) })),\n );\n },\n join(released, s, at, index) {\n const moving = membersOf(s);\n const target = stacksOf(released).find((x) => x.members.includes(at));\n const into = target ? target.members : [at];\n const i = Math.max(0, Math.min(into.length, index ?? into.length));\n const members = [...into.slice(0, i), ...moving, ...into.slice(i)];\n const active = moving[0]!;\n const drawn = target ? target.active : at;\n const ids = new Set(stacksOf(released).map((x) => x.id));\n let id = target?.id ?? `stack:${String(at)}`;\n for (let n = 2; !target && ids.has(id); n++) id = `stack:${String(at)}:${n}`;\n const stack: TilingStack<K> = { id, members, active };\n return of(\n mapKeys(released.split, (k) => (k === drawn ? active : k)),\n target ? stacksOf(released).map((x) => (x === target ? stack : x)) : [...stacksOf(released), stack],\n );\n },\n normalize(t) {\n const kept = stacksOf(t).filter((s) => s.members.length >= 2);\n return kept.length === stacksOf(t).length ? t : of(t.split, kept);\n },\n };\n}\n","/**\n * The properties of a tiling drag's layout half, run on any `TilingTree` adapter: a host runs them on its own adapter\n * and trees, the library's tests on the reference one. Pure: no test runner, no DOM. See docs/placement.md, Entry: tiling.\n */\nimport { EPS, overlap, type Rect } from \"../geometry\";\nimport { PANE_SIDES } from \"./regions\";\nimport { layoutSplitTree } from \"./layout\";\nimport { panesOf, type Split } from \"./split\";\nimport { tilingDrag, type TilingDragOptions, type TilingHeld, type TilingSubject } from \"./drag\";\n\n/** The properties, by name (each is a key of `TilingConformance.counts`). */\nexport const TILING_PROPERTIES = [\n /** `after(home).tree` is the lift tree itself, its layout the lift's, never normalized. */\n \"home-is-lift\",\n /** `home` is the subject's lift rect when the release takes a drawn pane away, else null. */\n \"home-is-the-gap\",\n /** Home lies only over base panes whose rect changed when the subject was released. */\n \"home-over-changed\",\n /** `after(held).layout` is `after(held).tree` laid out; the landing is the subject's rect there; a refused place is the lift. */\n \"one-layout\",\n /** A swap puts the partner in the subject's lift rect and the subject in the partner's, and the others keep theirs. Not checked under per-child layout callbacks (`fixed`, `fixedAcross`, `floor`), which may move the ratios. */\n \"swap-exchanges\",\n /** A swap puts the partner in the subject's old slot of the split (as it is drawn there) and the subject in the partner's. Checked under every option, the per-child callbacks included. */\n \"swap-trades-slots\",\n /** A pane swapped with a stack's drawn member takes its place in that stack, and the stack's other members stay, in order; a member torn out of a stack leaves the partner in its place there. */\n \"swap-keeps-stack-mates\",\n /**\n * The subject is in every tree exactly once: no key (a drawn pane, or a member of a stack) is in an `after(held).tree`\n * twice; the base holds none of the subject's members (a torn member's stack mates stay); and every `after(held).tree`\n * holds the base's keys and the subject's, and no other. Catches an adapter whose `release` leaves the subject in.\n */\n \"subject-once\",\n /** `beside` and `join` commit `normalize(change(release(tree)))`: the subject is released first, then placed. */\n \"release-first\",\n /** A whole stack moves as one: after any change its members are in one stack, in their order. */\n \"stack-moves-whole\",\n /** `normalize` changes nothing on any `after(held).tree`. */\n \"normalize-idempotent\",\n /** The drag never changes the tree it is given, and remembers each held place (the same place, the same object). */\n \"nothing-changes\",\n] as const;\n\nexport type TilingProperty = (typeof TILING_PROPERTIES)[number];\n\n/** A conformance run: whether every property held, the first failures (in words), and per property how many checks ran and failed. */\nexport interface TilingConformance {\n readonly ok: boolean;\n readonly failures: readonly string[];\n readonly counts: Readonly<Record<TilingProperty, { readonly checked: number; readonly failed: number }>>;\n}\n\n/** Structural equality of plain data: primitives, arrays, plain objects, Maps and Sets. */\nfunction sameData(a: unknown, b: unknown): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== \"object\" || typeof b !== \"object\" || a === null || b === null) return false;\n if (a instanceof Map || b instanceof Map) {\n if (!(a instanceof Map && b instanceof Map) || a.size !== b.size) return false;\n for (const [k, v] of a) if (!b.has(k) || !sameData(v, b.get(k))) return false;\n return true;\n }\n if (a instanceof Set || b instanceof Set) {\n if (!(a instanceof Set && b instanceof Set) || a.size !== b.size) return false;\n for (const v of a) if (!b.has(v)) return false;\n return true;\n }\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n const ka = Object.keys(a).filter((k) => (a as Record<string, unknown>)[k] !== undefined);\n const kb = Object.keys(b).filter((k) => (b as Record<string, unknown>)[k] !== undefined);\n if (ka.length !== kb.length) return false;\n return ka.every((k) => sameData((a as Record<string, unknown>)[k], (b as Record<string, unknown>)[k]));\n}\n\n/** A deep copy of plain data (arrays, plain objects, Maps, Sets), to prove the drag left its tree alone. */\nfunction copy<V>(v: V): V {\n if (typeof v !== \"object\" || v === null) return v;\n if (v instanceof Map) return new Map([...v].map(([k, x]) => [k, copy(x)])) as V;\n if (v instanceof Set) return new Set([...v].map(copy)) as V;\n if (Array.isArray(v)) return v.map(copy) as V;\n return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, copy(x)])) as V;\n}\n\nconst near = (a: Rect | undefined | null, b: Rect | undefined | null, by = 0.5): boolean =>\n !!a && !!b && Math.abs(a.x - b.x) <= by && Math.abs(a.y - b.y) <= by && Math.abs(a.width - b.width) <= by && Math.abs(a.height - b.height) <= by;\n\n/** The way from the root of `split` to the pane `key` (`a` and `b` at each split), or null when it is not drawn. */\nfunction pathOf<K>(split: Split<K> | null, key: K): readonly (\"a\" | \"b\")[] | null {\n if (!split) return null;\n if (\"pane\" in split) return split.pane === key ? [] : null;\n for (const side of [\"a\", \"b\"] as const) {\n const rest = pathOf(split[side], key);\n if (rest) return [side, ...rest];\n }\n return null;\n}\n\n/** The pane at the end of `path` in `split`, or undefined when the path does not end on a pane. */\nfunction paneAt<K>(split: Split<K> | null, path: readonly (\"a\" | \"b\")[]): K | undefined {\n let node = split;\n for (const side of path) {\n if (!node || \"pane\" in node) return undefined;\n node = node[side];\n }\n return node && \"pane\" in node ? node.pane : undefined;\n}\n\nconst sameList = <K>(a: readonly K[], b: readonly K[]): boolean => a.length === b.length && a.every((k, i) => Object.is(k, b[i]));\n\nconst show = (h: TilingHeld<unknown>): string =>\n h.kind === \"home\" ? \"home\" : `${h.kind} ${String(h.at)}${h.kind === \"beside\" ? ` ${h.side}` : h.kind === \"join\" && h.index !== undefined ? ` @${h.index}` : \"\"}`;\n\n/** Every subject a tree offers: each pane drawn alone, each stack whole, and each member of a stack torn out of it. */\nexport function tilingSubjects<T, K>(tree: T, options: Pick<TilingDragOptions<T, K>, \"ops\">): TilingSubject<K>[] {\n const { ops } = options;\n const out: TilingSubject<K>[] = [];\n for (const pane of panesOf(ops.split(tree))) {\n const stack = ops.stackOf?.(tree, pane) ?? null;\n if (!stack) out.push({ kind: \"pane\", pane });\n else out.push({ kind: \"stack\", stack }, ...stack.members.map((m): TilingSubject<K> => ({ kind: \"pane\", pane: m })));\n }\n return out;\n}\n\n/**\n * Runs every property on every subject of every tree (`tilingSubjects`) and every held place of its drag: home, and for\n * each pane drawn in the base a swap, the four sides and a join (last and first). Trees are taken as committed ones,\n * so `normalize` (if any) must leave them as they are. Gives the first `limit` failures (default 20) in words.\n */\nexport function tilingConformance<T, K>(trees: Iterable<T>, options: TilingDragOptions<T, K>, limit = 20): TilingConformance {\n const { ops, area } = options;\n const counts = Object.fromEntries(TILING_PROPERTIES.map((p) => [p, { checked: 0, failed: 0 }])) as Record<TilingProperty, { checked: number; failed: number }>;\n const failures: string[] = [];\n const norm = (t: T): T => (ops.normalize ? ops.normalize(t) : t);\n const lay = (t: T) => layoutSplitTree(ops.split(t), area, options).panes;\n const drawnAs = (t: T, k: K): K => ops.stackOf?.(t, k)?.active ?? k;\n const callbacks = !!(options.fixed || options.fixedAcross || options.floor);\n /** Every key of `t`: each drawn pane, a stack counted as its members. */\n const keysOf = (t: T): K[] => panesOf(ops.split(t)).flatMap((p) => ops.stackOf?.(t, p)?.members ?? [p]);\n /** The keys `keys` holds more than once. */\n const twice = (keys: readonly K[]): K[] => keys.filter((k, i) => keys.indexOf(k) !== i);\n let n = 0;\n for (const tree of trees) {\n const snapshot = copy(tree);\n for (const subject of tilingSubjects(tree, options)) {\n const name = `tree ${n}, ${subject.kind === \"pane\" ? `pane ${String(subject.pane)}` : `stack ${subject.stack.id}`}`;\n const check = (p: TilingProperty, ok: boolean, why: () => string): void => {\n counts[p].checked++;\n if (ok) return;\n counts[p].failed++;\n if (failures.length < limit) failures.push(`${p}: ${name}: ${why()}`);\n };\n const drag = tilingDrag(tree, subject, options);\n const key = subject.kind === \"pane\" ? subject.pane : subject.stack.active;\n const liftOf = (k: K): Rect | undefined => drag.lift.layout.get(drag.lift.layout.has(k) ? k : drawnAs(tree, k));\n const subjectLift = liftOf(key);\n\n // The subject, exactly once: out of the base, and in every after's tree beside the base's keys.\n const members: readonly K[] = subject.kind === \"pane\" ? [subject.pane] : subject.stack.members;\n const baseKeys = keysOf(drag.base.tree);\n const kept = baseKeys.filter((k) => members.includes(k));\n check(\"subject-once\", kept.length === 0 && twice(baseKeys).length === 0, () => `the base holds ${kept.length ? `the subject's ${kept.map(String).join(\", \")}` : `${twice(baseKeys).map(String).join(\", \")} twice`}`);\n const want = new Set<K>([...baseKeys, ...members]);\n\n // Home.\n const home = drag.after({ kind: \"home\" });\n check(\"home-is-lift\", home.tree === tree && sameData(home.layout, drag.lift.layout) && home.refusal === null, () => \"after(home) is not the lift tree laid out\");\n const takes = panesOf(ops.split(drag.base.tree)).length < panesOf(ops.split(tree)).length;\n check(\"home-is-the-gap\", takes ? near(drag.home, subjectLift, EPS) : drag.home === null, () => `home ${JSON.stringify(drag.home)}, the release ${takes ? \"takes\" : \"takes no\"} drawn pane`);\n if (drag.home) {\n for (const [pane, r] of drag.base.layout) {\n if (overlap(drag.home, r) <= EPS) continue;\n check(\"home-over-changed\", !near(r, liftOf(pane), EPS), () => `home lies over ${String(pane)}, which the release left at ${JSON.stringify(r)}`);\n }\n }\n\n // Every held place on every base pane.\n const held: TilingHeld<K>[] = [{ kind: \"home\" }];\n for (const at of drag.base.layout.keys()) {\n held.push({ kind: \"swap\", at }, ...PANE_SIDES.map((side): TilingHeld<K> => ({ kind: \"beside\", at, side })));\n if (ops.join) held.push({ kind: \"join\", at }, { kind: \"join\", at, index: 0 });\n }\n for (const h of held) {\n const a = drag.after(h);\n check(\"nothing-changes\", drag.after(h) === a, () => `${show(h)}: after() gave a new object for the same place`);\n check(\"normalize-idempotent\", sameData(norm(a.tree), a.tree), () => `${show(h)}: normalize changes after().tree`);\n const keys = keysOf(a.tree);\n const extra = keys.filter((k) => !want.has(k));\n const lost = [...want].filter((k) => !keys.includes(k));\n check(\n \"subject-once\",\n twice(keys).length === 0 && extra.length === 0 && lost.length === 0,\n () => `${show(h)}: after().tree holds ${[twice(keys).length ? `${twice(keys).map(String).join(\", \")} twice` : \"\", extra.length ? `${extra.map(String).join(\", \")} it should not` : \"\", lost.length ? `no ${lost.map(String).join(\", \")}` : \"\"].filter(Boolean).join(\"; \")}`,\n );\n if (a.refusal) {\n check(\"one-layout\", a.tree === tree && a.landing === null && a.moved.length === 0, () => `${show(h)}: refused (${a.refusal!.code}) but not the lift`);\n continue;\n }\n const own = drawnAs(a.tree, key);\n check(\"one-layout\", sameData(a.layout, lay(a.tree)) && near(a.landing, a.layout.get(own), EPS), () => `${show(h)}: the layout or the landing is not after().tree's`);\n // Per-child layout callbacks (floors, fixed lengths) read which pane is where, so a swap may move the split\n // ratios themselves: the exchange is then what those callbacks make of it, and is not checked.\n if (h.kind === \"swap\" && !callbacks) {\n const partner = drawnAs(a.tree, h.at);\n const exchanged = near(a.layout.get(partner), subjectLift) && near(a.layout.get(own), liftOf(h.at));\n const others = [...a.layout].every(([p, r]) => p === own || p === partner || near(r, liftOf(p)));\n check(\"swap-exchanges\", exchanged && others, () => `${show(h)}: partner at ${JSON.stringify(a.layout.get(partner))} (subject was ${JSON.stringify(subjectLift)}), subject at ${JSON.stringify(a.layout.get(own))}${others ? \"\" : \", and another pane moved\"}`);\n }\n if (h.kind === \"swap\") {\n // The slots themselves, which no layout callback moves: the partner where the subject was drawn, and back.\n const liftSplit = ops.split(tree);\n const afterSplit = ops.split(a.tree);\n const subjectSlot = pathOf(liftSplit, drawnAs(tree, key));\n const partnerSlot = pathOf(liftSplit, h.at);\n const partnerThere = !!subjectSlot && paneAt(afterSplit, subjectSlot) === drawnAs(a.tree, h.at);\n const subjectThere = !!partnerSlot && paneAt(afterSplit, partnerSlot) === drawnAs(a.tree, key);\n check(\"swap-trades-slots\", partnerThere && subjectThere, () => `${show(h)}: ${partnerThere ? \"\" : `the partner is not in the subject's old slot (${String(subjectSlot && paneAt(afterSplit, subjectSlot))} is)`}${partnerThere || subjectThere ? \"\" : \"; \"}${subjectThere ? \"\" : `the subject is not in the partner's old slot (${String(partnerSlot && paneAt(afterSplit, partnerSlot))} is)`}`);\n if (subject.kind === \"pane\" && ops.stackOf) {\n // Each pane that stood in a stack is replaced there by the other, the stack's other members in place.\n for (const [from, to] of [\n [h.at, subject.pane],\n [subject.pane, h.at],\n ] as const) {\n const was = ops.stackOf(tree, from);\n if (!was) continue;\n const now = ops.stackOf(a.tree, to);\n const expect = was.members.map((m) => (m === from ? to : m));\n check(\"swap-keeps-stack-mates\", !!now && sameList(now.members, expect), () => `${show(h)}: ${String(to)} is in ${now ? `[${now.members.map(String).join(\", \")}]` : \"no stack\"}, expected [${expect.map(String).join(\", \")}]`);\n }\n }\n }\n if (h.kind === \"beside\" || h.kind === \"join\") {\n const released = ops.release(tree, subject);\n const changed = h.kind === \"beside\" ? ops.beside(released, subject, h.at, h.side, { kind: \"half\" }) : ops.join!(released, subject, h.at, h.index);\n check(\"release-first\", sameData(a.tree, norm(changed)), () => `${show(h)}: after().tree is not normalize(change(release(tree)))`);\n }\n if (subject.kind === \"stack\" && h.kind !== \"home\") {\n const ms = subject.stack.members;\n const st = ops.stackOf?.(a.tree, ms[0]!) ?? null;\n const i = st ? st.members.indexOf(ms[0]!) : -1;\n const whole = !!st && ms.every((m, j) => st.members[i + j] === m);\n check(\"stack-moves-whole\", whole, () => `${show(h)}: the stack's members are not together in one stack`);\n }\n }\n check(\"nothing-changes\", sameData(tree, snapshot), () => \"the drag changed the tree it was given\");\n }\n n++;\n }\n return { ok: failures.length === 0 && Object.values(counts).every((c) => c.failed === 0), failures, counts };\n}\n","/**\n * The nearest pane in a direction: the rule a host moves focus by. See docs/placement.md, Entry: tiling.\n */\nimport type { Rect } from \"../geometry\";\n\n/** A direction on the plane: `\"up\"` is toward smaller y. */\nexport type Direction = \"left\" | \"right\" | \"up\" | \"down\";\n\n/**\n * The pane nearest `from` in `direction`, or null when none lies that way. A candidate's center has to be strictly on\n * that side of `from`'s center. Its score is the center distance along the direction, plus a quarter of the center\n * distance across it, plus 100 when it does not overlap `from` across the direction (the overlap strictly above 0);\n * the lowest score wins, ties to the first in the map's order. A pane that is not in `rects` has no neighbor.\n *\n * The host chooses which rects to pass. One option: lay the tree out in a unit square (`{ x: 0, y: 0, width: 1,\n * height: 1 }`) with the host's px floors. A floor of tens of px cannot fit in a unit square, so a split's two floors\n * cannot both fit and it lays out at 0.5 whatever its ratio; fixed lengths in px along a split do not fit either, and\n * the area's size and the gap drop out. Fixed lengths across a split are not checked against the cross extent, so\n * they still apply in a unit square, and a host leaves `fixedAcross` out there. The rects of the real layout work too.\n */\nexport function neighbor<K>(rects: ReadonlyMap<K, Rect>, from: K, direction: Direction): K | null {\n const origin = rects.get(from);\n if (!origin) return null;\n const horizontal = direction === \"left\" || direction === \"right\";\n // Centers and ends as sums of edges (right = x + width), so a host that keeps edge rects gets the same bits.\n const center = (r: Rect, x: boolean): number => (x ? (r.x + (r.x + r.width)) / 2 : (r.y + (r.y + r.height)) / 2);\n const reach = (r: Rect, x: boolean): [number, number] => (x ? [r.x, r.x + r.width] : [r.y, r.y + r.height]);\n const fromAlong = center(origin, horizontal);\n const fromAcross = center(origin, !horizontal);\n const [originStart, originEnd] = reach(origin, !horizontal);\n const sign = direction === \"left\" || direction === \"up\" ? -1 : 1;\n let best: K | null = null;\n let bestScore = Number.POSITIVE_INFINITY;\n for (const [key, r] of rects) {\n if (key === from) continue;\n const along = center(r, horizontal);\n if (sign < 0 ? along >= fromAlong : along <= fromAlong) continue;\n const [start, end] = reach(r, !horizontal);\n const overlap = Math.max(0, Math.min(originEnd, end) - Math.max(originStart, start));\n const score = Math.abs(along - fromAlong) + Math.abs(center(r, !horizontal) - fromAcross) * 0.25 + (overlap > 0 ? 0 : 100);\n if (score < bestScore) {\n bestScore = score;\n best = key;\n }\n }\n return best;\n}\n"],"mappings":";;;;;;;AAmCO,IAAM,cAAc,CAAC,MAAmC,MAAM,UAAa,CAAC,OAAO,SAAS,CAAC,IAAI,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,CAAC,CAAC;AAGvI,SAAS,YAAY,OAA2B,GAAmB;AACxE,QAAM,IAAI,KAAK,MAAM,SAAS,CAAC;AAC/B,SAAO,KAAK,IAAI,KAAK,IAAI,OAAO,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACtE;AAGA,SAAS,OAAU,OAAqB,GAAW,GAAW,OAAe,QAAgB,UAAmB,KAAa,KAAyB;AACpJ,QAAM,IAAI,MA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AACZ,aAAO;AAAA,IACT;AAAA,EACF;AACA,SAAO;AACT;","names":["px","px","lay","stack","x","lay","overlap"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n-uf/placement",
3
- "version": "26.11.56",
3
+ "version": "26.11.58",
4
4
  "description": "Where things fit: the stage cut into edge bands, the items along one edge fitted with their forms, one edge's drop places, floats kept clear, panes tiled and popups positioned. Pure geometry in, rects out. No DOM, no framework, no motion.",
5
5
  "keywords": [
6
6
  "layout",