@ohhwells/bridge 0.1.180-next.482 → 0.1.180-next.484

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -126,6 +126,7 @@ __export(index_exports, {
126
126
  ensureFooterTree: () => ensureFooterTree,
127
127
  ensureSectionButtonCollections: () => ensureSectionButtonCollections,
128
128
  filterAvailablePages: () => filterAvailablePages,
129
+ fitButtonCollection: () => fitButtonCollection,
129
130
  foldAlignIntoTrees: () => foldAlignIntoTrees,
130
131
  getEditModeInitialState: () => getEditModeInitialState,
131
132
  getLogoVersions: () => getLogoVersions,
@@ -2984,41 +2985,45 @@ function readRootVar(doc, name) {
2984
2985
  const root = doc.documentElement;
2985
2986
  return root.style.getPropertyValue(name).trim() || getComputedStyle(root).getPropertyValue(name).trim();
2986
2987
  }
2988
+ function readVarAt(el, name) {
2989
+ const local = el.isConnected ? getComputedStyle(el).getPropertyValue(name).trim() : "";
2990
+ return local || readRootVar(el.ownerDocument, name);
2991
+ }
2987
2992
  function sameColor(a, b) {
2988
2993
  return Math.round(a.r) === Math.round(b.r) && Math.round(a.g) === Math.round(b.g) && Math.round(a.b) === Math.round(b.b) && Math.abs(a.a - b.a) < 0.02;
2989
2994
  }
2990
- function brandTrackedColor(doc, color, roles) {
2995
+ function brandTrackedColor(el, color, roles) {
2991
2996
  if (!color || color.includes("var(")) return color;
2992
2997
  const parsed = parseColor(color);
2993
2998
  if (!parsed || isTransparent(parsed)) return color;
2994
2999
  for (const role of roles) {
2995
3000
  const name = `--brand-${role}`;
2996
- const token = parseColor(readRootVar(doc, name));
3001
+ const token = parseColor(readVarAt(el, name));
2997
3002
  if (token && !isTransparent(token) && sameColor(parsed, token)) return `var(${name}, ${color})`;
2998
3003
  }
2999
3004
  return color;
3000
3005
  }
3001
- function brandTrackedChrome(doc, chrome) {
3006
+ function brandTrackedChrome(el, chrome) {
3002
3007
  return {
3003
3008
  ...chrome,
3004
- background: brandTrackedColor(doc, chrome.background, BRAND_TRACK_PRECEDENCE.background),
3005
- color: brandTrackedColor(doc, chrome.color, BRAND_TRACK_PRECEDENCE.color),
3006
- borderColor: brandTrackedColor(doc, chrome.borderColor, BRAND_TRACK_PRECEDENCE.borderColor)
3009
+ background: brandTrackedColor(el, chrome.background, BRAND_TRACK_PRECEDENCE.background),
3010
+ color: brandTrackedColor(el, chrome.color, BRAND_TRACK_PRECEDENCE.color),
3011
+ borderColor: brandTrackedColor(el, chrome.borderColor, BRAND_TRACK_PRECEDENCE.borderColor)
3007
3012
  };
3008
3013
  }
3009
- function firstFamily(stack) {
3010
- const first = stack.split(",")[0]?.trim() ?? "";
3014
+ function firstFamily(stack2) {
3015
+ const first = stack2.split(",")[0]?.trim() ?? "";
3011
3016
  return first.replace(/^['"]|['"]$/g, "").toLowerCase();
3012
3017
  }
3013
- function brandTrackedFontFamily(doc, stack) {
3014
- if (!stack || stack.includes("var(")) return stack;
3015
- const family = firstFamily(stack);
3016
- if (!family) return stack;
3018
+ function brandTrackedFontFamily(doc, stack2) {
3019
+ if (!stack2 || stack2.includes("var(")) return stack2;
3020
+ const family = firstFamily(stack2);
3021
+ if (!family) return stack2;
3017
3022
  for (const name of FONT_TRACK_VARS) {
3018
3023
  const raw = readRootVar(doc, name);
3019
- if (raw && firstFamily(raw) === family) return `var(${name}, ${stack})`;
3024
+ if (raw && firstFamily(raw) === family) return `var(${name}, ${stack2})`;
3020
3025
  }
3021
- return stack;
3026
+ return stack2;
3022
3027
  }
3023
3028
  var paintLockByEl = /* @__PURE__ */ new WeakMap();
3024
3029
  var paintObserverByEl = /* @__PURE__ */ new WeakMap();
@@ -3048,17 +3053,23 @@ function surfaceBehind(el) {
3048
3053
  }
3049
3054
  return { r: 255, g: 255, b: 255, a: 1 };
3050
3055
  }
3056
+ function parseTrackedColor(el, value) {
3057
+ if (!value) return null;
3058
+ const tracked = value.trim().match(/^var\(\s*(--[\w-]+)\s*(?:,\s*(.+))?\)$/);
3059
+ if (!tracked) return parseColor(value);
3060
+ return parseColor(readVarAt(el, tracked[1])) ?? (tracked[2] ? parseTrackedColor(el, tracked[2]) : null);
3061
+ }
3051
3062
  function readableOnSurface(el, chrome, primary) {
3052
- const fill = parseColor(chrome.background);
3063
+ const fill = parseTrackedColor(el, chrome.background);
3053
3064
  if (fill && !isTransparent(fill)) return chrome;
3054
- const ink = parseColor(chrome.color);
3065
+ const ink = parseTrackedColor(el, chrome.color);
3055
3066
  if (!ink || isTransparent(ink)) return chrome;
3056
3067
  const surface = surfaceBehind(el);
3057
3068
  const dark = surface ? relativeLuminance(surface) < 0.4 : toneFor(el) === "dark";
3058
3069
  const readable = surface ? contrastRatio({ ...ink, a: 1 }, surface) >= 3 : dark === relativeLuminance(ink) > 0.4;
3059
3070
  if (readable) return chrome;
3060
- const primaryFill = parseColor(primary.background);
3061
- const primaryLabel = parseColor(primary.color);
3071
+ const primaryFill = parseTrackedColor(el, primary.background);
3072
+ const primaryLabel = parseTrackedColor(el, primary.color);
3062
3073
  let next;
3063
3074
  if (dark) {
3064
3075
  next = primaryLabel && relativeLuminance(primaryLabel) > 0.55 ? toCss({ ...primaryLabel, a: 1 }) : "rgb(255, 255, 255)";
@@ -3136,9 +3147,9 @@ function applyButtonStyle(el, assignment, tokens) {
3136
3147
  const tracked = {
3137
3148
  ...tokens,
3138
3149
  variants: {
3139
- primary: brandTrackedChrome(doc, tokens.variants.primary),
3140
- secondary: brandTrackedChrome(doc, tokens.variants.secondary),
3141
- ghost: brandTrackedChrome(doc, tokens.variants.ghost)
3150
+ primary: brandTrackedChrome(el, tokens.variants.primary),
3151
+ secondary: brandTrackedChrome(el, tokens.variants.secondary),
3152
+ ghost: brandTrackedChrome(el, tokens.variants.ghost)
3142
3153
  }
3143
3154
  };
3144
3155
  paintLockByEl.set(el, { assignment, tokens: tracked });
@@ -3550,6 +3561,80 @@ function applyCollectionPositionsFromContent(doc, content) {
3550
3561
  unwrapEmptyColumns(doc);
3551
3562
  }
3552
3563
 
3564
+ // src/lib/button-collection-fit.ts
3565
+ var STACKED_ATTR = "data-ohw-collection-stacked";
3566
+ var MEDIA_SELECTOR = 'img, picture, video, svg, figure, [data-ohw-editable="image"], [data-ohw-editable="bg-image"]';
3567
+ var COPY_SELECTOR = '[data-ohw-href-key*="-copy-"]';
3568
+ var BUTTON_SELECTOR2 = '[data-ohw-role="button"]';
3569
+ function overlaps(a, b) {
3570
+ return a.left < b.right - 1 && b.left < a.right - 1 && a.top < b.bottom - 1 && b.top < a.bottom - 1;
3571
+ }
3572
+ function visibleButtons(collection) {
3573
+ return Array.from(collection.querySelectorAll(BUTTON_SELECTOR2)).filter(
3574
+ (el) => el.getClientRects().length > 0 && el.style.display !== "none"
3575
+ );
3576
+ }
3577
+ function covers2(outer, inner) {
3578
+ return outer.left <= inner.left + 1 && outer.top <= inner.top + 1 && outer.right >= inner.right - 1 && outer.bottom >= inner.bottom - 1;
3579
+ }
3580
+ function sectionMedia(collection) {
3581
+ const section = collection.closest("[data-ohw-section], section") ?? collection.ownerDocument.body;
3582
+ const own = collection.getBoundingClientRect();
3583
+ const boxes = [];
3584
+ for (const el of Array.from(section.querySelectorAll(MEDIA_SELECTOR))) {
3585
+ if (collection.contains(el) || el.contains(collection)) continue;
3586
+ if (el.closest(BUTTON_SELECTOR2)) continue;
3587
+ const r2 = el.getBoundingClientRect();
3588
+ if (r2.width < 1 || r2.height < 1) continue;
3589
+ if (covers2(r2, own)) continue;
3590
+ boxes.push(r2);
3591
+ }
3592
+ return boxes;
3593
+ }
3594
+ function hitsMedia(collection) {
3595
+ const media = sectionMedia(collection);
3596
+ if (media.length === 0) return false;
3597
+ return visibleButtons(collection).some((button) => {
3598
+ const box = button.getBoundingClientRect();
3599
+ return media.some((m) => overlaps(box, m));
3600
+ });
3601
+ }
3602
+ function stack(collection, on) {
3603
+ if (on) {
3604
+ collection.setAttribute(STACKED_ATTR, "");
3605
+ collection.style.flexDirection = "column";
3606
+ collection.style.alignItems = "flex-start";
3607
+ } else if (collection.hasAttribute(STACKED_ATTR)) {
3608
+ collection.removeAttribute(STACKED_ATTR);
3609
+ collection.style.flexDirection = "";
3610
+ collection.style.alignItems = "";
3611
+ }
3612
+ }
3613
+ function fitButtonCollection(collection) {
3614
+ if (!collection.querySelector(COPY_SELECTOR)) {
3615
+ stack(collection, false);
3616
+ return;
3617
+ }
3618
+ if (!/flex/.test(getComputedStyle(collection).display)) return;
3619
+ stack(collection, false);
3620
+ if (visibleButtons(collection).length < 2) return;
3621
+ if (hitsMedia(collection)) stack(collection, true);
3622
+ }
3623
+ var watched = /* @__PURE__ */ new WeakSet();
3624
+ function fitButtonCollections(doc, collectionAttr) {
3625
+ for (const collection of Array.from(doc.querySelectorAll(`[${collectionAttr}]`))) {
3626
+ fitButtonCollection(collection);
3627
+ }
3628
+ const win = doc.defaultView;
3629
+ if (!win || watched.has(doc)) return;
3630
+ watched.add(doc);
3631
+ let frame = 0;
3632
+ win.addEventListener("resize", () => {
3633
+ win.cancelAnimationFrame(frame);
3634
+ frame = win.requestAnimationFrame(() => fitButtonCollections(doc, collectionAttr));
3635
+ });
3636
+ }
3637
+
3553
3638
  // src/lib/button-collections.ts
3554
3639
  var BUTTON_COLLECTIONS_KEY = "__ohw_button_collections";
3555
3640
  var BUTTON_SNAPSHOTS_KEY = "__ohw_button_snapshots";
@@ -3698,8 +3783,21 @@ function addButtonNextTo(button, content) {
3698
3783
  const collection = buttonCollectionOf(button) ?? (isSectionCta(button) ? ensureSectionButtonCollection(button, content) : null);
3699
3784
  return collection ? addButtonToCollection(collection, content) : duplicateButton(button, content, "new");
3700
3785
  }
3786
+ var LABEL_EDITABLE_SELECTOR = '[data-ohw-editable="text"], [data-ohw-editable="plain"]';
3701
3787
  function labelElement2(el) {
3702
- return el.querySelector('[data-ohw-editable="text"], [data-ohw-editable="plain"]') ?? el.querySelector("[data-ohw-key]");
3788
+ return el.querySelector(LABEL_EDITABLE_SELECTOR) ?? (el.matches(LABEL_EDITABLE_SELECTOR) ? el : null) ?? el.querySelector("[data-ohw-key]") ?? (el.hasAttribute("data-ohw-key") ? el : null);
3789
+ }
3790
+ function keepOnlyLabel(copy, label) {
3791
+ if (!label || label === copy) return;
3792
+ let node = label;
3793
+ while (node && node !== copy) {
3794
+ const parent = node.parentElement;
3795
+ if (!parent) break;
3796
+ for (const sibling of Array.from(parent.children)) {
3797
+ if (sibling !== node) sibling.remove();
3798
+ }
3799
+ node = parent;
3800
+ }
3703
3801
  }
3704
3802
  function buttonLabel(el) {
3705
3803
  const label = labelElement2(el);
@@ -3829,7 +3927,7 @@ function syncCollectionEmpty(collection) {
3829
3927
  const marked = collection.hasAttribute(EMPTY_ATTR);
3830
3928
  if (empty && !marked) {
3831
3929
  collection.setAttribute(EMPTY_ATTR, collection.style.display);
3832
- collection.style.display = "none";
3930
+ collection.style.setProperty("display", "none", "important");
3833
3931
  } else if (!empty && marked) {
3834
3932
  collection.style.display = collection.getAttribute(EMPTY_ATTR) ?? "";
3835
3933
  collection.removeAttribute(EMPTY_ATTR);
@@ -3884,6 +3982,17 @@ function stampVariantClass(el, variant) {
3884
3982
  const without = raw.replace(/\bbtn--(?:primary|secondary|ghost)\b/g, "").replace(/\s+/g, " ").trim();
3885
3983
  el.className = without ? `${without} btn--${variant}` : `btn btn--${variant}`;
3886
3984
  }
3985
+ function keepSourceWidth(copy, source) {
3986
+ const row = copy.parentElement;
3987
+ if (!row || !source.isConnected) return;
3988
+ const rowWidth = row.getBoundingClientRect().width;
3989
+ const copyWidth = copy.getBoundingClientRect().width;
3990
+ const sourceWidth = source.getBoundingClientRect().width;
3991
+ if (rowWidth <= 0) return;
3992
+ const copyFills = copyWidth >= rowWidth - 1;
3993
+ const sourceFills = sourceWidth >= rowWidth - 1;
3994
+ if (copyFills && !sourceFills) copy.style.width = "auto";
3995
+ }
3887
3996
  function snapshotOf(el) {
3888
3997
  const id = buttonId(el) ?? "";
3889
3998
  const label = labelElement2(el);
@@ -3918,10 +4027,10 @@ function duplicateButton(source, content, mode = "duplicate") {
3918
4027
  if (href) copy.setAttribute("href", href);
3919
4028
  const sourceAssignment = readAssignments(content)[sourceId] ?? assignmentFor(source, content, tokens);
3920
4029
  const copyAssignment = mode === "new" ? { ...sourceAssignment, variant: "secondary" } : { ...sourceAssignment };
3921
- stampVariantClass(copy, copyAssignment.variant);
3922
- applyButtonStyle(copy, copyAssignment, paintedTokensOf(source) ?? tokens);
3923
4030
  const copyLabelEl = labelElement2(copy);
4031
+ if (mode === "new") keepOnlyLabel(copy, copyLabelEl);
3924
4032
  if (copyLabelEl) copyLabelEl.innerHTML = label;
4033
+ else if (mode === "new") copy.textContent = label;
3925
4034
  let collection = buttonCollectionOf(source) ?? (isSectionCta(source) ? ensureSectionButtonCollection(source, content) : null);
3926
4035
  const collections = readCollections(content);
3927
4036
  let collectionId = collection?.getAttribute(COLLECTION_ATTR) ?? "";
@@ -3943,6 +4052,10 @@ function duplicateButton(source, content, mode = "duplicate") {
3943
4052
  const at = members.indexOf(sourceId);
3944
4053
  members.splice(at >= 0 ? at + 1 : members.length, 0, copyId);
3945
4054
  }
4055
+ stampVariantClass(copy, copyAssignment.variant);
4056
+ keepSourceWidth(copy, source);
4057
+ applyButtonStyle(copy, copyAssignment, paintedTokensOf(source) ?? tokens);
4058
+ fitButtonCollection(collection);
3946
4059
  const sourceLabelKey = labelElement2(source)?.getAttribute("data-ohw-key");
3947
4060
  const snapshots = {
3948
4061
  ...readSnapshots(content),
@@ -4243,7 +4356,7 @@ function persistCollectionOrder(collection, content) {
4243
4356
  function hideButton(el) {
4244
4357
  if (el.getAttribute("data-ohw-button-hidden") === "") return;
4245
4358
  el.setAttribute("data-ohw-button-hidden", "");
4246
- el.style.display = "none";
4359
+ el.style.setProperty("display", "none", "important");
4247
4360
  }
4248
4361
  function syncButtonsFromContent(doc, content) {
4249
4362
  reconcileButtonCollections(doc, content);
@@ -4251,6 +4364,7 @@ function syncButtonsFromContent(doc, content) {
4251
4364
  applyCollectionPositionsFromContent(doc, content);
4252
4365
  applyButtonContentFromContent(doc, content);
4253
4366
  applyButtonStylesFromContent(doc, content);
4367
+ fitButtonCollections(doc, COLLECTION_ATTR);
4254
4368
  }
4255
4369
  function applyButtonContentFromContent(doc, content) {
4256
4370
  const snapshots = readSnapshots(content);
@@ -4291,7 +4405,7 @@ function reconcileButtonCollections(doc, content) {
4291
4405
  members.forEach((id) => claimed.add(id));
4292
4406
  const live = members.map((id) => findButton(doc, id) ?? restoreSnapshot(doc, snapshots[id], content)).filter((el) => Boolean(el && !hidden.has(buttonId(el) ?? "")));
4293
4407
  if (live.length === 0) continue;
4294
- const anchor = live.find((el) => el.isConnected) ?? live[0];
4408
+ const anchor = live.find((el) => el.isConnected) ?? copiesHome(doc, live) ?? live[0];
4295
4409
  const section = isSectionCta(anchor);
4296
4410
  if (live.length === 1 && !section) {
4297
4411
  const existing = buttonCollectionOf(live[0]);
@@ -4315,6 +4429,15 @@ function reconcileButtonCollections(doc, content) {
4315
4429
  if (section) syncCollectionEmpty(collection);
4316
4430
  }
4317
4431
  }
4432
+ function copiesHome(doc, copies) {
4433
+ for (const copy of copies) {
4434
+ const id = buttonId(copy);
4435
+ if (!id) continue;
4436
+ const origin = findButton(doc, `${hrefKeyBase(id)}-href`);
4437
+ if (origin?.isConnected && origin.parentElement) return origin;
4438
+ }
4439
+ return null;
4440
+ }
4318
4441
  function dropUnsavedCopies(doc, snapshots, collections) {
4319
4442
  const stale = Array.from(doc.querySelectorAll('[data-ohw-href-key*="-copy-"]')).filter((el) => {
4320
4443
  const id = buttonId(el);
@@ -9246,7 +9369,7 @@ function presetOf(node) {
9246
9369
  }
9247
9370
  function maxButtonsIn(parent) {
9248
9371
  if (parent.type === "card") return presetOf(parent) === "pricing" ? 2 : 1;
9249
- return 2;
9372
+ return Infinity;
9250
9373
  }
9251
9374
  function hasOnePrimaryIfPricing(parent) {
9252
9375
  if (parent.type !== "card" || presetOf(parent) !== "pricing" || parent.children.length !== 2) return true;
@@ -10010,8 +10133,8 @@ function parseBrandKit(raw) {
10010
10133
  return null;
10011
10134
  }
10012
10135
  }
10013
- function familyOf(stack) {
10014
- const first = stack.split(",")[0]?.trim() ?? "";
10136
+ function familyOf(stack2) {
10137
+ const first = stack2.split(",")[0]?.trim() ?? "";
10015
10138
  return first.replace(/^['"]|['"]$/g, "");
10016
10139
  }
10017
10140
  function quoteFamily(family) {
@@ -14278,8 +14401,8 @@ var GENERIC_FONT_KEYWORDS = /* @__PURE__ */ new Set([
14278
14401
  "emoji",
14279
14402
  "fangsong"
14280
14403
  ]);
14281
- function primaryFontFamily(stack) {
14282
- const first = stack.split(",").map((part) => part.trim().replace(/^["']|["']$/g, "")).find((part) => part && !GENERIC_FONT_KEYWORDS.has(part.toLowerCase()));
14404
+ function primaryFontFamily(stack2) {
14405
+ const first = stack2.split(",").map((part) => part.trim().replace(/^["']|["']$/g, "")).find((part) => part && !GENERIC_FONT_KEYWORDS.has(part.toLowerCase()));
14283
14406
  return first ?? "";
14284
14407
  }
14285
14408
  function humanizeFontFamily(name) {
@@ -22427,7 +22550,7 @@ function apiBase() {
22427
22550
  function bridgeVersion() {
22428
22551
  try {
22429
22552
  if (true) {
22430
- return "0.1.180-next.482";
22553
+ return "0.1.180-next.484";
22431
22554
  }
22432
22555
  } catch {
22433
22556
  }
@@ -22441,7 +22564,7 @@ function stampBridgeVersionOnDocument() {
22441
22564
  return;
22442
22565
  }
22443
22566
  try {
22444
- const v = true ? "0.1.180-next.482" : "";
22567
+ const v = true ? "0.1.180-next.484" : "";
22445
22568
  if (v) {
22446
22569
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
22447
22570
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -24346,11 +24469,11 @@ function MediaStripToolbar({
24346
24469
  ) });
24347
24470
  }
24348
24471
  function findMediaStripSlots(tree) {
24349
- const stack = tree.rows.flatMap((row) => row.blocks);
24350
- while (stack.length) {
24351
- const node = stack.shift();
24472
+ const stack2 = tree.rows.flatMap((row) => row.blocks);
24473
+ while (stack2.length) {
24474
+ const node = stack2.shift();
24352
24475
  if (node.type === "media-strip") return node.slots ?? {};
24353
- if (node.children) stack.push(...node.children);
24476
+ if (node.children) stack2.push(...node.children);
24354
24477
  }
24355
24478
  return null;
24356
24479
  }
@@ -24894,13 +25017,13 @@ function PricingCardToolbar({
24894
25017
  ) });
24895
25018
  }
24896
25019
  function findPricingCardNode(tree, index) {
24897
- const stack = tree.rows.flatMap((row) => row.blocks);
24898
- while (stack.length) {
24899
- const node = stack.shift();
25020
+ const stack2 = tree.rows.flatMap((row) => row.blocks);
25021
+ while (stack2.length) {
25022
+ const node = stack2.shift();
24900
25023
  if (node.type === "collection" && Array.isArray(node.children) && node.children[0]?.type === "card" && node.children[0].slots?.preset === "pricing") {
24901
25024
  return node.children[index] ?? null;
24902
25025
  }
24903
- if (node.children) stack.push(...node.children);
25026
+ if (node.children) stack2.push(...node.children);
24904
25027
  }
24905
25028
  return null;
24906
25029
  }
@@ -29686,7 +29809,7 @@ function isIconMarkupValue(value) {
29686
29809
  function isIconEditable(el) {
29687
29810
  return el.dataset.ohwEditable === "icon";
29688
29811
  }
29689
- var MEDIA_SELECTOR = '[data-ohw-editable="image"], [data-ohw-editable="bg-image"], [data-ohw-editable="video"]';
29812
+ var MEDIA_SELECTOR2 = '[data-ohw-editable="image"], [data-ohw-editable="bg-image"], [data-ohw-editable="video"]';
29690
29813
  var EDITOR_CHROME_SELECTOR = '[data-ohw-toolbar], [data-ohw-form-toolbar], [data-ohw-field-toolbar], [data-ohw-dropdown-option-toolbar], [data-ohw-item-toolbar], [data-ohw-more-menu], [data-ohw-state-toggle], [data-ohw-max-badge], [data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]';
29691
29814
  function isOverEditorChrome(x, y) {
29692
29815
  return document.elementsFromPoint(x, y).some((el) => el instanceof HTMLElement && el.matches(EDITOR_CHROME_SELECTOR));
@@ -30035,8 +30158,8 @@ function resolveNavContainerSelectionTarget(target, clientX, clientY) {
30035
30158
  function getNavigationSelectionParent(el) {
30036
30159
  const socialsRow = findSocialsRow(el);
30037
30160
  if (socialsRow) return socialsRow;
30038
- const buttonCollection = canAddButton(el) ? buttonCollectionOf(el) : null;
30039
- if (buttonCollection) return buttonCollection;
30161
+ const buttonCollection = buttonCollectionOf(el.parentElement);
30162
+ if (buttonCollection && isSectionButtonCollection(buttonCollection)) return buttonCollection;
30040
30163
  if (isNavigationItem2(el)) {
30041
30164
  const childrenRoot = el.closest("[data-ohw-nav-children]");
30042
30165
  if (childrenRoot) {
@@ -34909,7 +35032,7 @@ function OhhwellsBridge() {
34909
35032
  };
34910
35033
  const findImageAtPoint = (clientX, clientY, fromParentViewport) => {
34911
35034
  const { x, y } = toProbeCoords(clientX, clientY, fromParentViewport);
34912
- const images = Array.from(document.querySelectorAll(MEDIA_SELECTOR));
35035
+ const images = Array.from(document.querySelectorAll(MEDIA_SELECTOR2));
34913
35036
  const matches = [];
34914
35037
  for (let i = images.length - 1; i >= 0; i--) {
34915
35038
  const el = images[i];
@@ -37243,7 +37366,7 @@ function OhhwellsBridge() {
37243
37366
  if (e.data?.type !== "ow:click-at") return;
37244
37367
  const { clientX, clientY } = e.data;
37245
37368
  const allImages = Array.from(
37246
- document.querySelectorAll(MEDIA_SELECTOR)
37369
+ document.querySelectorAll(MEDIA_SELECTOR2)
37247
37370
  ).filter((el) => !!el.closest("[data-ohw-editable-state]"));
37248
37371
  const stateCardImage = allImages.find((el) => {
37249
37372
  const ownerCard = el.closest("[data-ohw-editable-state]");
@@ -37758,7 +37881,7 @@ function OhhwellsBridge() {
37758
37881
  postToParent2({
37759
37882
  type: "ow:ready",
37760
37883
  version: "1",
37761
- bridgeVersion: "0.1.180-next.482",
37884
+ bridgeVersion: "0.1.180-next.484",
37762
37885
  path: pathname,
37763
37886
  nodes: collectEditableNodes(editContentRef.current),
37764
37887
  sections
@@ -38461,7 +38584,7 @@ function OhhwellsBridge() {
38461
38584
  const currentSections = sectionsByPath[pathname] ?? [];
38462
38585
  linkPopoverOpenRef.current = linkPopover !== null;
38463
38586
  const handleMediaSelect = (0, import_react29.useCallback)((key) => {
38464
- const el = hoveredImageRef.current?.dataset.ohwKey === key ? hoveredImageRef.current : Array.from(document.querySelectorAll(MEDIA_SELECTOR)).find(
38587
+ const el = hoveredImageRef.current?.dataset.ohwKey === key ? hoveredImageRef.current : Array.from(document.querySelectorAll(MEDIA_SELECTOR2)).find(
38465
38588
  (m) => (m.dataset.ohwKey ?? "") === key
38466
38589
  ) ?? null;
38467
38590
  if (!el) return;
@@ -39340,6 +39463,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
39340
39463
  ensureFooterTree,
39341
39464
  ensureSectionButtonCollections,
39342
39465
  filterAvailablePages,
39466
+ fitButtonCollection,
39343
39467
  foldAlignIntoTrees,
39344
39468
  getEditModeInitialState,
39345
39469
  getLogoVersions,