@n-uf/placement 26.11.51 → 26.11.52

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.
@@ -198,15 +198,32 @@ var floatOrientOf = (item) => {
198
198
  for (const k of Object.keys(item.forms)) if ((k === "row" || k === "column") && formsOf(item, k).length > 0) return k;
199
199
  return "column";
200
200
  };
201
- function floatSizeOf(item, orient2 = floatOrientOf(item)) {
202
- if (item.floatSize) return item.floatSize;
201
+ var sized = (s) => !!s && Number.isFinite(s.width) && Number.isFinite(s.height) && s.width > 0 && s.height > 0;
202
+ var declaresFloatSizes = (item) => item.floatSizes !== void 0 && item.floatSizes !== null;
203
+ function naturalFloatSize(item, orient2) {
203
204
  const f = formsOf(item, orient2)[0];
204
- if (!f || f.main.grows) return DEFAULT_FLOAT_SIZE;
205
+ if (!f || f.main.grows) return void 0;
205
206
  const main = Number.isFinite(f.main.natural) ? Math.max(0, f.main.natural) : 0;
206
207
  const cross = Number.isFinite(f.cross.natural) ? Math.max(0, f.cross.natural) : 0;
207
- if (main <= 0 || cross <= 0) return DEFAULT_FLOAT_SIZE;
208
+ if (main <= 0 || cross <= 0) return void 0;
208
209
  return orient2 === "row" ? { width: main, height: cross } : { width: cross, height: main };
209
210
  }
211
+ function floatSizesOf(item, floatOrient = floatOrientOf(item)) {
212
+ const out = {};
213
+ if (sized(item.floatSize)) out[floatOrient] = item.floatSize;
214
+ for (const o of ["row", "column"]) {
215
+ const s = item.floatSizes?.[o];
216
+ if (sized(s)) out[o] = s;
217
+ }
218
+ return out.row || out.column ? out : void 0;
219
+ }
220
+ function floatSizeOf(item, orient2 = floatOrientOf(item), floatOrient = floatOrientOf(item)) {
221
+ if (!declaresFloatSizes(item)) return sized(item.floatSize) ? item.floatSize : naturalFloatSize(item, orient2) ?? DEFAULT_FLOAT_SIZE;
222
+ const own = item.floatSizes?.[orient2];
223
+ if (sized(own)) return own;
224
+ if (sized(item.floatSize) && orient2 === floatOrient) return item.floatSize;
225
+ return naturalFloatSize(item, orient2) ?? DEFAULT_FLOAT_SIZE;
226
+ }
210
227
  function foldedByOf(item, forms, form, start, edge) {
211
228
  if (item.closed || form < 1) return void 0;
212
229
  if (startOf(item, forms, edge) > 0) return "hand";
@@ -261,7 +278,7 @@ function floatShape(item, f) {
261
278
  const fm = forms[form];
262
279
  if (orient2 === "column" && forms.slice(0, form + 1).some(isWrap)) return { form, width: px2(fm.cross.natural), height: px2(fm.main.natural) };
263
280
  if (form > 0) return orient2 === "column" ? { form, width: w, height: px2(fm.main.natural) } : { form, width: px2(fm.main.natural), height: h };
264
- return { form, width: w, height: h };
281
+ return { form, ...fm.main.grows || !declaresFloatSizes(item) ? { width: w, height: h } : floatSizeOf(item, orient2, f.orient ?? floatOrientOf(item)) };
265
282
  }
266
283
 
267
284
  // src/scene/targets/ids.ts
@@ -559,6 +576,7 @@ function emit(d, edge, r, solved, extra = {}) {
559
576
  hidden: inMenu ? [] : f?.hides ?? [],
560
577
  rect: drawnRect,
561
578
  kind: it.kind,
579
+ axis: column ? "column" : "row",
562
580
  form: p.form,
563
581
  formKind: p.kind,
564
582
  edge: edge.id,
@@ -715,9 +733,9 @@ function solveEdge(scene, edge, ids, length, room, previous) {
715
733
  const lo2 = Math.max(px(edge.cross.min), ...setters.map((p) => formCrossMin(formsById(p.id)[p.form])));
716
734
  const s = Math.min(Math.max(size, lo2), Math.max(lo2, maxOf), room);
717
735
  if (Math.abs(s - free.cross) > EPS) {
718
- const sized = { ...input, cross: { ...cross, min: s, max: s } };
719
- const stack = fitStack(sized, previous ? { previous: previous.stack } : {});
720
- return { stack, free, tabs: [], closedTabs: none, input: sized, starts };
736
+ const sized2 = { ...input, cross: { ...cross, min: s, max: s } };
737
+ const stack = fitStack(sized2, previous ? { previous: previous.stack } : {});
738
+ return { stack, free, tabs: [], closedTabs: none, input: sized2, starts };
721
739
  }
722
740
  }
723
741
  return { stack: free, free, tabs: [], closedTabs: none, input, starts };
@@ -850,7 +868,7 @@ function layFloats(d, stage, content, inset) {
850
868
  if (fit.snapped) notes.push({ code: "float-moved", id: f.id });
851
869
  if (fit.covers.length > 0) notes.push({ code: "float-covers", id: f.id });
852
870
  const foldedBy = foldedByOf(it, formsOf(it, fo), from);
853
- items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), hidden: form?.hides ?? [], rect: fit.rect, kind: it.kind, form: from, formKind: form?.kind ?? "open", floating: true, ...foldedBy ? { foldedBy } : {} };
871
+ items[f.id] = { ...shapeOf(form, fit.rect, fo, fit.rect.width), hidden: form?.hides ?? [], rect: fit.rect, kind: it.kind, axis: fo, form: from, formKind: form?.kind ?? "open", floating: true, ...foldedBy ? { foldedBy } : {} };
854
872
  floats.push(f.id);
855
873
  }
856
874
  return floats;
@@ -1049,7 +1067,7 @@ function layRiders(d, host, riders, top) {
1049
1067
  for (const b of bars) {
1050
1068
  const at = rect(hr.x, y, hr.width, b.h);
1051
1069
  const it = scene.items[b.id];
1052
- items[b.id] = { rect: at, hidden: b.f?.hides ?? [], kind: it.kind, form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand", foldedBy: "hand" };
1070
+ items[b.id] = { rect: at, hidden: b.f?.hides ?? [], kind: it.kind, axis: "column", form: b.form, formKind: b.f?.kind ?? "header", edge: c.edge.id, zone: zoneOf(it), rides: host.edge.id, folded: "hand", foldedBy: "hand" };
1053
1071
  y += b.h;
1054
1072
  }
1055
1073
  edges[c.edge.id] = { side: c.edge.side, ring: finite(c.edge.ring, 0), rect: rect(hr.x, y0, hr.width, y - y0), cross: 0, menu: null, items: bars.map((b) => b.id), tabs: [], stack: c.solved.stack, free: c.solved.free, rides: host.edge.id, folded: "hand" };
@@ -1094,7 +1112,7 @@ function layRail(d, side, railRect, railed, g) {
1094
1112
  const form = p ? p.form : ri >= 0 ? ri : forms.length === 0 ? 0 : startOf(it, forms);
1095
1113
  const at = p ? rect(railRect.x, railRect.y + p.rect.y, railRect.width, p.rect.height) : rect(railRect.x, y, railRect.width, ri >= 0 ? px(forms[ri].main.natural) : railRect.width);
1096
1114
  const title = forms[form]?.title === true;
1097
- items[id] = { rect: at, hidden: forms[form]?.hides ?? [], kind: it.kind, form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: startOf(it, forms) > 0 ? "hand" : "auto" };
1115
+ items[id] = { rect: at, hidden: forms[form]?.hides ?? [], kind: it.kind, axis: "column", form, formKind: "rail", edge: c.edge.id, zone: zoneOf(it), rail: side, ...title ? { railTitle: side } : {}, folded: g.auto.has(c) ? "auto" : "hand", foldedBy: startOf(it, forms) > 0 ? "hand" : "auto" };
1098
1116
  segments.push({ id, edge: c.edge.id, rect: at });
1099
1117
  y += at.height;
1100
1118
  }
@@ -1511,15 +1529,22 @@ function floatAt(scene, id, at, orient2) {
1511
1529
  if (!item || item.fixed || !scene.floatKinds.includes(item.kind)) return scene;
1512
1530
  const was = scene.floats.find((f) => f.id === id);
1513
1531
  const o = orient2 ?? was?.orient;
1514
- const size = floatSizeOf(item, o ?? floatOrientOf(item));
1532
+ const fo = o ?? floatOrientOf(item);
1533
+ const size = floatSizeOf(item, fo, was?.orient ?? floatOrientOf(item));
1515
1534
  const since = was ? was.since : nextSince(scene);
1516
1535
  const seq = since !== void 0 ? { since } : {};
1517
1536
  const float = at ? { id, rect: { x: at.x, y: at.y, width: at.width, height: at.height }, ...o ? { orient: o } : {}, ...seq } : { id, rect: { x: 0, y: 0, width: size.width, height: size.height }, anchor: "content-top-right", ...o ? { orient: o } : {}, ...seq };
1518
1537
  const { space: _space, ...unspaced } = item;
1519
- const next = at && at.width > 0 && at.height > 0 ? { ...unspaced, floatSize: { width: at.width, height: at.height } } : unspaced;
1538
+ const set = at && at.width > 0 && at.height > 0 ? { orient: fo, size: { width: at.width, height: at.height } } : void 0;
1539
+ const next = set || declaresFloatSizes(item) ? withFloatSizes(unspaced, was?.orient ?? floatOrientOf(item), set) : unspaced;
1520
1540
  const lifted = withItem(lift(scene, id), next);
1521
1541
  return { ...lifted, floats: [...lifted.floats, float] };
1522
1542
  }
1543
+ function withFloatSizes(item, floatOrient, set) {
1544
+ const { floatSize: _legacy, floatSizes: _sizes, ...rest } = item;
1545
+ const sizes = { ...floatSizesOf(item, floatOrient), ...set ? { [set.orient]: set.size } : {} };
1546
+ return sizes.row || sizes.column ? { ...rest, floatSizes: sizes } : rest;
1547
+ }
1523
1548
  function canFold(scene, id) {
1524
1549
  const item = itemOf(scene, id);
1525
1550
  if (!item || item.fixed && !scene.edges.some((e) => e.foldable === true && e.items.includes(id))) return false;
@@ -1566,10 +1591,18 @@ function raise(scene, id) {
1566
1591
  return { ...scene, floats: [...scene.floats.slice(0, i), ...scene.floats.slice(i + 1), scene.floats[i]] };
1567
1592
  }
1568
1593
  function orient(scene, id, to) {
1569
- const i = scene.floats.findIndex((f) => f.id === id);
1594
+ const i = scene.floats.findIndex((f2) => f2.id === id);
1570
1595
  const item = scene.items[id];
1571
- if (i < 0 || !item || (scene.floats[i].orient ?? floatOrientOf(item)) === to) return scene;
1572
- return { ...scene, floats: scene.floats.map((f, k) => k === i ? { ...f, orient: to } : f) };
1596
+ const f = scene.floats[i];
1597
+ if (!f || !item) return scene;
1598
+ const from = f.orient ?? floatOrientOf(item);
1599
+ if (from === to) return scene;
1600
+ if (!declaresFloatSizes(item)) return { ...scene, floats: scene.floats.map((g, k) => k === i ? { ...g, orient: to } : g) };
1601
+ const grows = formsOf(item, from)[0]?.main.grows === true;
1602
+ const kept = withFloatSizes(item, from, grows && f.rect.width > 0 && f.rect.height > 0 ? { orient: from, size: { width: f.rect.width, height: f.rect.height } } : void 0);
1603
+ const size = drawnFloatSize(kept, { rect: { ...f.rect, ...floatSizeOf(kept, to, from) }, orient: to });
1604
+ const turned = { ...f, rect: { x: f.rect.x, y: f.rect.y, width: size.width, height: size.height }, orient: to };
1605
+ return withItem({ ...scene, floats: scene.floats.map((g, k) => k === i ? turned : g) }, kept);
1573
1606
  }
1574
1607
  function resize(scene, id, size, moving = { right: true, bottom: true }) {
1575
1608
  if (typeof size === "number") return resizeEdge(scene, id, size);
@@ -1579,7 +1612,8 @@ function resize(scene, id, size, moving = { right: true, bottom: true }) {
1579
1612
  if (!fit || i < 0 || !item) return scene;
1580
1613
  const { anchor: _a, ...plain } = scene.floats[i];
1581
1614
  const float = { ...plain, rect: fit.rect };
1582
- return withItem({ ...scene, floats: scene.floats.map((g, k) => k === i ? float : g) }, { ...item, floatSize: { width: fit.rect.width, height: fit.rect.height } });
1615
+ const fo = float.orient ?? floatOrientOf(item);
1616
+ return withItem({ ...scene, floats: scene.floats.map((g, k) => k === i ? float : g) }, withFloatSizes(item, fo, { orient: fo, size: { width: fit.rect.width, height: fit.rect.height } }));
1583
1617
  }
1584
1618
  function resizeEdge(scene, edgeId, size) {
1585
1619
  const edge = scene.edges.find((e) => e.id === edgeId);
@@ -1681,10 +1715,19 @@ function railModesOf(v, drop) {
1681
1715
  }
1682
1716
  return Object.keys(out).length > 0 ? out : null;
1683
1717
  }
1718
+ function floatSizesStored(it) {
1719
+ const out = {};
1720
+ for (const o of ["row", "column"]) {
1721
+ const s = it.floatSizes?.[o];
1722
+ if (s && isSize(s.width) && isSize(s.height)) out[o] = { width: s.width, height: s.height };
1723
+ }
1724
+ return out.row || out.column ? out : void 0;
1725
+ }
1684
1726
  function storeScene(scene) {
1685
1727
  const items = record();
1686
1728
  for (const [id, it] of Object.entries(scene.items)) {
1687
1729
  if (id === "__proto__") continue;
1730
+ const sizes = floatSizesStored(it);
1688
1731
  items[id] = {
1689
1732
  used: isNum(it.used) ? it.used : 0,
1690
1733
  ...it.kept ? { kept: true } : {},
@@ -1692,7 +1735,8 @@ function storeScene(scene) {
1692
1735
  ...it.closed ? { closed: true } : {},
1693
1736
  ...it.align === "center" || it.align === "end" ? { align: it.align } : {},
1694
1737
  ...isNum(it.space) && it.space > 0 ? { space: it.space } : {},
1695
- ...it.floatSize && isSize(it.floatSize.width) && isSize(it.floatSize.height) ? { floatSize: { width: it.floatSize.width, height: it.floatSize.height } } : {}
1738
+ ...it.floatSize && isSize(it.floatSize.width) && isSize(it.floatSize.height) ? { floatSize: { width: it.floatSize.width, height: it.floatSize.height } } : {},
1739
+ ...sizes ? { floatSizes: sizes } : {}
1696
1740
  };
1697
1741
  }
1698
1742
  const modes = railModesOf(scene.railModes);
@@ -1739,6 +1783,7 @@ function read(data, base) {
1739
1783
  const known = (id) => typeof id === "string" && id !== "__proto__" && Object.hasOwn(base.items, id);
1740
1784
  const isFixed = (id) => known(id) && base.items[id].fixed === true;
1741
1785
  const items = { ...base.items };
1786
+ const legacy = /* @__PURE__ */ new Set();
1742
1787
  if (data.items !== void 0 && !isObject(data.items)) drop("items");
1743
1788
  else if (isObject(data.items)) {
1744
1789
  for (const id of Object.keys(data.items)) {
@@ -1748,9 +1793,9 @@ function read(data, base) {
1748
1793
  continue;
1749
1794
  }
1750
1795
  const b = base.items[id];
1751
- const { kept: _k, from: _f, closed: _c, align: _a, space: _sp, floatSize: _s, ...plain } = b;
1796
+ const { kept: _k, from: _f, closed: _c, align: _a, space: _sp, floatSize: _s, floatSizes: _ss, ...plain } = b;
1752
1797
  let it = { ...plain, used: b.used };
1753
- for (const k of Object.keys(s)) if (!["used", "kept", "from", "closed", "align", "space", "floatSize"].includes(k)) drop(`item:${id}:${k}`);
1798
+ for (const k of Object.keys(s)) if (!["used", "kept", "from", "closed", "align", "space", "floatSize", "floatSizes"].includes(k)) drop(`item:${id}:${k}`);
1754
1799
  if (isNum(s.used)) it = { ...it, used: s.used };
1755
1800
  else if (s.used !== void 0) drop(`item:${id}:used`);
1756
1801
  if (s.kept === true) it = { ...it, kept: true };
@@ -1767,8 +1812,20 @@ function read(data, base) {
1767
1812
  if (isNum(s.space) && s.space > 0 && !b.fixed) it = { ...it, space: s.space };
1768
1813
  else if (s.space !== void 0) drop(`item:${id}:space`);
1769
1814
  const fs = s.floatSize;
1770
- if (isObject(fs) && isSize(fs.width) && isSize(fs.height)) it = { ...it, floatSize: { width: fs.width, height: fs.height } };
1771
- else if (fs !== void 0) drop(`item:${id}:floatSize`);
1815
+ if (isObject(fs) && isSize(fs.width) && isSize(fs.height)) {
1816
+ it = { ...it, floatSize: { width: fs.width, height: fs.height } };
1817
+ legacy.add(id);
1818
+ } else if (fs !== void 0) drop(`item:${id}:floatSize`);
1819
+ const sizes2 = s.floatSizes;
1820
+ if (isObject(sizes2)) {
1821
+ const own = {};
1822
+ for (const k of Object.keys(sizes2)) {
1823
+ const v = sizes2[k];
1824
+ if ((k === "row" || k === "column") && isObject(v) && isSize(v.width) && isSize(v.height)) own[k] = { width: v.width, height: v.height };
1825
+ else drop(`item:${id}:floatSizes:${k}`);
1826
+ }
1827
+ if (own.row || own.column) it = { ...it, floatSizes: own };
1828
+ } else if (sizes2 !== void 0) drop(`item:${id}:floatSizes`);
1772
1829
  items[id] = it;
1773
1830
  }
1774
1831
  }
@@ -1869,6 +1926,7 @@ function read(data, base) {
1869
1926
  return { ...plain, ring: rings.get(edge.id) ?? edge.ring, items: items1, ...size !== void 0 ? { size } : {} };
1870
1927
  });
1871
1928
  for (const f of base.floats) if (!placed.has(f.id)) floats.push(f);
1929
+ for (const id of Object.keys(items)) if ((legacy.has(id) || items[id].floatSize !== void 0) && declaresFloatSizes(items[id])) items[id] = withFloatSizes(items[id], floats.find((f) => f.id === id)?.orient ?? floatOrientOf(items[id]));
1872
1930
  let scene = prune({ ...base, ...railModes ? { railModes } : {}, items, edges: closeRings(edges, new Set(made.length > 0 || rings.size > 0 ? ["left", "right"] : [])), floats });
1873
1931
  for (const [id, side] of moves) scene = setSide(scene, id, side);
1874
1932
  return { scene, dropped };
@@ -2057,10 +2115,12 @@ function edgeSlots(c, edge, accepts) {
2057
2115
  const fromAnchor = (zone === "start" ? members : zone === "end" ? [...members].reverse() : []).filter((id) => fixedHere(id) || shown(id));
2058
2116
  const firstMovable = fromAnchor.findIndex((id) => !fixedHere(id));
2059
2117
  const anchored2 = new Set(firstMovable < 0 ? fromAnchor : fromAnchor.slice(0, firstMovable));
2060
- const isProtected = (id) => fixedHere(id) && (zone === "center" || zoneOf(rest.items[id]) !== zone || anchored2.has(id));
2118
+ const pushable = (id) => fixedHere(id) && scene.items[id]?.pushable === true;
2119
+ const isProtected = (id) => fixedHere(id) && (zone === "center" || zoneOf(rest.items[id]) !== zone || anchored2.has(id) && !pushable(id));
2061
2120
  for (let k = 0; k <= members.length; k++) {
2062
2121
  const next = members.slice(k).find(shown);
2063
2122
  const before = members.slice(0, k).reverse().find(shown);
2123
+ if (before && next && pushable(before) && pushable(next)) continue;
2064
2124
  const line = next ? at(occupied(next)) : before ? at(occupied(before)) + len2(occupied(before)) : anchorLine[zone];
2065
2125
  const s = { ...slotAt(c, zone, line, slotId(zone, k), { kind: "gap", edge: edge.id, zone, at: k }, lands), order: before0 + members.slice(0, k).filter(aimed).length };
2066
2126
  const movesFixed = members0.some((id) => {
@@ -2074,6 +2134,11 @@ function edgeSlots(c, edge, accepts) {
2074
2134
  }
2075
2135
  return slots;
2076
2136
  }
2137
+ function thickerThan(forms, cross) {
2138
+ const shown = forms.filter((f) => f.kind !== "menu");
2139
+ return shown.length > 0 && shown.every((f) => !formSetsCross(f) && formCrossMin(f) > cross + EPS);
2140
+ }
2141
+ var roomReason = (spec, zone) => spec.refuse(zone) === "too-thick" ? "too-thick" : "no-room";
2077
2142
  function edgeSpec(c, edge) {
2078
2143
  const { scene, rest, now, dragged, kind } = c;
2079
2144
  const el = now.edges[edge.id];
@@ -2115,6 +2180,7 @@ function edgeSpec(c, edge) {
2115
2180
  return column ? rect(e.rect.x, slot.y, e.cross, 0) : rect(slot.x, e.rect.y, 0, e.cross);
2116
2181
  };
2117
2182
  const takes = (zone) => accepts && zoneTakes(edge, zone, kind);
2183
+ const tooThick = thickerThan(formsOf(scene.items[dragged], axisOf(edge.side)), el.stack.cross);
2118
2184
  return {
2119
2185
  id: edge.id,
2120
2186
  edge,
@@ -2123,7 +2189,7 @@ function edgeSpec(c, edge) {
2123
2189
  vertical: column,
2124
2190
  zones,
2125
2191
  slots,
2126
- refuse: (zone) => takes(zone) ? "no-room" : accepts || area(el.rect) > EPS ? "not-accepted" : null,
2192
+ refuse: (zone) => takes(zone) ? tooThick ? "too-thick" : "no-room" : accepts || area(el.rect) > EPS ? "not-accepted" : null,
2127
2193
  own: ownHere,
2128
2194
  holds: !!ownNow && ownNow.edge === edge.id && !ownNow.floating,
2129
2195
  reserved,
@@ -2456,7 +2522,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2456
2522
  for (const [pa, pb] of pieces) {
2457
2523
  const { inPiece, at } = linesIn(spec, z, mine, pieces, [pa, pb], own);
2458
2524
  if (inPiece.length === 0) {
2459
- const lone = reason === "no-room" && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);
2525
+ const lone = (reason === "no-room" || reason === "too-thick") && mine.length === 0 && slots.some((s) => s.zone === z.zone && s.home);
2460
2526
  const near = mine.length === 0 || data.virtual || mine.some((s) => pb > s.line - data.reach + EPS && pa < s.line + data.reach - EPS);
2461
2527
  const joins = data.virtual ? mine.filter((s) => s.ok && !s.home) : [];
2462
2528
  if (joins.length > 0) {
@@ -2497,7 +2563,7 @@ function tileEdge(c, spec, { cuts, bodies }, lost) {
2497
2563
  for (const [u, w] of less([[a, b]], faced)) {
2498
2564
  const line = Math.min(Math.max(p, u), w);
2499
2565
  const hit = band(u, w, s.result.layout);
2500
- if (!s.ok) out.push(...refused(z.zone, hit, "no-room"));
2566
+ if (!s.ok) out.push(...refused(z.zone, hit, roomReason(spec, z.zone)));
2501
2567
  else out.push(...split(tile(z.zone, hit, { kind: "slot", id: s.id, order: data.layer, priority: data.priority, keep: keepAt(line, hit), place: s.place, result: s.result, marker: spec.marker(s), slot: s.result.layout.items[c.dragged].rect })));
2502
2568
  }
2503
2569
  });
@@ -2596,7 +2662,7 @@ function clipTiles(tiles, own, chrome, lost) {
2596
2662
  return;
2597
2663
  }
2598
2664
  const solidPieces = pieces.filter((p) => p.width >= 1 && p.height >= 1);
2599
- for (const p of pieces) if (!solidPieces.includes(p)) (data.virtual ? later : refused).push({ ...t, kind: "refuse", reason: "no-room", hit: p, keep: null });
2665
+ for (const p of pieces) if (!solidPieces.includes(p)) (data.virtual ? later : refused).push({ ...t, kind: "refuse", reason: t.spec ? roomReason(t.spec, t.zone) : "no-room", hit: p, keep: null });
2600
2666
  if (solidPieces.length === 0) return;
2601
2667
  landed.set(t, [placed.length]);
2602
2668
  placed.push(withPieces(t, solidPieces));
@@ -2665,6 +2731,8 @@ function columnLines(c, side, railLands) {
2665
2731
  const span2 = (a, b) => [Math.min(a, b), Math.max(a, b)];
2666
2732
  return { line, zone: span2(railFirst ? band0 : windowEdge, line + dir * reach), owned: span2(band0, band0 + dir * edgePlace) };
2667
2733
  };
2734
+ const most = scene.columns?.[side]?.cross.max;
2735
+ const tooThick = most !== void 0 && thickerThan(formsOf(scene.items[dragged], "column"), most);
2668
2736
  return lines.map((l, i) => {
2669
2737
  const p = placeOf(l, i);
2670
2738
  return {
@@ -2675,7 +2743,7 @@ function columnLines(c, side, railLands) {
2675
2743
  vertical: false,
2676
2744
  zones: [{ zone: "start", a: Math.max(p.zone[0], stage.x), b: Math.min(p.zone[1], stage.x + stage.width) }],
2677
2745
  slots: [slotAt(c, "start", p.line, targetId({ kind: "column", side, ring: l.ring }), { kind: "column", side, ring: l.ring }, lands)],
2678
- refuse: () => "no-room",
2746
+ refuse: () => tooThick ? "too-thick" : "no-room",
2679
2747
  own: null,
2680
2748
  holds: false,
2681
2749
  reserved: [],
@@ -2745,6 +2813,8 @@ function railStops(c, side) {
2745
2813
  const arriving = scene.foldedColumnDrop === "end" && !ownRail;
2746
2814
  const end = arriving && shown ? railEnd(c, side, rail.segments, at.y + at.height) : null;
2747
2815
  if (arriving && (shown ? !end : !isHandFolded(scene, dragged))) return null;
2816
+ const width = scene.rails?.[side]?.width;
2817
+ const tooThick = width !== void 0 && thickerThan(formsOf(scene.items[dragged], "column"), width);
2748
2818
  return {
2749
2819
  id: virtualEdgeId("rail", side),
2750
2820
  edge: null,
@@ -2754,7 +2824,7 @@ function railStops(c, side) {
2754
2824
  vertical: true,
2755
2825
  zones: [{ zone: "start", a: at.y, b: at.y + at.height }],
2756
2826
  slots: end ? [end] : stops2.map((s) => slotAt(c, "start", s.y, targetId({ kind: "rail", side, ring: s.ring }), { kind: "rail", side, ring: s.ring }, lands, ownRail)),
2757
- refuse: () => "no-room",
2827
+ refuse: () => tooThick ? "too-thick" : "no-room",
2758
2828
  own: null,
2759
2829
  holds: false,
2760
2830
  reserved: [],
@@ -3202,7 +3272,8 @@ function generateShown(scene, dragged, options, hidden) {
3202
3272
  if (scene.floatKinds.includes(item.kind)) {
3203
3273
  const was = scene.floats.find((f) => f.id === dragged);
3204
3274
  const fo = options.floatOrient ?? was?.orient ?? floatOrientOf(item);
3205
- const size = options.floatSize ?? (was ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo));
3275
+ const wasOrient = was?.orient ?? floatOrientOf(item);
3276
+ const size = options.floatSize ?? (was && wasOrient === fo ? { width: was.rect.width, height: was.rect.height } : floatSizeOf(item, fo, wasOrient));
3206
3277
  targets2.push({
3207
3278
  id: targetId({ kind: "float", item: dragged }),
3208
3279
  priority: 3,
@@ -3344,6 +3415,21 @@ function othersKey(layout, dragged) {
3344
3415
  return it.inMenu ? `${id}:m` : `${id}:${Math.round(it.rect.x)},${Math.round(it.rect.y)},${Math.round(it.rect.width)},${Math.round(it.rect.height)}`;
3345
3416
  }).join(";");
3346
3417
  }
3418
+ function clipAtDrawn(band, axis, cuts) {
3419
+ let a = lo(band, axis);
3420
+ let b = a + len(band, axis);
3421
+ const center = (a + b) / 2;
3422
+ const x = axis === "x" ? "y" : "x";
3423
+ const line = lo(band, x) + len(band, x) / 2;
3424
+ for (const c of cuts) {
3425
+ if (!(lo(c, x) < line - EPS && line < lo(c, x) + len(c, x) - EPS)) continue;
3426
+ const c0 = lo(c, axis);
3427
+ const c1 = c0 + len(c, axis);
3428
+ if ((c0 + c1) / 2 <= center) a = Math.max(a, c1);
3429
+ else b = Math.min(b, c0);
3430
+ }
3431
+ return b - a > EPS ? along(band, axis, a, b) : band;
3432
+ }
3347
3433
  var memo = /* @__PURE__ */ new WeakMap();
3348
3434
  var previousIds = /* @__PURE__ */ new WeakMap();
3349
3435
  var nextPrevious = 1;
@@ -3369,12 +3455,20 @@ function lanes(scene, dragged, options = {}) {
3369
3455
  const held = list.find((r) => r.id === options.spot);
3370
3456
  const rebuilt = base.lanes.map((l) => {
3371
3457
  const raws = base.raws.get(l.id);
3372
- if (!raws) return l;
3373
- const again = laneFrom(l.id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, l.id === heldLane && !held.slide, true);
3374
- if (!again) return l;
3375
- return l.id === heldLane ? again : { ...l, marks: again.marks };
3458
+ if (!raws) return asDrawn(l);
3459
+ const again = l.id === heldLane ? heldLaneIn(l.id, raws, held, base, dragged) : laneFrom(l.id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(l.id), base.share, base.marking, false, true);
3460
+ if (!again) return asDrawn(l);
3461
+ return l.id === heldLane ? again : { ...asDrawn(l), marks: again.marks };
3376
3462
  });
3377
- return { ...base.regions, lanes: rebuilt.map((l) => settle(l, held.layout, scene, dragged, rebuilt, options.emptyLanes)) };
3463
+ return { ...base.regions, lanes: rebuilt.map((l) => settle(l, held.layout, scene, dragged, rebuilt, options.emptyLanes, base.raws.get(l.id) ? laneRectOver(base.raws.get(l.id), held.layout, base.seen, base.marking).rect : l.rect)) };
3464
+ }
3465
+ function asDrawn(l) {
3466
+ if (!l.entry && !l.corners) return l;
3467
+ const { entry: _entry, corners: _corners, ...rest } = l;
3468
+ return rest;
3469
+ }
3470
+ function heldLaneIn(id, raws, held, base, dragged) {
3471
+ return laneFrom(id, raws, held.layout, base.seen, dragged, base.refusals, base.halves.has(id), base.share, base.marking, !held.slide, true);
3378
3472
  }
3379
3473
  function build(scene, dragged, options) {
3380
3474
  const seen = solve(scene, options.previous ? { previous: options.previous } : {});
@@ -3427,14 +3521,16 @@ function build(scene, dragged, options) {
3427
3521
  return main?.grows ? main.natural : void 0;
3428
3522
  },
3429
3523
  gap: (edge) => nonNeg(scene.edges.find((e) => e.id === edge)?.gap),
3430
- lifted
3524
+ lifted,
3525
+ crossing: (edge, over) => scene.edges.filter((e) => e.id !== edge && byLane.has(e.id) && (over.edges[e.id]?.cross ?? 0) > EPS && axisOfEdge(e.id) !== axisOfEdge(edge)).map((e) => over.edges[e.id].rect)
3431
3526
  };
3432
3527
  const shareOf = (g, size) => g === void 0 || !Number.isFinite(g) || size <= EPS ? 0.5 : clamp(g / size, 0, 1);
3433
3528
  const w = own?.rect.width ?? 0;
3434
3529
  const h = own?.rect.height ?? 0;
3435
3530
  const share = { x: w >= h ? shareOf(options.grab?.x, w) : 0.5, y: h > w ? shareOf(options.grab?.y, h) : 0.5 };
3436
3531
  const built = [...byLane].map(([id, list]) => laneFrom(id, list, seen, seen, dragged, rs, halves.has(id), share, marking)).filter((l) => !!l);
3437
- const laneList = built.map((l) => settle(l, seen, scene, dragged, built, options.emptyLanes));
3532
+ const settled = built.map((l) => settle(l, seen, scene, dragged, built, options.emptyLanes));
3533
+ const laneList = options.emptyLanes === "edge" ? settled : predict(settled, byLane, { seen, refusals: rs, halves, share, marking }, scene, dragged, built, options.emptyLanes);
3438
3534
  const onLanes = new Set(laneList.map((l) => l.id));
3439
3535
  const rails = Object.values(seen.rails).flatMap((r) => r && r.rect.width > EPS && r.rect.height > EPS ? [r.rect] : []);
3440
3536
  const blocked = [
@@ -3465,17 +3561,23 @@ function build(scene, dragged, options) {
3465
3561
  }
3466
3562
  };
3467
3563
  }
3564
+ function laneRectOver(list, over, seen, marking) {
3565
+ const first = list[0];
3566
+ const axis = first.axis;
3567
+ const edgeLayout = first.edge ? over.edges[first.edge] : void 0;
3568
+ const band = list.map((r) => r.landing).reduce(hull2);
3569
+ if (!edgeLayout) return { rect: list.every((r) => r.strip) ? list.map((r) => r.hit).reduce(hull2) : list.map((r) => r.hit).reduce(hull2, band) };
3570
+ const drawnHere = edgeLayout.cross > EPS;
3571
+ const whole = drawnHere ? edgeLayout.rect : axis === "x" ? rect(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
3572
+ const emptyAsSeen = (seen.edges[first.edge]?.cross ?? 0) <= EPS;
3573
+ const clipped = emptyAsSeen ? clipAtDrawn(whole, axis, marking.crossing(first.edge, seen)) : whole;
3574
+ return drawnHere ? { rect: clipped } : { rect: clipped, band: whole };
3575
+ }
3468
3576
  function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, heldHere = false, spotHeld = false) {
3469
3577
  if (list.length === 0) return null;
3470
3578
  const first = list[0];
3471
3579
  const axis = first.axis;
3472
- const edgeLayout = first.edge ? seen.edges[first.edge] : void 0;
3473
- const band = list.map((r) => r.landing).reduce(hull2);
3474
- let laneRect;
3475
- if (edgeLayout && edgeLayout.cross > EPS) laneRect = edgeLayout.rect;
3476
- else if (edgeLayout) laneRect = axis === "x" ? rect(edgeLayout.rect.x, band.y, edgeLayout.rect.width, band.height) : rect(band.x, edgeLayout.rect.y, band.width, edgeLayout.rect.height);
3477
- else if (list.every((r) => r.strip)) laneRect = list.map((r) => r.hit).reduce(hull2);
3478
- else laneRect = list.map((r) => r.hit).reduce(hull2, band);
3580
+ const { rect: laneRect, band: markBand } = laneRectOver(list, seen, seen, marking);
3479
3581
  const firstOf = (r) => r.slide?.first ?? r.landing;
3480
3582
  const lastOf = (r) => r.slide?.last ?? r.landing;
3481
3583
  const sorted = [...list].sort((a, b) => mid(firstOf(a), axis) - mid(firstOf(b), axis) || (a.home ? -1 : b.home ? 1 : 0));
@@ -3490,6 +3592,9 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
3490
3592
  }
3491
3593
  const start = lo(laneRect, axis);
3492
3594
  const end = start + len(laneRect, axis);
3595
+ const whole = markBand ?? laneRect;
3596
+ const bandStart = lo(whole, axis);
3597
+ const bandEnd = bandStart + len(whole, axis);
3493
3598
  const drawnItems = first.edge && halves ? new Map(onEdge(drawn, first.edge, dragged, axis).map((o) => [o.id, o.r])) : /* @__PURE__ */ new Map();
3494
3599
  const held = halves ? 0.5 : share[axis];
3495
3600
  const cuts = [];
@@ -3505,11 +3610,16 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
3505
3610
  const slack = Math.max(0, marking.pitch) / 2;
3506
3611
  const atGrab = clamp(across2 + (held - 0.5) * (len(aLanding, axis) + len(bLanding, axis)) / 2, lo(bLanding, axis) - slack, aEnd + slack);
3507
3612
  const raw = shared ? mid(shared, axis) : overlap ? atGrab : across2;
3508
- cuts.push(clamp(Math.max(raw, cuts[i - 1] ?? start), start, end));
3613
+ cuts.push(clamp(Math.max(raw, cuts[i - 1] ?? bandStart), bandStart, bandEnd));
3509
3614
  }
3510
- const spots = unique.map((x, i) => ({
3615
+ const spots = unique.flatMap((x, i) => {
3616
+ const a = i === 0 ? bandStart : cuts[i - 1];
3617
+ const b = i === unique.length - 1 ? bandEnd : cuts[i];
3618
+ const along2 = [clamp(a, start, end), clamp(b, start, end)];
3619
+ return along2[1] - along2[0] > EPS || b - a <= EPS || x.home ? [{ x, along: along2 }] : [];
3620
+ }).map(({ x, along: along2 }) => ({
3511
3621
  id: x.id,
3512
- along: [i === 0 ? start : cuts[i - 1], i === unique.length - 1 ? end : cuts[i]],
3622
+ along: along2,
3513
3623
  landing: x.landing,
3514
3624
  target: x.target,
3515
3625
  ...x.home ? { home: true } : {},
@@ -3521,7 +3631,7 @@ function laneFrom(id, list, drawn, seen, dragged, rs, halves, share, marking, he
3521
3631
  const refused = first.edge ? rs.filter((f) => f.edge === first.edge).flatMap((f) => (f.hits ?? [f.hit]).map((h) => ({ along: [clamp(lo(h, axis), start, end), clamp(lo(h, axis) + len(h, axis), start, end)], reason: f.reason }))).filter((f) => f.along[1] - f.along[0] >= itemLen - EPS) : [];
3522
3632
  const places = new Set(unique.map((x) => `${x.before}|${x.next}`));
3523
3633
  const drawnEdge = first.edge ? drawn.edges[first.edge] : void 0;
3524
- const markRect = drawnEdge && drawnEdge.cross > EPS ? drawnEdge.rect : laneRect;
3634
+ const markRect = drawnEdge && drawnEdge.cross > EPS ? drawnEdge.rect : markBand ?? laneRect;
3525
3635
  const marked = first.edge ? onEdge(drawn, first.edge, heldHere ? "" : dragged, axis).map((o) => {
3526
3636
  const n = o.id === dragged || halves ? void 0 : marking.natural(o.id, axis);
3527
3637
  return n !== void 0 && n < len(o.r, axis) ? { ...o, r: along(o.r, axis, lo(o.r, axis), lo(o.r, axis) + n) } : o;
@@ -3611,7 +3721,20 @@ function virtualMarks(lane, spots, held) {
3611
3721
  return { id: `${lane}/line/${s.id}`, kind: "line", rect: rect(x, l.y, 0, l.height) };
3612
3722
  });
3613
3723
  }
3614
- function settle(l, drawn, scene, dragged, all, emptyLanes = "real") {
3724
+ function inLane(l, r) {
3725
+ const marks = l.marks.flatMap((m) => {
3726
+ const x0 = Math.max(m.rect.x, r.x);
3727
+ const y0 = Math.max(m.rect.y, r.y);
3728
+ const x1 = Math.min(m.rect.x + m.rect.width, r.x + r.width);
3729
+ const y1 = Math.min(m.rect.y + m.rect.height, r.y + r.height);
3730
+ if (m.kind === "line") return x1 - x0 >= m.rect.width - EPS && y1 - y0 >= m.rect.height - EPS ? [m] : [];
3731
+ if (x1 - x0 <= EPS || y1 - y0 <= EPS) return [];
3732
+ return x1 - x0 >= m.rect.width - EPS && y1 - y0 >= m.rect.height - EPS ? [m] : [{ ...m, rect: rect(x0, y0, x1 - x0, y1 - y0) }];
3733
+ });
3734
+ return marks.length === l.marks.length && marks.every((m, i) => m === l.marks[i]) ? l : { ...l, marks };
3735
+ }
3736
+ function settle(lane, drawn, scene, dragged, all, emptyLanes = "real", within = lane.rect) {
3737
+ const l = inLane(lane, within);
3615
3738
  const edgeOf = (id) => scene.edges.find((e) => e.id === id);
3616
3739
  const isDrawn = (id) => !!edgeOf(id) && (drawn.edges[id]?.cross ?? 0) > EPS;
3617
3740
  const across2 = (side) => side === "top" || side === "bottom" ? "x" : "y";
@@ -3632,17 +3755,7 @@ function settle(l, drawn, scene, dragged, all, emptyLanes = "real") {
3632
3755
  };
3633
3756
  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 > EPS && it.rect.height > EPS).map(([, it]) => it.rect) : [];
3634
3757
  if (cuts.length === 0 && !(empty && (emptyLanes === "edge" || l.marks.some((m) => m.kind === "box" && stays.some((s) => overlaps3(m.rect, s)))))) return l;
3635
- const span = (r) => [lo(r, l.axis), lo(r, l.axis) + len(r, l.axis)];
3636
- const crosses = (r, c) => l.axis === "x" ? c.y < r.y + r.height - EPS && r.y < c.y + c.height - EPS : c.x < r.x + r.width - EPS && r.x < c.x + c.width - EPS;
3637
- const cut2 = (r, cs) => {
3638
- let ps = [span(r)];
3639
- for (const c of cs) {
3640
- if (!crosses(r, c)) continue;
3641
- const [c0, c1] = span(c);
3642
- ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS);
3643
- }
3644
- return ps;
3645
- };
3758
+ const cut2 = (r, cs) => piecesLess(r, l.axis, cs);
3646
3759
  const marks = [];
3647
3760
  for (const m of l.marks) {
3648
3761
  const kept = cut2(m.rect, m.kind === "box" ? [...cuts, ...stays] : cuts);
@@ -3671,6 +3784,54 @@ function settle(l, drawn, scene, dragged, all, emptyLanes = "real") {
3671
3784
  }
3672
3785
  return { ...l, marks };
3673
3786
  }
3787
+ function piecesLess(r, axis, cs) {
3788
+ const span = (x) => [lo(x, axis), lo(x, axis) + len(x, axis)];
3789
+ const crosses = (c) => axis === "x" ? c.y < r.y + r.height - EPS && r.y < c.y + c.height - EPS : c.x < r.x + r.width - EPS && r.x < c.x + c.width - EPS;
3790
+ let ps = [span(r)];
3791
+ for (const c of cs) {
3792
+ if (!crosses(c)) continue;
3793
+ const [c0, c1] = span(c);
3794
+ ps = ps.flatMap(([p, q]) => [[p, Math.min(q, c0)], [Math.max(p, c1), q]]).filter(([p, q]) => q - p > EPS);
3795
+ }
3796
+ return ps;
3797
+ }
3798
+ function marksLess(marks, axis, cs) {
3799
+ return marks.flatMap((m) => {
3800
+ const over = cs.filter((c) => overlaps3(m.rect, c));
3801
+ if (over.length === 0) return [m];
3802
+ const kept = piecesLess(m.rect, axis, over);
3803
+ if (m.kind === "line") return kept.length === 1 && Math.abs(kept[0][1] - kept[0][0] - len(m.rect, axis)) < EPS ? [m] : [];
3804
+ return kept.map(([p, q], i) => ({ ...m, id: i ? `${m.id}~c${i}` : m.id, rect: along(m.rect, axis, p, q) }));
3805
+ });
3806
+ }
3807
+ function predict(settled, byLane, base, scene, dragged, built, emptyLanes) {
3808
+ const whole = /* @__PURE__ */ new Map();
3809
+ for (const l of settled) {
3810
+ const raws = byLane.get(l.id);
3811
+ if (!raws || l.spots.length !== 1 || !scene.edges.some((e) => e.id === l.id) || (base.seen.edges[l.id]?.cross ?? 0) > EPS) continue;
3812
+ const held = raws.find((r) => r.id === l.spots[0].id);
3813
+ if (!held || (held.layout.edges[l.id]?.cross ?? 0) <= EPS) continue;
3814
+ const again = heldLaneIn(l.id, raws, held, base, dragged);
3815
+ if (again) whole.set(l.id, settle(again, held.layout, scene, dragged, built, emptyLanes, laneRectOver(raws, held.layout, base.seen, base.marking).rect).marks);
3816
+ }
3817
+ if (whole.size === 0) return [...settled];
3818
+ const order = [...settled].filter((l) => whole.has(l.id)).sort((a, b) => a.axis === b.axis ? 0 : a.axis === "x" ? -1 : 1);
3819
+ const final = new Map(settled.filter((l) => !whole.has(l.id)).map((l) => [l.id, l.marks]));
3820
+ const meets = /* @__PURE__ */ new Map();
3821
+ for (const l of order) {
3822
+ const mine = whole.get(l.id);
3823
+ const others = [...final].filter(([id, ms]) => id !== l.id && ms.some((m) => mine.some((x) => overlaps3(x.rect, m.rect))));
3824
+ meets.set(l.id, others.map(([id]) => id));
3825
+ final.set(l.id, marksLess(mine, l.axis, others.flatMap(([, ms]) => ms.map((m) => m.rect))));
3826
+ }
3827
+ return settled.map((l) => {
3828
+ const marks = final.get(l.id);
3829
+ const mine = whole.get(l.id);
3830
+ if (!mine) return l;
3831
+ const corners = meets.get(l.id);
3832
+ return corners.length > 0 ? { ...l, marks, entry: mine, corners } : { ...l, marks };
3833
+ });
3834
+ }
3674
3835
  var overlaps3 = (a, b) => a.x < b.x + b.width - EPS && b.x < a.x + a.width - EPS && a.y < b.y + b.height - EPS && b.y < a.y + a.height - EPS;
3675
3836
  function pitchedSpots(scene, dragged, options, seen, lifted, raws, pitch) {
3676
3837
  const out = [];
@@ -3977,6 +4138,7 @@ export {
3977
4138
  isSideBar,
3978
4139
  isSideColumn,
3979
4140
  floatOrientOf,
4141
+ declaresFloatSizes,
3980
4142
  floatSizeOf,
3981
4143
  targetId,
3982
4144
  parseTargetId,
@@ -4013,4 +4175,4 @@ export {
4013
4175
  HATCH_END,
4014
4176
  HATCH_EDGE
4015
4177
  };
4016
- //# sourceMappingURL=chunk-UPZXNTIR.js.map
4178
+ //# sourceMappingURL=chunk-67D32MZ4.js.map