@ohhwells/bridge 0.1.170 → 0.1.172

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
@@ -53,6 +53,7 @@ __export(index_exports, {
53
53
  FOOTER_COLUMN_BLOCKS: () => FOOTER_COLUMN_BLOCKS,
54
54
  FOOTER_COLUMN_SPANS: () => FOOTER_COLUMN_SPANS,
55
55
  FOOTER_SOCIAL_PLATFORMS: () => FOOTER_SOCIAL_PLATFORMS,
56
+ HIDDEN_EDITABLES_KEY: () => HIDDEN_EDITABLES_KEY,
56
57
  ItemActionToolbar: () => ItemActionToolbar,
57
58
  ItemInteractionLayer: () => ItemInteractionLayer,
58
59
  LinkEditorPanel: () => LinkEditorPanel,
@@ -75,9 +76,14 @@ __export(index_exports, {
75
76
  addFooterLinkColumn: () => addFooterLinkColumn,
76
77
  appendFooterSocial: () => appendFooterSocial,
77
78
  applyBrandChrome: () => applyBrandChrome,
79
+ applyHiddenEditablesToDom: () => applyHiddenEditablesToDom,
78
80
  applyStickySearchParams: () => applyStickySearchParams,
81
+ blockPathFromEditKey: () => blockPathFromEditKey,
79
82
  buildDefaultFooterTree: () => buildDefaultFooterTree,
80
83
  buildTarget: () => buildTarget,
84
+ canRemoveAiBlock: () => canRemoveAiBlock,
85
+ canRemoveAiTextBlock: () => canRemoveAiTextBlock,
86
+ canSoftHideEditable: () => canSoftHideEditable,
81
87
  dropIndicatorVariants: () => dropIndicatorVariants,
82
88
  ensureFooterTree: () => ensureFooterTree,
83
89
  filterAvailablePages: () => filterAvailablePages,
@@ -88,6 +94,7 @@ __export(index_exports, {
88
94
  insertFooterHours: () => insertFooterHours,
89
95
  isDeadPageHref: () => isDeadPageHref,
90
96
  isEditSessionActive: () => isEditSessionActive,
97
+ isEditableKeyHidden: () => isEditableKeyHidden,
91
98
  isPlainLeftClick: () => isPlainLeftClick,
92
99
  isRenderableFooterTree: () => isRenderableFooterTree,
93
100
  isRenderableTree: () => isRenderableTree,
@@ -98,15 +105,22 @@ __export(index_exports, {
98
105
  parseAiFooterState: () => parseAiFooterState,
99
106
  parseAiSectionsState: () => parseAiSectionsState,
100
107
  parseTarget: () => parseTarget,
108
+ planAiBlockRemoval: () => planAiBlockRemoval,
109
+ planAiTextBlockRemoval: () => planAiTextBlockRemoval,
101
110
  planBuildPageSync: () => planBuildPageSync,
111
+ readHiddenEditables: () => readHiddenEditables,
102
112
  recordOverriddenPaths: () => recordOverriddenPaths,
103
113
  releaseTemplateLogoIfReplaced: () => releaseTemplateLogoIfReplaced,
114
+ removeBlockAtPath: () => removeBlockAtPath,
104
115
  removeFooterBlock: () => removeFooterBlock,
105
116
  resetOverriddenPathsCache: () => resetOverriddenPathsCache,
106
117
  resolveFooterCopyright: () => resolveFooterCopyright,
118
+ resolveSoftHideTarget: () => resolveSoftHideTarget,
107
119
  resolveStickyNavigation: () => resolveStickyNavigation,
108
120
  serializeAiFooterState: () => serializeAiFooterState,
109
121
  shouldFetchContentForPath: () => shouldFetchContentForPath,
122
+ softHideEditableInDom: () => softHideEditableInDom,
123
+ softUnhideEditableInDom: () => softUnhideEditableInDom,
110
124
  stepViableSlide: () => stepViableSlide,
111
125
  stripPlaceholderText: () => stripPlaceholderText,
112
126
  stripPlaceholders: () => stripPlaceholders,
@@ -114,7 +128,9 @@ __export(index_exports, {
114
128
  toggleVariants: () => toggleVariants,
115
129
  useOhwCarousel: () => useOhwCarousel,
116
130
  validateUrlInput: () => validateUrlInput,
117
- viableSlides: () => viableSlides
131
+ viableSlides: () => viableSlides,
132
+ withHiddenEditable: () => withHiddenEditable,
133
+ withoutHiddenEditable: () => withoutHiddenEditable
118
134
  });
119
135
  module.exports = __toCommonJS(index_exports);
120
136
 
@@ -5317,6 +5333,118 @@ function deleteNavbarItem(sourceAnchor) {
5317
5333
  };
5318
5334
  }
5319
5335
 
5336
+ // src/lib/hidden-editables.ts
5337
+ var HIDDEN_EDITABLES_KEY = "__ohw_hidden_editables";
5338
+ var HIDDEN_ATTR = "data-ohw-editable-hidden";
5339
+ var FORM_SELECTOR = '[data-ohw-editable="form"]';
5340
+ function parseJson3(raw) {
5341
+ if (!raw) return null;
5342
+ try {
5343
+ return JSON.parse(raw);
5344
+ } catch {
5345
+ return null;
5346
+ }
5347
+ }
5348
+ function readHiddenEditables(content) {
5349
+ const parsed = parseJson3(content?.[HIDDEN_EDITABLES_KEY]);
5350
+ if (!Array.isArray(parsed)) return [];
5351
+ return [...new Set(parsed.filter((key) => typeof key === "string" && key.length > 0))];
5352
+ }
5353
+ function isEditableKeyHidden(content, key) {
5354
+ if (!key) return false;
5355
+ return readHiddenEditables(content).includes(key);
5356
+ }
5357
+ function resolveSoftHideTarget(el) {
5358
+ const cta = el.closest(CTA_BUTTON_SELECTOR);
5359
+ if (cta) return cta;
5360
+ const form = el.closest(FORM_SELECTOR);
5361
+ if (form) return form;
5362
+ return el;
5363
+ }
5364
+ function canSoftHideEditable(el, opts) {
5365
+ if (!el) return false;
5366
+ const target = resolveSoftHideTarget(el);
5367
+ const key = target.dataset.ohwKey ?? el.dataset.ohwKey;
5368
+ if (!key) return false;
5369
+ if (key.startsWith("ai.")) return false;
5370
+ if (key.startsWith("__ohw_")) return false;
5371
+ if (el.hasAttribute("data-ohw-section") || target.hasAttribute("data-ohw-section")) return false;
5372
+ if (el.closest("[data-ohw-social-item]")) return false;
5373
+ if (target.matches(FORM_SELECTOR) || el.dataset.ohwEditable === "form") return true;
5374
+ const cta = el.closest(CTA_BUTTON_SELECTOR);
5375
+ if (cta) return !isLastNavbarButton(cta);
5376
+ if (opts?.isNavFooterItem) return false;
5377
+ if (el.closest("[data-ohw-nav-container], [data-ohw-nav-drawer], [data-ohw-nav-root], nav")) {
5378
+ if (el.closest("[data-ohw-href-key], [data-ohw-nav-item], [data-ohw-nav-group]")) return false;
5379
+ }
5380
+ if (el.closest("footer, [data-ai-footer]")) {
5381
+ if (el.closest("[data-ohw-href-key], [data-ohw-footer-item], [data-ohw-social-item]")) return false;
5382
+ }
5383
+ const kind = el.dataset.ohwEditable;
5384
+ return kind === "text" || kind === "plain" || kind === "image" || kind === "bg-image" || kind === "video" || kind === "icon" || kind === "link" || kind === "map";
5385
+ }
5386
+ function withHiddenEditable(content, key) {
5387
+ const hidden = readHiddenEditables(content);
5388
+ if (hidden.includes(key)) {
5389
+ return {
5390
+ content,
5391
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text: content[HIDDEN_EDITABLES_KEY] ?? "[]" }],
5392
+ added: false
5393
+ };
5394
+ }
5395
+ const nextHidden = [...hidden, key];
5396
+ const text = JSON.stringify(nextHidden);
5397
+ return {
5398
+ content: { ...content, [HIDDEN_EDITABLES_KEY]: text },
5399
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text }],
5400
+ added: true
5401
+ };
5402
+ }
5403
+ function withoutHiddenEditable(content, key) {
5404
+ const nextHidden = readHiddenEditables(content).filter((entry) => entry !== key);
5405
+ const text = JSON.stringify(nextHidden);
5406
+ return {
5407
+ content: { ...content, [HIDDEN_EDITABLES_KEY]: text },
5408
+ nodes: [{ key: HIDDEN_EDITABLES_KEY, text }]
5409
+ };
5410
+ }
5411
+ function escapeAttrValue(value) {
5412
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
5413
+ }
5414
+ function markHidden(el) {
5415
+ softHide(el);
5416
+ el.setAttribute(HIDDEN_ATTR, "");
5417
+ }
5418
+ function markVisible(el) {
5419
+ softUnhide(el);
5420
+ el.removeAttribute(HIDDEN_ATTR);
5421
+ }
5422
+ function applyHiddenEditablesToDom(content, root = document) {
5423
+ const hidden = readHiddenEditables(content);
5424
+ root.querySelectorAll(`[${HIDDEN_ATTR}]`).forEach((el) => markVisible(el));
5425
+ for (const key of hidden) {
5426
+ root.querySelectorAll(`[data-ohw-key="${escapeAttrValue(key)}"]`).forEach((el) => {
5427
+ markHidden(resolveSoftHideTarget(el));
5428
+ });
5429
+ }
5430
+ }
5431
+ function softHideEditableInDom(el, content) {
5432
+ if (!canSoftHideEditable(el)) return null;
5433
+ const target = resolveSoftHideTarget(el);
5434
+ const key = target.dataset.ohwKey ?? el.dataset.ohwKey;
5435
+ if (!key) return null;
5436
+ const next = withHiddenEditable(content, key);
5437
+ markHidden(target);
5438
+ return { content: next.content, nodes: next.nodes, key, target };
5439
+ }
5440
+ function softUnhideEditableInDom(key, content, root = document) {
5441
+ const next = withoutHiddenEditable(content, key);
5442
+ root.querySelectorAll(`[data-ohw-key="${escapeAttrValue(key)}"]`).forEach((el) => {
5443
+ markVisible(resolveSoftHideTarget(el));
5444
+ });
5445
+ return next;
5446
+ }
5447
+
5320
5448
  // src/lib/collect-editable-nodes.ts
5321
5449
  var VIDEO_AUTOPLAY_SUFFIX = "__ohw_autoplay";
5322
5450
  var VIDEO_MUTED_SUFFIX = "__ohw_muted";
@@ -5395,7 +5523,9 @@ function collectEditableNodes(extraContent, root = document) {
5395
5523
  BUTTON_ASSIGNMENTS_KEY,
5396
5524
  BUTTON_COLLECTIONS_KEY,
5397
5525
  BUTTON_SNAPSHOTS_KEY,
5398
- BUTTON_HIDDEN_KEY
5526
+ BUTTON_HIDDEN_KEY,
5527
+ // Soft-hidden template slots (non-AI Delete) — no DOM marker when hidden.
5528
+ HIDDEN_EDITABLES_KEY
5399
5529
  ]) {
5400
5530
  const text = extraContent[key];
5401
5531
  if (typeof text === "string" && text.length > 0) {
@@ -6955,6 +7085,127 @@ function rewriteIconSlot(tree, path, ref) {
6955
7085
  return next;
6956
7086
  }
6957
7087
 
7088
+ // src/lib/ai-remove-block.ts
7089
+ function blockPathFromEditKey(sectionId, key) {
7090
+ const prefix = aiSlotKeyPrefixFor(sectionId);
7091
+ if (!key.startsWith(prefix)) return void 0;
7092
+ const path = [];
7093
+ for (const part of key.slice(prefix.length).split(".")) {
7094
+ if (/^[rbc]\d+$/.test(part)) path.push(part);
7095
+ else break;
7096
+ }
7097
+ if (path.length < 2 || !/^r\d+$/.test(path[0]) || !/^b\d+$/.test(path[1])) return void 0;
7098
+ return path.join(".");
7099
+ }
7100
+ function parseBlockPath(path) {
7101
+ const segs = [];
7102
+ for (const part of path.split(".")) {
7103
+ const match = part.match(/^([rbc])(\d+)$/);
7104
+ if (!match) return void 0;
7105
+ segs.push({ kind: match[1], index: Number(match[2]) });
7106
+ }
7107
+ if (segs.length < 2 || segs[0].kind !== "r" || segs[1].kind !== "b") return void 0;
7108
+ return segs;
7109
+ }
7110
+ function cloneTree(tree) {
7111
+ return JSON.parse(JSON.stringify(tree));
7112
+ }
7113
+ function nodeAtPath2(tree, segs) {
7114
+ let node = tree.rows?.[segs[0].index]?.blocks?.[segs[1].index];
7115
+ for (let i = 2; i < segs.length; i += 1) {
7116
+ if (segs[i].kind !== "c") return null;
7117
+ node = node?.children?.[segs[i].index];
7118
+ }
7119
+ return node ?? null;
7120
+ }
7121
+ function unwrapPromoted(node) {
7122
+ if (node.promoted === true && node.slots?.layout === "stack" && (node.children?.length ?? 0) === 1) {
7123
+ const only = { ...node.children[0] };
7124
+ if (node.slot) only.slot = node.slot;
7125
+ only.span = node.span;
7126
+ return only;
7127
+ }
7128
+ return node;
7129
+ }
7130
+ function removeBlockAtPath(tree, path) {
7131
+ const segs = parseBlockPath(path);
7132
+ if (!segs) return { ok: false, reasons: [`invalid block path "${path}"`] };
7133
+ const next = cloneTree(tree);
7134
+ const rowIndex = segs[0].index;
7135
+ const row = next.rows[rowIndex];
7136
+ if (!row) return { ok: false, reasons: [`row ${rowIndex} not found`] };
7137
+ if (segs.length === 2) {
7138
+ const blockIndex = segs[1].index;
7139
+ if (!row.blocks[blockIndex]) return { ok: false, reasons: [`block ${path} not found`] };
7140
+ row.blocks.splice(blockIndex, 1);
7141
+ if (row.blocks.length === 0) {
7142
+ next.rows.splice(rowIndex, 1);
7143
+ } else if (row.blocks.length === 1) {
7144
+ row.blocks[0] = { ...row.blocks[0], span: 12 };
7145
+ delete row.blocks[0].slot;
7146
+ }
7147
+ } else {
7148
+ let parent = row.blocks[segs[1].index];
7149
+ for (let i = 2; i < segs.length - 1; i += 1) {
7150
+ if (!parent?.children || segs[i].kind !== "c") {
7151
+ return { ok: false, reasons: [`block ${path} not found`] };
7152
+ }
7153
+ parent = parent.children[segs[i].index];
7154
+ }
7155
+ const childIndex = segs[segs.length - 1].index;
7156
+ if (!parent?.children || segs[segs.length - 1].kind !== "c" || !parent.children[childIndex]) {
7157
+ return { ok: false, reasons: [`block ${path} not found`] };
7158
+ }
7159
+ parent.children.splice(childIndex, 1);
7160
+ if (segs.length === 3) {
7161
+ row.blocks[segs[1].index] = unwrapPromoted(parent);
7162
+ if (row.blocks[segs[1].index].type === "group" && (row.blocks[segs[1].index].children?.length ?? 0) === 0) {
7163
+ row.blocks.splice(segs[1].index, 1);
7164
+ if (row.blocks.length === 0) next.rows.splice(rowIndex, 1);
7165
+ }
7166
+ if (next.rows[rowIndex]?.blocks.length === 1) {
7167
+ next.rows[rowIndex].blocks[0] = { ...next.rows[rowIndex].blocks[0], span: 12 };
7168
+ delete next.rows[rowIndex].blocks[0].slot;
7169
+ }
7170
+ } else {
7171
+ const grand = row.blocks[segs[1].index];
7172
+ let cursor = grand;
7173
+ for (let i = 2; i < segs.length - 2; i += 1) {
7174
+ cursor = cursor?.children?.[segs[i].index];
7175
+ }
7176
+ const containerIndex = segs[segs.length - 2].index;
7177
+ if (cursor?.children?.[containerIndex]) {
7178
+ cursor.children[containerIndex] = unwrapPromoted(parent);
7179
+ }
7180
+ }
7181
+ }
7182
+ if (next.rows.length === 0) {
7183
+ return { ok: false, reasons: ["a section must keep at least one block"] };
7184
+ }
7185
+ return { ok: true, tree: next };
7186
+ }
7187
+ function planAiBlockRemoval(aiSectionsRaw, editKey) {
7188
+ if (!editKey || !editKey.startsWith("ai.")) return null;
7189
+ const state = parseAiSectionsState(aiSectionsRaw);
7190
+ const entry = state.sections.find((s) => editKey.startsWith(aiSlotKeyPrefixFor(s.id)));
7191
+ if (!entry) return null;
7192
+ const path = blockPathFromEditKey(entry.id, editKey);
7193
+ if (!path) return null;
7194
+ const segs = parseBlockPath(path);
7195
+ if (!segs) return null;
7196
+ const node = nodeAtPath2(entry.tree, segs);
7197
+ if (!node) return null;
7198
+ const removed = removeBlockAtPath(entry.tree, path);
7199
+ if (!removed.ok) return removed;
7200
+ return { ok: true, tree: removed.tree, path, entry };
7201
+ }
7202
+ var planAiTextBlockRemoval = planAiBlockRemoval;
7203
+ function canRemoveAiBlock(aiSectionsRaw, editKey) {
7204
+ const plan = planAiBlockRemoval(aiSectionsRaw, editKey);
7205
+ return plan?.ok === true;
7206
+ }
7207
+ var canRemoveAiTextBlock = canRemoveAiBlock;
7208
+
6958
7209
  // src/lib/ai-footer-tree.ts
6959
7210
  var FOOTER_COLUMN_SPANS = [12, 6, 4, 3];
6960
7211
  var FOOTER_COLUMN_BLOCKS = [
@@ -8054,12 +8305,19 @@ function footerBodyStyle(fallbackFont, color, weight = 500) {
8054
8305
  }
8055
8306
  var str = (value) => typeof value === "string" ? value : "";
8056
8307
  var cardRadius = (slots) => slots.cornerStyle === "sharp" ? 0 : AI_TREE_TOKENS.radiusCard;
8057
- var blockAlignStyle = (blockAlign) => blockAlign ? {
8058
- display: "flex",
8059
- flexDirection: "column",
8060
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8061
- textAlign: blockAlign
8062
- } : {};
8308
+ var HUG_ALIGN_TYPES = /* @__PURE__ */ new Set(["button", "button-row", "rating"]);
8309
+ var blockAlignStyle = (blockAlign, blockType) => {
8310
+ if (!blockAlign) return {};
8311
+ if (blockType && HUG_ALIGN_TYPES.has(blockType)) {
8312
+ return {
8313
+ display: "flex",
8314
+ flexDirection: "column",
8315
+ alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
8316
+ textAlign: blockAlign
8317
+ };
8318
+ }
8319
+ return { width: "100%", textAlign: blockAlign, boxSizing: "border-box" };
8320
+ };
8063
8321
  var fullBleedBlock = (block) => block.type === "carousel" || block.type === "group" && str(block.slots?.layout) === "overlap";
8064
8322
  var featureLines = (value) => value.split(/\n|<br\s*\/?>/i).map((line) => line.trim()).filter(Boolean);
8065
8323
  var AI_MOBILE_CSS = [
@@ -8582,7 +8840,13 @@ function TextBlock({
8582
8840
  "div",
8583
8841
  {
8584
8842
  ...textAttrs(ctx, `${path}.content`),
8585
- style: { ...typeStyle(spec, font), color: ctx.brand.palette.dark, textAlign: align },
8843
+ style: {
8844
+ ...typeStyle(spec, font),
8845
+ color: ctx.brand.palette.dark,
8846
+ textAlign: align,
8847
+ width: "100%",
8848
+ boxSizing: "border-box"
8849
+ },
8586
8850
  dangerouslySetInnerHTML: { __html: str(slots.content) }
8587
8851
  }
8588
8852
  );
@@ -8593,7 +8857,7 @@ function SectionHeaderBlock({ node, ctx, path }) {
8593
8857
  const children = node.children ?? [];
8594
8858
  const buttonRowIdx = children.findIndex((c) => c.type === "button-row");
8595
8859
  const buttonRow = buttonRowIdx >= 0 ? children[buttonRowIdx] : void 0;
8596
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { textAlign: align }, children: [
8860
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { textAlign: align, width: "100%", boxSizing: "border-box" }, children: [
8597
8861
  str(slots.tagline) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
8598
8862
  "div",
8599
8863
  {
@@ -10212,10 +10476,10 @@ function renderNode(node, ctx, path, ambientAlign) {
10212
10476
  gridColumn: `span ${typeof child.span === "number" ? Math.min(12, Math.max(1, child.span)) : 12}`,
10213
10477
  minWidth: 0
10214
10478
  } : { minWidth: 0 },
10215
- // A child's own `align` (or the group's inherited `ambientAlign`, e.g. from an
10216
- // `overlap` overlay layer — see renderNode) positions it within this column; a stack
10217
- // child otherwise stretches full-width (unchanged pre-existing behaviour).
10218
- ...blockAlignStyle(child.align ?? ambientAlign)
10479
+ // Same ambient as renderNode below: child's own align, else the group's, else the
10480
+ // inherited ambient (overlap overlay / section). Copy fills the column; button-row
10481
+ // etc. still hug via flex alignItems.
10482
+ ...blockAlignStyle(child.align ?? node.align ?? ambientAlign, child.type)
10219
10483
  },
10220
10484
  children: renderNode(child, ctx, `${path}.c${i}`, node.align ?? ambientAlign)
10221
10485
  },
@@ -10584,12 +10848,7 @@ function AiTreeRenderer({
10584
10848
  if (fillHeight) return "stretch";
10585
10849
  return (distributed ?? settings.verticalPosition) === "top" ? "start" : "center";
10586
10850
  };
10587
- const cellAlignStyle = (blockAlign) => blockAlign ? {
10588
- display: "flex",
10589
- flexDirection: "column",
10590
- alignItems: blockAlign === "left" ? "flex-start" : blockAlign === "right" ? "flex-end" : "center",
10591
- textAlign: blockAlign
10592
- } : {};
10851
+ const cellAlignStyle = (blockAlign, blockType) => blockAlignStyle(blockAlign, blockType);
10593
10852
  const needsOverlayClearance = fillHeight && pad === 0;
10594
10853
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
10595
10854
  "section",
@@ -10649,11 +10908,11 @@ function AiTreeRenderer({
10649
10908
  gridColumn: `span ${Math.min(12, Math.max(1, block.span))}`,
10650
10909
  minWidth: 0,
10651
10910
  // Cascades the section's min-height stretch (see `fillHeight` above) down to
10652
- // this cell; `cellAlignStyle` below overrides to `flex` when the block also has
10653
- // its own horizontal `align`, which takes priority for that block.
10911
+ // this cell; `cellAlignStyle` below overrides when the block also has its own
10912
+ // horizontal `align` (flex hug for buttons; width 100% for text).
10654
10913
  ...fillHeight ? { display: "grid" } : {},
10655
10914
  // Horizontal placement of the block's content within its column.
10656
- ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align),
10915
+ ...fullBleedBlock(block) ? {} : cellAlignStyle(block.align, block.type),
10657
10916
  // space-between: each column becomes a flex column whose content spreads over
10658
10917
  // the full row height instead of clumping at the top.
10659
10918
  ...distributed === "space-between" ? { display: "flex", flexDirection: "column", justifyContent: "space-between" } : {}
@@ -11377,7 +11636,7 @@ var import_client2 = require("react-dom/client");
11377
11636
  var import_react_dom2 = require("react-dom");
11378
11637
  var import_jsx_runtime3 = require("react/jsx-runtime");
11379
11638
  var CONTAINER_ATTR2 = "data-ohw-ai-footer";
11380
- var HIDDEN_ATTR = "data-ohw-ai-footer-replaced";
11639
+ var HIDDEN_ATTR2 = "data-ohw-ai-footer-replaced";
11381
11640
  var mounted2 = null;
11382
11641
  var mountOptions = {};
11383
11642
  var capturedSurface;
@@ -11407,12 +11666,12 @@ function findTemplateFooter() {
11407
11666
  function hideTemplateFooter(footer) {
11408
11667
  if (!footer) return;
11409
11668
  footer.style.display = "none";
11410
- footer.setAttribute(HIDDEN_ATTR, "");
11669
+ footer.setAttribute(HIDDEN_ATTR2, "");
11411
11670
  }
11412
11671
  function showTemplateFooter() {
11413
- for (const el of document.querySelectorAll(`[${HIDDEN_ATTR}]`)) {
11672
+ for (const el of document.querySelectorAll(`[${HIDDEN_ATTR2}]`)) {
11414
11673
  el.style.removeProperty("display");
11415
- el.removeAttribute(HIDDEN_ATTR);
11674
+ el.removeAttribute(HIDDEN_ATTR2);
11416
11675
  }
11417
11676
  }
11418
11677
  function unmountAiFooter() {
@@ -11607,7 +11866,7 @@ function pickFooterColumnIndex(columnBlockCounts) {
11607
11866
  }
11608
11867
 
11609
11868
  // src/lib/ai-footer-edits.ts
11610
- function cloneTree(tree) {
11869
+ function cloneTree2(tree) {
11611
11870
  return JSON.parse(JSON.stringify(tree));
11612
11871
  }
11613
11872
  function rebalanceFooterColumnSpans(columns) {
@@ -11657,7 +11916,7 @@ function countFooterLinkLists(tree) {
11657
11916
  return collectLinkListBlocks(tree).length;
11658
11917
  }
11659
11918
  function packFooterTreeBrand(tree) {
11660
- const next = cloneTree(tree);
11919
+ const next = cloneTree2(tree);
11661
11920
  const brand = collectBrandBlocks(next);
11662
11921
  const lists = collectLinkListBlocks(next);
11663
11922
  if (lists.length === 0) {
@@ -11742,7 +12001,7 @@ function ensureFooterTree(tree, opts) {
11742
12001
  return tree ?? buildDefaultFooterTree(opts);
11743
12002
  }
11744
12003
  function appendFooterSocial(tree, entry) {
11745
- const next = cloneTree(tree);
12004
+ const next = cloneTree2(tree);
11746
12005
  const platform = entry.platform.trim().toLowerCase();
11747
12006
  const href = entry.href.trim();
11748
12007
  for (const col2 of next.columns) {
@@ -11771,7 +12030,7 @@ function appendFooterSocial(tree, entry) {
11771
12030
  return next;
11772
12031
  }
11773
12032
  function insertFooterHours(tree, hours, title = "Hours") {
11774
- const next = cloneTree(tree);
12033
+ const next = cloneTree2(tree);
11775
12034
  const idx = pickFooterColumnIndex(next.columns.map((c) => c.blocks.length));
11776
12035
  const col = next.columns[idx] ?? next.columns[0];
11777
12036
  if (!col) return next;
@@ -11798,7 +12057,7 @@ function addFooterLinkColumn(tree, column) {
11798
12057
  return next;
11799
12058
  }
11800
12059
  function removeFooterBlock(tree, predicate) {
11801
- const next = cloneTree(tree);
12060
+ const next = cloneTree2(tree);
11802
12061
  for (let c = 0; c < next.columns.length; c++) {
11803
12062
  const col = next.columns[c];
11804
12063
  if (!col) continue;
@@ -11834,7 +12093,7 @@ function foldAiFooterSlotOverride(tree, key, value) {
11834
12093
  const path = key.slice(prefix.length);
11835
12094
  const brandMatch = path.match(/^brand\.b(\d+)\.(.+)$/);
11836
12095
  if (!brandMatch) return null;
11837
- const next = cloneTree(tree);
12096
+ const next = cloneTree2(tree);
11838
12097
  const brands = [];
11839
12098
  for (const col of next.columns) {
11840
12099
  for (const block2 of col.blocks) {
@@ -11879,7 +12138,7 @@ function textOf2(el) {
11879
12138
  return (el?.textContent ?? "").replace(/\s+/g, " ").trim();
11880
12139
  }
11881
12140
  function syncFooterTreeLinksFromDom(tree) {
11882
- const next = cloneTree(tree);
12141
+ const next = cloneTree2(tree);
11883
12142
  const domCols = listFooterColumns().map((col) => {
11884
12143
  const heading = getFooterColumnHeadingEl(col);
11885
12144
  const title = heading ? textOf2(heading) : void 0;
@@ -12360,7 +12619,7 @@ var PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]-?/g;
12360
12619
  var HAS_PLACEHOLDER_RE = /\[[A-Za-z][A-Za-z0-9 _/&#'.-]{0,30}\]/;
12361
12620
  var SKIPPED_TAGS = /* @__PURE__ */ new Set(["SCRIPT", "STYLE", "NOSCRIPT", "TEXTAREA", "CODE", "PRE"]);
12362
12621
  var TEXT_ATTRS = ["alt", "title", "aria-label", "placeholder"];
12363
- var HIDDEN_ATTR2 = "data-ohw-placeholder-hidden";
12622
+ var HIDDEN_ATTR3 = "data-ohw-placeholder-hidden";
12364
12623
  function hasPlaceholder(text) {
12365
12624
  return HAS_PLACEHOLDER_RE.test(text);
12366
12625
  }
@@ -12379,10 +12638,10 @@ function skipped(el) {
12379
12638
  }
12380
12639
  function hideIfEmptied(el) {
12381
12640
  const control = el?.closest("a, button");
12382
- if (!control || control.hasAttribute(HIDDEN_ATTR2)) return;
12641
+ if (!control || control.hasAttribute(HIDDEN_ATTR3)) return;
12383
12642
  if ((control.textContent ?? "").trim()) return;
12384
12643
  if (control.querySelector("img, svg, picture, video")) return;
12385
- control.setAttribute(HIDDEN_ATTR2, "");
12644
+ control.setAttribute(HIDDEN_ATTR3, "");
12386
12645
  control.style.display = "none";
12387
12646
  }
12388
12647
  function stripElementAttrs(el) {
@@ -17531,10 +17790,10 @@ function ItemInteractionLayer({
17531
17790
  }
17532
17791
 
17533
17792
  // src/lib/forms.ts
17534
- var FORM_SELECTOR = '[data-ohw-editable="form"]';
17793
+ var FORM_SELECTOR2 = '[data-ohw-editable="form"]';
17535
17794
  function getFormElement(el) {
17536
17795
  if (!el) return null;
17537
- return el.closest(FORM_SELECTOR);
17796
+ return el.closest(FORM_SELECTOR2);
17538
17797
  }
17539
17798
  function formKeyOf(form) {
17540
17799
  return form.getAttribute("data-ohw-key");
@@ -17595,7 +17854,7 @@ function clearSubmitError(form) {
17595
17854
  if (note) note.style.display = "none";
17596
17855
  }
17597
17856
  var SUCCESS_TEXT_ATTR = "data-ohw-form-success-text";
17598
- var HIDDEN_ATTR3 = "data-ohw-form-hidden";
17857
+ var HIDDEN_ATTR4 = "data-ohw-form-hidden";
17599
17858
  var DEFAULT_SUCCESS_TEXT = "Thanks! We'll be in touch.";
17600
17859
  function formSuccessKey(formKey) {
17601
17860
  return `${formKey}-success`;
@@ -17621,13 +17880,13 @@ function setFormViewState(form, formKey, state, initialText) {
17621
17880
  Array.from(form.children).forEach((child) => {
17622
17881
  if (!(child instanceof HTMLElement) || child === success) return;
17623
17882
  if (state === "success") {
17624
- if (!child.hasAttribute(HIDDEN_ATTR3)) {
17625
- child.setAttribute(HIDDEN_ATTR3, child.style.display);
17883
+ if (!child.hasAttribute(HIDDEN_ATTR4)) {
17884
+ child.setAttribute(HIDDEN_ATTR4, child.style.display);
17626
17885
  child.style.display = "none";
17627
17886
  }
17628
- } else if (child.hasAttribute(HIDDEN_ATTR3)) {
17629
- child.style.display = child.getAttribute(HIDDEN_ATTR3) ?? "";
17630
- child.removeAttribute(HIDDEN_ATTR3);
17887
+ } else if (child.hasAttribute(HIDDEN_ATTR4)) {
17888
+ child.style.display = child.getAttribute(HIDDEN_ATTR4) ?? "";
17889
+ child.removeAttribute(HIDDEN_ATTR4);
17631
17890
  }
17632
17891
  });
17633
17892
  success.style.display = state === "success" ? "" : "none";
@@ -17646,7 +17905,7 @@ function bindPublishedForms(apiUrl, subdomain, content = {}) {
17646
17905
  "submit",
17647
17906
  async (e) => {
17648
17907
  const target = e.target;
17649
- const form = target?.closest(FORM_SELECTOR);
17908
+ const form = target?.closest(FORM_SELECTOR2);
17650
17909
  if (!form || !(form instanceof HTMLFormElement)) return;
17651
17910
  const formKey = formKeyOf(form);
17652
17911
  if (!formKey) return;
@@ -17692,7 +17951,7 @@ function apiBase() {
17692
17951
  function bridgeVersion() {
17693
17952
  try {
17694
17953
  if (true) {
17695
- return "0.1.170";
17954
+ return "0.1.172";
17696
17955
  }
17697
17956
  } catch {
17698
17957
  }
@@ -17706,7 +17965,7 @@ function stampBridgeVersionOnDocument() {
17706
17965
  return;
17707
17966
  }
17708
17967
  try {
17709
- const v = true ? "0.1.170" : "";
17968
+ const v = true ? "0.1.172" : "";
17710
17969
  if (v) {
17711
17970
  document.documentElement.setAttribute("data-ohw-bridge-version", v);
17712
17971
  window.__OHW_BRIDGE_VERSION__ = v;
@@ -17867,7 +18126,9 @@ function isFieldRequired(wrapper) {
17867
18126
  function markFormFields(form) {
17868
18127
  form.querySelectorAll("input, textarea").forEach((input) => {
17869
18128
  const type = input.type;
17870
- if (type === "submit" || type === "button" || type === "reset" || type === "hidden") return;
18129
+ if (type === "submit" || type === "button" || type === "reset" || type === "hidden" || type === "checkbox" || type === "radio") {
18130
+ return;
18131
+ }
17871
18132
  if (getFieldWrapper(input)) return;
17872
18133
  let wrapper = input;
17873
18134
  while (wrapper.parentElement && wrapper.parentElement !== form && wrapper.parentElement.querySelectorAll("input, textarea").length === 1) {
@@ -18365,6 +18626,7 @@ function MediaOverlay({
18365
18626
  onFadeOutComplete,
18366
18627
  onReplace,
18367
18628
  onSelect,
18629
+ onDelete,
18368
18630
  onVideoSettingsChange
18369
18631
  }) {
18370
18632
  const { rect } = hover;
@@ -18518,35 +18780,66 @@ function MediaOverlay({
18518
18780
  }
18519
18781
  ),
18520
18782
  replaceMode === "none" || cueOnly ? null : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
18521
- Button,
18783
+ "div",
18522
18784
  {
18523
- "data-ohw-media-overlay": "",
18524
- variant: "outline",
18525
- size: "sm",
18526
- "aria-label": isVideo ? "Replace video" : "Replace image",
18527
- className: "gap-1.5 cursor-pointer hover:bg-background",
18528
- style: {
18529
- ...OVERLAY_BUTTON_STYLE,
18530
- // Icon-only is a square of the same height, so the pair can never differ vertically.
18531
- // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18532
- // minimum beats a width — the square came out wider than the avatar it sat on.
18533
- ...replaceMode === "icon" && buttonSize ? {
18534
- width: buttonSize.height,
18535
- minWidth: buttonSize.height,
18536
- padding: 0,
18537
- justifyContent: "center"
18538
- } : null,
18539
- // Don't let Replace steal clicks when text (e.g. nav) sits on top of this media.
18540
- pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto"
18541
- },
18542
- onMouseDown: (e) => e.preventDefault(),
18543
- onClick: (e) => {
18544
- e.stopPropagation();
18545
- onReplace(hover.key);
18546
- },
18785
+ className: "flex items-center gap-1.5",
18786
+ style: { pointerEvents: hover.hasTextOverlap || cueOnly ? "none" : "auto" },
18787
+ onClick: (e) => e.stopPropagation(),
18547
18788
  children: [
18548
- isVideo ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.Film, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.ImageIcon, { size: 14 }),
18549
- replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
18789
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
18790
+ Button,
18791
+ {
18792
+ "data-ohw-media-overlay": "",
18793
+ variant: "outline",
18794
+ size: "sm",
18795
+ "aria-label": isVideo ? "Replace video" : "Replace image",
18796
+ className: "gap-1.5 cursor-pointer hover:bg-background",
18797
+ style: {
18798
+ ...OVERLAY_BUTTON_STYLE,
18799
+ // Icon-only is a square of the same height, so the pair can never differ vertically.
18800
+ // `minWidth` has to go too: the button's own size carries `min-w-[64px]`, and a
18801
+ // minimum beats a width — the square came out wider than the avatar it sat on.
18802
+ ...replaceMode === "icon" && buttonSize ? {
18803
+ width: buttonSize.height,
18804
+ minWidth: buttonSize.height,
18805
+ padding: 0,
18806
+ justifyContent: "center"
18807
+ } : null
18808
+ },
18809
+ onMouseDown: (e) => e.preventDefault(),
18810
+ onClick: (e) => {
18811
+ e.stopPropagation();
18812
+ onReplace(hover.key);
18813
+ },
18814
+ children: [
18815
+ isVideo ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.Film, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.ImageIcon, { size: 14 }),
18816
+ replaceMode === "full" ? isVideo ? "Replace video" : hover.elementType === "bg-image" ? "Replace background" : "Replace image" : null
18817
+ ]
18818
+ }
18819
+ ),
18820
+ selected && onDelete ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
18821
+ Button,
18822
+ {
18823
+ "data-ohw-media-overlay": "",
18824
+ variant: "outline",
18825
+ size: "sm",
18826
+ "aria-label": "Delete",
18827
+ title: "Delete",
18828
+ className: "cursor-pointer hover:bg-background",
18829
+ style: {
18830
+ ...OVERLAY_BUTTON_STYLE,
18831
+ minWidth: 0,
18832
+ padding: buttonSize ? `0 ${(buttonSize.height - 14) / 2}px` : "0 8px",
18833
+ height: buttonSize?.height
18834
+ },
18835
+ onMouseDown: (e) => e.preventDefault(),
18836
+ onClick: (e) => {
18837
+ e.stopPropagation();
18838
+ onDelete(hover.key);
18839
+ },
18840
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_lucide_react5.Trash2, { size: 14 })
18841
+ }
18842
+ ) : null
18550
18843
  ]
18551
18844
  }
18552
18845
  )
@@ -26056,7 +26349,10 @@ function FloatingToolbar({
26056
26349
  onCommand,
26057
26350
  activeCommands,
26058
26351
  showEditLink,
26059
- onEditLink
26352
+ onEditLink,
26353
+ showDelete,
26354
+ onDelete,
26355
+ deleteDisabled
26060
26356
  }) {
26061
26357
  const localRef = import_react25.default.useRef(null);
26062
26358
  const [measuredW, setMeasuredW] = import_react25.default.useState(330);
@@ -26083,7 +26379,7 @@ function FloatingToolbar({
26083
26379
  const ro = new ResizeObserver(update);
26084
26380
  ro.observe(node);
26085
26381
  return () => ro.disconnect();
26086
- }, [showEditLink, activeCommands]);
26382
+ }, [showEditLink, showDelete, activeCommands]);
26087
26383
  const { top, left, transform } = calcToolbarPos(rect, parentScroll, measuredW);
26088
26384
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
26089
26385
  "div",
@@ -26148,7 +26444,28 @@ function FloatingToolbar({
26148
26444
  },
26149
26445
  children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Link, { className: "size-4 shrink-0", "aria-hidden": true })
26150
26446
  }
26151
- ) : null
26447
+ ) : null,
26448
+ showDelete ? /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)(import_jsx_runtime40.Fragment, { children: [
26449
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CustomToolbarDivider, {}),
26450
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
26451
+ CustomToolbarButton,
26452
+ {
26453
+ type: "button",
26454
+ title: "Delete",
26455
+ disabled: deleteDisabled,
26456
+ onMouseDown: (e) => {
26457
+ e.preventDefault();
26458
+ e.stopPropagation();
26459
+ if (!deleteDisabled) onDelete?.();
26460
+ },
26461
+ onClick: (e) => {
26462
+ e.preventDefault();
26463
+ e.stopPropagation();
26464
+ },
26465
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Trash2, { className: "size-4 shrink-0", "aria-hidden": true })
26466
+ }
26467
+ )
26468
+ ] }) : null
26152
26469
  ] })
26153
26470
  }
26154
26471
  );
@@ -26762,6 +27079,8 @@ function OhhwellsBridge() {
26762
27079
  const [activeCommands, setActiveCommands] = (0, import_react25.useState)(/* @__PURE__ */ new Set());
26763
27080
  const [sectionGap, setSectionGap] = (0, import_react25.useState)(null);
26764
27081
  const [toolbarShowEditLink, setToolbarShowEditLink] = (0, import_react25.useState)(false);
27082
+ const [toolbarShowAiBlockDelete, setToolbarShowAiBlockDelete] = (0, import_react25.useState)(false);
27083
+ const deletingAiBlockRef = (0, import_react25.useRef)(false);
26765
27084
  const hoveredNavContainerRef = (0, import_react25.useRef)(null);
26766
27085
  const [hoveredNavContainerRect, setHoveredNavContainerRect] = (0, import_react25.useState)(null);
26767
27086
  const hoveredItemElRef = (0, import_react25.useRef)(null);
@@ -27174,6 +27493,7 @@ function OhhwellsBridge() {
27174
27493
  setMaxBadge(null);
27175
27494
  setActiveCommands(/* @__PURE__ */ new Set());
27176
27495
  setToolbarShowEditLink(false);
27496
+ setToolbarShowAiBlockDelete(false);
27177
27497
  postToParent2({ type: "ow:exit-edit" });
27178
27498
  }, [postToParent2]);
27179
27499
  const clearSelectedAttr = (0, import_react25.useCallback)(() => {
@@ -27344,6 +27664,7 @@ function OhhwellsBridge() {
27344
27664
  setMaxBadge(null);
27345
27665
  setActiveCommands(/* @__PURE__ */ new Set());
27346
27666
  setToolbarShowEditLink(false);
27667
+ setToolbarShowAiBlockDelete(false);
27347
27668
  postToParent2({ type: "ow:exit-edit" });
27348
27669
  reselectNavigationItem(navAnchor);
27349
27670
  }, [postToParent2, reselectNavigationItem]);
@@ -28514,6 +28835,13 @@ function OhhwellsBridge() {
28514
28835
  }
28515
28836
  }
28516
28837
  setToolbarShowEditLink(Boolean(getHrefKeyFromElement(el)));
28838
+ setToolbarShowAiBlockDelete(
28839
+ canRemoveAiBlock(aiSectionsRef.current, el.dataset.ohwKey ?? null) || canSoftHideEditable(el, {
28840
+ isNavFooterItem: Boolean(
28841
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
28842
+ )
28843
+ })
28844
+ );
28517
28845
  const navAnchor = getNavigationItemAnchor(el);
28518
28846
  if (navAnchor) {
28519
28847
  if (isNestedNavChild(navAnchor)) {
@@ -28667,6 +28995,7 @@ function OhhwellsBridge() {
28667
28995
  applySocialsDisplayFromContent(content);
28668
28996
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28669
28997
  syncButtonsFromContent(document, content);
28998
+ applyHiddenEditablesToDom(content);
28670
28999
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28671
29000
  if (typeof content[STYLE_STORE_KEY] === "string") {
28672
29001
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -28892,6 +29221,7 @@ function OhhwellsBridge() {
28892
29221
  applySocialsDisplayFromContent(content);
28893
29222
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
28894
29223
  syncButtonsFromContent(document, content);
29224
+ applyHiddenEditablesToDom(content);
28895
29225
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
28896
29226
  if (typeof content[STYLE_STORE_KEY] === "string") {
28897
29227
  applyStylesToDom(parseStyleStore(content[STYLE_STORE_KEY]));
@@ -29030,6 +29360,7 @@ function OhhwellsBridge() {
29030
29360
  applySocialsDisplayFromContent(content);
29031
29361
  applySocialsLabelsFromContent(content, document, { fillEmptyOnly: isEditModeRef.current });
29032
29362
  syncButtonsFromContent(document, content);
29363
+ applyHiddenEditablesToDom(content);
29033
29364
  if (isEditModeRef.current) requestMissingSocialIconsRef.current();
29034
29365
  document.querySelectorAll("footer [data-ohw-href-key]").forEach((el) => {
29035
29366
  if (isFooterHrefKey(el.getAttribute("data-ohw-href-key")) || getSocialItem(el)) {
@@ -31177,6 +31508,7 @@ function OhhwellsBridge() {
31177
31508
  reconcileNavbarItemsFromContent(editContentRef.current);
31178
31509
  reconcileFooterOrderFromContent(editContentRef.current);
31179
31510
  syncButtonsFromContent(document, editContentRef.current);
31511
+ applyHiddenEditablesToDom(editContentRef.current);
31180
31512
  if (selectedElRef.current && !selectedElRef.current.isConnected) deselectRef.current();
31181
31513
  syncNavigationDragCursorAttrs();
31182
31514
  if (typeof content[STYLE_STORE_KEY] === "string") {
@@ -31980,7 +32312,7 @@ function OhhwellsBridge() {
31980
32312
  return;
31981
32313
  }
31982
32314
  }
31983
- if ((e.key === "Delete" || e.key === "Backspace") && selectedElRef.current && !activeElRef.current && !linkPopoverOpenRef.current) {
32315
+ if ((e.key === "Delete" || e.key === "Backspace") && !activeElRef.current && !linkPopoverOpenRef.current && (selectedElRef.current || selectedMediaElRef.current || selectedIconElRef.current)) {
31984
32316
  if (handleDeleteSelectedRef.current()) {
31985
32317
  e.preventDefault();
31986
32318
  return;
@@ -32929,7 +33261,7 @@ function OhhwellsBridge() {
32929
33261
  postToParent2({
32930
33262
  type: "ow:ready",
32931
33263
  version: "1",
32932
- bridgeVersion: "0.1.170",
33264
+ bridgeVersion: "0.1.172",
32933
33265
  path: pathname,
32934
33266
  nodes: collectEditableNodes(editContentRef.current),
32935
33267
  sections
@@ -33286,7 +33618,154 @@ function OhhwellsBridge() {
33286
33618
  enforceLinkHrefs();
33287
33619
  return true;
33288
33620
  }, []);
33621
+ const deleteAiBlock = (0, import_react25.useCallback)(
33622
+ (editKey, opts) => {
33623
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33624
+ if (deletingAiBlockRef.current) return false;
33625
+ const plan = planAiBlockRemoval(aiSectionsRef.current, editKey);
33626
+ if (!plan) return false;
33627
+ if (!plan.ok) {
33628
+ postToParent2({
33629
+ type: "ow:toast",
33630
+ title: plan.reasons[0] ?? "That block cannot be deleted",
33631
+ toastType: "error"
33632
+ });
33633
+ return true;
33634
+ }
33635
+ const { tree: nextTree, entry } = plan;
33636
+ const previous = aiSectionsRef.current;
33637
+ deletingAiBlockRef.current = true;
33638
+ void requestValidateTree5(postToParent2, nextTree).then(({ ok, reasons }) => {
33639
+ deletingAiBlockRef.current = false;
33640
+ if (!ok) {
33641
+ postToParent2({
33642
+ type: "ow:toast",
33643
+ title: reasons[0] ?? "That change is not allowed.",
33644
+ toastType: "error"
33645
+ });
33646
+ return;
33647
+ }
33648
+ clearMediaSelectionRef.current();
33649
+ clearIconSelectionRef.current();
33650
+ applyTreeLocalRef.current?.({
33651
+ id: entry.id,
33652
+ mode: "replace",
33653
+ targetSectionId: entry.id,
33654
+ tree: nextTree,
33655
+ label: entry.label,
33656
+ media: entry.media,
33657
+ ...entry.brand ? { brand: entry.brand } : {},
33658
+ skipScrollIntoView: true
33659
+ });
33660
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `delete-block-${Date.now()}`;
33661
+ pendingDeleteUndoRef.current = {
33662
+ actionId,
33663
+ restore: () => {
33664
+ clearInteractionChromeRef.current();
33665
+ aiSectionsRef.current = previous;
33666
+ applyAiSectionsToDom(parseAiSectionsState(previous));
33667
+ const restoreHeight = document.body.scrollHeight;
33668
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33669
+ postToParent2({ type: "ow:change", nodes: [{ key: AI_SECTIONS_KEY, text: previous }] });
33670
+ postToParent2({
33671
+ type: "ow:ai-sections-changed",
33672
+ sections: collectSections(),
33673
+ nodes: collectEditableNodes(editContentRef.current)
33674
+ });
33675
+ }
33676
+ };
33677
+ postToParent2({
33678
+ type: "ow:toast",
33679
+ title: "Block deleted",
33680
+ toastType: "success",
33681
+ actionLabel: "Undo",
33682
+ actionId,
33683
+ duration: 6e3
33684
+ });
33685
+ });
33686
+ return true;
33687
+ },
33688
+ [postToParent2]
33689
+ );
33690
+ const softHideTemplateEditable = (0, import_react25.useCallback)(
33691
+ (el, opts) => {
33692
+ if (!opts?.fromToolbar && activeElRef.current) return false;
33693
+ if (!canSoftHideEditable(el, {
33694
+ isNavFooterItem: Boolean(
33695
+ getNavigationItemAnchor(el) && isNavFooterScopedNavigationItem(el) && !isCtaButton(el)
33696
+ )
33697
+ })) {
33698
+ return false;
33699
+ }
33700
+ const previousContent = editContentRef.current;
33701
+ const result = softHideEditableInDom(el, previousContent);
33702
+ if (!result) return false;
33703
+ editContentRef.current = result.content;
33704
+ postToParent2({ type: "ow:change", nodes: result.nodes });
33705
+ clearMediaSelectionRef.current();
33706
+ clearIconSelectionRef.current();
33707
+ clearInteractionChromeRef.current();
33708
+ clearFormPickRef.current?.();
33709
+ deselectRef.current();
33710
+ const actionId = typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `hide-editable-${Date.now()}`;
33711
+ const hiddenKey = result.key;
33712
+ pendingDeleteUndoRef.current = {
33713
+ actionId,
33714
+ restore: () => {
33715
+ clearInteractionChromeRef.current();
33716
+ const restored = softUnhideEditableInDom(hiddenKey, editContentRef.current);
33717
+ editContentRef.current = restored.content;
33718
+ postToParent2({ type: "ow:change", nodes: restored.nodes });
33719
+ const restoreHeight = document.body.scrollHeight;
33720
+ if (restoreHeight > 50) postToParent2({ type: "ow:height", height: restoreHeight });
33721
+ }
33722
+ };
33723
+ postToParent2({
33724
+ type: "ow:toast",
33725
+ title: "Block deleted",
33726
+ toastType: "success",
33727
+ actionLabel: "Undo",
33728
+ actionId,
33729
+ duration: 6e3
33730
+ });
33731
+ return true;
33732
+ },
33733
+ [postToParent2]
33734
+ );
33735
+ const deleteFromToolbar = (0, import_react25.useCallback)(
33736
+ (editKey, el) => {
33737
+ if (!editKey && !el) return false;
33738
+ if (editKey && canRemoveAiBlock(aiSectionsRef.current, editKey)) {
33739
+ return deleteAiBlock(editKey, { fromToolbar: true });
33740
+ }
33741
+ const target = el ?? (editKey ? document.querySelector(`[data-ohw-key="${editKey.replace(/"/g, '\\"')}"]`) : null);
33742
+ if (target) return softHideTemplateEditable(target, { fromToolbar: true });
33743
+ return false;
33744
+ },
33745
+ [deleteAiBlock, softHideTemplateEditable]
33746
+ );
33747
+ const resolveSelectedAiBlockKey = (0, import_react25.useCallback)(() => {
33748
+ const candidates = [
33749
+ activeElRef.current?.dataset.ohwKey,
33750
+ selectedMediaElRef.current?.dataset.ohwKey,
33751
+ selectedMedia?.key,
33752
+ selectedIconElRef.current?.dataset.ohwKey,
33753
+ selectedElRef.current?.getAttribute("data-ohw-href-key"),
33754
+ selectedElRef.current?.dataset.ohwKey,
33755
+ selectedElRef.current?.querySelector("[data-ohw-key]")?.dataset.ohwKey
33756
+ ];
33757
+ for (const key of candidates) {
33758
+ if (key && canRemoveAiBlock(aiSectionsRef.current, key)) return key;
33759
+ }
33760
+ return null;
33761
+ }, [selectedMedia]);
33289
33762
  const handleDeleteSelected = (0, import_react25.useCallback)(() => {
33763
+ if (!activeElRef.current) {
33764
+ const aiKey = resolveSelectedAiBlockKey();
33765
+ if (aiKey && deleteAiBlock(aiKey)) return true;
33766
+ const mediaEl = selectedMediaElRef.current;
33767
+ if (mediaEl && softHideTemplateEditable(mediaEl, { fromToolbar: true })) return true;
33768
+ }
33290
33769
  const selected = selectedElRef.current;
33291
33770
  if (!selected) return false;
33292
33771
  if (isCtaButton(selected)) {
@@ -33345,7 +33824,7 @@ function OhhwellsBridge() {
33345
33824
  }
33346
33825
  }
33347
33826
  return deleted;
33348
- }, [postToParent2]);
33827
+ }, [postToParent2, deleteAiBlock, softHideTemplateEditable, resolveSelectedAiBlockKey]);
33349
33828
  handleDeleteSelectedRef.current = handleDeleteSelected;
33350
33829
  runPendingDeleteUndoRef.current = runPendingDeleteUndo;
33351
33830
  const handleLinkPopoverSubmit = (0, import_react25.useCallback)(
@@ -33563,6 +34042,13 @@ function OhhwellsBridge() {
33563
34042
  isUploading: false,
33564
34043
  onReplace: handleMediaReplace,
33565
34044
  onSelect: handleMediaSelect,
34045
+ onDelete: canRemoveAiBlock(aiSectionsRef.current, selectedMedia.key) || selectedMediaElRef.current != null && canSoftHideEditable(selectedMediaElRef.current, {
34046
+ isNavFooterItem: Boolean(
34047
+ getNavigationItemAnchor(selectedMediaElRef.current) && isNavFooterScopedNavigationItem(selectedMediaElRef.current) && !isCtaButton(selectedMediaElRef.current)
34048
+ )
34049
+ }) ? (key) => {
34050
+ deleteFromToolbar(key, selectedMediaElRef.current);
34051
+ } : void 0,
33566
34052
  onVideoSettingsChange: handleVideoSettingsChange
33567
34053
  }
33568
34054
  ),
@@ -33727,7 +34213,24 @@ function OhhwellsBridge() {
33727
34213
  children: state
33728
34214
  },
33729
34215
  state
33730
- )) })
34216
+ )) }),
34217
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "mx-0.5 h-5 w-px bg-border" }),
34218
+ /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
34219
+ "button",
34220
+ {
34221
+ type: "button",
34222
+ "aria-label": "Delete form",
34223
+ title: "Delete",
34224
+ className: "flex h-7 w-7 items-center justify-center rounded-md text-foreground transition-colors hover:bg-muted/80",
34225
+ onClick: () => {
34226
+ setFieldTypePickerOpen(false);
34227
+ const form = formPickElRef.current;
34228
+ if (!form) return;
34229
+ softHideTemplateEditable(form, { fromToolbar: true });
34230
+ },
34231
+ children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(import_lucide_react22.Trash2, { size: 15, "aria-hidden": true })
34232
+ }
34233
+ )
33731
34234
  ]
33732
34235
  }
33733
34236
  )
@@ -33896,7 +34399,15 @@ function OhhwellsBridge() {
33896
34399
  onCommand: handleCommand,
33897
34400
  activeCommands,
33898
34401
  showEditLink,
33899
- onEditLink: openLinkPopoverForActive
34402
+ onEditLink: openLinkPopoverForActive,
34403
+ showDelete: toolbarShowAiBlockDelete,
34404
+ deleteDisabled: deletingAiBlockRef.current,
34405
+ onDelete: () => {
34406
+ const el = activeElRef.current;
34407
+ const key = el?.dataset.ohwKey;
34408
+ if (!key) return;
34409
+ deleteFromToolbar(key, el);
34410
+ }
33900
34411
  }
33901
34412
  )
33902
34413
  ] }),
@@ -34126,6 +34637,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34126
34637
  FOOTER_COLUMN_BLOCKS,
34127
34638
  FOOTER_COLUMN_SPANS,
34128
34639
  FOOTER_SOCIAL_PLATFORMS,
34640
+ HIDDEN_EDITABLES_KEY,
34129
34641
  ItemActionToolbar,
34130
34642
  ItemInteractionLayer,
34131
34643
  LinkEditorPanel,
@@ -34148,9 +34660,14 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34148
34660
  addFooterLinkColumn,
34149
34661
  appendFooterSocial,
34150
34662
  applyBrandChrome,
34663
+ applyHiddenEditablesToDom,
34151
34664
  applyStickySearchParams,
34665
+ blockPathFromEditKey,
34152
34666
  buildDefaultFooterTree,
34153
34667
  buildTarget,
34668
+ canRemoveAiBlock,
34669
+ canRemoveAiTextBlock,
34670
+ canSoftHideEditable,
34154
34671
  dropIndicatorVariants,
34155
34672
  ensureFooterTree,
34156
34673
  filterAvailablePages,
@@ -34161,6 +34678,7 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34161
34678
  insertFooterHours,
34162
34679
  isDeadPageHref,
34163
34680
  isEditSessionActive,
34681
+ isEditableKeyHidden,
34164
34682
  isPlainLeftClick,
34165
34683
  isRenderableFooterTree,
34166
34684
  isRenderableTree,
@@ -34171,15 +34689,22 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34171
34689
  parseAiFooterState,
34172
34690
  parseAiSectionsState,
34173
34691
  parseTarget,
34692
+ planAiBlockRemoval,
34693
+ planAiTextBlockRemoval,
34174
34694
  planBuildPageSync,
34695
+ readHiddenEditables,
34175
34696
  recordOverriddenPaths,
34176
34697
  releaseTemplateLogoIfReplaced,
34698
+ removeBlockAtPath,
34177
34699
  removeFooterBlock,
34178
34700
  resetOverriddenPathsCache,
34179
34701
  resolveFooterCopyright,
34702
+ resolveSoftHideTarget,
34180
34703
  resolveStickyNavigation,
34181
34704
  serializeAiFooterState,
34182
34705
  shouldFetchContentForPath,
34706
+ softHideEditableInDom,
34707
+ softUnhideEditableInDom,
34183
34708
  stepViableSlide,
34184
34709
  stripPlaceholderText,
34185
34710
  stripPlaceholders,
@@ -34187,6 +34712,8 @@ function EmptySection({ title, homeHref = "/", eyebrowKey, titleKey, subtitleKey
34187
34712
  toggleVariants,
34188
34713
  useOhwCarousel,
34189
34714
  validateUrlInput,
34190
- viableSlides
34715
+ viableSlides,
34716
+ withHiddenEditable,
34717
+ withoutHiddenEditable
34191
34718
  });
34192
34719
  //# sourceMappingURL=index.cjs.map