@n-uf/docking 26.11.59 → 26.11.60

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.
@@ -2183,39 +2183,13 @@ function read(data, base) {
2183
2183
  }
2184
2184
 
2185
2185
  // src/targets.ts
2186
- import { EPS as EPS22, PLANE, area as area6, clamp as clamp3, contains, overlaps as overlaps7, rect as rect19 } from "@n-uf/placement";
2186
+ import { EPS as EPS23, PLANE, area as area6, clamp as clamp4, contains, overlaps as overlaps7, rect as rect19 } from "@n-uf/placement";
2187
2187
 
2188
- // src/targets/anchor.ts
2189
- import { EPS as EPS11, area, rect as rect10, subtract } from "@n-uf/placement";
2190
- var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
2191
- function anchorTargets(state, dragged, options) {
2192
- const none = { targets: [], refusals: [], lost: [] };
2193
- const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
2194
- const now = solve(state, prev);
2195
- const me = now.items[dragged];
2196
- const edge = me?.edge ? state.edges.find((e) => e.id === me.edge) : void 0;
2197
- if (!me || !edge || edge.moves !== "side" || me.floating) return none;
2198
- const homeAfter = () => ({ state, layout: now });
2199
- const targets2 = [];
2200
- const side = OTHER[edge.side];
2201
- const moved = markUsed(setSide(state, edge.id, side), dragged);
2202
- const layout = solve(moved, prev);
2203
- const placed = layout.edges[edge.id]?.rect;
2204
- const slot = layout.items[dragged]?.rect;
2205
- if (placed && slot && area(placed) > EPS11) {
2206
- const pieces = keepClearFor(state, now, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p, rect10(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);
2207
- if (pieces.length > 0) {
2208
- const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
2209
- const result = { state: moved, layout };
2210
- targets2.push({ id: targetId({ kind: "side", side }), priority: 2, hit, ...pieces.length > 1 ? { hits: pieces } : {}, slot, item: dragged, place: { kind: "side", edge: edge.id, side }, after: () => result });
2211
- }
2212
- }
2213
- targets2.push({ id: targetId({ kind: "home", item: dragged }), priority: 1, hit: me.rect, item: dragged, place: { kind: "home" }, after: homeAfter });
2214
- return { targets: targets2, refusals: [], lost: [] };
2215
- }
2188
+ // src/grab.ts
2189
+ import { EPS as EPS12, clamp as clamp2 } from "@n-uf/placement";
2216
2190
 
2217
2191
  // src/aim.ts
2218
- import { EPS as EPS12, clamp } from "@n-uf/placement";
2192
+ import { EPS as EPS11, clamp } from "@n-uf/placement";
2219
2193
  var SPOT_PITCH = 40;
2220
2194
  var SNAP_DISTANCE = 8;
2221
2195
  var lo = (r, axis) => axis === "x" ? r.x : r.y;
@@ -2230,19 +2204,19 @@ function aimSlack(pitch) {
2230
2204
  return Math.max(0, pitch === void 0 || !Number.isFinite(pitch) ? SPOT_PITCH : pitch) / 2;
2231
2205
  }
2232
2206
  function grabShare(own, grab) {
2233
- const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS12 ? 0.5 : clamp(g / size, 0, 1);
2207
+ const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS11 ? 0.5 : clamp(g / size, 0, 1);
2234
2208
  const w = own?.width ?? 0;
2235
2209
  const h = own?.height ?? 0;
2236
2210
  return { x: w >= h ? shareOf(grab?.x, w) : 0.5, y: h > w ? shareOf(grab?.y, h) : 0.5 };
2237
2211
  }
2238
- function aimCut(a, b, axis, held, slack, shared) {
2212
+ function aimCut(a, b, axis, heldA, heldB, slack, shared) {
2239
2213
  if (shared) return lo(shared, axis) + len(shared, axis) / 2;
2240
2214
  const aEnd = lo(a, axis) + len(a, axis);
2241
2215
  const bStart = lo(b, axis);
2242
2216
  const across2 = (aEnd + bStart) / 2;
2243
- if (!(bStart < aEnd - EPS12)) return across2;
2217
+ if (!(bStart < aEnd - EPS11)) return across2;
2244
2218
  const s = Math.max(0, slack);
2245
- return clamp(across2 + (held - 0.5) * (len(a, axis) + len(b, axis)) / 2, bStart - s, aEnd + s);
2219
+ return clamp(across2 + (heldA - len(a, axis) / 2 + (heldB - len(b, axis) / 2)) / 2, bStart - s, aEnd + s);
2246
2220
  }
2247
2221
  function crossFreeCuts(n, cut2, pinned, min = -Infinity, max = Infinity) {
2248
2222
  const active = Array.from({ length: n }, (_, i) => i);
@@ -2250,7 +2224,7 @@ function crossFreeCuts(n, cut2, pinned, min = -Infinity, max = Infinity) {
2250
2224
  changed = false;
2251
2225
  for (let k = 1; k + 1 < active.length; k++) {
2252
2226
  const [p, q, r] = [active[k - 1], active[k], active[k + 1]];
2253
- if (!pinned(q) && cut2(q, r) < cut2(p, q) - EPS12) {
2227
+ if (!pinned(q) && cut2(q, r) < cut2(p, q) - EPS11) {
2254
2228
  active.splice(k, 1);
2255
2229
  changed = true;
2256
2230
  break;
@@ -2263,13 +2237,129 @@ function crossFreeCuts(n, cut2, pinned, min = -Infinity, max = Infinity) {
2263
2237
  }
2264
2238
  function rangeTries(a, b, w, sample) {
2265
2239
  const tries = [a];
2266
- for (let x0 = a + sample; x0 < b - w - EPS12; x0 += sample) tries.push(x0);
2267
- if (b - w > a + EPS12) tries.push(b - w);
2240
+ for (let x0 = a + sample; x0 < b - w - EPS11; x0 += sample) tries.push(x0);
2241
+ if (b - w > a + EPS11) tries.push(b - w);
2268
2242
  return tries;
2269
2243
  }
2270
2244
 
2245
+ // src/grab.ts
2246
+ function grabPlaceOf(it) {
2247
+ const side = it.rail ?? it.railTitle;
2248
+ if (side) return { kind: "rail", side, orient: it.axis };
2249
+ if (!it.floating && it.edge !== void 0) return { kind: "spot", edge: it.edge };
2250
+ return { kind: "float" };
2251
+ }
2252
+ var samePlace = (a, b) => a.kind === b.kind && (a.kind !== "spot" || a.edge === b.edge) && (a.kind !== "rail" || a.side === b.side && a.orient === b.orient);
2253
+ function sameForm(a, b) {
2254
+ return a.axis === b.axis && a.form === b.form && a.formKind === b.formKind && samePlace(grabPlaceOf(a), grabPlaceOf(b));
2255
+ }
2256
+ var sizeOf = (r) => ({ width: r.width, height: r.height });
2257
+ function liftOf(state, seen, dragged, own) {
2258
+ const home = seen.items[dragged];
2259
+ const edge = home?.edge ? state.edges.find((e) => e.id === home.edge) : void 0;
2260
+ const grown = home && edge && growsOnBar(state, edge, dragged, home.form) && home.rect.width > 0 && home.rect.height > 0 ? home.rect : void 0;
2261
+ return { ...home ? { home } : {}, ...own ? { own } : {}, ...grown ? { grown } : {} };
2262
+ }
2263
+ function grabOf(lift, grab, onNote) {
2264
+ const host = typeof grab === "function" ? grab : void 0;
2265
+ const ask = (laid2, size) => {
2266
+ if (!host || !laid2) return void 0;
2267
+ const p = host({ ...laid2, place: grabPlaceOf(laid2) }, { width: size.width, height: size.height });
2268
+ return p && Number.isFinite(p.x) && Number.isFinite(p.y) ? { x: clamp2(p.x, 0, Math.max(0, size.width)), y: clamp2(p.y, 0, Math.max(0, size.height)) } : void 0;
2269
+ };
2270
+ const home = lift.home;
2271
+ const homeSize = home ? sizeOf(home.rect) : void 0;
2272
+ const press = host ? ask(home, homeSize ?? { width: 0, height: 0 }) : grab;
2273
+ const share = grabShare(lift.own, press);
2274
+ const grown = lift.grown;
2275
+ const atHome = (laid2, size) => !!home && !!homeSize && !!laid2 && sameForm(laid2, home) && Math.abs(size.width - homeSize.width) < EPS12 && Math.abs(size.height - homeSize.height) < EPS12;
2276
+ if (host) {
2277
+ const asked = (laid2, size) => {
2278
+ const p = ask(laid2, size);
2279
+ if (onNote && p && press && !noted.has(host) && atHome(laid2, size) && Math.max(Math.abs(p.x - press.x), Math.abs(p.y - press.y)) > LIFT_SLACK) {
2280
+ noted.add(host);
2281
+ onNote({ code: "lift-drift", press, at: p });
2282
+ }
2283
+ return p;
2284
+ };
2285
+ return (laid2, size, rule) => asked(laid2, size) ?? twin(laid2, size, rule);
2286
+ }
2287
+ return twin;
2288
+ function twin(laid2, size, rule) {
2289
+ if (press && rule !== "lane" && atHome(laid2, size)) return press;
2290
+ if (rule === "lift") return laid2?.floating ? twin(laid2, size, "float") : twin(laid2, size, "lane");
2291
+ if (rule === "float") {
2292
+ if (!press) return { x: size.width / 2, y: size.height / 2 };
2293
+ return grown ? { x: clamp2(press.x / grown.width, 0, 1) * size.width, y: clamp2(press.y / grown.height, 0, 1) * size.height } : press;
2294
+ }
2295
+ return { x: share.x * size.width, y: share.y * size.height };
2296
+ }
2297
+ }
2298
+ var LIFT_SLACK = 0.5;
2299
+ var noted = /* @__PURE__ */ new WeakSet();
2300
+ function grabResolver(lift) {
2301
+ let last = null;
2302
+ return (grab) => {
2303
+ if (last && last.grab === grab) return last.fn;
2304
+ last = { grab, fn: grabOf(lift, grab) };
2305
+ return last.fn;
2306
+ };
2307
+ }
2308
+ var fnIds = /* @__PURE__ */ new WeakMap();
2309
+ var nextFnId = 0;
2310
+ function grabKey(grab) {
2311
+ if (!grab) return null;
2312
+ if (typeof grab !== "function") return [grab.x, grab.y];
2313
+ let id = fnIds.get(grab);
2314
+ if (id === void 0) fnIds.set(grab, id = nextFnId++);
2315
+ return `fn${id}`;
2316
+ }
2317
+ var samePoint = (a, b) => Math.abs(a.x - b.x) < EPS12 && Math.abs(a.y - b.y) < EPS12;
2318
+ function aimOnce(fn, rule, first, aim, laidOf, sizeIn) {
2319
+ const g0 = fn(first.laid, first.size, rule);
2320
+ const r1 = aim(g0);
2321
+ const l1 = laidOf(r1);
2322
+ if (!first.laid || !l1 || sameForm(l1, first.laid)) return { result: r1, grab: g0 };
2323
+ const g1 = fn(l1, sizeIn(l1), rule);
2324
+ if (samePoint(g1, g0)) return { result: r1, grab: g1 };
2325
+ const r2 = aim(g1);
2326
+ const l2 = laidOf(r2);
2327
+ if (l2 && sameForm(l2, l1)) return { result: r2, grab: g1 };
2328
+ if (l2 && sameForm(l2, first.laid)) return { result: r2, grab: g0 };
2329
+ return { result: r1, grab: g1 };
2330
+ }
2331
+
2332
+ // src/targets/anchor.ts
2333
+ import { EPS as EPS13, area, rect as rect10, subtract } from "@n-uf/placement";
2334
+ var OTHER = { left: "right", right: "left", top: "bottom", bottom: "top" };
2335
+ function anchorTargets(state, dragged, options) {
2336
+ const none = { targets: [], refusals: [], lost: [] };
2337
+ const prev = { ...options.previous ? { previous: options.previous } : {}, ...options.fresh ? { fresh: options.fresh } : {} };
2338
+ const now = solve(state, prev);
2339
+ const me = now.items[dragged];
2340
+ const edge = me?.edge ? state.edges.find((e) => e.id === me.edge) : void 0;
2341
+ if (!me || !edge || edge.moves !== "side" || me.floating) return none;
2342
+ const homeAfter = () => ({ state, layout: now });
2343
+ const targets2 = [];
2344
+ const side = OTHER[edge.side];
2345
+ const moved = markUsed(setSide(state, edge.id, side), dragged);
2346
+ const layout = solve(moved, prev);
2347
+ const placed = layout.edges[edge.id]?.rect;
2348
+ const slot = layout.items[dragged]?.rect;
2349
+ if (placed && slot && area(placed) > EPS13) {
2350
+ const pieces = keepClearFor(state, now, "targets").reduce((ps, c) => ps.flatMap((p) => subtract(p, rect10(c.x, c.y, c.width, c.height))), [placed]).filter((p) => p.width >= 1 && p.height >= 1);
2351
+ if (pieces.length > 0) {
2352
+ const hit = pieces.reduce((a, p) => area(p) > area(a) ? p : a);
2353
+ const result = { state: moved, layout };
2354
+ targets2.push({ id: targetId({ kind: "side", side }), priority: 2, hit, ...pieces.length > 1 ? { hits: pieces } : {}, slot, item: dragged, place: { kind: "side", edge: edge.id, side }, after: () => result });
2355
+ }
2356
+ }
2357
+ targets2.push({ id: targetId({ kind: "home", item: dragged }), priority: 1, hit: me.rect, item: dragged, place: { kind: "home" }, after: homeAfter });
2358
+ return { targets: targets2, refusals: [], lost: [] };
2359
+ }
2360
+
2271
2361
  // src/targets/edges.ts
2272
- import { EPS as EPS13, area as area2, rect as rect11 } from "@n-uf/placement";
2362
+ import { EPS as EPS14, area as area2, rect as rect11 } from "@n-uf/placement";
2273
2363
  import { formCrossMin as formCrossMin4, formMenu as formMenu5, formSetsCross as formSetsCross4, itemSteps as itemSteps3 } from "@n-uf/placement/stack";
2274
2364
 
2275
2365
  // src/targets/kinds.ts
@@ -2325,7 +2415,7 @@ function distinctSlots(c, slots) {
2325
2415
  if (a.zone !== b.zone) return false;
2326
2416
  if (a.home && b.home) return true;
2327
2417
  const [p, q] = [landing(a), landing(b)];
2328
- const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) < EPS13;
2418
+ const sameLine = a.place.kind === "rail" && b.place.kind === "rail" || Math.abs(a.line - b.line) < EPS14;
2329
2419
  return sameLine && (!p || !q ? p === q : Math.abs(p.x - q.x) + Math.abs(p.y - q.y) + Math.abs(p.width - q.width) + Math.abs(p.height - q.height) < 0.01);
2330
2420
  };
2331
2421
  const wins = (o, j, s, i) => o.home !== s.home ? o.home : j < i;
@@ -2452,7 +2542,7 @@ function edgeSlots(c, edge, accepts) {
2452
2542
  }
2453
2543
  function thickerThan(forms, cross) {
2454
2544
  const shown = forms.filter((f) => !formMenu5(f));
2455
- return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS13);
2545
+ return shown.length > 0 && shown.every((f) => !formSetsCross4(f) && formCrossMin4(f) > cross + EPS14);
2456
2546
  }
2457
2547
  var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
2458
2548
  function edgeSpec(c, edge, as) {
@@ -2466,17 +2556,17 @@ function edgeSpec(c, edge, as) {
2466
2556
  const len2 = (r2) => column ? r2.height : r2.width;
2467
2557
  const empty = el.stack.items.every((p) => el.stack.menu?.items.includes(p.id)) && !el.menu;
2468
2558
  const accepts = edgeTakes(edge, kind);
2469
- if (!accepts && (empty || area2(el.rect) <= EPS13)) return null;
2559
+ if (!accepts && (empty || area2(el.rect) <= EPS14)) return null;
2470
2560
  if (accepts && empty && !opensEmpty(state, edge, kind)) return null;
2471
2561
  const ownNow = c.room.items[dragged];
2472
- const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area2(ownNow.rect) > EPS13 ? ownNow.rect : null;
2562
+ const ownHere = ownNow && ownNow.edge === edge.id && !ownNow.floating && area2(ownNow.rect) > EPS14 ? ownNow.rect : null;
2473
2563
  const oneEnd = state.foldedColumnDrop === "end" && column && el.tabs.length > 0 && ownNow?.edge !== edge.id && zoneTakes(edge, "start", kind);
2474
2564
  const allSlots = edgeSlots(c, edge, accepts);
2475
2565
  const slots = oneEnd ? allSlots.filter((s) => s.zone === "start").sort((a, b) => a.line - b.line).slice(-1) : allSlots;
2476
2566
  const spanOf = (r2) => [at(r2), at(r2) + len2(r2)];
2477
2567
  const grows = (id) => !!formsOf(state.items[id], axisOf(edge.side))[now.items[id].form]?.main.grows;
2478
2568
  const reserved = Object.entries(now.items).filter(([id, p]) => p.edge === edge.id && p.fixed && !p.inMenu && !grows(id)).map(([, p]) => spanOf(p.rect));
2479
- const cards = Object.entries(c.room.items).filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area2(p.rect) > EPS13).map(([, p]) => spanOf(p.rect));
2569
+ const cards = Object.entries(c.room.items).filter(([id, p]) => id !== dragged && p.edge === edge.id && !p.fixed && !p.inMenu && !p.floating && area2(p.rect) > EPS14).map(([, p]) => spanOf(p.rect));
2480
2570
  const zones = oneEnd ? [{ zone: "start", a: at(el.rect) - c.reach, b: at(el.rect) + len2(el.rect) + c.reach }] : zoneSpans(state, c.room, edge, c.reach, (zone) => {
2481
2571
  const s = slots.find((x) => x.zone === zone && x.place.kind === "gap" && x.place.at === 0);
2482
2572
  const me = s?.result.layout.items[dragged];
@@ -2505,7 +2595,7 @@ function edgeSpec(c, edge, as) {
2505
2595
  vertical: column,
2506
2596
  zones,
2507
2597
  slots,
2508
- refuse: (zone) => takes(zone) ? tooThick ? "too-thick" : "no-room" : accepts || area2(el.rect) > EPS13 ? "not-accepted" : null,
2598
+ refuse: (zone) => takes(zone) ? tooThick ? "too-thick" : "no-room" : accepts || area2(el.rect) > EPS14 ? "not-accepted" : null,
2509
2599
  own: ownHere,
2510
2600
  holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,
2511
2601
  reserved,
@@ -2584,6 +2674,8 @@ function context(state, dragged, options, others = []) {
2584
2674
  const rest = liftItem(state, dragged);
2585
2675
  const base = solve(rest, prev);
2586
2676
  const here = placeKey(prune(state), dragged);
2677
+ const own = landedLayout(state, now, dragged, prev).items[dragged];
2678
+ const lift = liftOf(state, now, dragged, own?.rect);
2587
2679
  const c = {
2588
2680
  state,
2589
2681
  others,
@@ -2599,8 +2691,9 @@ function context(state, dragged, options, others = []) {
2599
2691
  isHome: (r) => placeKey(r.state, dragged) === here,
2600
2692
  sound: soundness(state, base, dragged),
2601
2693
  lay: layKeys(state),
2602
- // (Held, a movable grower is its natural length, as `lanes()` reads the grab: `landedLayout`.)
2603
- share: grabShare(landedLayout(state, now, dragged, prev).items[dragged]?.rect, options.grab),
2694
+ lift,
2695
+ grab: grabOf(lift, options.grab, options.onGrabNote),
2696
+ ...own ? { own } : {},
2604
2697
  slack: aimSlack(options.pitch),
2605
2698
  slideRanges: /* @__PURE__ */ new Map()
2606
2699
  };
@@ -2608,22 +2701,22 @@ function context(state, dragged, options, others = []) {
2608
2701
  }
2609
2702
 
2610
2703
  // src/targets/meet.ts
2611
- import { EPS as EPS14, rect as rect12 } from "@n-uf/placement";
2704
+ import { EPS as EPS15, rect as rect12 } from "@n-uf/placement";
2612
2705
  function meet(a, b) {
2613
2706
  const x = Math.max(a.x, b.x);
2614
2707
  const y = Math.max(a.y, b.y);
2615
2708
  const w = Math.min(a.x + a.width, b.x + b.width) - x;
2616
2709
  const h = Math.min(a.y + a.height, b.y + b.height) - y;
2617
- return w > EPS14 && h > EPS14 ? rect12(x, y, w, h) : null;
2710
+ return w > EPS15 && h > EPS15 ? rect12(x, y, w, h) : null;
2618
2711
  }
2619
2712
 
2620
2713
  // src/targets/ownership.ts
2621
- import { EPS as EPS16, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
2714
+ import { EPS as EPS17, area as area3, overlaps as overlaps3, rect as rect13, subtract as subtract2 } from "@n-uf/placement";
2622
2715
  import { formBody as formBody2, itemSteps as itemSteps5 } from "@n-uf/placement/stack";
2623
2716
 
2624
2717
  // src/targets/model.ts
2625
- import { EPS as EPS15 } from "@n-uf/placement";
2626
- var less = (spans, away) => away.reduce((acc, [ra, rb]) => acc.flatMap(([a, b]) => rb <= a || ra >= b ? [[a, b]] : [[a, Math.max(a, ra)], [Math.min(b, rb), b]].filter(([u, w]) => w - u > EPS15)), [...spans]);
2718
+ import { EPS as EPS16 } from "@n-uf/placement";
2719
+ var less = (spans, away) => away.reduce((acc, [ra, rb]) => acc.flatMap(([a, b]) => rb <= a || ra >= b ? [[a, b]] : [[a, Math.max(a, ra)], [Math.min(b, rb), b]].filter(([u, w]) => w - u > EPS16)), [...spans]);
2627
2720
 
2628
2721
  // src/targets/ownership.ts
2629
2722
  var isBody = (f) => !!f && formBody2(f);
@@ -2645,10 +2738,10 @@ function ownedRectsOf(s, along2) {
2645
2738
  return along2.map(([a, b]) => s.vertical ? rect13(o.x, a, o.width, b - a) : rect13(a, o.y, b - a, o.height));
2646
2739
  }
2647
2740
  function drawnOf(c, live) {
2648
- const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS16 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
2741
+ const edges = Object.entries(c.now.edges).filter(([id, e]) => area3(e.rect) > EPS17 && c.lay.has(id)).map(([id, e]) => ({ spec: live.find((s) => s.edge?.id === id) ?? null, rect: e.rect, lay: c.lay.get(id) }));
2649
2742
  const rails = ["left", "right"].flatMap((side) => {
2650
2743
  const rail = c.now.rails[side];
2651
- if (!rail || rail.segments.length === 0 || area3(rail.rect) <= EPS16) return [];
2744
+ if (!rail || rail.segments.length === 0 || area3(rail.rect) <= EPS17) return [];
2652
2745
  const spec = live.find((s) => s.kind === "railStop" && s.lay.side === side) ?? null;
2653
2746
  const lay = spec?.lay ?? { phase: EDGE_KINDS.railStop.phase, side, at: -1 };
2654
2747
  const me = c.now.items[c.dragged];
@@ -2670,7 +2763,7 @@ function homeRectOf(c, ownSpec) {
2670
2763
  if (!ownSpec) {
2671
2764
  const e = c.now.edges[own.edge];
2672
2765
  const vanishes = !c.rest.edges.some((x) => x.id === own.edge);
2673
- return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS16 ? hull3(o, e.rect) : o;
2766
+ return e && vanishes && !e.folded && !e.rides && area3(e.rect) > EPS17 ? hull3(o, e.rect) : o;
2674
2767
  }
2675
2768
  const [c0, c1] = ownSpec.across();
2676
2769
  return ownSpec.vertical ? hull3(o, rect13(c0, o.y, c1 - c0, o.height)) : hull3(o, rect13(o.x, c0, o.width, c1 - c0));
@@ -2690,7 +2783,7 @@ function ownersOf(c, live, drawn, alongOf) {
2690
2783
  if (!s.thinOwned) return rects.map((r) => ({ spec: s, rect: r, lay: s.lay, place: !s.drawn }));
2691
2784
  const thin = (r) => s.vertical ? rect13(Math.max(r.x, s.thinOwned[0]), r.y, Math.min(r.x + r.width, s.thinOwned[1]) - Math.max(r.x, s.thinOwned[0]), r.height) : rect13(r.x, Math.max(r.y, s.thinOwned[0]), r.width, Math.min(r.y + r.height, s.thinOwned[1]) - Math.max(r.y, s.thinOwned[0]));
2692
2785
  return rects.flatMap((r) => [{ spec: s, rect: thin(r), lay: s.lay, place: true }, ...subtract2(r, thin(r)).map((d) => ({ spec: s, rect: d, lay: s.lay, place: true, deep: true }))]);
2693
- }).filter((o) => area3(o.rect) > EPS16),
2786
+ }).filter((o) => area3(o.rect) > EPS17),
2694
2787
  // Every seen rect: the edges the tiler doesn't read (folded, riding, taking nothing) among them.
2695
2788
  ...drawn.map((d) => ({ ...d, place: false }))
2696
2789
  ];
@@ -2716,7 +2809,7 @@ function ownership(c, live, alongOf, aloneOf) {
2716
2809
  const e = s.edge ? now.edges[s.id] : void 0;
2717
2810
  if (!e) return null;
2718
2811
  const span = s.vertical ? [e.rect.y, e.rect.y + e.rect.height] : [e.rect.x, e.rect.x + e.rect.width];
2719
- return span[1] - span[0] > EPS16 ? span : null;
2812
+ return span[1] - span[0] > EPS17 ? span : null;
2720
2813
  };
2721
2814
  const pastEnds = (s, r) => {
2722
2815
  const ends = endsOf(s);
@@ -2768,7 +2861,7 @@ function ownership(c, live, alongOf, aloneOf) {
2768
2861
  const half = e ? halfBandOf(e) : null;
2769
2862
  if (!e || half === null) return [];
2770
2863
  const column = axisOf(e.side) === "column";
2771
- return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a > EPS16);
2864
+ return Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && iid !== dragged && isBody(formsOf(state.items[iid], axisOf(e.side))[p.form])).map(([, p]) => column ? [p.rect.y + half, p.rect.y + p.rect.height - half] : [p.rect.x + half, p.rect.x + p.rect.width - half]).filter(([a, b]) => b - a > EPS17);
2772
2865
  };
2773
2866
  const rooms = /* @__PURE__ */ new Map();
2774
2867
  const cutsOf = (s) => {
@@ -2785,23 +2878,23 @@ function ownership(c, live, alongOf, aloneOf) {
2785
2878
  const owned = [];
2786
2879
  for (let k = 1; k < ends.length; k++) {
2787
2880
  const [u, w] = [ends[k - 1], ends[k]];
2788
- const over2 = rs.filter((r) => along2(r)[0] <= u + EPS16 && along2(r)[1] >= w - EPS16).map(across2);
2789
- if (w - u > EPS16 && less([across2(b)], over2).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
2881
+ const over2 = rs.filter((r) => along2(r)[0] <= u + EPS17 && along2(r)[1] >= w - EPS17).map(across2);
2882
+ if (w - u > EPS17 && less([across2(b)], over2).reduce((n, [p, q]) => n + q - p, 0) < 1) owned.push([u, w]);
2790
2883
  }
2791
2884
  const half = s.edge ? halfBandOf(s.edge) : null;
2792
2885
  const raw = bodySpans(s.edge);
2793
2886
  if (half === null || raw.length === 0) return { cuts: owned, bodies: raw };
2794
2887
  const merged = owned.reduce((m, [u, w]) => {
2795
2888
  const last = m[m.length - 1];
2796
- if (last && u <= last[1] + EPS16) last[1] = Math.max(last[1], w);
2889
+ if (last && u <= last[1] + EPS17) last[1] = Math.max(last[1], w);
2797
2890
  else m.push([u, w]);
2798
2891
  return m;
2799
2892
  }, []);
2800
2893
  const [lo2, hi] = endsOf(s) ?? along2(b);
2801
2894
  const placed = (p) => {
2802
- const cut2 = merged.find(([u, w]) => p >= u - EPS16 && p <= w + EPS16);
2895
+ const cut2 = merged.find(([u, w]) => p >= u - EPS17 && p <= w + EPS17);
2803
2896
  if (!cut2) return p;
2804
- const sides = [...cut2[0] > lo2 + EPS16 ? [cut2[0]] : [], ...cut2[1] < hi - EPS16 ? [cut2[1]] : []];
2897
+ const sides = [...cut2[0] > lo2 + EPS17 ? [cut2[0]] : [], ...cut2[1] < hi - EPS17 ? [cut2[1]] : []];
2805
2898
  return sides.length === 0 ? p : sides.reduce((m, x) => Math.abs(x - p) < Math.abs(m - p) ? x : m);
2806
2899
  };
2807
2900
  const bands = s.slots.map((sl) => [placed(sl.line) - half, placed(sl.line) + half]);
@@ -2819,7 +2912,7 @@ function ownership(c, live, alongOf, aloneOf) {
2819
2912
  const column = axisOf(e.side) === "column";
2820
2913
  const across2 = (a, b) => column ? rect13(-1e9, a, 2e9, b - a) : rect13(a, -1e9, b - a, 2e9);
2821
2914
  const reserved = Object.entries(now.items).filter(([iid, p]) => p.edge === e.id && p.fixed && !p.inMenu && !grows(iid)).map(([, p]) => column ? across2(p.rect.y, p.rect.y + p.rect.height) : across2(p.rect.x, p.rect.x + p.rect.width));
2822
- return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS16);
2915
+ return [...reserved, ...cutsOf(s).bodies.map(([a, b]) => across2(a, b))].filter((b) => area3(b) > EPS17);
2823
2916
  };
2824
2917
  const drawnBySpec = /* @__PURE__ */ new Map();
2825
2918
  const drawnBesides = (s) => {
@@ -2831,15 +2924,15 @@ function ownership(c, live, alongOf, aloneOf) {
2831
2924
  }
2832
2925
 
2833
2926
  // src/targets/tiles.ts
2834
- import { EPS as EPS18, area as area4, overlaps as overlaps4, rect as rect15, subtract as subtract3 } from "@n-uf/placement";
2927
+ import { EPS as EPS19, area as area4, overlaps as overlaps4, rect as rect15, subtract as subtract3 } from "@n-uf/placement";
2835
2928
 
2836
2929
  // src/slide.ts
2837
- import { EPS as EPS17, rect as rect14 } from "@n-uf/placement";
2930
+ import { EPS as EPS18, rect as rect14 } from "@n-uf/placement";
2838
2931
  import { itemSteps as itemSteps6 } from "@n-uf/placement/stack";
2839
2932
  var mid = (r, axis) => lo(r, axis) + len(r, axis) / 2;
2840
2933
  var nonNeg = (v) => Number.isFinite(v) && v > 0 ? v : 0;
2841
2934
  function onEdge(l, edge, dragged, axis) {
2842
- return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width > EPS17 && it.rect.height > EPS17).map(([id, it]) => ({ id, r: it.rect, zone: it.zone })).sort((a, b) => lo(a.r, axis) - lo(b.r, axis));
2935
+ return Object.entries(l.items).filter(([id, it]) => id !== dragged && it.edge === edge && !it.inMenu && !it.floating && it.rect.width > EPS18 && it.rect.height > EPS18).map(([id, it]) => ({ id, r: it.rect, zone: it.zone })).sort((a, b) => lo(a.r, axis) - lo(b.r, axis));
2843
2936
  }
2844
2937
  function neighbors(after, edge, dragged, axis) {
2845
2938
  const me = after.items[dragged];
@@ -2861,7 +2954,7 @@ function slackOf(state, id, axis, r) {
2861
2954
  }
2862
2955
  function placeOf(se, l) {
2863
2956
  const counts = (id) => !(se.state.items[id]?.fixed && itemSteps6(se.state.items[id]));
2864
- const shown = Object.entries(l.items).filter(([id, it]) => counts(id) && it.edge === se.e.id && !it.inMenu && !it.floating && it.rect.width > EPS17 && it.rect.height > EPS17).sort(([, p], [, q]) => lo(p.rect, se.axis) - lo(q.rect, se.axis)).map(([id]) => id);
2957
+ const shown = Object.entries(l.items).filter(([id, it]) => counts(id) && it.edge === se.e.id && !it.inMenu && !it.floating && it.rect.width > EPS18 && it.rect.height > EPS18).sort(([, p], [, q]) => lo(p.rect, se.axis) - lo(q.rect, se.axis)).map(([id]) => id);
2865
2958
  const menu = Object.entries(l.items).filter(([id, it]) => counts(id) && it.inMenu && it.edge === se.e.id).map(([id]) => id).sort();
2866
2959
  return `${shown.join(" ")} \xBB ${menu.join(" ")}`;
2867
2960
  }
@@ -2929,7 +3022,7 @@ function slideLand(se, room, x0) {
2929
3022
  for (const zone of [near, near === "start" ? "end" : "start"]) {
2930
3023
  if (!room.zones.includes(zone)) continue;
2931
3024
  const space = room.spaceAt(zone, x0);
2932
- if (space < -EPS17) continue;
3025
+ if (space < -EPS18) continue;
2933
3026
  const place = { edge: se.e.id, zone, at: room.atOf(zone), space: Math.max(0, space) };
2934
3027
  const hit = landsAt(se, place, x0);
2935
3028
  if (hit && (room.place === void 0 || placeOf(se, hit.layout) === room.place)) return { place, result: { state: hit.next, layout: hit.layout } };
@@ -2973,7 +3066,7 @@ function tilerOf(spec) {
2973
3066
  const part = (a, b) => v ? rect15(a, h.y, b - a, h.height) : rect15(h.x, a, h.width, b - a);
2974
3067
  const beyond = less([[h0, h1]], [spec.owned]);
2975
3068
  if (beyond.length === 0) return [t];
2976
- if (c1 - c0 <= EPS18) return [{ ...t, order: data.overreach }];
3069
+ if (c1 - c0 <= EPS19) return [{ ...t, order: data.overreach }];
2977
3070
  const core = { ...t, hit: part(c0, c1), keep: t.keep && keepAt(v ? t.keep.y : t.keep.x, part(c0, c1)) };
2978
3071
  return [core, ...beyond.map(([a, b]) => ({ ...t, kind: "reach", of: core, order: data.overreach, hit: part(a, b), keep: null }))];
2979
3072
  };
@@ -2987,7 +3080,7 @@ function wholeRefusal(c, spec) {
2987
3080
  const data = EDGE_KINDS[spec.kind];
2988
3081
  return { edge: spec.id, spec, edgeKind: spec.kind, vertical: spec.vertical, zone: "start", hit, kind: "refuse", id: "", order: data.layer, priority: data.priority, keep: null, reason: "not-accepted", whole: true };
2989
3082
  }
2990
- var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a > EPS18);
3083
+ var hasRoom = (spans, away) => less(spans, away).some(([a, b]) => b - a > EPS19);
2991
3084
  function linesIn(spec, z, mine, pieces, [pa, pb], own) {
2992
3085
  const reserved = spec.reserved;
2993
3086
  const lines = mine.map((s) => s.line);
@@ -2996,42 +3089,42 @@ function linesIn(spec, z, mine, pieces, [pa, pb], own) {
2996
3089
  const free = less([[z.a, z.b]], reserved);
2997
3090
  const freeLen = free.reduce((n, [a, b]) => n + (b - a), 0);
2998
3091
  const spread = (x) => {
2999
- if (hi - lo2 <= EPS18 || freeLen <= EPS18) return x;
3092
+ if (hi - lo2 <= EPS19 || freeLen <= EPS19) return x;
3000
3093
  let d = (x - lo2) / (hi - lo2) * freeLen;
3001
3094
  for (const [a, b] of free) {
3002
- if (d <= b - a + EPS18) return a + Math.min(d, b - a);
3095
+ if (d <= b - a + EPS19) return a + Math.min(d, b - a);
3003
3096
  d -= b - a;
3004
3097
  }
3005
3098
  return free[free.length - 1][1];
3006
3099
  };
3007
- const past = lines.some((x) => x < z.a - EPS18 || x > z.b + EPS18);
3100
+ const past = lines.some((x) => x < z.a - EPS19 || x > z.b + EPS19);
3008
3101
  const nearer = (p, [a, b]) => p > a && p < b ? p - a < b - p ? a : b : p;
3009
3102
  const proj = (x) => {
3010
3103
  const q = reserved.reduce((r, s) => nearer(r, s), past ? spread(x) : x);
3011
3104
  const p = own ? nearer(q, own) : q;
3012
- if (pieces.some(([a, b]) => p >= a - EPS18 && p <= b + EPS18)) return p;
3105
+ if (pieces.some(([a, b]) => p >= a - EPS19 && p <= b + EPS19)) return p;
3013
3106
  return pieces.map(([a, b]) => Math.min(Math.max(p, a), b)).reduce((m, y) => Math.abs(y - p) < Math.abs(m - p) ? y : m);
3014
3107
  };
3015
- const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) < EPS18 || Math.abs(s.line - own[1]) < EPS18);
3016
- const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa - EPS18 && s.line <= pb + EPS18 : proj(s.line) >= pa - EPS18 && proj(s.line) <= pb + EPS18).sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);
3108
+ const ownEnd = (s) => !!own && s.home && (Math.abs(s.line - own[0]) < EPS19 || Math.abs(s.line - own[1]) < EPS19);
3109
+ const inPiece = mine.filter((s) => ownEnd(s) ? s.line >= pa - EPS19 && s.line <= pb + EPS19 : proj(s.line) >= pa - EPS19 && proj(s.line) <= pb + EPS19).sort((a, b) => proj(a.line) - proj(b.line) || a.line - b.line);
3017
3110
  const projected = inPiece.map((s) => proj(s.line));
3018
- const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <= EPS18) ? inPiece.map((_, i) => pa + (i + 0.5) * (pb - pa) / inPiece.length) : projected;
3111
+ const at = projected.some((p, i) => i > 0 && p - projected[i - 1] <= EPS19) ? inPiece.map((_, i) => pa + (i + 0.5) * (pb - pa) / inPiece.length) : projected;
3019
3112
  return { inPiece, at };
3020
3113
  }
3021
3114
  function reachStrips(c, spec, room, ends) {
3022
- const inEdge = (s) => !!ends && s[0] < ends[1] - EPS18 && s[1] > ends[0] + EPS18;
3115
+ const inEdge = (s) => !!ends && s[0] < ends[1] - EPS19 && s[1] > ends[0] + EPS19;
3023
3116
  const pieces = room.filter(inEdge);
3024
3117
  if (!ends || pieces.length === 0) return { pieces: [...room], before: [], after: [] };
3025
3118
  const [c0, c1] = spec.across();
3026
3119
  const bandOf2 = (a, b) => spec.vertical ? rect15(c0, a, c1 - c0, b - a) : rect15(a, c0, b - a, c1 - c0);
3027
3120
  const across2 = c.state.edges.filter((e) => axisOf(e.side) === "column" !== spec.vertical).map((e) => c.now.edges[e.id]);
3028
- const drawnBetween = (a, b) => b - a > EPS18 && across2.some((e) => !!e && e.cross > EPS18 && area4(e.rect) > EPS18 && overlaps4(e.rect, bandOf2(a, b)));
3121
+ const drawnBetween = (a, b) => b - a > EPS19 && across2.some((e) => !!e && e.cross > EPS19 && area4(e.rect) > EPS19 && overlaps4(e.rect, bandOf2(a, b)));
3029
3122
  const first = pieces[0][0];
3030
3123
  const last = pieces[pieces.length - 1][1];
3031
3124
  return {
3032
3125
  pieces,
3033
- before: room.filter((s) => s[1] <= ends[0] + EPS18 && !drawnBetween(s[1], first)),
3034
- after: room.filter((s) => s[0] >= ends[1] - EPS18 && !drawnBetween(last, s[0]))
3126
+ before: room.filter((s) => s[1] <= ends[0] + EPS19 && !drawnBetween(s[1], first)),
3127
+ after: room.filter((s) => s[0] >= ends[1] - EPS19 && !drawnBetween(last, s[0]))
3035
3128
  };
3036
3129
  }
3037
3130
  function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
@@ -3043,7 +3136,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3043
3136
  const own = spec.own ? v ? [spec.own.y, spec.own.y + spec.own.height] : [spec.own.x, spec.own.x + spec.own.width] : null;
3044
3137
  const { band, keepAt, tile, split } = tilerOf(spec);
3045
3138
  const drawn = spec.edge ? c.now.edges[spec.id]?.rect : void 0;
3046
- const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS18 ? v ? rect15(-1e9, drawn.y, 2e9, drawn.height) : rect15(drawn.x, -1e9, drawn.width, 2e9) : null;
3139
+ const alongLimit = drawn && (v ? drawn.height : drawn.width) > EPS19 ? v ? rect15(-1e9, drawn.y, 2e9, drawn.height) : rect15(drawn.x, -1e9, drawn.width, 2e9) : null;
3047
3140
  const refused = (zone, hit, reason) => {
3048
3141
  const inEdge = alongLimit ? meet(hit, alongLimit) : hit;
3049
3142
  const shown = inEdge && meet(inEdge, c.state.stage);
@@ -3052,11 +3145,11 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3052
3145
  const slots = distinctSlots(c, spec.slots);
3053
3146
  const runs = [...spec.reserved].sort((p, q) => p[0] - q[0]).reduce((acc, [a, b]) => {
3054
3147
  const last = acc[acc.length - 1];
3055
- if (last && a <= last[1] + EPS18) acc[acc.length - 1] = [last[0], Math.max(last[1], b)];
3148
+ if (last && a <= last[1] + EPS19) acc[acc.length - 1] = [last[0], Math.max(last[1], b)];
3056
3149
  else acc.push([a, b]);
3057
3150
  return acc;
3058
3151
  }, []);
3059
- const wedged = (line) => runs.some(([a, b]) => line > a + EPS18 && line < b - EPS18);
3152
+ const wedged = (line) => runs.some(([a, b]) => line > a + EPS19 && line < b - EPS19);
3060
3153
  const homeSlot = spec.holds && own ? slots.find((s) => s.home && s.order !== void 0) : void 0;
3061
3154
  const ends = alongLimit && drawn ? v ? [drawn.y, drawn.y + drawn.height] : [drawn.x, drawn.x + drawn.width] : null;
3062
3155
  const out = [];
@@ -3070,7 +3163,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3070
3163
  });
3071
3164
  const axis = v ? "y" : "x";
3072
3165
  const span = (r) => v ? [r.y, r.y + r.height] : [r.x, r.x + r.width];
3073
- const orderIn = (l) => Object.entries(l.items).filter(([, it]) => it.edge === spec.id && !it.inMenu && !it.floating && area4(it.rect) > EPS18).sort(([, p], [, q]) => span(p.rect)[0] - span(q.rect)[0]).map(([id]) => id).join(" ");
3166
+ const orderIn = (l) => Object.entries(l.items).filter(([, it]) => it.edge === spec.id && !it.inMenu && !it.floating && area4(it.rect) > EPS19).sort(([, p], [, q]) => span(p.rect)[0] - span(q.rect)[0]).map(([id]) => id).join(" ");
3074
3167
  const homeOrder = orderIn(c.now);
3075
3168
  const nearHome = (s) => {
3076
3169
  if (halves || s.home || !spec.own || !ownRect || c.now.items[c.dragged]?.inMenu) return false;
@@ -3086,18 +3179,18 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3086
3179
  };
3087
3180
  const stretchesOf = [];
3088
3181
  for (const z of spec.zones) {
3089
- const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a > EPS18);
3182
+ const room = less([[z.a, z.b]], [...cuts, ...spec.reserved]).filter(([a, b]) => b - a > EPS19);
3090
3183
  const { pieces, before, after } = reachStrips(c, spec, own ? less(room, [own]) : room, ends);
3091
3184
  if (!hasRoom(pieces, bodies)) continue;
3092
3185
  const lined = slots.flatMap((s) => spec.holds && s.home ? own ? [{ ...s, line: own[0] }, { ...s, line: own[1] }] : [] : [s]);
3093
- const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach + EPS18 && a < s.line + data.reach - EPS18));
3186
+ const mine = lined.filter((s) => s.zone === z.zone && !wedged(s.line) && pieces.some(([a, b]) => b > s.line - data.reach + EPS19 && a < s.line + data.reach - EPS19));
3094
3187
  const reason = spec.refuse(z.zone);
3095
3188
  for (const [k, [pa, pb]] of pieces.entries()) {
3096
3189
  const { inPiece, at } = linesIn(spec, z, mine, pieces, [pa, pb], own);
3097
3190
  const stripsOf = (i) => [...k === 0 && i === 0 ? before : [], ...k === pieces.length - 1 && i === inPiece.length - 1 ? after : []];
3098
3191
  if (inPiece.length === 0) {
3099
3192
  const lone = (reason === "no-room" || reason === "too-thick") && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);
3100
- const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS18 && pa < s.line + data.reach - EPS18);
3193
+ const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS19 && pa < s.line + data.reach - EPS19);
3101
3194
  const joins = data.virtual ? mine.filter((s) => s.ok && !s.home) : [];
3102
3195
  if (joins.length > 0) {
3103
3196
  const s = joins.reduce((m, x) => Math.abs(x.line - (pa + pb) / 2) < Math.abs(m.line - (pa + pb) / 2) ? x : m);
@@ -3111,12 +3204,12 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3111
3204
  const meets = [];
3112
3205
  for (let i = 1; i < inPiece.length; i++) {
3113
3206
  const [lo2, hi] = [at[i - 1], at[i]];
3114
- const between = spec.cards.filter(([u2, w2]) => u2 >= inPiece[i - 1].line - EPS18 && w2 <= inPiece[i].line + EPS18);
3207
+ const between = spec.cards.filter(([u2, w2]) => u2 >= inPiece[i - 1].line - EPS19 && w2 <= inPiece[i].line + EPS19);
3115
3208
  const la = landingOf(inPiece[i - 1]);
3116
3209
  const lb = landingOf(inPiece[i]);
3117
3210
  const [u, w] = between[0] ?? [NaN, NaN];
3118
- const mid3 = between.length === 1 ? aimCut(la ?? rect15(0, 0, 0, 0), lb ?? rect15(0, 0, 0, 0), v ? "y" : "x", 0.5, 0, v ? rect15(0, u, 0, w - u) : rect15(u, 0, w - u, 0)) : NaN;
3119
- meets[i] = mid3 > lo2 + EPS18 && mid3 < hi - EPS18 ? mid3 : (lo2 + hi) / 2;
3211
+ const mid3 = between.length === 1 ? aimCut(la ?? rect15(0, 0, 0, 0), lb ?? rect15(0, 0, 0, 0), v ? "y" : "x", 0, 0, 0, v ? rect15(0, u, 0, w - u) : rect15(u, 0, w - u, 0)) : NaN;
3212
+ meets[i] = mid3 > lo2 + EPS19 && mid3 < hi - EPS19 ? mid3 : (lo2 + hi) / 2;
3120
3213
  }
3121
3214
  const meet2 = (i) => meets[i];
3122
3215
  inPiece.forEach((s, i) => {
@@ -3126,7 +3219,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3126
3219
  const b0 = Math.min(i === inPiece.length - 1 ? pb : meet2(i + 1), p + lim);
3127
3220
  stretchesOf.push({ s, a: a0, b: b0, make: (a, b) => makeTiles(a, b) });
3128
3221
  const makeTiles = (a, b) => {
3129
- if (b - a <= EPS18) {
3222
+ if (b - a <= EPS19) {
3130
3223
  if (s.ok && !s.home) lost.push(s.id);
3131
3224
  return;
3132
3225
  }
@@ -3139,7 +3232,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3139
3232
  for (const [u, w] of [[a, b], ...stripsOf(i)]) out.push(...split(homeTile(s.home ? s.id : homeSlot?.id ?? s.id, u, w, p)));
3140
3233
  return;
3141
3234
  }
3142
- const faced = halves && homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a + EPS18 && u < b - EPS18) : [];
3235
+ const faced = halves && homeSlot && s.order === homeSlot.order ? spec.cards.filter(([u, w]) => w > a + EPS19 && u < b - EPS19) : [];
3143
3236
  for (const [u, w] of faced) out.push(...split(homeTile(homeSlot.id, Math.max(u, a), Math.min(w, b), p)));
3144
3237
  for (const [u, w] of [...less([[a, b]], faced), ...stripsOf(i)]) {
3145
3238
  const line = Math.min(Math.max(p, u), w);
@@ -3210,8 +3303,15 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3210
3303
  if (runs2.some((run) => run.some((x) => !rangeFor(x.s) && !rangeFor(r.s) && sameAt(x.s, r.s)))) dropped.push(r);
3211
3304
  else runs2.push([r]);
3212
3305
  }
3213
- const facing = (run, end) => run.map((r) => end ? lastOf(r.s) : firstOf(r.s)).reduce((m, x) => end ? span(x)[1] > span(m)[1] ? x : m : span(x)[0] < span(m)[0] ? x : m);
3214
- const cutOf = (p, q) => aimCut(facing(p, true), facing(q, false), axis, c.share[axis], c.slack);
3306
+ const facing = (run, end) => run.map((r) => ({ r: end ? lastOf(r.s) : firstOf(r.s), s: r.s })).reduce((m, x) => end ? span(x.r)[1] > span(m.r)[1] ? x : m : span(x.r)[0] < span(m.r)[0] ? x : m);
3307
+ const heldIn = ({ r, s }) => {
3308
+ const laid2 = s.home || nearHome(s) ? c.own : s.result.layout.items[c.dragged];
3309
+ return c.grab(laid2 ? { ...laid2, rect: r } : void 0, sizeOf(r), "lane")[axis];
3310
+ };
3311
+ const cutOf = (p, q) => {
3312
+ const [a, b] = [facing(p, true), facing(q, false)];
3313
+ return aimCut(a.r, b.r, axis, heldIn(a), heldIn(b), c.slack);
3314
+ };
3215
3315
  const bandStart = ends?.[0] ?? -Infinity;
3216
3316
  const bandEnd = ends?.[1] ?? Infinity;
3217
3317
  const cuts2 = crossFreeCuts(runs2.length, (i, j) => cutOf(runs2[i], runs2[j]), (i) => runs2[i].some((x) => x.s.home), bandStart, bandEnd);
@@ -3220,7 +3320,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3220
3320
  const cp = i > 0 ? cuts2[i - 1] : Math.min(...run.map((r) => r.a));
3221
3321
  const cn = i + 1 < runs2.length ? cuts2[i] : Math.max(...run.map((r) => r.b));
3222
3322
  for (const r of run) [r.a, r.b] = [Math.min(Math.max(r.a, cp), cn), Math.max(Math.min(r.b, cn), cp)];
3223
- const held = run.filter((r) => r.b - r.a > EPS18).sort((p, q) => p.a - q.a);
3323
+ const held = run.filter((r) => r.b - r.a > EPS19).sort((p, q) => p.a - q.a);
3224
3324
  if (held.length === 0) {
3225
3325
  const one = run.find((r) => !ownStretch.includes(r)) ?? run[0];
3226
3326
  [one.a, one.b] = [cp, Math.max(cp, cn)];
@@ -3228,20 +3328,20 @@ function tileEdge(c, spec, { cuts, bodies }, lost, slides) {
3228
3328
  held[0].a = cp;
3229
3329
  held.at(-1).b = Math.max(cp, cn);
3230
3330
  }
3231
- if (cn - cp > EPS18) spans.push([cp, cn]);
3331
+ if (cn - cp > EPS19) spans.push([cp, cn]);
3232
3332
  });
3233
3333
  for (const r of dropped) r.a = r.b;
3234
3334
  for (const r of lands) if (r.s.ok && !r.s.home) lost.push(r.s.id);
3235
- if (ownStretch[0]) ownKept = ownStretch[0].b - ownStretch[0].a > EPS18 ? [[ownStretch[0].a, ownStretch[0].b]] : [];
3335
+ if (ownStretch[0]) ownKept = ownStretch[0].b - ownStretch[0].a > EPS19 ? [[ownStretch[0].a, ownStretch[0].b]] : [];
3236
3336
  for (const r of all.filter((x) => !lands.includes(x))) {
3237
- const left = less([[r.a, r.b]], spans).filter(([u, w]) => w - u > EPS18);
3337
+ const left = less([[r.a, r.b]], spans).filter(([u, w]) => w - u > EPS19);
3238
3338
  [r.a, r.b] = left.length ? left.reduce((m, x) => x[1] - x[0] > m[1] - m[0] ? x : m) : [r.a, r.a];
3239
3339
  }
3240
3340
  }
3241
3341
  for (const r of stretchesOf) r.make(r.a, r.b);
3242
3342
  if (own && spec.own && (ownKept === null || ownKept.length > 0)) {
3243
3343
  const home = spec.slots.find((s) => s.home);
3244
- const kept = ownKept ?? (halves ? [] : less([own], slotSpans).filter(([u, w]) => w - u > EPS18));
3344
+ const kept = ownKept ?? (halves ? [] : less([own], slotSpans).filter(([u, w]) => w - u > EPS19));
3245
3345
  const [a, b] = kept.length > 0 ? kept.reduce((m, x) => x[1] - x[0] > m[1] - m[0] ? x : m) : own;
3246
3346
  const h = band(a, b);
3247
3347
  const o = spec.own;
@@ -3263,7 +3363,7 @@ function placeReach(t, pieces, placed, landed, gone) {
3263
3363
  if (at.length === 0 && gone.has(of)) {
3264
3364
  const line = t.vertical ? of.keep.y : of.keep.x;
3265
3365
  const whole = pieces.filter((p) => p.width >= 1 && p.height >= 1);
3266
- const on = whole.filter((p) => t.vertical ? p.y <= line + EPS18 && line <= p.y + p.height + EPS18 : p.x <= line + EPS18 && line <= p.x + p.width + EPS18);
3366
+ const on = whole.filter((p) => t.vertical ? p.y <= line + EPS19 && line <= p.y + p.height + EPS19 : p.x <= line + EPS19 && line <= p.x + p.width + EPS19);
3267
3367
  const kept = (on.length > 0 ? on : whole).reduce((a, p) => !a || area4(p) > area4(a) ? p : a, null);
3268
3368
  if (kept) {
3269
3369
  placed.push({ ...of, hit: kept });
@@ -3276,7 +3376,7 @@ function placeReach(t, pieces, placed, landed, gone) {
3276
3376
  for (let k = 0; k < cover.length; k++) {
3277
3377
  const h = cover[k];
3278
3378
  const joint = pieces.find(
3279
- (p) => t.vertical ? p.y <= h.y + EPS18 && p.y + p.height >= h.y + h.height - EPS18 && (Math.abs(p.x - h.x - h.width) < EPS18 || Math.abs(p.x + p.width - h.x) < EPS18) : p.x <= h.x + EPS18 && p.x + p.width >= h.x + h.width - EPS18 && (Math.abs(p.y - h.y - h.height) < EPS18 || Math.abs(p.y + p.height - h.y) < EPS18)
3379
+ (p) => t.vertical ? p.y <= h.y + EPS19 && p.y + p.height >= h.y + h.height - EPS19 && (Math.abs(p.x - h.x - h.width) < EPS19 || Math.abs(p.x + p.width - h.x) < EPS19) : p.x <= h.x + EPS19 && p.x + p.width >= h.x + h.width - EPS19 && (Math.abs(p.y - h.y - h.height) < EPS19 || Math.abs(p.y + p.height - h.y) < EPS19)
3280
3380
  );
3281
3381
  if (!joint) continue;
3282
3382
  const merged = t.vertical ? rect15(Math.min(h.x, joint.x), h.y, Math.max(h.x + h.width, joint.x + joint.width) - Math.min(h.x, joint.x), h.height) : rect15(h.x, Math.min(h.y, joint.y), h.width, Math.max(h.y + h.height, joint.y + joint.height) - Math.min(h.y, joint.y));
@@ -3347,10 +3447,10 @@ function clipTiles(tiles, own, chrome, lost) {
3347
3447
  }
3348
3448
 
3349
3449
  // src/targets/rail-strip.ts
3350
- import { EPS as EPS20, overlaps as overlaps5, rect as rect17, subtract as subtract4 } from "@n-uf/placement";
3450
+ import { EPS as EPS21, overlaps as overlaps5, rect as rect17, subtract as subtract4 } from "@n-uf/placement";
3351
3451
 
3352
3452
  // src/targets/virtual.ts
3353
- import { EPS as EPS19, clamp as clamp2, rect as rect16 } from "@n-uf/placement";
3453
+ import { EPS as EPS20, clamp as clamp3, rect as rect16 } from "@n-uf/placement";
3354
3454
  function ringsOf(c, side) {
3355
3455
  const seen = sideRings(c.state.edges, side);
3356
3456
  const kept = c.rest.edges.filter((e) => e.side === side).map((e) => seen.get(e.id) ?? e.ring);
@@ -3363,7 +3463,7 @@ function railOuter(c, side) {
3363
3463
  const windowEdge = side === "left" ? state.stage.x : state.stage.x + state.stage.width;
3364
3464
  if (!place) return windowEdge;
3365
3465
  const placeOuter = side === "left" ? place.x : place.x + place.width;
3366
- const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter + EPS19 : e.rect.x >= placeOuter - EPS19));
3466
+ const barOutside = Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= placeOuter + EPS20 : e.rect.x >= placeOuter - EPS20));
3367
3467
  return barOutside ? placeOuter : windowEdge;
3368
3468
  }
3369
3469
  function collapsesAt(c, result, side) {
@@ -3394,13 +3494,13 @@ function columnLines(c, side, railLands) {
3394
3494
  const { reach, place, edgePlace } = EDGE_KINDS.columnLine;
3395
3495
  const stage = c.state.stage;
3396
3496
  const dir = side === "left" ? 1 : -1;
3397
- const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS19 : e.rect.x >= x - EPS19));
3497
+ const outside2 = (x) => Object.values(now.edges).some((e) => e.side === side && e.rect.width > 0 && e.rect.height > 0 && (side === "left" ? e.rect.x + e.rect.width <= x + EPS20 : e.rect.x >= x - EPS20));
3398
3498
  const railFirst = railLands && !!c.state.rails?.[side]?.accepts.includes(c.kind) && !!now.railPlaces[side] && !(now.rails[side]?.segments.length ?? 0);
3399
3499
  const placeOf2 = (l, i) => {
3400
- const atEdge = side === "left" ? l.x <= stage.x + EPS19 : l.x >= stage.x + stage.width - EPS19;
3500
+ const atEdge = side === "left" ? l.x <= stage.x + EPS20 : l.x >= stage.x + stage.width - EPS20;
3401
3501
  if (i > 0 || outside2(l.x) || !(atEdge || railFirst)) return { line: l.x, zone: [l.x - reach, l.x + reach], owned: [l.x - place / 2, l.x + place / 2] };
3402
3502
  const windowEdge = side === "left" ? stage.x : stage.x + stage.width;
3403
- const boundary = clamp2(l.x, stage.x, stage.x + stage.width);
3503
+ const boundary = clamp3(l.x, stage.x, stage.x + stage.width);
3404
3504
  const band0 = railFirst ? railOuter(c, side) + dir * RAIL_EDGE : boundary;
3405
3505
  const line = band0 + dir * edgePlace / 2;
3406
3506
  const span2 = (a, b) => [Math.min(a, b), Math.max(a, b)];
@@ -3428,7 +3528,7 @@ function columnLines(c, side, railLands) {
3428
3528
  ownedAlong: p.owned,
3429
3529
  drawn: false,
3430
3530
  // Where the new column's edge lands: the line itself, inside the stage.
3431
- marker: () => rect16(clamp2(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
3531
+ marker: () => rect16(clamp3(l.x, stage.x, stage.x + stage.width), span.y, 0, span.height)
3432
3532
  };
3433
3533
  });
3434
3534
  }
@@ -3540,7 +3640,7 @@ function columnStrip(c, side, policy) {
3540
3640
  if (moved === c.state) return null;
3541
3641
  const result = c.settle(markUsed(moved, c.dragged));
3542
3642
  const el = result.layout.edges[edge.id];
3543
- if (!el || el.rect.width <= EPS20 || !collapsesAt(c, result, side)) return null;
3643
+ if (!el || el.rect.width <= EPS21 || !collapsesAt(c, result, side)) return null;
3544
3644
  const r = el.rect;
3545
3645
  const railWidth = result.layout.items[c.dragged].tab ? r.width : edge.cross.rail ?? 30;
3546
3646
  const [x, w] = across(side, side === "left" ? r.x : r.x + r.width, policy.railStripWidth ?? Math.max(RAIL_STRIP_MIN, railWidth));
@@ -3691,13 +3791,13 @@ function clearOfStrips(t, dragged, strips) {
3691
3791
  if (!overlaps5(r, s)) continue;
3692
3792
  dx += s.x + s.width / 2 < r.x + r.width / 2 ? s.x + s.width - r.x : s.x - (r.x + r.width);
3693
3793
  }
3694
- return dx === 0 ? first : t.after({ x: at.x + dx + (grab?.x ?? at.width / 2), y: point.y }, grab);
3794
+ return dx === 0 ? first : t.after({ x: at.x + dx + (first.grab?.x ?? at.width / 2), y: point.y }, grab);
3695
3795
  }
3696
3796
  };
3697
3797
  }
3698
3798
 
3699
3799
  // src/targets/min-hit.ts
3700
- import { EPS as EPS21, area as area5, rect as rect18, subtract as subtract5 } from "@n-uf/placement";
3800
+ import { EPS as EPS22, area as area5, rect as rect18, subtract as subtract5 } from "@n-uf/placement";
3701
3801
  function kindOf(c, t) {
3702
3802
  const p = parseTargetId(t.id);
3703
3803
  if (!p) return null;
@@ -3710,8 +3810,8 @@ function kindOf(c, t) {
3710
3810
  return null;
3711
3811
  }
3712
3812
  var largest3 = (ps) => ps.reduce((a, p) => area5(p) > area5(a) ? p : a);
3713
- var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS21 && Math.max(r.width, r.height) >= m.along - EPS21;
3714
- var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS21 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS21;
3813
+ var keepsMinHit = (r, m) => Math.min(r.width, r.height) >= m.across - EPS22 && Math.max(r.width, r.height) >= m.along - EPS22;
3814
+ var overlaps6 = (a, b) => Math.min(a.x + a.width, b.x + b.width) - Math.max(a.x, b.x) > EPS22 && Math.min(a.y + a.height, b.y + b.height) - Math.max(a.y, b.y) > EPS22;
3715
3815
  var cut = (ps, g) => ps.flatMap((p) => subtract5(p, g)).filter((p) => p.width >= 1 && p.height >= 1);
3716
3816
  var piecesOf = (t) => t.hits ?? [t.hit];
3717
3817
  var withPieces2 = (t, ps) => {
@@ -3732,9 +3832,9 @@ var union = (a, gs) => {
3732
3832
  function mayGrow(c, targets2, i, grow, minOf, zone, away) {
3733
3833
  const s = c.state.stage;
3734
3834
  for (const g of grow) {
3735
- if (g.x < s.x - EPS21 || g.y < s.y - EPS21 || g.x + g.width > s.x + s.width + EPS21 || g.y + g.height > s.y + s.height + EPS21) return false;
3835
+ if (g.x < s.x - EPS22 || g.y < s.y - EPS22 || g.x + g.width > s.x + s.width + EPS22 || g.y + g.height > s.y + s.height + EPS22) return false;
3736
3836
  if ([...keepClearFor(c.state, c.now, "targets"), ...away].some((r) => overlaps6(r, g))) return false;
3737
- if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS21)) return false;
3837
+ if (zone.reduce((ps, z) => ps.flatMap((p) => subtract5(p, z)), [g]).some((p) => area5(p) > EPS22)) return false;
3738
3838
  }
3739
3839
  return targets2.every((o, j) => {
3740
3840
  if (j === i || o.free || !piecesOf(o).some((p) => grow.some((g) => overlaps6(p, g)))) return true;
@@ -3769,7 +3869,7 @@ function partialGrowth(c, targets2, i, l, axis, d, m, minOf, zone, away) {
3769
3869
  }
3770
3870
  if (runStart !== null) runs.push([runStart, marks[marks.length - 1]]);
3771
3871
  for (const [a, b] of runs.sort((p, q) => q[1] - q[0] - (p[1] - p[0]))) {
3772
- if (b - a < m.along - EPS21) break;
3872
+ if (b - a < m.along - EPS22) break;
3773
3873
  const r = strip(a, b);
3774
3874
  if (mayGrow(c, targets2, i, [r], minOf, zone, away) && (!best || area5(r) > area5(best))) best = r;
3775
3875
  break;
@@ -3784,7 +3884,7 @@ function withMinHit(c, targets2, refusals2, zones) {
3784
3884
  const k = kindOf(c, t);
3785
3885
  return k ? EDGE_KINDS[k].minHit : null;
3786
3886
  };
3787
- const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width > EPS21 && e.rect.height > EPS21);
3887
+ const drawn = Object.entries(c.now.edges).filter(([, e]) => e.rect.width > EPS22 && e.rect.height > EPS22);
3788
3888
  for (let i = 0; i < out.length; i++) {
3789
3889
  const t = out[i];
3790
3890
  const m = minOf(t);
@@ -3801,7 +3901,7 @@ function withMinHit(c, targets2, refusals2, zones) {
3801
3901
  const axis = step === "across" ? narrowX ? "x" : "y" : narrowX ? "y" : "x";
3802
3902
  const size = axis === "x" ? l.width : l.height;
3803
3903
  const d = (step === "across" ? m.across : m.along) - size;
3804
- if (d <= EPS21) continue;
3904
+ if (d <= EPS22) continue;
3805
3905
  let grow = growths(l, axis, d).find((g) => mayGrow(c, out, i, g, minOf, zone, away));
3806
3906
  if (!grow && step === "across") grow = partialGrowth(c, out, i, l, axis, d, m, minOf, zone, away) ?? void 0;
3807
3907
  if (!grow) continue;
@@ -3903,17 +4003,17 @@ function hull(a, b) {
3903
4003
  var thicknessChanges = (now, after) => {
3904
4004
  const a = now.content;
3905
4005
  const b = after.content;
3906
- return Math.abs(b.x - a.x) > EPS22 || Math.abs(b.y - a.y) > EPS22 || Math.abs(b.x + b.width - (a.x + a.width)) > EPS22 || Math.abs(b.y + b.height - (a.y + a.height)) > EPS22;
4006
+ return Math.abs(b.x - a.x) > EPS23 || Math.abs(b.y - a.y) > EPS23 || Math.abs(b.x + b.width - (a.x + a.width)) > EPS23 || Math.abs(b.y + b.height - (a.y + a.height)) > EPS23;
3907
4007
  };
3908
4008
  var WINDOW_EDGE_KINDS = /* @__PURE__ */ new Set(["rail", "railStop", "sideBar", "columnLine"]);
3909
- var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS22 || r.x + r.width >= stage.x + stage.width - EPS22);
4009
+ var touchesSide = (stage, pieces) => pieces.some((r) => r.x <= stage.x + EPS23 || r.x + r.width >= stage.x + stage.width - EPS23);
3910
4010
  function slotOverMoved(now, lifted, after, slot, dragged, onto) {
3911
4011
  const from = now.items[dragged]?.edge;
3912
4012
  return Object.entries(now.items).some(([id, was]) => {
3913
4013
  if (!overlaps7(slot, was.rect) || id === dragged || was.floating || was.edge === onto) return false;
3914
4014
  const r = after.items[id]?.rect;
3915
4015
  const start = (from !== void 0 && was.edge === from ? lifted.items[id]?.rect : void 0) ?? was.rect;
3916
- return !!r && (Math.abs(r.x - start.x) > EPS22 || Math.abs(r.y - start.y) > EPS22 || Math.abs(r.width - start.width) > EPS22 || Math.abs(r.height - start.height) > EPS22);
4016
+ return !!r && (Math.abs(r.x - start.x) > EPS23 || Math.abs(r.y - start.y) > EPS23 || Math.abs(r.width - start.width) > EPS23 || Math.abs(r.height - start.height) > EPS23);
3917
4017
  });
3918
4018
  }
3919
4019
  function aloneRects(tiles) {
@@ -3942,7 +4042,8 @@ function generate(state, dragged, options) {
3942
4042
  ...t,
3943
4043
  after: (point, grab) => {
3944
4044
  const a = t.after(point, grab);
3945
- if (a.state === shown) return { state, layout: showsIn ? solveLanded(state, dragged, prev) : a.layout };
4045
+ const held = a.grab ? { grab: a.grab } : {};
4046
+ if (a.state === shown) return { state, layout: showsIn ? solveLanded(state, dragged, prev) : a.layout, ...held };
3946
4047
  const on = t.place.kind === "gap" ? shown.edges.find((e) => t.place.kind === "gap" && e.id === t.place.edge) : void 0;
3947
4048
  const named = !!on && namesZone(on, state.items[dragged].kind);
3948
4049
  const back = withHiddenOf(state, a.state, lent, dragged, named, rezoned);
@@ -3950,7 +4051,7 @@ function generate(state, dragged, options) {
3950
4051
  const ringOf = new Map(a.state.edges.map((e) => [e.id, e.ring]));
3951
4052
  const renumbered = restored.edges.some((e) => e.hidden !== true && ringOf.get(e.id) !== e.ring);
3952
4053
  const layout = renumbered || showsIn || rezoned.size > 0 ? solveLanded(restored, dragged, prev) : a.layout;
3953
- return { state: restored, layout };
4054
+ return { state: restored, layout, ...held };
3954
4055
  }
3955
4056
  });
3956
4057
  return { ...g, targets: g.targets.map(wrap), ...g.places ? { places: g.places.map(wrap) } : {} };
@@ -3981,10 +4082,9 @@ function generateShown(state, dragged, options, hidden) {
3981
4082
  const fo = options.floatOrient ?? was?.orient ?? floatOrientOf(item);
3982
4083
  const wasOrient = was?.orient ?? floatOrientOf(item);
3983
4084
  const size = options.floatSize ?? (was && wasOrient === fo ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));
3984
- const seenOwn = now.items[dragged];
3985
- const seenEdge = seenOwn?.edge ? state.edges.find((e) => e.id === seenOwn.edge) : void 0;
3986
- const grown = seenOwn && seenEdge && growsOnBar(state, seenEdge, dragged, seenOwn.form) && seenOwn.rect.width > 0 && seenOwn.rect.height > 0 ? seenOwn.rect : null;
3987
- const handOf = (g) => g && grown ? { x: clamp3(g.x / grown.width, 0, 1) * size.width, y: clamp3(g.y / grown.height, 0, 1) * size.height } : g;
4085
+ const grabs = grabResolver(c.lift);
4086
+ let probe = null;
4087
+ const probeForm = () => (probe ??= { laid: solve(markUsed(floatAt(state, dragged, rect19(0, 0, size.width, size.height), options.floatOrient), dragged), prev).items[dragged] }).laid;
3988
4088
  targets2.push({
3989
4089
  id: targetId({ kind: "float", item: dragged }),
3990
4090
  priority: 3,
@@ -3995,17 +4095,20 @@ function generateShown(state, dragged, options, hidden) {
3995
4095
  item: dragged,
3996
4096
  place: { kind: "float" },
3997
4097
  after(point, grab) {
3998
- const g = handOf(grab) ?? { x: size.width / 2, y: size.height / 2 };
3999
- const raw = options.floatFromHeld ? heldRect(state, dragged, size, point, g) : rect19(point.x - g.x, point.y - g.y, size.width, size.height);
4000
- const first = solve(markUsed(floatAt(state, dragged, raw, options.floatOrient), dragged), prev);
4098
+ const aimed = (g2) => {
4099
+ const raw2 = options.floatFromHeld ? heldRect(state, dragged, size, point, g2) : rect19(point.x - g2.x, point.y - g2.y, size.width, size.height);
4100
+ return { raw: raw2, first: solve(markUsed(floatAt(state, dragged, raw2, options.floatOrient), dragged), prev) };
4101
+ };
4102
+ const { result, grab: g } = aimOnce(grabs(grab), "float", { laid: probeForm(), size }, aimed, (a) => a.first.items[dragged], (l) => sizeOf(l.rect));
4103
+ const { raw, first } = result;
4001
4104
  const fitted = first.items[dragged]?.rect;
4002
4105
  const at = fitted ?? raw;
4003
4106
  const placed2 = (x, y, stays) => {
4004
4107
  const s = floatAt(state, dragged, rect19(x, y, size.width, size.height), options.floatOrient);
4005
- return c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged));
4108
+ return { ...c.settle(markUsed(stays ? { ...s, floats: s.floats.map((f) => f.id === dragged ? { ...f, stays: true } : f) } : s, dragged)), grab: g };
4006
4109
  };
4007
4110
  const hand = heldRect(state, dragged, fitted ?? size, point, g);
4008
- const on = { x: clamp3(point.x, hand.x, hand.x + hand.width), y: clamp3(point.y, hand.y, hand.y + hand.height) };
4111
+ const on = { x: clamp4(point.x, hand.x, hand.x + hand.width), y: clamp4(point.y, hand.y, hand.y + hand.height) };
4009
4112
  const clear = !first.notes.some((n) => n.code === "float-covers" && n.id === dragged);
4010
4113
  if (!fitted || clear && contains(fitted, on)) return placed2(at.x, at.y, false);
4011
4114
  const left = placed2(hand.x, hand.y, true);
@@ -4082,7 +4185,7 @@ function stopsKey(dragged, o) {
4082
4185
  prev = layoutIds.get(o.previous) ?? nextLayoutId++;
4083
4186
  layoutIds.set(o.previous, prev);
4084
4187
  }
4085
- return JSON.stringify([dragged, prev, o.endReach ?? null, o.floatOrient ?? null, o.floatSize ? [o.floatSize.width, o.floatSize.height] : null, o.fresh ?? null, o.grab ? [o.grab.x, o.grab.y] : null, o.pitch ?? null]);
4188
+ return JSON.stringify([dragged, prev, o.endReach ?? null, o.floatOrient ?? null, o.floatSize ? [o.floatSize.width, o.floatSize.height] : null, o.fresh ?? null, grabKey(o.grab), o.pitch ?? null]);
4086
4189
  }
4087
4190
  function orderedStops(state, dragged, options) {
4088
4191
  const g = generate(state, dragged, options);
@@ -4112,7 +4215,7 @@ function orderedStops(state, dragged, options) {
4112
4215
  }
4113
4216
 
4114
4217
  // src/lanes.ts
4115
- import { EPS as EPS23, area as area7, clamp as clamp4, rect as rect20, subtract as subtract6 } from "@n-uf/placement";
4218
+ import { EPS as EPS24, area as area7, clamp as clamp5, rect as rect20, subtract as subtract6 } from "@n-uf/placement";
4116
4219
  var STEP = 1;
4117
4220
  var mid2 = (r, axis) => lo(r, axis) + len(r, axis) / 2;
4118
4221
  var hull2 = (a, b) => {
@@ -4139,25 +4242,25 @@ function clipAtDrawn(band, axis, cuts) {
4139
4242
  const x = axis === "x" ? "y" : "x";
4140
4243
  const line = lo(band, x) + len(band, x) / 2;
4141
4244
  for (const c of cuts) {
4142
- if (!(lo(c, x) < line - EPS23 && line < lo(c, x) + len(c, x) - EPS23)) continue;
4245
+ if (!(lo(c, x) < line - EPS24 && line < lo(c, x) + len(c, x) - EPS24)) continue;
4143
4246
  const c0 = lo(c, axis);
4144
4247
  const c1 = c0 + len(c, axis);
4145
4248
  if ((c0 + c1) / 2 <= center) a = Math.max(a, c1);
4146
4249
  else b = Math.min(b, c0);
4147
4250
  }
4148
- return b - a > EPS23 ? along(band, axis, a, b) : band;
4251
+ return b - a > EPS24 ? along(band, axis, a, b) : band;
4149
4252
  }
4150
4253
  var memo = /* @__PURE__ */ new WeakMap();
4151
4254
  var previousIds = /* @__PURE__ */ new WeakMap();
4152
4255
  var nextPrevious = 1;
4153
4256
  function keyOf(dragged, o) {
4154
- const { previous, ...rest } = o;
4257
+ const { previous, grab, ...rest } = o;
4155
4258
  let p = 0;
4156
4259
  if (previous) {
4157
4260
  if (!previousIds.has(previous)) previousIds.set(previous, nextPrevious++);
4158
4261
  p = previousIds.get(previous);
4159
4262
  }
4160
- return `${dragged}\0${p}\0${JSON.stringify(rest)}`;
4263
+ return `${dragged}\0${p}\0${JSON.stringify(rest)}\0${JSON.stringify(grabKey(grab))}`;
4161
4264
  }
4162
4265
  function lanes(state, dragged, options = {}) {
4163
4266
  const base = baseOf(state, dragged, options);
@@ -4176,7 +4279,7 @@ function marksIn(base, state, dragged, layout, held, emptyLanes) {
4176
4279
  const on = heldEdge && !heldEdge.floating && !heldEdge.inMenu ? heldEdge.edge : void 0;
4177
4280
  const built = base.lanes.flatMap((l) => {
4178
4281
  const raws = base.raws.get(l.id);
4179
- const again = raws ? laneFrom(l.id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === on, l.id === on && held === "slide" ? MIN_BOX : void 0) : null;
4282
+ const again = raws ? laneFrom(l.id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.held, base.marking, l.id === on, l.id === on && held === "slide" ? MIN_BOX : void 0) : null;
4180
4283
  return again ? [{ lane: again, over: laneRectOver(raws, layout, base.marking).rect }] : [];
4181
4284
  });
4182
4285
  const over2 = built.map(({ lane, over: r }) => ({ ...lane, rect: r }));
@@ -4193,7 +4296,7 @@ function newColumnsGiveWay(ls, idOf, state) {
4193
4296
  }
4194
4297
  function spotsIn(base, id, layout, dragged) {
4195
4298
  const raws = base.raws.get(id);
4196
- return raws ? laneFrom(id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(id), base.share, base.marking)?.spots ?? null : null;
4299
+ return raws ? laneFrom(id, raws, layout, base.seen, dragged, base.refusals, base.halves.has(id), base.held, base.marking)?.spots ?? null : null;
4197
4300
  }
4198
4301
  function rawSpot(base, id) {
4199
4302
  for (const [lane, list] of base.raws) {
@@ -4208,6 +4311,7 @@ function build(state, dragged, options) {
4208
4311
  const own = landedLayout(state, seen, dragged, options.previous ? { previous: options.previous } : {}).items[dragged];
4209
4312
  const ownEdge = own && !own.floating && !own.inMenu ? own.edge : void 0;
4210
4313
  const pitch = options.pitch === void 0 ? SPOT_PITCH : options.pitch;
4314
+ const lift = liftOf(state, seen, dragged, own?.rect);
4211
4315
  const raws = [];
4212
4316
  const axisOfEdge = (id) => {
4213
4317
  const e = state.edges.find((x) => x.id === id);
@@ -4238,7 +4342,7 @@ function build(state, dragged, options) {
4238
4342
  }
4239
4343
  const lifted = liftedLayout(state, dragged, options);
4240
4344
  if (options.stretchPositions !== "pitched") {
4241
- const { spots, absorbed } = slidingSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH);
4345
+ const { spots, absorbed } = slidingSpots(state, dragged, options, seen, lifted, raws, pitch > 0 ? pitch : SPOT_PITCH, grabResolver(lift));
4242
4346
  for (let i = raws.length - 1; i >= 0; i--) if (absorbed.has(raws[i])) raws.splice(i, 1);
4243
4347
  raws.push(...spots);
4244
4348
  } else if (pitch > 0) raws.push(...pitchedSpots(state, dragged, options, seen, lifted, raws, pitch));
@@ -4254,15 +4358,25 @@ function build(state, dragged, options) {
4254
4358
  return it?.fixed && main?.grows ? main.natural : void 0;
4255
4359
  },
4256
4360
  gap: (edge) => nonNeg2(state.edges.find((e) => e.id === edge)?.gap),
4257
- crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS23 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
4361
+ crossing: (edge, over2) => state.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over2.edges[e.id]?.cross ?? 0) > EPS24 && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over2.edges[e.id].rect)
4258
4362
  };
4259
- const share = grabShare(own?.rect, options.grab);
4260
- const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
4363
+ const grab = grabOf(lift, options.grab, options.onGrabNote);
4364
+ const heldAt = /* @__PURE__ */ new WeakMap();
4365
+ const held = (r, end) => {
4366
+ let both = heldAt.get(r);
4367
+ if (!both) {
4368
+ const laid2 = r.layout.items[dragged];
4369
+ const at = (x) => grab(laid2 ? { ...laid2, rect: x } : void 0, sizeOf(x), "lane")[r.axis];
4370
+ heldAt.set(r, both = [at(r.slide?.first ?? r.landing), at(r.slide?.last ?? r.landing)]);
4371
+ }
4372
+ return both[end ? 1 : 0];
4373
+ };
4374
+ const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), held, marking)).filter((l) => !!l);
4261
4375
  const laneList = newColumnsGiveWay(built.map((l) => settle(l, seen, state, dragged, built, options.emptyLanes)), (l) => l.id, state).map((l) => clearOfRail(l, seen, byLane.get(l.id)));
4262
4376
  const onLanes = new Set(laneList.map((l) => l.id));
4263
- const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS23 && r.rect.height > EPS23 ? [r.rect] : []);
4377
+ const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS24 && r.rect.height > EPS24 ? [r.rect] : []);
4264
4378
  const blocked = [
4265
- ...Object.values(seen.edges).filter((e) => e.cross > EPS23).map((e) => e.rect),
4379
+ ...Object.values(seen.edges).filter((e) => e.cross > EPS24).map((e) => e.rect),
4266
4380
  ...Object.entries(seen.items).filter(([id, it]) => id !== dragged && !it.floating && !it.inMenu).map(([, it]) => it.rect),
4267
4381
  ...keepClearFor(state, seen, "targets"),
4268
4382
  ...rails,
@@ -4278,7 +4392,8 @@ function build(state, dragged, options) {
4278
4392
  seen,
4279
4393
  refusals: rs,
4280
4394
  halves,
4281
- share,
4395
+ grab,
4396
+ held,
4282
4397
  marking,
4283
4398
  regions: {
4284
4399
  refused: rs.filter((f) => !onLanes.has(f.edge)).flatMap((f) => f.hits ?? [f.hit]),
@@ -4318,12 +4433,12 @@ function drawnIn(layout, id) {
4318
4433
  function drawnRect(layout, id) {
4319
4434
  const e = layout.edges[id];
4320
4435
  if (!e) return void 0;
4321
- if (e.cross > EPS23) return e.rect;
4436
+ if (e.cross > EPS24) return e.rect;
4322
4437
  if (!e.folded) return void 0;
4323
4438
  const run = Object.values(layout.rails).flatMap((r) => r?.segments.filter((g) => g.edge === id).map((g) => g.rect) ?? []);
4324
4439
  return run.length > 0 ? run.reduce(hull2) : void 0;
4325
4440
  }
4326
- function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, showsHeld = false, besideFloor) {
4441
+ function laneFrom(id, list, drawn, seen, dragged, rs, halves, held, marking, showsHeld = false, besideFloor) {
4327
4442
  if (list.length === 0) return null;
4328
4443
  const first = list[0];
4329
4444
  const axis = first.axis;
@@ -4347,31 +4462,31 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, sh
4347
4462
  const bandStart = lo(whole, axis);
4348
4463
  const bandEnd = bandStart + len(whole, axis);
4349
4464
  const drawnItems = first.edge && halves ? new Map(onEdge(drawn, first.edge, dragged, axis).map((o) => [o.id, o.r])) : /* @__PURE__ */ new Map();
4350
- const held = halves ? 0.5 : share[axis];
4351
4465
  const cutOf = (a, b) => {
4352
4466
  const shared = a.next === b.before && a.next !== "$" ? drawnItems.get(a.next) : void 0;
4353
- return aimCut(lastOf(a), firstOf(b), axis, held, aimSlack(marking.pitch), shared);
4467
+ const [la, lb] = [lastOf(a), firstOf(b)];
4468
+ return aimCut(la, lb, axis, halves ? len(la, axis) / 2 : held(a, true), halves ? len(lb, axis) / 2 : held(b, false), aimSlack(marking.pitch), shared);
4354
4469
  };
4355
4470
  const cuts = crossFreeCuts(unique.length, (i, j) => cutOf(unique[i], unique[j]), (i) => halves || !!unique[i].home, bandStart, bandEnd);
4356
4471
  const spots = unique.flatMap((x, i) => {
4357
4472
  const a = i === 0 ? bandStart : cuts[i - 1];
4358
4473
  const b = i === unique.length - 1 ? bandEnd : cuts[i];
4359
- const along2 = [clamp4(a, start, end), clamp4(b, start, end)];
4360
- return along2[1] - along2[0] > EPS23 || b - a <= EPS23 || x.home ? [{ x, along: along2 }] : [];
4474
+ const along2 = [clamp5(a, start, end), clamp5(b, start, end)];
4475
+ return along2[1] - along2[0] > EPS24 || b - a <= EPS24 || x.home ? [{ x, along: along2 }] : [];
4361
4476
  }).map(({ x, along: along2 }) => ({
4362
4477
  id: x.id,
4363
4478
  along: along2,
4364
4479
  landing: x.landing,
4365
4480
  // A sliding spot's target holds the pointer over its stretch only (its range of landings runs past the cuts either
4366
4481
  // side, over the neighbors' stretches).
4367
- target: x.slide && along2[1] - along2[0] > EPS23 ? { ...x.target, hit: axis === "x" ? rect20(along2[0], x.target.hit.y, along2[1] - along2[0], x.target.hit.height) : rect20(x.target.hit.x, along2[0], x.target.hit.width, along2[1] - along2[0]) } : x.target,
4482
+ target: x.slide && along2[1] - along2[0] > EPS24 ? { ...x.target, hit: axis === "x" ? rect20(along2[0], x.target.hit.y, along2[1] - along2[0], x.target.hit.height) : rect20(x.target.hit.x, along2[0], x.target.hit.width, along2[1] - along2[0]) } : x.target,
4368
4483
  ...x.home ? { home: true } : {},
4369
4484
  ...x.pitched ? { pitched: true } : {},
4370
4485
  ...x.slide ? { slide: { from: x.slide.from, to: x.slide.to, snaps: x.slide.snaps, snapDistance: x.slide.snapDistance, step: x.slide.step } } : {},
4371
4486
  others: othersKey(x.layout, dragged)
4372
4487
  }));
4373
4488
  const itemLen = Math.min(...unique.map((x) => len(x.landing, axis)));
4374
- const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp4(lo(h, axis), start, end), clamp4(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS23) : [];
4489
+ const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp5(lo(h, axis), start, end), clamp5(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS24) : [];
4375
4490
  const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
4376
4491
  const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
4377
4492
  const markRect = (first.edge ? drawnRect(drawn, first.edge) : void 0) ?? laneRectOver(list, drawn, marking).band ?? markBand ?? laneRect;
@@ -4404,8 +4519,8 @@ var HATCH_EDGE = 8;
4404
4519
  function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, more) {
4405
4520
  const { besideMin } = more;
4406
4521
  const hatches = (pair, a, b, p, q, gl, gr) => {
4407
- if (gl && Math.abs(p - a) < EPS23) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });
4408
- if (gr && Math.abs(q - b) < EPS23) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });
4522
+ if (gl && Math.abs(p - a) < EPS24) out.push({ id: `${lane}/hatch/${pair}:before`, kind: "hatch", rect: along(laneRect, axis, p, p + Math.min(HATCH_END, (q - p) / 2)), givesWay: gl });
4523
+ if (gr && Math.abs(q - b) < EPS24) out.push({ id: `${lane}/hatch/${pair}:after`, kind: "hatch", rect: along(laneRect, axis, q - Math.min(HATCH_END, (q - p) / 2), q), givesWay: gr });
4409
4524
  };
4410
4525
  const heldAt = items.find((o) => o.id === held);
4411
4526
  const heldSpan = heldAt ? [lo(heldAt.r, axis), lo(heldAt.r, axis) + len(heldAt.r, axis)] : null;
@@ -4415,10 +4530,10 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
4415
4530
  const ends = [{ id: "^", a: start, b: start }, ...items.map((o) => ({ id: o.id, a: lo(o.r, axis), b: lo(o.r, axis) + len(o.r, axis) })), { id: "$", a: end, b: end }];
4416
4531
  const isRefused2 = (v) => refused.some((f) => v >= f.along[0] && v <= f.along[1]);
4417
4532
  for (let i = 0; i + 1 < ends.length; i++) {
4418
- const a = clamp4(ends[i].b, start, end);
4419
- const b = clamp4(ends[i + 1].a, start, end);
4533
+ const a = clamp5(ends[i].b, start, end);
4534
+ const b = clamp5(ends[i + 1].a, start, end);
4420
4535
  const pair = `${ends[i].id}|${ends[i + 1].id}`;
4421
- if (ends[i + 1].a < start - EPS23 || ends[i].b > end + EPS23 || !lands(pair)) continue;
4536
+ if (ends[i + 1].a < start - EPS24 || ends[i].b > end + EPS24 || !lands(pair)) continue;
4422
4537
  const left = ends[i].id === held ? ends[i - 1]?.id ?? "^" : ends[i].id;
4423
4538
  const right = ends[i + 1].id === held ? ends[i + 2]?.id ?? "$" : ends[i + 1].id;
4424
4539
  const named = `${left}|${right}`;
@@ -4427,12 +4542,12 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
4427
4542
  const spot = !beside && named === pair && items.length > 0 && !isRefused2((a + b) / 2) ? more.landingOf(pair) : void 0;
4428
4543
  const gl = spot && left !== "^" && more.givesWay(left, "before", spot.layout) ? left : null;
4429
4544
  const gr = spot && right !== "$" && more.givesWay(right, "after", spot.layout) ? right : null;
4430
- if (b - a < min - EPS23) {
4431
- if (spot && b - a >= besideMin - EPS23) {
4545
+ if (b - a < min - EPS24) {
4546
+ if (spot && b - a >= besideMin - EPS24) {
4432
4547
  let ps = [[a, b]];
4433
4548
  for (const f of refused) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]);
4434
4549
  if (heldSpan) ps = ps.flatMap(([p, q]) => [[p, Math.min(q, heldSpan[0])], [Math.max(p, heldSpan[1]), q]]);
4435
- ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS23);
4550
+ ps = ps.filter(([p, q]) => q - p >= MIN_BOX - EPS24);
4436
4551
  ps.forEach(([p, q], k2) => {
4437
4552
  out.push({ id: `${lane}/box/${pair}${k2 ? `#${k2}` : ""}`, kind: "box", rect: along(laneRect, axis, p, q) });
4438
4553
  hatches(pair, a, b, p, q, gl, gr);
@@ -4444,10 +4559,10 @@ function edgeMarks(lane, laneRect, axis, items, refused, itemLen, lands, held, m
4444
4559
  continue;
4445
4560
  }
4446
4561
  let pieces = [[a, b]];
4447
- for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p > EPS23);
4562
+ for (const f of refused) pieces = pieces.flatMap(([p, q]) => [[p, Math.min(q, f.along[0])], [Math.max(p, f.along[1]), q]]).filter(([p, q]) => q - p > EPS24);
4448
4563
  let k = 0;
4449
4564
  for (const [p, q] of pieces) {
4450
- if (q - p < min - EPS23) continue;
4565
+ if (q - p < min - EPS24) continue;
4451
4566
  const base = `${lane}/box/${named}${beside ? `:${beside}` : ""}${k++ ? `#${k - 1}` : ""}`;
4452
4567
  out.push({ id: out.some((m) => m.id === base) ? `${base}~2` : base, kind: "box", rect: along(laneRect, axis, p, q) });
4453
4568
  hatches(pair, a, b, p, q, gl, gr);
@@ -4469,9 +4584,9 @@ function inLane(l, r) {
4469
4584
  const y0 = Math.max(m.rect.y, r.y);
4470
4585
  const x1 = Math.min(m.rect.x + m.rect.width, r.x + r.width);
4471
4586
  const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
4472
- if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS23 && y1 - y0 >= m.rect.height - EPS23 ? [m] : [];
4473
- if (x1 - x0 <= EPS23 || y1 - y0 <= EPS23) return [];
4474
- return x1 - x0 >= m.rect.width - EPS23 && y1 - y0 >= m.rect.height - EPS23 ? [m] : [{ ...m, rect: rect20(x0, y0, x1 - x0, y1 - y0) }];
4587
+ if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS24 && y1 - y0 >= m.rect.height - EPS24 ? [m] : [];
4588
+ if (x1 - x0 <= EPS24 || y1 - y0 <= EPS24) return [];
4589
+ return x1 - x0 >= m.rect.width - EPS24 && y1 - y0 >= m.rect.height - EPS24 ? [m] : [{ ...m, rect: rect20(x0, y0, x1 - x0, y1 - y0) }];
4475
4590
  });
4476
4591
  return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
4477
4592
  }
@@ -4495,14 +4610,14 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
4495
4610
  const e = edge ? edgeOf(edge) : void 0;
4496
4611
  return !!e && (e.side === "top" || e.side === "bottom" || !!e.compact);
4497
4612
  };
4498
- const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS23 && it.rect.height > EPS23).map(([, it]) => it.rect) : [];
4613
+ const stays = empty ? Object.entries(drawn.items).filter(([id, it]) => id !== dragged && it.edge !== l.id && barOrRail(it.edge) && !it.floating && !it.inMenu && it.rect.width > EPS24 && it.rect.height > EPS24).map(([, it]) => it.rect) : [];
4499
4614
  if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps8(m.rect, s)))))) return l;
4500
4615
  const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
4501
4616
  const marks = [];
4502
4617
  for (const m of l.marks) {
4503
4618
  const kept = cut2(m.rect, m.kind === "box" ? [...cuts, ...stays] : cuts);
4504
4619
  if (m.kind === "line") {
4505
- if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) < EPS23) marks.push(m);
4620
+ if (kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, l.axis)) < EPS24) marks.push(m);
4506
4621
  continue;
4507
4622
  }
4508
4623
  kept.forEach(([p, q], i) => {
@@ -4528,12 +4643,12 @@ function settle(lane, drawn, state, dragged, all, emptyLanes = "real", within =
4528
4643
  }
4529
4644
  function piecesLess(r, axis, cs) {
4530
4645
  const span = (x) => [lo(x, axis), lo(x, axis) + len(x, axis)];
4531
- const crosses = (c) => axis === "x" ? c.y < r.y + r.height - EPS23 && r.y < c.y + c.height - EPS23 : c.x < r.x + r.width - EPS23 && r.x < c.x + c.width - EPS23;
4646
+ const crosses = (c) => axis === "x" ? c.y < r.y + r.height - EPS24 && r.y < c.y + c.height - EPS24 : c.x < r.x + r.width - EPS24 && r.x < c.x + c.width - EPS24;
4532
4647
  let ps = [span(r)];
4533
4648
  for (const c of cs) {
4534
4649
  if (!crosses(c)) continue;
4535
4650
  const [c0, c1] = span(c);
4536
- ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS23);
4651
+ ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS24);
4537
4652
  }
4538
4653
  return ps;
4539
4654
  }
@@ -4544,11 +4659,11 @@ function marksLess(marks, axis, cs, options = {}) {
4544
4659
  const over2 = cs.filter((c) => overlaps8(m.rect, c));
4545
4660
  if (over2.length === 0) return [m];
4546
4661
  const kept = piecesLess(m.rect, axis, over2);
4547
- if (m.kind === "line") return (options.lines === "covered" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS23) ? [m] : [];
4662
+ if (m.kind === "line") return (options.lines === "covered" ? kept.length > 0 : kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS24) ? [m] : [];
4548
4663
  return kept.filter(([p, q]) => m.kind !== "box" || q - p > minBox).map(([p, q], i) => ({ ...m, id: i ? `${m.id}${suffix}${i}` : m.id, rect: along(m.rect, axis, p, q) }));
4549
4664
  });
4550
4665
  }
4551
- var overlaps8 = (a, b) => a.x < b.x + b.width - EPS23 && b.x < a.x + a.width - EPS23 && a.y < b.y + b.height - EPS23 && b.y < a.y + a.height - EPS23;
4666
+ var overlaps8 = (a, b) => a.x < b.x + b.width - EPS24 && b.x < a.x + a.width - EPS24 && a.y < b.y + b.height - EPS24 && b.y < a.y + a.height - EPS24;
4552
4667
  function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
4553
4668
  const out = [];
4554
4669
  stretches(state, dragged, options, seen, lifted, raws, (run) => {
@@ -4573,12 +4688,12 @@ function pitchedSpots(state, dragged, options, seen, lifted, raws, pitch) {
4573
4688
  };
4574
4689
  return ({ a, b, w, zones, atOf, spaceAt, before, after }) => {
4575
4690
  const end = (x0, order, flush) => {
4576
- for (const zone of order) if (spaceAt(zone, x0) >= -EPS23 && emit3(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;
4691
+ for (const zone of order) if (spaceAt(zone, x0) >= -EPS24 && emit3(zone, atOf(zone), Math.max(0, spaceAt(zone, x0)), x0, flush)) return;
4577
4692
  };
4578
4693
  end(a, zones, before?.id ?? "^");
4579
- if (b - w > a + EPS23) end(b - w, [...zones].reverse(), after?.id ?? "$");
4694
+ if (b - w > a + EPS24) end(b - w, [...zones].reverse(), after?.id ?? "$");
4580
4695
  if (b - a < w + pitch) return;
4581
- for (let x0 = a + pitch; x0 + w <= b - pitch + EPS23; x0 += pitch) {
4696
+ for (let x0 = a + pitch; x0 + w <= b - pitch + EPS24; x0 += pitch) {
4582
4697
  const zone = x0 + w / 2 < middle ? "start" : "end";
4583
4698
  if (!zones.includes(zone)) continue;
4584
4699
  emit3(zone, atOf(zone), spaceAt(zone, x0), x0);
@@ -4641,7 +4756,7 @@ function takeoverSpots(state, dragged, options, seen, lifted, raws, pitch) {
4641
4756
  });
4642
4757
  return out;
4643
4758
  }
4644
- function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4759
+ function slidingSpots(state, dragged, options, seen, lifted, raws, sample, grabs) {
4645
4760
  const spots = [];
4646
4761
  const absorbed = /* @__PURE__ */ new Set();
4647
4762
  const snapDistance = Number.isFinite(options.snapDistance) && options.snapDistance >= 0 ? options.snapDistance : SNAP_DISTANCE;
@@ -4661,7 +4776,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4661
4776
  const firstZone = (() => {
4662
4777
  for (const zone3 of zones) {
4663
4778
  const space = spaceAt(zone3, from);
4664
- if (space < -EPS23) continue;
4779
+ if (space < -EPS24) continue;
4665
4780
  const place2 = { edge: e.id, zone: zone3, at: atOf(zone3), space: Math.max(0, space) };
4666
4781
  const hit = landsAt(run, place2, from);
4667
4782
  if (hit) return { place: place2, result: { state: hit.next, layout: hit.layout } };
@@ -4705,9 +4820,9 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4705
4820
  return best;
4706
4821
  };
4707
4822
  const startAt = (raw) => {
4708
- const c = clamp4(raw, from, to);
4823
+ const c = clamp5(raw, from, to);
4709
4824
  const s = snapped(c);
4710
- return snaps.includes(s) ? s : clamp4(Math.round(c / STEP) * STEP, from, to);
4825
+ return snaps.includes(s) ? s : clamp5(Math.round(c / STEP) * STEP, from, to);
4711
4826
  };
4712
4827
  const results = /* @__PURE__ */ new Map();
4713
4828
  const commitAt = (x0) => {
@@ -4719,7 +4834,7 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4719
4834
  results.set(k, result);
4720
4835
  return result;
4721
4836
  };
4722
- const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(clamp4(lo(own.rect, axis), from, to)) : from;
4837
+ const rest = homeRaw ? lo(homeRaw.landing, axis) : ownEdge === e.id && own ? snapped(clamp5(lo(own.rect, axis), from, to)) : from;
4723
4838
  const restResult = commitAt(rest);
4724
4839
  const ownZone = own?.zone;
4725
4840
  const restPlace = (() => {
@@ -4728,8 +4843,16 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4728
4843
  return p && p.kind === "gap" ? p : land(rest)?.place;
4729
4844
  })();
4730
4845
  const landing = homeRaw ? homeRaw.landing : restResult.layout.items[dragged]?.rect ?? at(rest);
4731
- const ownLen = own ? Math.max(own.rect.width, own.rect.height) : 0;
4732
- const long = own && own.rect.width >= own.rect.height ? "x" : "y";
4846
+ const restLaid = restResult.layout.items[dragged];
4847
+ const cross = restLaid?.rect ?? landing;
4848
+ const inStretch = axis === "x" ? { width: w, height: cross.height } : { width: cross.width, height: w };
4849
+ const aimed = /* @__PURE__ */ new Map();
4850
+ const withGrab = (r, g, x0) => {
4851
+ const k = `${Math.round(x0 * 1e3) / 1e3} ${g.x} ${g.y}`;
4852
+ let out = aimed.get(k);
4853
+ if (!out || out.state !== r.state) aimed.set(k, out = { ...r, grab: g });
4854
+ return out;
4855
+ };
4733
4856
  const target = {
4734
4857
  id: `slide:${e.id}:${bId}|${nId}`,
4735
4858
  priority: 2,
@@ -4738,9 +4861,13 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4738
4861
  item: dragged,
4739
4862
  place: { kind: "gap", edge: e.id, zone: restPlace?.zone ?? zones[0], at: restPlace?.at ?? atOf(zones[0]), ...restPlace?.space ? { space: restPlace.space } : {} },
4740
4863
  after: (point, grab) => {
4741
- const g = grab ? grab[long] : ownLen / 2;
4742
- const share = axis === long && ownLen > EPS23 && Number.isFinite(g) ? clamp4(g / ownLen, 0, 1) : 0.5;
4743
- return commitAt(startAt((axis === "x" ? point.x : point.y) - share * w));
4864
+ const p = axis === "x" ? point.x : point.y;
4865
+ const aimAt = (g2) => {
4866
+ const x0 = startAt(p - g2[axis]);
4867
+ return { x0, r: commitAt(x0) };
4868
+ };
4869
+ const { result, grab: g } = aimOnce(grabs(grab), "lane", { laid: restLaid, size: inStretch }, aimAt, (a) => a.r.layout.items[dragged], (l) => sizeOf(l.rect));
4870
+ return withGrab(result.r, g, result.x0);
4744
4871
  }
4745
4872
  };
4746
4873
  const zone = zones[0];
@@ -4766,20 +4893,20 @@ function slidingSpots(state, dragged, options, seen, lifted, raws, sample) {
4766
4893
  }
4767
4894
 
4768
4895
  // src/drag.ts
4769
- import { EPS as EPS24, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
4896
+ import { EPS as EPS25, area as area8, overlaps as overlaps9, subtract as subtract7 } from "@n-uf/placement";
4770
4897
  var MIN_PIECE = 8;
4771
4898
  function trimmedBy(marks, cs) {
4772
4899
  if (cs.length === 0) return [...marks];
4773
4900
  return marks.flatMap((m) => {
4774
4901
  const r = m.rect;
4775
- if (r.width <= EPS24 || r.height <= EPS24) {
4776
- const across2 = r.height <= EPS24;
4902
+ if (r.width <= EPS25 || r.height <= EPS25) {
4903
+ const across2 = r.height <= EPS25;
4777
4904
  const at = across2 ? r.y : r.x;
4778
4905
  let pieces2 = [across2 ? [r.x, r.x + r.width] : [r.y, r.y + r.height]];
4779
4906
  let touched = false;
4780
4907
  for (const c of cs) {
4781
4908
  const [lo2, hi] = across2 ? [c.y, c.y + c.height] : [c.x, c.x + c.width];
4782
- if (!(at > lo2 + EPS24 && at < hi - EPS24)) continue;
4909
+ if (!(at > lo2 + EPS25 && at < hi - EPS25)) continue;
4783
4910
  const [a, b] = across2 ? [c.x, c.x + c.width] : [c.y, c.y + c.height];
4784
4911
  pieces2 = pieces2.flatMap(([s2, e2]) => {
4785
4912
  if (b <= s2 || a >= e2) return [[s2, e2]];
@@ -4791,7 +4918,7 @@ function trimmedBy(marks, cs) {
4791
4918
  const kept = pieces2.filter(([s2, e2]) => e2 - s2 >= 1);
4792
4919
  if (kept.length === 0) return [];
4793
4920
  const [s, e] = kept.reduce((x, y) => y[1] - y[0] > x[1] - x[0] ? y : x);
4794
- if (Math.abs(s - (across2 ? r.x : r.y)) < EPS24 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS24) return [m];
4921
+ if (Math.abs(s - (across2 ? r.x : r.y)) < EPS25 && Math.abs(e - s - (across2 ? r.width : r.height)) < EPS25) return [m];
4795
4922
  return [{ ...m, rect: across2 ? { x: s, y: r.y, width: e - s, height: r.height } : { x: r.x, y: s, width: r.width, height: e - s } }];
4796
4923
  }
4797
4924
  const over2 = cs.filter((c) => overlaps9(m.rect, c));
@@ -4810,7 +4937,12 @@ function dockDrag(state, dragged, options = {}) {
4810
4937
  const fixed = /* @__PURE__ */ new Map();
4811
4938
  const axisOf2 = new Map(base.lanes.map((l) => [l.id, l.axis]));
4812
4939
  const flat = (ls) => ls.flatMap((l) => l.marks.map((m) => ({ ...m, lane: l.lane })));
4813
- const rest = { state, layout: base.seen, landing: null, marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };
4940
+ const grabIn = (layout, lift = false) => {
4941
+ const laid2 = layout.items[dragged];
4942
+ if (laid2) return base.grab(laid2, sizeOf(laid2.rect), lift ? "lift" : laid2.floating ? "float" : "lane");
4943
+ return grab && typeof grab !== "function" ? { x: grab.x, y: grab.y } : ORIGIN2;
4944
+ };
4945
+ const rest = { state, layout: base.seen, landing: null, grab: grabIn(base.seen, true), marks: flat(base.lanes.map((l) => ({ lane: l.id, axis: l.axis, marks: l.marks }))) };
4814
4946
  let lastFloat = null;
4815
4947
  const of = (result, spot) => {
4816
4948
  const known = byResult.get(result);
@@ -4818,7 +4950,7 @@ function dockDrag(state, dragged, options = {}) {
4818
4950
  const it = result.layout.items[dragged];
4819
4951
  const landing = it && !it.inMenu && (spot ? !it.floating : it.floating) ? it.rect : null;
4820
4952
  const spots = spot ? spotsIn(base, spot.lane, result.layout, dragged) : null;
4821
- const out = { ...result, landing, marks: flat(marksIn(base, state, dragged, result.layout, spot ? spot.slide ? "slide" : "spot" : false, options.emptyLanes)), ...spots ? { spots } : {} };
4953
+ const out = { ...result, landing, grab: result.grab ?? grabIn(result.layout), marks: flat(marksIn(base, state, dragged, result.layout, spot ? spot.slide ? "slide" : "spot" : false, options.emptyLanes)), ...spots ? { spots } : {} };
4822
4954
  byResult.set(result, out);
4823
4955
  return out;
4824
4956
  };
@@ -4856,7 +4988,7 @@ function dockDrag(state, dragged, options = {}) {
4856
4988
  const screenOf = (frame) => {
4857
4989
  const held = after(frame.held);
4858
4990
  if (frame.room || held === rest) return held;
4859
- return held.landing ? { ...rest, landing: held.landing } : rest;
4991
+ return held.landing ? { ...rest, landing: held.landing, grab: held.grab } : rest;
4860
4992
  };
4861
4993
  const shownLayout = (frame) => screenOf(frame).layout;
4862
4994
  const guides = (frame) => {
@@ -4885,7 +5017,7 @@ function dockDrag(state, dragged, options = {}) {
4885
5017
  shown.push(near);
4886
5018
  }
4887
5019
  const drawnStays = [
4888
- ...state.edges.filter((e) => (e.side === "top" || e.side === "bottom" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) > EPS24).map((e) => screen.layout.edges[e.id].rect),
5020
+ ...state.edges.filter((e) => (e.side === "top" || e.side === "bottom" || !!e.compact) && (screen.layout.edges[e.id]?.cross ?? 0) > EPS25).map((e) => screen.layout.edges[e.id].rect),
4889
5021
  ...Object.values(screen.layout.rails).flatMap((r) => r?.segments.filter((g) => g.id !== dragged).map((g) => g.rect) ?? [])
4890
5022
  ];
4891
5023
  const onScreen = [...shown.filter((s) => !s.created && s !== near).flatMap((s) => s.marks.map((m) => m.rect)), ...drawnStays, ...screen.landing ? [screen.landing] : []];
@@ -4972,4 +5104,4 @@ export {
4972
5104
  HATCH_EDGE,
4973
5105
  dockDrag
4974
5106
  };
4975
- //# sourceMappingURL=chunk-Y3RK6BQT.js.map
5107
+ //# sourceMappingURL=chunk-Y2IM76RG.js.map